From b13fd3384c97d3098582a275ae1f84f486e120e0 Mon Sep 17 00:00:00 2001 From: Manuel Cagigas Date: Mon, 8 Oct 2018 14:41:49 +0200 Subject: [PATCH] 7.7.0 stable version --- VERSION | 2 +- thirdpartylibs.xml | 2 +- tinymce/VERSION | 2 +- tinymce/configuration.ini.dist | 4 + tinymce/core/core.js | 4 +- tinymce/core/package-lock.json | 646 +++++++++++++++++------------ tinymce/core/src/contentmanager.js | 39 +- tinymce/core/src/core.src.js | 113 ++--- tinymce/core/src/image.js | 31 ++ tinymce/core/src/latex.js | 7 +- tinymce/core/src/mathml.js | 66 ++- tinymce/core/src/modal.js | 12 +- tinymce/core/src/parser.js | 8 +- tinymce/core/src/util.js | 5 +- tinymce/editor_plugin.js | 18 +- tinymce/editor_plugin.src.js | 4 +- tinymce/editor_plugin_src.js | 18 +- tinymce/package-lock.json | 646 +++++++++++++++++------------ tinymce/plugin.js | 18 +- tinymce/plugin.min.js | 4 +- tinymce/wirisplugin-generic.js | 4 +- tinymce/wirisplugin-generic.src.js | 2 +- version.php | 6 +- 23 files changed, 1008 insertions(+), 653 deletions(-) diff --git a/VERSION b/VERSION index 6fabba8..f5274bf 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -7.6.1.1393 +7.7.0.1394 diff --git a/thirdpartylibs.xml b/thirdpartylibs.xml index c87fb76..7b47304 100644 --- a/thirdpartylibs.xml +++ b/thirdpartylibs.xml @@ -3,7 +3,7 @@ tinymce/core MathType JavaScript engine - 7.6.1.1393 + 7.7.0.1394 GPL 3.0+ diff --git a/tinymce/VERSION b/tinymce/VERSION index 6fabba8..f5274bf 100644 --- a/tinymce/VERSION +++ b/tinymce/VERSION @@ -1 +1 @@ -7.6.1.1393 +7.7.0.1394 diff --git a/tinymce/configuration.ini.dist b/tinymce/configuration.ini.dist index fbafd7d..4dfb125 100644 --- a/tinymce/configuration.ini.dist +++ b/tinymce/configuration.ini.dist @@ -126,6 +126,10 @@ #wirisimageformat = svg +## Specifies if MathML should contain semantics element. false by default. + +#wirissavehandtraces = false + ############################################################################################### # Editor inherit parameters # # The format is a JSON containing MathType Web parameters defined on the following page: # diff --git a/tinymce/core/core.js b/tinymce/core/core.js index df8fbeb..1ff1092 100644 --- a/tinymce/core/core.js +++ b/tinymce/core/core.js @@ -1,3 +1,3 @@ -!function(e){var t={};function i(n){if(t[n])return t[n].exports;var r=t[n]={i:n,l:!1,exports:{}};return e[n].call(r.exports,r,r.exports,i),r.l=!0,r.exports}i.m=e,i.c=t,i.d=function(e,t,n){i.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},i.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.t=function(e,t){if(1&t&&(e=i(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)i.d(n,r,function(t){return e[t]}.bind(null,r));return n},i.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(t,"a",t),t},i.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},i.p="",i(i.s=6)}([function(module,__webpack_exports__,__webpack_require__){"use strict";function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var md5,_unused_webpack_default_export=md5;!function(){var HxOverrides=function(){};HxOverrides.__name__=!0,HxOverrides.dateStr=function(e){var t=e.getMonth()+1,i=e.getDate(),n=e.getHours(),r=e.getMinutes(),s=e.getSeconds();return e.getFullYear()+"-"+(t<10?"0"+t:""+t)+"-"+(i<10?"0"+i:""+i)+" "+(n<10?"0"+n:""+n)+":"+(r<10?"0"+r:""+r)+":"+(s<10?"0"+s:""+s)},HxOverrides.strDate=function(e){switch(e.length){case 8:var t=e.split(":"),i=new Date;return i.setTime(0),i.setUTCHours(t[0]),i.setUTCMinutes(t[1]),i.setUTCSeconds(t[2]),i;case 10:t=e.split("-");return new Date(t[0],t[1]-1,t[2],0,0,0);case 19:var n=(t=e.split(" "))[0].split("-"),r=t[1].split(":");return new Date(n[0],n[1]-1,n[2],r[0],r[1],r[2]);default:throw"Invalid date format : "+e}},HxOverrides.cca=function(e,t){var i=e.charCodeAt(t);if(i==i)return i},HxOverrides.substr=function(e,t,i){return null!=t&&0!=t&&null!=i&&i<0?"":(null==i&&(i=e.length),t<0?(t=e.length+t)<0&&(t=0):i<0&&(i=e.length+i-t),e.substr(t,i))},HxOverrides.remove=function(e,t){for(var i=0,n=e.length;i>>32-t},str2blks:function(e){for(var t=1+(e.length+8>>6),i=new Array,n=0,r=16*t;n>2]|=HxOverrides.cca(e,s)<<(8*e.length+s)%4*8,s++;i[s>>2]|=128<<(8*e.length+s)%4*8;var o=8*e.length,a=16*t-2;return i[a]=255&o,i[a]|=(o>>>8&255)<<8,i[a]|=(o>>>16&255)<<16,i[a]|=(o>>>24&255)<<24,i},rhex:function(e){for(var t="",i=0;i<4;){var n=i++;t+="0123456789abcdef".charAt(e>>8*n+4&15)+"0123456789abcdef".charAt(e>>8*n&15)}return t},addme:function(e,t){var i=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(i>>16)<<16|65535&i},bitAND:function(e,t){return(e>>>1&t>>>1)<<1|1&e&t},bitXOR:function(e,t){return(e>>>1^t>>>1)<<1|1&e^1&t},bitOR:function(e,t){return(e>>>1|t>>>1)<<1|(1&e|1&t)},__class__:haxe.Md5},haxe.Timer=function(e){var t=this;this.id=window.setInterval(function(){t.run()},e)},haxe.Timer.__name__=!0,haxe.Timer.delay=function(e,t){var i=new haxe.Timer(t);return i.run=function(){i.stop(),e()},i},haxe.Timer.measure=function(e,t){var i=haxe.Timer.stamp(),n=e();return haxe.Log.trace(haxe.Timer.stamp()-i+"s",t),n},haxe.Timer.stamp=function(){return(new Date).getTime()/1e3},haxe.Timer.prototype={run:function(){},stop:function(){null!=this.id&&(window.clearInterval(this.id),this.id=null)},__class__:haxe.Timer};var js=js||{},$_;function $bind(e,t){var i=function e(){return e.method.apply(e.scope,arguments)};return i.scope=e,i.method=t,i}js.Boot=function(){},js.Boot.__name__=!0,js.Boot.__unhtml=function(e){return e.split("&").join("&").split("<").join("<").split(">").join(">")},js.Boot.__trace=function(e,t){var i,n=null!=t?t.fileName+":"+t.lineNumber+": ":"";n+=js.Boot.__string_rec(e,""),"undefined"!=typeof document&&null!=(i=document.getElementById("haxe:trace"))?i.innerHTML+=js.Boot.__unhtml(n)+"
":"undefined"!=typeof console&&null!=console.log&&console.log(n)},js.Boot.__clear_trace=function(){var e=document.getElementById("haxe:trace");null!=e&&(e.innerHTML="")},js.Boot.isClass=function(e){return e.__name__},js.Boot.isEnum=function(e){return e.__ename__},js.Boot.getClass=function(e){return e.__class__},js.Boot.__string_rec=function(e,t){if(null==e)return"null";if(t.length>=5)return"<...>";var i=_typeof(e);switch("function"==i&&(e.__name__||e.__ename__)&&(i="object"),i){case"object":if(e instanceof Array){if(e.__enum__){if(2==e.length)return e[0];var n=e[0]+"(";t+="\t";for(var r=2,s=e.length;r0?",":"")+js.Boot.__string_rec(e[l],t)}return n+="]"}var c;try{c=e.toString}catch(e){return"???"}if(null!=c&&c!=Object.toString){var u=e.toString();if("[object Object]"!=u)return u}var h=null;n="{\n";t+="\t";var d=null!=e.hasOwnProperty;for(var h in e)d&&!e.hasOwnProperty(h)||"prototype"!=h&&"__class__"!=h&&"__super__"!=h&&"__interfaces__"!=h&&"__properties__"!=h&&(2!=n.length&&(n+=", \n"),n+=t+h+" : "+js.Boot.__string_rec(e[h],t));return n+="\n"+(t=t.substring(1))+"}";case"function":return"";case"string":return e;default:return String(e)}},js.Boot.__interfLoop=function(e,t){if(null==e)return!1;if(e==t)return!0;var i=e.__interfaces__;if(null!=i)for(var n=0,r=i.length;n>>32-t},str2blks:function(e){for(var t=1+(e.length+8>>6),i=new Array,n=0,r=16*t;n>2]|=HxOverrides.cca(e,s)<<(8*e.length+s)%4*8,s++;i[s>>2]|=128<<(8*e.length+s)%4*8;var o=8*e.length,a=16*t-2;return i[a]=255&o,i[a]|=(o>>>8&255)<<8,i[a]|=(o>>>16&255)<<16,i[a]|=(o>>>24&255)<<24,i},rhex:function(e){for(var t="",i=0;i<4;){var n=i++;t+="0123456789abcdef".charAt(e>>8*n+4&15)+"0123456789abcdef".charAt(e>>8*n&15)}return t},addme:function(e,t){var i=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(i>>16)<<16|65535&i},bitAND:function(e,t){return(e>>>1&t>>>1)<<1|1&e&t},bitXOR:function(e,t){return(e>>>1^t>>>1)<<1|1&e^1&t},bitOR:function(e,t){return(e>>>1|t>>>1)<<1|(1&e|1&t)},__class__:haxe.Md5},haxe.Timer=function(e){var t=this;this.id=window.setInterval(function(){t.run()},e)},haxe.Timer.__name__=!0,haxe.Timer.delay=function(e,t){var i=new haxe.Timer(t);return i.run=function(){i.stop(),e()},i},haxe.Timer.measure=function(e,t){var i=haxe.Timer.stamp(),n=e();return haxe.Log.trace(haxe.Timer.stamp()-i+"s",t),n},haxe.Timer.stamp=function(){return(new Date).getTime()/1e3},haxe.Timer.prototype={run:function(){},stop:function(){null!=this.id&&(window.clearInterval(this.id),this.id=null)},__class__:haxe.Timer};var js=js||{},$_;function $bind(e,t){var i=function e(){return e.method.apply(e.scope,arguments)};return i.scope=e,i.method=t,i}js.Boot=function(){},js.Boot.__name__=!0,js.Boot.__unhtml=function(e){return e.split("&").join("&").split("<").join("<").split(">").join(">")},js.Boot.__trace=function(e,t){var i,n=null!=t?t.fileName+":"+t.lineNumber+": ":"";n+=js.Boot.__string_rec(e,""),"undefined"!=typeof document&&null!=(i=document.getElementById("haxe:trace"))?i.innerHTML+=js.Boot.__unhtml(n)+"
":"undefined"!=typeof console&&null!=console.log&&console.log(n)},js.Boot.__clear_trace=function(){var e=document.getElementById("haxe:trace");null!=e&&(e.innerHTML="")},js.Boot.isClass=function(e){return e.__name__},js.Boot.isEnum=function(e){return e.__ename__},js.Boot.getClass=function(e){return e.__class__},js.Boot.__string_rec=function(e,t){if(null==e)return"null";if(t.length>=5)return"<...>";var i=_typeof(e);switch("function"==i&&(e.__name__||e.__ename__)&&(i="object"),i){case"object":if(e instanceof Array){if(e.__enum__){if(2==e.length)return e[0];var n=e[0]+"(";t+="\t";for(var r=2,s=e.length;r0?",":"")+js.Boot.__string_rec(e[l],t)}return n+="]"}var c;try{c=e.toString}catch(e){return"???"}if(null!=c&&c!=Object.toString){var u=e.toString();if("[object Object]"!=u)return u}var h=null;n="{\n";t+="\t";var d=null!=e.hasOwnProperty;for(var h in e)d&&!e.hasOwnProperty(h)||"prototype"!=h&&"__class__"!=h&&"__super__"!=h&&"__interfaces__"!=h&&"__properties__"!=h&&(2!=n.length&&(n+=", \n"),n+=t+h+" : "+js.Boot.__string_rec(e[h],t));return n+="\n"+(t=t.substring(1))+"}";case"function":return"";case"string":return e;default:return String(e)}},js.Boot.__interfLoop=function(e,t){if(null==e)return!1;if(e==t)return!0;var i=e.__interfaces__;if(null!=i)for(var n=0,r=i.length;n=0&&l.splice(t,1)}function m(e){var t=document.createElement("style");if(void 0===e.attrs.type&&(e.attrs.type="text/css"),void 0===e.attrs.nonce){var n=function(){0;return i.nc}();n&&(e.attrs.nonce=n)}return g(t,e.attrs),d(e,t),t}function g(e,t){Object.keys(t).forEach(function(i){e.setAttribute(i,t[i])})}function p(e,t){var i,n,r,s;if(t.transform&&e.css){if(!(s=t.transform(e.css)))return function(){};e.css=s}if(t.singleton){var l=a++;i=o||(o=m(t)),n=b.bind(null,i,l,!1),r=b.bind(null,i,l,!0)}else e.sourceMap&&"function"==typeof URL&&"function"==typeof URL.createObjectURL&&"function"==typeof URL.revokeObjectURL&&"function"==typeof Blob&&"function"==typeof btoa?(i=function(e){var t=document.createElement("link");return void 0===e.attrs.type&&(e.attrs.type="text/css"),e.attrs.rel="stylesheet",g(t,e.attrs),d(e,t),t}(t),n=function(e,t,i){var n=i.css,r=i.sourceMap,s=void 0===t.convertToAbsoluteUrls&&r;(t.convertToAbsoluteUrls||s)&&(n=c(n));r&&(n+="\n/*# sourceMappingURL=data:application/json;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(r))))+" */");var o=new Blob([n],{type:"text/css"}),a=e.href;e.href=URL.createObjectURL(o),a&&URL.revokeObjectURL(a)}.bind(null,i,t),r=function(){f(i),i.href&&URL.revokeObjectURL(i.href)}):(i=m(t),n=function(e,t){var i=t.css,n=t.media;n&&e.setAttribute("media",n);if(e.styleSheet)e.styleSheet.cssText=i;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(i))}}.bind(null,i),r=function(){f(i)});return n(e),function(t){if(t){if(t.css===e.css&&t.media===e.media&&t.sourceMap===e.sourceMap)return;n(e=t)}else r()}}e.exports=function(e,t){if("undefined"!=typeof DEBUG&&DEBUG&&"object"!=typeof document)throw new Error("The style-loader cannot be used in a non-browser environment");(t=t||{}).attrs="object"==typeof t.attrs?t.attrs:{},t.singleton||"boolean"==typeof t.singleton||(t.singleton=r()),t.insertInto||(t.insertInto="head"),t.insertAt||(t.insertAt="bottom");var i=h(e,t);return u(i,t),function(e){for(var r=[],s=0;s«/mo»",ampElement:"«mo»&«/mo»"}}},{key:"safeGoodBlackboardCharacters",get:function(){return{ltElement:"«mo»§lt;«/mo»",gtElement:"«mo»§gt;«/mo»",ampElement:"«mo»§amp;«/mo»"}}}]),e}();function s(e,t){for(var i=0;i",doubleQuote:'"',ampersand:"&",quote:"'"},r.safeXmlCharacters={tagOpener:"«",tagCloser:"»",doubleQuote:"¨",ampersand:"§",quote:"`",realDoubleQuote:"¨"};var o=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}return function(e,t,i){t&&s(e.prototype,t),i&&s(e,i)}(e,null,[{key:"isMathmlInAttribute",value:function(e,t){var i=new RegExp("^['\"][\\s]*=[\\s]*[\\w-]+([\\s]*(\"[^\"]*\"|'[^']*')[\\s]*=[\\s]*[\\w-]+[\\s]*)*[\\s]+gmi<"),n=e.substring(0,t).split("").reverse().join("");return i.test(n)}},{key:"safeXmlDecode",value:function(e){e=(e=(e=(e=e.split(r.safeXmlCharactersEntities.tagOpener).join(r.safeXmlCharacters.tagOpener)).split(r.safeXmlCharactersEntities.tagCloser).join(r.safeXmlCharacters.tagCloser)).split(r.safeXmlCharactersEntities.doubleQuote).join(r.safeXmlCharacters.doubleQuote)).split(r.safeXmlCharactersEntities.realDoubleQuote).join(r.safeXmlCharacters.realDoubleQuote),"_wrs_blackboard"in window&&window._wrs_blackboard&&(e=(e=(e=e.split(r.safeBadBlackboardCharacters.ltElement).join(r.safeGoodBlackboardCharacters.ltElement)).split(r.safeBadBlackboardCharacters.gtElement).join(r.safeGoodBlackboardCharacters.gtElement)).split(r.safeBadBlackboardCharacters.ampElement).join(r.safeGoodBlackboardCharacters.ampElement)),e=(e=(e=(e=(e=e.split(r.safeXmlCharacters.tagOpener).join(r.xmlCharacters.tagOpener)).split(r.safeXmlCharacters.tagCloser).join(r.xmlCharacters.tagCloser)).split(r.safeXmlCharacters.doubleQuote).join(r.xmlCharacters.doubleQuote)).split(r.safeXmlCharacters.ampersand).join(r.xmlCharacters.ampersand)).split(r.safeXmlCharacters.quote).join(r.xmlCharacters.quote);for(var t="",i=null,n=0;n128)t+="&#"+e.codePointAt(i)+";",e.codePointAt(i)>65535&&i++;else if("&"==n){var r=e.indexOf(";",i+1);if(r>=0){var s=document.createElement("span");s.innerHTML=e.substring(i,r+1),t+="&#"+v.fixedCharCodeAt(s.innerText||s.textContent,0)+";",i=r}else t+=n}else t+=n}return t}},{key:"addCustomEditorClassAttribute",value:function(e,t){var i="",n=e.indexOf("");if(-1==e.indexOf("class"))return i=e.substr(n,r)+' class="wrs_'+t+'">',i+=e.substr(r+1,e.length)}return e}},{key:"removeCustomEditorClassAttribute",value:function(e,t){return-1==e.indexOf("class")||e.indexOf("wrs_"+t)?e:-1!==e.indexOf('class="wrs_'+t+'"')?e.replace('class="wrs_'+t+'"',""):e.replace("wrs_"+t,"")}},{key:"insertSemanticsMathml",value:function(e,t,i){if(""==t)return e;var n='',r=e.indexOf(">"),s=e.indexOf(""),o=e.substring(e.indexOf("<"),e.indexOf(">")).indexOf("math");if(-1!=r&&-1!=s&&o){var a=e.substring(r+1,s);if(0!=a.indexOf(""))var l=""+a+""+n+t+"";else l=""+a+n+t+"";return e.replace(a,l)}return e}},{key:"removeSemanticsMathml",value:function(e,t){var i='',n=e,r=e.indexOf("");if(-1!=r){var s=e.indexOf(i,r+"".length);-1!=s&&(n=e.substring(0,r)+e.substring(r+"".length,s)+"")}return n}},{key:"containClass",value:function(e,t){var i=e.indexOf("class");if(-1==i)return!1;var n=e.indexOf(">",i);return-1!=e.substring(i,n).indexOf(t)}}]),e}();function a(e,t){for(var i=0;i=0;--n)if(i[n]==t)return!0;return!1}},{key:"removeClass",value:function(e,t){for(var i="",n=e.className.split(" "),r=0;r").join("").split("").join("")).split("").join("
").split("").join("
");var n=e.createElement("div",{},i);return n.innerHTML=t,function t(n){if(n.getAttribute&&"WirisParam"==n.getAttribute("wirisObject")){for(var r={},s=0;s0){i+=">";for(n=0;n"}else"DIV"==t.nodeName||"SCRIPT"==t.nodeName?i+=">":i+="/>";return i}return 3==t.nodeType?e.htmlEntities(t.nodeValue):""}}},{key:"concatenateUrl",value:function(e,t){var i="";return e.indexOf("/")!=e.length&&0!=t.indexOf("/")&&(i="/"),(e+i+t).replace(/([^:]\/)\/+/g,"$1")}},{key:"htmlEntities",value:function(e){return e.split("&").join("&").split("<").join("<").split(">").join(">").split('"').join(""")}},{key:"htmlEntitiesDecode",value:function(e){return e.split(""").join('"').split(">").join(">").split("<").join("<").split("&").join("&")}},{key:"createHttpRequest",value:function(){if("file://"==window.location.toString().substr(0,window.location.toString().lastIndexOf("/")+1).substr(0,7))throw Core.getStringManager().getString("exception_cross_site");if("undefined"!=typeof XMLHttpRequest)return new XMLHttpRequest;try{return new ActiveXObject("Msxml2.XMLHTTP")}catch(e){try{return new ActiveXObject("Microsoft.XMLHTTP")}catch(e){}}return!1}},{key:"httpBuildQuery",value:function(t){var i="";for(var n in t)null!=t[n]&&(i+=e.urlEncode(n)+"="+e.urlEncode(t[n])+"&");return"&"==i.substring(i.length-1)&&(i=i.substring(0,i.length-1)),i}},{key:"propertiesToString",value:function(t){var i=[];for(var n in t)t.hasOwnProperty(n)&&i.push(n);for(var r=i.length,s=0;s0&&(i[s]=l,i[o]=a)}var c="";for(s=0;ss?s:r;for(n=0;n0){var i=e.substring(t+1).split("&"),n=new Object;for(t=0;t1&&(n[r[0]]=decodeURIComponent(r[1].replace(/\+/g," ")))}return n}return new Object}},{key:"urlEncode",value:function(e){return encodeURIComponent(e)}},{key:"getWIRISImageOutput",value:function(t,i,n){var r=e.createObject(t);if(r){if(r.className==l.get("imageClassName")||r.getAttribute(l.get("imageMathmlAttribute"))){if(!i)return t;var s=r.getAttribute(l.get("imageMathmlAttribute"));return null==s&&(s=r.getAttribute("alt")),n||(s=o.safeXmlDecode(s)),s}if(r.className==l.get("CASClassName")){var a=r.getAttribute(l.get("CASMathmlAttribute"));a=o.safeXmlDecode(a);var c=e.createObject(a);c.setAttribute("src",r.src);var u=e.createObjectCode(c);return n&&(u=o.safeXmlEncode(u)),u}}return t}},{key:"getNodeLength",value:function(e){function t(t){return e.apply(this,arguments)}return t.toString=function(){return e.toString()},t}(function(e){if(3==e.nodeType)return e.nodeValue.length;if(1==e.nodeType){var t={IMG:1,BR:1}[e.nodeName.toUpperCase()];void 0===t&&(t=0);for(var i=0;i0)return 0==c.text.length?e.getSelectedItem(t,i,!0):null;r.document.execCommand("InsertImage",!1,"#");var s,o=c.parentElement();return"IMG"!=o.nodeName.toUpperCase()&&(c.pasteHTML(''),o=r.document.getElementById("wrs_openEditorWindow_temporalObject")),o.nextSibling&&3==o.nextSibling.nodeType?(a=o.nextSibling,s=0):o.previousSibling&&3==o.previousSibling.nodeType?s=(a=o.previousSibling).nodeValue.length:(a=r.document.createTextNode(""),o.parentNode.insertBefore(a,o),s=0),o.parentNode.removeChild(o),{node:a,caretPosition:s}}return c.length>1?null:{node:c.item(0)}}if(r.getSelection){var a,l=r.getSelection();try{var c=l.getRangeAt(0)}catch(e){c=r.document.createRange()}if(3==(a=c.startContainer).nodeType)return{node:a,caretPosition:c.startOffset};if(a!=c.endContainer)return null;if(1==a.nodeType){var u=c.startOffset;if(a.childNodes[u])return{node:a.childNodes[u]}}}return null}},{key:"getSelectedItemOnTextarea",value:function(e){var t=document.createTextNode(e.value),i=g.getLatexFromTextNode(t,e.selectionStart);return null===i?null:{node:t,caretPosition:e.selectionStart,startPosition:i.startPosition,endPosition:i.endPosition}}},{key:"getElementsByNameFromString",value:function(e,t,i){var n=[];e=e.toLowerCase();t=t.toLowerCase();for(var r=e.indexOf("<"+t+" ");-1!=r;){var s;s=i?">":"";var o=e.indexOf(s,r);-1!=o?(o+=s.length,n.push({start:r,end:o})):o=r+1,r=e.indexOf("<"+t+" ",o)}return n}},{key:"decode64",value:function(e){var t="+".charCodeAt(0),i="/".charCodeAt(0),n="0".charCodeAt(0),r="a".charCodeAt(0),s="A".charCodeAt(0),o="-".charCodeAt(0),a="_".charCodeAt(0),l=e.charCodeAt(0);return l===t||l===o?62:l===i||l===a?63:l0)throw new Error("Invalid string. Length must be a multiple of 4");var r=new Array;if(i)o=i;else var s="="===t.charAt(t.length-2)?2:"="===t.charAt(t.length-1)?1:0,o=s>0?t.length-4:t.length;for(var a=0;a>16&255),r.push(n>>8&255),r.push(255&n);return s&&(2===s?(n=e.decode64(t.charAt(a))<<2|e.decode64(t.charAt(a+1))>>4,r.push(255&n)):1===s&&(n=e.decode64(t.charAt(a))<<10|e.decode64(t.charAt(a+1))<<4|e.decode64(t.charAt(a+2))>>2,r.push(n>>8&255),r.push(255&n))),r}},{key:"readInt32",value:function(e){if(e.length<4)return!1;var t=e.splice(0,4);return t[0]<<24|t[1]<<16|t[2]<<8|t[3]<<0}},{key:"readByte",value:function(e){return e.shift()<<0}},{key:"readBytes",value:function(e,t,i){return e.splice(t,i)}},{key:"updateTextArea",value:function(e,t){if(e&&t)if(e.focus(),null!=e.selectionStart){var i=e.selectionEnd;e.value=e.value.substring(0,e.selectionStart)+t+e.value.substring(e.selectionEnd,e.value.length),e.selectionEnd=i+t.length}else{document.selection.createRange().text=t}}},{key:"updateExistingTextOnTextarea",value:function(e,t,i,n){e.focus(),e.value=e.value.substring(0,i)+t+e.value.substring(n,e.value.length),e.selectionEnd=i+t.length}},{key:"addArgument",value:function(e,t,i){return e+(e.indexOf("?")>0?"&":"?")+t+"="+i}}]),e}();function b(e,t){for(var i=0;i-1,this.deviceProperties.isIOS=this.ua.indexOf("ipad")>-1||this.ua.indexOf("iphone")>-1,this.toolbar=null,this.modalDialogInstance=null,this.listeners=new y,this.mathML=null,this.isNewElement=!0,this.integrationModel=null,this.isEditorLoaded=!1}return function(e,t,i){t&&E(e.prototype,t),i&&E(e,i)}(e,[{key:"addListener",value:function(e){this.listeners.add(e)}},{key:"setIntegrationModel",value:function(e){this.integrationModel=e}},{key:"setModalDialogInstance",value:function(e){this.modalDialogInstance=e}},{key:"insert",value:function(){this.updateTitle(this.modalDialogInstance),this.insertEditor(this.modalDialogInstance)}},{key:"insertEditor",value:function(){if("com"in window&&"wiris"in window.com&&"jsEditor"in window.com.wiris){if(this.editor=com.wiris.jsEditor.JsEditor.newInstance(this.editorAttributes),this.editor.insertInto(this.modalDialogInstance.contentContainer),this.editor.focus(),this.modalDialogInstance.rtl&&this.editor.action("rtl"),this.editor.getEditorModel().isRTL()&&(this.editor.element.style.direction="rtl"),this.editor.getEditorModel().addEditorListener(this.editorListener),this.modalDialogInstance.deviceProperties.isIOS){setTimeout(function(){this.modalDialogInstance.hideKeyboard()},400);var t=document.getElementsByClassName("wrs_formulaDisplay")[0];v.addEvent(t,"focus",this.modalDialogInstance.openedIosSoftkeyboard.bind()),v.addEvent(t,"blur",this.modalDialogInstance.closedIosSoftkeyboard.bind())}this.listeners.fire("onLoad",{}),this.isEditorLoaded=!0}else setTimeout(e.prototype.insertEditor.bind(this,this.modalDialogInstance),100)}},{key:"init",value:function(){for(var e=window.location.search.substring(1).split("&"),t=0;t=0&&(version=e[t].substring(2))}var i=document.createElement("script");i.type="text/javascript";var n=l.get("editorUrl"),r=document.createElement("a");r.href=n,0==window.location.href.indexOf("https://")&&"http:"==r.protocol&&(r.protocol="https:"),n="80"==r.port||"443"==r.port?r.protocol+"//"+r.hostname+"/"+r.pathname:r.protocol+"//"+r.hostname+":"+r.port+"/"+r.pathname;var s={};"editor"in this.environment?s.editor=this.environment.editor:s.editor="unknown","mode"in this.environment?s.mode=this.environment.mode:s.mode=l.get("saveMode"),"version"in this.environment?s.version=this.environment.version:s.version=l.get("version"),i.src=n+"?lang="+this.language+"&stats-editor="+s.editor+"&stats-mode="+s.mode+"&stats-version="+s.version,document.getElementsByTagName("head")[0].appendChild(i)}},{key:"setInitialContent",value:function(){this.isNewElement||this.setMathML(this.mathML)}},{key:"setMathML",value:function(e,t){void 0===t&&(t=!1),this.editor.setMathMLWithCallback(e,function(){this.editorListener.setWaitingForChanges(!0)}.bind(this)),setTimeout(function(){this.editorListener.setIsContentChanged(!1)}.bind(this),500),t||this.onFocus()}},{key:"onFocus",value:function(){void 0!==this.editor&&null!=this.editor&&this.editor.focus()}},{key:"submitAction",value:function(){var e=this.editor.getMathML();if(null!=this.customEditors.getActiveEditor())e=o.addCustomEditorClassAttribute(e,this.customEditors.getActiveEditor().toolbar);else for(var t in this.customEditors.editors)e=o.removeCustomEditorClassAttribute(e,t);var i=o.mathMLEntities(e);this.integrationModel.updateFormula(i),this.customEditors.disable(),this.integrationModel.notifyWindowClosed(),this.setEmptyMathML(),this.customEditors.disable(),setTimeout(function(){"undefined"!=typeof _wrs_currentEditor&&_wrs_currentEditor&&_wrs_currentEditor.focus()},100)}},{key:"setEmptyMathML",value:function(){this.deviceProperties.isAndroid||this.deviceProperties.isIOS?this.editor.getEditorModel().isRTL()?this.setMathML('[]"',!0):this.setMathML('[]"',!0):this.editor.getEditorModel().isRTL()?this.setMathML('',!0):this.setMathML("",!0)}},{key:"onOpen",value:function(){this.isNewElement?this.setEmptyMathML():this.setMathML(this.mathML),this.updateToolbar(),this.onFocus()}},{key:"updateToolbar",value:function(){var e;if(this.updateTitle(this.modalDialogInstance),e=this.customEditors.getActiveEditor()){var t=e.toolbar?e.toolbar:_wrs_int_wirisProperties.toolbar;null!=this.toolbar&&this.toolbar==t||this.setToolbar(t)}else{t=this.getToolbar();null!=this.toolbar&&this.toolbar==t||(this.setToolbar(t),this.customEditors.disable())}}},{key:"updateTitle",value:function(){var e;(e=this.customEditors.getActiveEditor())?this.modalDialogInstance.setTitle(e.title):this.modalDialogInstance.setTitle("MathType")}},{key:"getToolbar",value:function(){var e;return"general"==(e="toolbar"in this.editorAttributes?this.editorAttributes.toolbar:"general")&&(e="undefined"==typeof _wrs_int_wirisProperties||void 0===_wrs_int_wirisProperties.toolbar?"general":_wrs_int_wirisProperties.toolbar),e}},{key:"setToolbar",value:function(e){this.toolbar=e,this.editor.setParams({toolbar:this.toolbar})}},{key:"hasChanges",value:function(){return!this.editor.isFormulaEmpty()&&this.editorListener.getIsContentChanged()}}]),e}();function k(e,t){for(var i=0;i-1,r=i.indexOf("ipad")>-1||i.indexOf("iphone")>-1;this.iosSoftkeyboardOpened=!1,this.iosMeasureUnit=-1==i.indexOf("crios")?"%":"vh",this.iosDivHeight="100"+this.iosMeasureUnit;var s=window.outerWidth,o=window.outerHeight,a=s>o,l=so||l&&this.attributes.width>s);this.instanceId=document.getElementsByClassName("wrs_modal_dialogContainer").length,this.deviceProperties={orientation:a?"landscape":"portait",isAndroid:!!n,isIOS:!!r,isMobile:c,isDesktop:!c&&!r&&!n},this.properties={created:!1,state:"",previousState:"",position:{bottom:0,right:10},size:{height:338,width:580}};var u={class:"wrs_modal_overlay"};u.id=this.getElementId(u.class),this.overlay=v.createElement("div",u),(u={}).class="wrs_modal_title_bar",u.id=this.getElementId(u.class),this.titleBar=v.createElement("div",u),(u={}).class="wrs_modal_title",u.id=this.getElementId(u.class),this.title=v.createElement("div",u),this.title.innerHTML="",(u={}).class="wrs_modal_close_button",u.id=this.getElementId(u.class),u.title=$.getStringManager().getString("close"),this.closeDiv=v.createElement("a",u),this.closeDiv.setAttribute("role","button"),(u={}).class="wrs_modal_stack_button",u.id=this.getElementId(u.class),u.title="Exit full-screen",this.stackDiv=v.createElement("a",u),this.stackDiv.setAttribute("role","button"),(u={}).class="wrs_modal_maximize_button",u.id=this.getElementId(u.class),u.title=$.getStringManager().getString("fullscreen"),this.maximizeDiv=v.createElement("a",u),this.maximizeDiv.setAttribute("role","button"),(u={}).class="wrs_modal_minimize_button",u.id=this.getElementId(u.class),u.title=$.getStringManager().getString("minimise"),this.minimizeDiv=v.createElement("a",u),this.minimizeDiv.setAttribute("role","button"),(u={}).class="wrs_modal_dialogContainer",u.id=this.getElementId(u.class),this.container=v.createElement("div",u),(u={}).class="wrs_modal_wrapper",u.id=this.getElementId(u.class),this.wrapper=v.createElement("div",u),(u={}).class="wrs_content_container",u.id=this.getElementId(u.class),this.contentContainer=v.createElement("div",u),(u={}).class="wrs_modal_controls",u.id=this.getElementId(u.class),this.controls=v.createElement("div",u),(u={}).class="wrs_modal_buttons_container",u.id=this.getElementId(u.class),this.buttonContainer=v.createElement("div",u),this.submitButton=this.createSubmitButton({id:this.getElementId("wrs_modal_button_accept"),class:"wrs_modal_button_accept",innerHTML:$.getStringManager().getString("accept")},this.submitAction.bind(this)),this.cancelButton=this.createSubmitButton({id:this.getElementId("wrs_modal_button_cancel"),class:"wrs_modal_button_cancel",innerHTML:$.getStringManager().getString("cancel")},this.cancelAction.bind(this)),this.contentManager=null;var h={cancelString:$.getStringManager().getString("cancel"),submitString:$.getStringManager().getString("close"),message:$.getStringManager().getString("close_modal_warning")},d={closeCallback:function(){this.close()}.bind(this),cancelCallback:function(){this.focus()}.bind(this)},f={overlayElement:this.container,callbacks:d,strings:h};this.popup=new S(f),this.rtl=!1,"rtl"in this.attributes&&(this.rtl=this.attributes.rtl)}return function(e,t,i){t&&O(e.prototype,t),i&&O(e,i)}(e,[{key:"setContentManager",value:function(e){this.contentManager=e}},{key:"getContentManager",value:function(){return this.contentManager}},{key:"submitAction",value:function(){void 0!==this.contentManager.submitAction&&this.contentManager.submitAction(),this.close()}},{key:"cancelAction",value:function(){void 0===this.contentManager.hasChanges?this.close():this.contentManager.hasChanges()?this.showPopUpMessage():this.close()}},{key:"createSubmitButton",value:function(e,t){function i(e,t){this.element=document.createElement("button"),this.element.id=e.id,this.element.className=e.class,this.element.innerHTML=e.innerHTML,v.addEvent(this.element,"click",t)}return i.prototype.getElement=function(){return this.element},new i(e,t).getElement()}},{key:"create",value:function(){this.titleBar.appendChild(this.closeDiv),this.titleBar.appendChild(this.stackDiv),this.titleBar.appendChild(this.maximizeDiv),this.titleBar.appendChild(this.minimizeDiv),this.titleBar.appendChild(this.title),this.deviceProperties.isDesktop&&this.container.appendChild(this.titleBar),this.wrapper.appendChild(this.contentContainer),this.wrapper.appendChild(this.controls),this.controls.appendChild(this.buttonContainer),this.buttonContainer.appendChild(this.submitButton),this.buttonContainer.appendChild(this.cancelButton),this.container.appendChild(this.wrapper),this.recalculateScrollBar(),document.body.appendChild(this.container),document.body.appendChild(this.overlay),this.deviceProperties.isDesktop?(this.createModalWindowDesktop(),this.createResizeButtons(),this.addListeners(),l.get("modalWindowFullScreen")&&this.maximize()):this.deviceProperties.isAndroid?this.createModalWindowAndroid():this.deviceProperties.isIOS&&!this.deviceProperties.isMobile&&this.createModalWindowIos(),null!=this.contentManager&&this.contentManager.insert(this),this.properties.open=!0,this.properties.created=!0,this.isRTL()&&(this.container.style.right=window.innerWidth-this.scrollbarWidth-this.container.offsetWidth+"px",this.container.className+=" wrs_modal_rtl")}},{key:"createResizeButtons",value:function(){this.resizerBR=document.createElement("div"),this.resizerBR.className="wrs_bottom_right_resizer",this.resizerBR.innerHTML="◢",this.resizerTL=document.createElement("div"),this.resizerTL.className="wrs_bottom_left_resizer",this.container.appendChild(this.resizerBR),this.titleBar.appendChild(this.resizerTL),v.addEvent(this.resizerBR,"mousedown",this.activateResizeStateBR.bind(this)),v.addEvent(this.resizerTL,"mousedown",this.activateResizeStateTL.bind(this))}},{key:"activateResizeStateBR",value:function(e){this.initializeResizeProperties(e,!1)}},{key:"activateResizeStateTL",value:function(e){this.initializeResizeProperties(e,!0)}},{key:"initializeResizeProperties",value:function(e,t){v.addClass(document.body,"wrs_noselect"),v.addClass(this.overlay,"wrs_overlay_active"),this.resizeDataObject={x:this.eventClient(e).X,y:this.eventClient(e).Y},this.initialWidth=parseInt(this.container.style.width),this.initialHeight=parseInt(this.container.style.height),t?this.leftScale=!0:(this.initialRight=parseInt(this.container.style.right),this.initialBottom=parseInt(this.container.style.bottom)),this.initialRight||(this.initialRight=0),this.initialBottom||(this.initialBottom=0),document.body.style["user-select"]="none"}},{key:"open",value:function(){if(this.removeClass("wrs_closed"),(this.deviceProperties.isIOS||this.deviceProperties.isAndroid||this.deviceProperties.isMobile)&&(this.restoreWebsiteScale(),this.blockWebsiteScroll(),setTimeout(function(){this.hideKeyboard()}.bind(this),400)),this.properties.created?(this.properties.open||(this.properties.open=!0,this.deviceProperties.isAndroid||this.deviceProperties.isIOS||this.restoreState()),this.deviceProperties.isDesktop&&l.get("modalWindowFullScreen")&&this.maximize(),this.deviceProperties.isIOS&&(this.iosSoftkeyboardOpened=!1,this.setContainerHeight("100"+this.iosMeasureUnit))):this.create(),!1===this.contentManager.isEditorLoaded){var e=y.newListener("onLoad",function(){this.contentManager.onOpen(this)}.bind(this));this.contentManager.addListener(e)}else this.contentManager.onOpen(this)}},{key:"close",value:function(){this.removeClass("wrs_maximized"),this.removeClass("wrs_minimized"),this.removeClass("wrs_stack"),this.addClass("wrs_closed"),this.saveModalProperties(),this.unblockWebsiteScroll(),this.properties.open=!1}},{key:"restoreWebsiteScale",value:function(){var e=document.querySelector("meta[name=viewport]"),t=["initial-scale=","minimum-scale=","maximum-scale="],i=["1.0","1.0","1.0"],n=function(e,t){var n=e.getAttribute("content");if(n){for(var r=n.split(","),s="",o=[],a=0;a=0||navigator.userAgent.search("Trident/")>=0||navigator.userAgent.search("Edge/")>=0}},{key:"isRTL",value:function(){return"ar"==this.attributes.language||"he"==this.attributes.language||this.rtl}},{key:"addClass",value:function(e){v.addClass(this.overlay,e),v.addClass(this.titleBar,e),v.addClass(this.overlay,e),v.addClass(this.container,e),v.addClass(this.contentContainer,e),v.addClass(this.stackDiv,e),v.addClass(this.minimizeDiv,e),v.addClass(this.maximizeDiv,e),v.addClass(this.wrapper,e)}},{key:"removeClass",value:function(e){v.removeClass(this.overlay,e),v.removeClass(this.titleBar,e),v.removeClass(this.overlay,e),v.removeClass(this.container,e),v.removeClass(this.contentContainer,e),v.removeClass(this.stackDiv,e),v.removeClass(this.minimizeDiv,e),v.removeClass(this.maximizeDiv,e),v.removeClass(this.wrapper,e)}},{key:"createModalWindowDesktop",value:function(){this.addClass("wrs_modal_desktop"),this.stack()}},{key:"createModalWindowAndroid",value:function(){this.addClass("wrs_modal_android"),window.addEventListener("resize",this.orientationChangeAndroidSoftkeyboard.bind(this))}},{key:"createModalWindowIos",value:function(){this.addClass("wrs_modal_ios"),window.addEventListener("resize",this.orientationChangeIosSoftkeyboard.bind(this))}},{key:"restoreState",value:function(){"maximized"==this.properties.state?this.maximize():"minimized"==this.properties.state?(this.properties.state=this.properties.previousState,this.properties.previousState="",this.minimize()):this.stack()}},{key:"stack",value:function(){this.properties.previousState=this.properties.state,this.properties.state="stack",this.removeClass("wrs_maximized"),this.minimizeDiv.title="Minimise",this.removeClass("wrs_minimized"),this.addClass("wrs_stack"),this.restoreModalProperties(),void 0!==this.resizerBR&&void 0!==this.resizerTL&&this.setResizeButtonsVisibility(),this.recalculateScrollBar(),this.recalculatePosition(),this.recalculateScale(),this.focus()}},{key:"minimize",value:function(){this.saveModalProperties(),"minimized"==this.properties.state&&"stack"==this.properties.previousState?this.stack():"minimized"==this.properties.state&&"maximized"==this.properties.previousState?this.maximize():(this.container.style.height="30px",this.container.style.width="250px",this.container.style.bottom="0px",this.container.style.right="10px",this.removeListeners(),this.properties.previousState=this.properties.state,this.properties.state="minimized",this.setResizeButtonsVisibility(),this.minimizeDiv.title="Maximise",v.containsClass(this.overlay,"wrs_stack")?this.removeClass("wrs_stack"):this.removeClass("wrs_maximized"),this.addClass("wrs_minimized"))}},{key:"maximize",value:function(){this.saveModalProperties(),"maximized"!=this.properties.state&&(this.properties.previousState=this.properties.state,this.properties.state="maximized"),this.setResizeButtonsVisibility(),v.containsClass(this.overlay,"wrs_minimized")?(this.minimizeDiv.title="Minimise",this.removeClass("wrs_minimized")):v.containsClass(this.overlay,"wrs_stack")&&(this.container.style.left=null,this.container.style.top=null,this.removeClass("wrs_stack")),this.addClass("wrs_maximized"),this.setSize(parseInt(.8*window.innerHeight),parseInt(.8*window.innerWidth));this.container.clientHeight>700&&(this.container.style.height="700px"),this.container.clientWidth>1200&&(this.container.style.width="1200px"),this.setPosition(window.innerHeight/2-this.container.offsetHeight/2,window.innerWidth/2-this.container.offsetWidth/2),this.recalculateScale(),this.recalculatePosition(),this.recalculateSize(),this.focus()}},{key:"setSize",value:function(e,t){this.container.style.height=e+"px",this.container.style.width=t+"px",this.recalculateSize()}},{key:"setPosition",value:function(e,t){this.container.style.bottom=e+"px",this.container.style.right=t+"px"}},{key:"saveModalProperties",value:function(){"stack"==this.properties.state&&(this.properties.position.bottom=parseInt(this.container.style.bottom),this.properties.position.right=parseInt(this.container.style.right),this.properties.size.width=parseInt(this.container.style.width),this.properties.size.height=parseInt(this.container.style.height))}},{key:"restoreModalProperties",value:function(){"stack"==this.properties.state&&(this.setPosition(this.properties.position.bottom,this.properties.position.right),this.setSize(this.properties.size.height,this.properties.size.width))}},{key:"recalculateSize",value:function(){this.wrapper.style.width=this.container.clientWidth-12+"px",this.wrapper.style.height=this.container.clientHeight-38+"px",this.contentContainer.style.height=parseInt(this.wrapper.offsetHeight-50)+"px"}},{key:"setResizeButtonsVisibility",value:function(){"stack"==this.properties.state?(this.resizerTL.style.visibility="visible",this.resizerBR.style.visibility="visible"):(this.resizerTL.style.visibility="hidden",this.resizerBR.style.visibility="hidden")}},{key:"addListeners",value:function(){this.maximizeDiv.addEventListener("click",this.maximize.bind(this),!0),this.stackDiv.addEventListener("click",this.stack.bind(this),!0),this.minimizeDiv.addEventListener("click",this.minimize.bind(this),!0),this.closeDiv.addEventListener("click",this.cancelAction.bind(this)),v.addEvent(window,"mousedown",this.startDrag.bind(this)),v.addEvent(window,"mouseup",this.stopDrag.bind(this)),v.addEvent(window,"mousemove",this.drag.bind(this)),v.addEvent(window,"resize",this.onWindowResize.bind(this)),v.addEvent(window,"keydown",this.onKeyDown.bind(this))}},{key:"removeListeners",value:function(){v.removeEvent(window,"mousedown",this.startDrag),v.removeEvent(window,"mouseup",this.stopDrag),v.removeEvent(window,"mousemove",this.drag),v.removeEvent(window,"resize",this.onWindowResize),v.removeEvent(window,"keydown",this.onKeyDown)}},{key:"eventClient",value:function(e){if(void 0===e.clientX&&e.changedTouches){var t={X:e.changedTouches[0].clientX,Y:e.changedTouches[0].clientY};return t}return t={X:e.clientX,Y:e.clientY}}},{key:"startDrag",value:function(e){"minimized"!=this.properties.state&&e.target===this.title&&(void 0!==this.dragDataObject&&null!==this.dragDataObject||(e=e||event,this.dragDataObject={x:this.eventClient(e).X,y:this.eventClient(e).Y},this.lastDrag={x:"0px",y:"0px"},""==this.container.style.right&&(this.container.style.right="0px"),""==this.container.style.bottom&&(this.container.style.bottom="0px"),this.isIE11(),v.addClass(document.body,"wrs_noselect"),v.addClass(this.overlay,"wrs_overlay_active"),this.limitWindow=this.getLimitWindow()))}},{key:"drag",value:function(e){if(this.dragDataObject){e.preventDefault(),e=e||event;var t=Math.min(this.eventClient(e).Y,this.limitWindow.minPointer.y);t=Math.max(this.limitWindow.maxPointer.y,t);var i=Math.min(this.eventClient(e).X,this.limitWindow.minPointer.x),n=(i=Math.max(this.limitWindow.maxPointer.x,i))-this.dragDataObject.x+"px",r=t-this.dragDataObject.y+"px";this.lastDrag={x:n,y:r},this.container.style.transform="translate3d("+n+","+r+",0)"}if(this.resizeDataObject){var s;i=Math.min(this.eventClient(e).X,window.innerWidth-this.scrollbarWidth-7),t=Math.min(this.eventClient(e).Y,window.innerHeight-7);i<0&&(i=0),t<0&&(t=0),s=this.leftScale?-1:1,this.container.style.width=this.initialWidth+s*(i-this.resizeDataObject.x)+"px",this.container.style.height=this.initialHeight+s*(t-this.resizeDataObject.y)+"px",this.leftScale||(this.resizeDataObject.x-i-this.initialWidth<-580?this.container.style.right=this.initialRight-(i-this.resizeDataObject.x)+"px":(this.container.style.right=this.initialRight+this.initialWidth-580+"px",this.container.style.width="580px"),this.resizeDataObject.y-t580?(this.container.style.width=Math.min(parseInt(this.container.style.width),window.innerWidth-this.scrollbarWidth)+"px",e=!0):(this.container.style.width="580px",e=!0),parseInt(this.container.style.height)>338?(this.container.style.height=Math.min(parseInt(this.container.style.height),window.innerHeight)+"px",e=!0):(this.container.style.height="338px",e=!0),e&&this.recalculateSize()}},{key:"recalculateScrollBar",value:function(){this.hasScrollBar=window.innerWidth>document.documentElement.clientWidth,this.hasScrollBar?this.scrollbarWidth=this.getScrollBarWidth():this.scrollbarWidth=0}},{key:"hideKeyboard",value:function(){document.activeElement.blur()}},{key:"focus",value:function(){null!=this.contentManager&&void 0!==this.contentManager.onFocus&&this.contentManager.onFocus()}},{key:"portraitMode",value:function(){return window.innerHeight>window.innerWidth}},{key:"openedIosSoftkeyboard",value:function(){this.iosSoftkeyboardOpened||null==this.iosDivHeight||this.iosDivHeight!="100"+this.iosMeasureUnit||(this.portraitMode()?this.setContainerHeight("63"+this.iosMeasureUnit):this.setContainerHeight("40"+this.iosMeasureUnit)),this.iosSoftkeyboardOpened=!0}},{key:"closedIosSoftkeyboard",value:function(){this.iosSoftkeyboardOpened=!1,this.setContainerHeight("100"+this.iosMeasureUnit)}},{key:"orientationChangeIosSoftkeyboard",value:function(){this.iosSoftkeyboardOpened?this.portraitMode()?this.setContainerHeight("63"+this.iosMeasureUnit):this.setContainerHeight("40"+this.iosMeasureUnit):this.setContainerHeight("100"+this.iosMeasureUnit)}},{key:"orientationChangeAndroidSoftkeyboard",value:function(){this.setContainerHeight("100%")}},{key:"setContainerHeight",value:function(e){this.iosDivHeight=e,this.wrapper.style.height=e}},{key:"showPopUpMessage",value:function(){"minimized"==this.properties.state&&this.stack(),this.popup.show()}},{key:"setTitle",value:function(e){this.title.innerHTML=e}},{key:"getElementId",value:function(e){return e+"["+this.instanceId+"]"}}]),e}();function I(e){return(I="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function T(e,t){for(var i=0;i=4;){v.readInt32(e);var t=v.readInt32(e);if(1229472850==t){var i=v.readInt32(e),n=v.readInt32(e);v.readInt32(e),v.readByte(e)}else if(1650545477==t)var r=v.readInt32(e);else if(1883789683==t){var s=v.readInt32(e);s=Math.round(s/39.37),v.readInt32(e),v.readByte(e)}v.readInt32(e)}if(void 0!==i){var o=new Array;return o.cw=i,o.ch=n,o.dpi=s,r&&(o.cb=r),o}}}]),e}();function A(e,t){for(var i=0;i"),m=c.substring(0,f),p=m.split(" width=").join(' class="Wiriscas" width=');c=(c=c.split(m).join(p)).split("'").join('"')}}var b='';t=t.substring(0,n[a].start+s)+b+t.substring(n[a].end+s),s+=b.length-(n[a].end-n[a].start)}}return t}},{key:"initParseEditMode",value:function(e){if(-1!=l.get("parseModes").indexOf("latex"))for(var t=v.getElementsByNameFromString(e,"img",!0),i='encoding="LaTeX">',n=0,r=0;r",d),m=h.substring(d,f),g="$$"+v.htmlEntitiesDecode(m)+"$$";e=e.substring(0,t[r].start+n)+g+e.substring(t[r].end+n),n+=g.length-(t[r].end-t[r].start)}}}}return e}},{key:"endParse",value:function(t){return t=e.endParseEditMode(t),e.endParseSaveMode(t)}},{key:"endParseEditMode",value:function(e){if(-1!=l.get("parseModes").indexOf("latex")){for(var t="",i=0,n=e.indexOf("$$");-1!=n;){if(t+=e.substring(i,n),-1!=(i=e.indexOf("$$",n+2))){var r=e.substring(n+2,i);r=v.htmlEntitiesDecode(r),t+=g.getMathMLFromLatex(r,!0),i+=2}else t+="$$",i=n+2;n=e.indexOf("$$",i)}e=t+=e.substring(i,e.length)}return e}},{key:"endParseSaveMode",value:function(t){return l.get("saveMode")&&("safeXml"==l.get("saveMode")?t=e.codeImgTransform(t,"img2mathml"):"xml"==l.get("saveMode")?t=e.codeImgTransform(t,"img2mathml"):"base64"==l.get("saveMode")&&"image"==l.get("editMode")&&(t=e.codeImgTransform(t,"img264"))),t}},{key:"createShowImageSrc",value:function(e,t){var i=[],n="mml,color,centerbaseline,zoom,dpi,fontSize,fontFamily,defaultStretchy,backgroundColor,format".split(",");for(var r in n){var s=n[r];void 0!==e[s]&&(i[s]=e[s])}var o={};for(var r in e)"mml"!=r&&(o[r]=e[r]);return o.formula=com.wiris.js.JsPluginTools.md5encode(v.propertiesToString(i)),o.lang=void 0===t?"en":t,o.version=l.get("version"),f.getService("showimage",v.httpBuildQuery(o),!0)}},{key:"codeImgTransform",value:function(t,i){for(var n="",r=0,s=/"==h&&(r=u+1);++u}if(r",u):c.length,o.isMathmlInAttribute(t,u)||-1!=d)s+=t.substring(u,h);else{var f=t.substring(u,h);f=i==r.safeXmlCharacters?o.safeXmlDecode(f):o.mathMLEntities(f),s+=v.createObjectCode(e.mathmlToImgObject(document,f,null,n))}u=t.indexOf(a,h)}return s+=t.substring(h,t.length)}}]),e}();if("undefined"!=typeof MutationObserver){var D=new MutationObserver(function(e){e.forEach(function(e){e.oldValue===l.get("imageClassName")&&"class"===e.attributeName&&-1==e.target.className.indexOf(l.get("imageClassName"))&&(e.target.className=l.get("imageClassName"))})});B.observer=Object.create(D),B.observer.Config={attributes:!0,attributeOldValue:!0},B.observer.observe=function(e){this.__proto__.observe(e,this.Config)}}function R(e,t){for(var i=0;i=0&&(t=e[i].src.substr(0,n-1))}return t}},{key:"setLanguage",value:function(e){this.language=e}},{key:"setCore",value:function(e){this.core=e,e.setIntegrationModel(this)}},{key:"getCore",value:function(){return this.core}},{key:"setTarget",value:function(e){this.target=e,this.isIframe="IFRAME"===this.target.tagName.toUpperCase()}},{key:"setEditorObject",value:function(e){this.editorObject=e}},{key:"openNewFormulaEditor",value:function(){this.core.editionProperties.isNewElement=!0,this.core.openModalDialog(this.target,this.isIframe)}},{key:"openExistingFormulaEditor",value:function(){this.core.editionProperties.isNewElement=!1,this.core.openModalDialog(this.target,this.isIframe)}},{key:"updateFormula",value:function(e){this.isIframe?this.core.updateFormula(this.target.contentWindow,this.target.contentWindow,e,null):this.core.updateFormula(this.target,window,e,null)}},{key:"getSelection",value:function(){return this.isIframe?(this.target.contentWindow.focus(),this.target.contentWindow.getSelection()):(this.target.focus(),window.getSelection())}},{key:"addEvents",value:function(){var e=this.isIframe?this.target.contentWindow.document:this.target;v.addElementEvents(e,function(e,t){this.doubleClickHandler(e,t)}.bind(this),function(e,t){this.mousedownHandler(e,t)}.bind(this),function(e,t){this.mouseupHandler(e,t)}.bind(this))}},{key:"doubleClickHandler",value:function(e){if("img"==e.nodeName.toLowerCase()){if(this.core.getCustomEditors().disable(),e.hasAttribute("data-custom-editor")){var t=e.getAttribute("data-custom-editor");this.core.getCustomEditors().enable(t)}v.containsClass(e,l.get("imageClassName"))&&(this.core.editionProperties.temporalImage=e,this.core.editionProperties.isNewElement=!0,this.openExistingFormulaEditor())}}},{key:"mouseupHandler",value:function(){this.temporalImageResizing&&setTimeout(function(){P.fixAfterResize(this.temporalImageResizing)}.bind(this),10)}},{key:"mousedownHandler",value:function(e){"img"==e.nodeName.toLowerCase()&&v.containsClass(e,l.get("imageClassName"))&&(this.temporalImageResizing=e)}},{key:"getLanguage",value:function(){return this.getBrowserLanguage()}},{key:"getBrowserLanguage",value:function(){return navigator.userLanguage?navigator.userLanguage.substring(0,2):navigator.language?navigator.language.substring(0,2):"en"}},{key:"callbackFunction",value:function(){var e=y.newListener("onTargetReady",function(){this.addEvents(this.target)}.bind(this));this.listeners.add(e)}},{key:"notifyWindowClosed",value:function(){}},{key:"getMathmlFromTextNode",value:function(e,t){}},{key:"fillNonLatexNode",value:function(e,t,i){}},{key:"getSelectedItem",value:function(e,t){}}]),e}();function J(e,t){for(var i=0;i=0?"EDGE":e.search("Chrome/")>=0?"CHROME":e.search("Trident/")>=0?"IE":e.search("Firefox/")>=0?"FIREFOX":e.search("Safari/")>=0?"SAFARI":void 0}(),this.listeners=new y}return function(e,t,i){t&&J(e.prototype,t),i&&J(e,i)}(e,[{key:"init",value:function(e){this.load(e)}},{key:"setIntegrationModel",value:function(e){this.integrationModel=e}},{key:"setEnvironment",value:function(e){"editor"in e&&(this.environment.editor=e.editor),"mode"in e&&(this.environment.mode=e.mode),"version"in e&&(this.environment.version=e.version)}},{key:"getModalDialog",value:function(){return this.modalDialog}},{key:"load",value:function(t){var i="undefined"!=typeof XMLHttpRequest?new XMLHttpRequest:new ActiveXObject("Microsoft.XMLHTTP");this.integrationPath=0==t.indexOf("/")||0==t.indexOf("http")?t:v.concatenateUrl(this.integrationModel.getPath(),t),i.open("GET",this.integrationPath,!1),i.onload=function(t){var n=this;if(4===i.readyState){var r=JSON.parse(i.responseText);Object.keys(r);if(l.addConfiguration(r),l.addConfiguration(H),this.loadServicePaths(),this.loadLangFile(),this.loadCSS(),null===e.stringManager){var s=y.newListener("onLoad",function(){n.listeners.fire("onLoad",{})});e.stringManager.addListener(s)}else this.listeners.fire("onLoad",{})}}.bind(this),i.send(null)}},{key:"loadServicePaths",value:function(){var e=this.integrationPath.replace("configurationjs","createimage"),t=this.integrationPath.replace("configurationjs","showimage"),i=(e=this.integrationPath.replace("configurationjs","createimage"),this.integrationPath.replace("configurationjs","getmathml")),n=this.integrationPath.replace("configurationjs","service");if(0==this.integrationPath.indexOf("/")){var r=this.getServerPath();t=r+t,e=r+e,i=r+i,n=r+n}f.setServicePath("showimage",t),f.setServicePath("createimage",e),f.setServicePath("service",n),f.setServicePath("getmathml",i)}},{key:"getServerPath",value:function(){var e=this.integrationModel.getPath(),t=e.indexOf("/",e.indexOf("/")+2);return e.substr(0,t)}},{key:"loadLangFile",value:function(){var t="ar,ca,cs,da,de,en,es,et,eu,fi,fr,gl,he,hr,hu,it,ja,ko,nl,no,pl,pt,pt_br,ru,sv,tr,zh,el".split(","),i=this.language;-1==t.indexOf(i)&&(i=i.substr(0,2)),-1==t.indexOf(i)&&(i="en");var n=document.createElement("script");n.type="text/javascript",n.src=this.integrationModel.getPath()+"/"+this.integrationModel.langFolderName+"/"+i+"/strings.js",n.onload=function(){e.getStringManager().loadStrings(wrs_strings)},document.getElementsByTagName("head")[0].appendChild(n)}},{key:"loadCSS",value:function(){var e=document.createElement("link");e.setAttribute("rel","stylesheet"),e.setAttribute("type","text/css"),e.setAttribute("href",v.concatenateUrl(this.integrationModel.getPath(),"/core/styles.css")),document.getElementsByTagName("head")[0].appendChild(e)}},{key:"addListener",value:function(e){this.listeners.add(e)}},{key:"updateFormula",value:function(t,i,n,r){var s=new F;for(var o in s.mathml=n,s.wirisProperties={},r)s.wirisProperties[o]=r[o];if(s.language=this.language,s.editMode=this.editMode,!this.listeners.fire("onBeforeFormulaInsertion",s)&&!e.globalListeners.fire("onBeforeFormulaInsertion",s)){n=s.mathml,r=s.wirisProperties;var a=new F;if(a.editMode=this.editMode,a.windowTarget=i,a.focusElement=t,0==n.length)this.insertElementOnSelection(null,t,i);else if("latex"==this.editMode)a.latex=g.getLatexFromMathML(n),this.integrationModel.fillNonLatexNode&&void 0===a.latex?this.integrationModel.fillNonLatexNode(a,i,n):a.node=i.document.createTextNode("$$"+a.latex+"$$"),this.insertElementOnSelection(a.node,t,i);else if("iframes"==this.editMode){var l=wrs_mathmlToIframeObject(i,n);this.insertElementOnSelection(l,t,i)}else a.node=B.mathmlToImgObject(i.document,n,r,this.language),this.insertElementOnSelection(a.node,t,i);this.listeners.fire("onAfterFormulaInsertion",a)||e.globalListeners.fire("onAfterFormulaInsertion",a)}}},{key:"placeCaretAfterNode",value:function(e){this.integrationModel.getSelection();var t=e.ownerDocument;if(void 0!==t.getSelection){var i=t.createRange();i.setStartAfter(e),i.collapse(!0);var n=t.getSelection();n.removeAllRanges(),n.addRange(i),t.body.focus()}}},{key:"insertElementOnSelection",value:function(e,t,i){if(this.editionProperties.isNewElement)if("textarea"==t.type)v.updateTextArea(t,e.textContent);else if(document.selection&&0==document.getSelection){var n=i.document.selection.createRange();if(i.document.execCommand("InsertImage",!1,e.src),"parentElement"in n||(i.document.execCommand("delete",!1),n=i.document.selection.createRange(),i.document.execCommand("InsertImage",!1,e.src)),"parentElement"in n){var r=n.parentElement();"IMG"==r.nodeName.toUpperCase()?r.parentNode.replaceChild(e,r):n.pasteHTML(v.createObjectCode(e))}}else{var s,o=this.integrationModel.getSelection();this.editionProperties.range?(s=this.editionProperties.range,this.editionProperties.range=null):s=o.getRangeAt(0),s.deleteContents();var a=s.startContainer,l=s.startOffset;3==a.nodeType?(a=a.splitText(l)).parentNode.insertBefore(e,a):1==a.nodeType&&a.insertBefore(e,a.childNodes[l]),this.placeCaretAfterNode(e)}else if(this.editionProperties.latexRange)if(document.selection&&0==document.getSelection)this.editionProperties.isNewElement=!0,this.editionProperties.latexRange.select(),this.insertElementOnSelection(e,t,i);else{this.editionProperties.latexRange.startContainer;this.editionProperties.latexRange.deleteContents(),this.editionProperties.latexRange.insertNode(e),this.placeCaretAfterNode(e)}else if("textarea"==t.type){var c;c=void 0!==this.integrationModel.getSelectedItem?this.integrationModel.getSelectedItem(t,!1):v.getSelectedItemOnTextarea(t),v.updateExistingTextOnTextarea(t,e.textContent,c.startPosition,c.endPosition)}else e||this.editionProperties.temporalImage.parentNode.removeChild(this.editionProperties.temporalImage),this.editionProperties.temporalImage.parentNode.replaceChild(e,this.editionProperties.temporalImage),this.placeCaretAfterNode(e)}},{key:"openModalDialog",value:function(e,t){this.editMode="images";try{if(t){e.contentWindow.focus();var i=e.contentWindow.getSelection();this.editionProperties.range=i.getRangeAt(0)}else{e.focus();var n=getSelection();this.editionProperties.range=n.getRangeAt(0)}}catch(e){this.editionProperties.range=null}var r;if(void 0===t&&(t=!0),this.editionProperties.latexRange=null,e)if(r=void 0!==this.integrationModel.getSelectedItem?this.integrationModel.getSelectedItem(e,t):v.getSelectedItem(e,t)){if(!r.caretPosition&&v.containsClass(r.node,l.get("imageClassName")))this.editionProperties.temporalImage=r.node,this.editionProperties.isNewElement=!1;else if(3===r.node.nodeType)if(this.integrationModel.getMathmlFromTextNode){var s=this.integrationModel.getMathmlFromTextNode(r.node,r.caretPosition);s&&(this.editMode="latex",this.editionProperties.isNewElement=!1,this.editionProperties.temporalImage=document.createElement("img"),this.editionProperties.temporalImage.setAttribute(l.get("imageMathmlAttribute"),o.safeXmlEncode(s)))}else{var a=g.getLatexFromTextNode(r.node,r.caretPosition);if(a){var c=g.getMathMLFromLatex(a.latex);this.editMode="latex",this.editionProperties.isNewElement=!1,this.editionProperties.temporalImage=document.createElement("img"),this.editionProperties.temporalImage.setAttribute(l.get("imageMathmlAttribute"),o.safeXmlEncode(c));var u=t?e.contentWindow:window;if("textarea"!==e.tagName.toLowerCase())if(document.selection){for(var h=0,d=a.startNode.previousSibling;d;)h+=v.getNodeLength(d),d=d.previousSibling;this.editionProperties.latexRange=u.document.selection.createRange(),this.editionProperties.latexRange.moveToElementText(a.startNode.parentNode),this.editionProperties.latexRange.move("character",h+a.startPosition),this.editionProperties.latexRange.moveEnd("character",a.latex.length+4)}else this.editionProperties.latexRange=u.document.createRange(),this.editionProperties.latexRange.setStart(a.startNode,a.startPosition),this.editionProperties.latexRange.setEnd(a.endNode,a.endPosition)}}}else"textarea"===e.tagName.toLowerCase()&&(this.editMode="latex");for(var f=l.get("editorAttributes").split(", "),m={},p=0,b=f.length;p>>32-t},str2blks:function(e){for(var t=1+(e.length+8>>6),i=new Array,n=0,r=16*t;n>2]|=HxOverrides.cca(e,s)<<(8*e.length+s)%4*8,s++;i[s>>2]|=128<<(8*e.length+s)%4*8;var a=8*e.length,o=16*t-2;return i[o]=255&a,i[o]|=(a>>>8&255)<<8,i[o]|=(a>>>16&255)<<16,i[o]|=(a>>>24&255)<<24,i},rhex:function(e){for(var t="",i=0;i<4;){var n=i++;t+="0123456789abcdef".charAt(e>>8*n+4&15)+"0123456789abcdef".charAt(e>>8*n&15)}return t},addme:function(e,t){var i=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(i>>16)<<16|65535&i},bitAND:function(e,t){return(e>>>1&t>>>1)<<1|1&e&t},bitXOR:function(e,t){return(e>>>1^t>>>1)<<1|1&e^1&t},bitOR:function(e,t){return(e>>>1|t>>>1)<<1|(1&e|1&t)},__class__:haxe.Md5},haxe.Timer=function(e){var t=this;this.id=window.setInterval(function(){t.run()},e)},haxe.Timer.__name__=!0,haxe.Timer.delay=function(e,t){var i=new haxe.Timer(t);return i.run=function(){i.stop(),e()},i},haxe.Timer.measure=function(e,t){var i=haxe.Timer.stamp(),n=e();return haxe.Log.trace(haxe.Timer.stamp()-i+"s",t),n},haxe.Timer.stamp=function(){return(new Date).getTime()/1e3},haxe.Timer.prototype={run:function(){},stop:function(){null!=this.id&&(window.clearInterval(this.id),this.id=null)},__class__:haxe.Timer};var js=js||{},$_;function $bind(e,t){var i=function e(){return e.method.apply(e.scope,arguments)};return i.scope=e,i.method=t,i}js.Boot=function(){},js.Boot.__name__=!0,js.Boot.__unhtml=function(e){return e.split("&").join("&").split("<").join("<").split(">").join(">")},js.Boot.__trace=function(e,t){var i,n=null!=t?t.fileName+":"+t.lineNumber+": ":"";n+=js.Boot.__string_rec(e,""),"undefined"!=typeof document&&null!=(i=document.getElementById("haxe:trace"))?i.innerHTML+=js.Boot.__unhtml(n)+"
":"undefined"!=typeof console&&null!=console.log&&console.log(n)},js.Boot.__clear_trace=function(){var e=document.getElementById("haxe:trace");null!=e&&(e.innerHTML="")},js.Boot.isClass=function(e){return e.__name__},js.Boot.isEnum=function(e){return e.__ename__},js.Boot.getClass=function(e){return e.__class__},js.Boot.__string_rec=function(e,t){if(null==e)return"null";if(t.length>=5)return"<...>";var i=_typeof(e);switch("function"==i&&(e.__name__||e.__ename__)&&(i="object"),i){case"object":if(e instanceof Array){if(e.__enum__){if(2==e.length)return e[0];var n=e[0]+"(";t+="\t";for(var r=2,s=e.length;r0?",":"")+js.Boot.__string_rec(e[l],t)}return n+="]"}var c;try{c=e.toString}catch(e){return"???"}if(null!=c&&c!=Object.toString){var u=e.toString();if("[object Object]"!=u)return u}var h=null;n="{\n";t+="\t";var d=null!=e.hasOwnProperty;for(var h in e)d&&!e.hasOwnProperty(h)||"prototype"!=h&&"__class__"!=h&&"__super__"!=h&&"__interfaces__"!=h&&"__properties__"!=h&&(2!=n.length&&(n+=", \n"),n+=t+h+" : "+js.Boot.__string_rec(e[h],t));return n+="\n"+(t=t.substring(1))+"}";case"function":return"";case"string":return e;default:return String(e)}},js.Boot.__interfLoop=function(e,t){if(null==e)return!1;if(e==t)return!0;var i=e.__interfaces__;if(null!=i)for(var n=0,r=i.length;n>>32-t},str2blks:function(e){for(var t=1+(e.length+8>>6),i=new Array,n=0,r=16*t;n>2]|=HxOverrides.cca(e,s)<<(8*e.length+s)%4*8,s++;i[s>>2]|=128<<(8*e.length+s)%4*8;var a=8*e.length,o=16*t-2;return i[o]=255&a,i[o]|=(a>>>8&255)<<8,i[o]|=(a>>>16&255)<<16,i[o]|=(a>>>24&255)<<24,i},rhex:function(e){for(var t="",i=0;i<4;){var n=i++;t+="0123456789abcdef".charAt(e>>8*n+4&15)+"0123456789abcdef".charAt(e>>8*n&15)}return t},addme:function(e,t){var i=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(i>>16)<<16|65535&i},bitAND:function(e,t){return(e>>>1&t>>>1)<<1|1&e&t},bitXOR:function(e,t){return(e>>>1^t>>>1)<<1|1&e^1&t},bitOR:function(e,t){return(e>>>1|t>>>1)<<1|(1&e|1&t)},__class__:haxe.Md5},haxe.Timer=function(e){var t=this;this.id=window.setInterval(function(){t.run()},e)},haxe.Timer.__name__=!0,haxe.Timer.delay=function(e,t){var i=new haxe.Timer(t);return i.run=function(){i.stop(),e()},i},haxe.Timer.measure=function(e,t){var i=haxe.Timer.stamp(),n=e();return haxe.Log.trace(haxe.Timer.stamp()-i+"s",t),n},haxe.Timer.stamp=function(){return(new Date).getTime()/1e3},haxe.Timer.prototype={run:function(){},stop:function(){null!=this.id&&(window.clearInterval(this.id),this.id=null)},__class__:haxe.Timer};var js=js||{},$_;function $bind(e,t){var i=function e(){return e.method.apply(e.scope,arguments)};return i.scope=e,i.method=t,i}js.Boot=function(){},js.Boot.__name__=!0,js.Boot.__unhtml=function(e){return e.split("&").join("&").split("<").join("<").split(">").join(">")},js.Boot.__trace=function(e,t){var i,n=null!=t?t.fileName+":"+t.lineNumber+": ":"";n+=js.Boot.__string_rec(e,""),"undefined"!=typeof document&&null!=(i=document.getElementById("haxe:trace"))?i.innerHTML+=js.Boot.__unhtml(n)+"
":"undefined"!=typeof console&&null!=console.log&&console.log(n)},js.Boot.__clear_trace=function(){var e=document.getElementById("haxe:trace");null!=e&&(e.innerHTML="")},js.Boot.isClass=function(e){return e.__name__},js.Boot.isEnum=function(e){return e.__ename__},js.Boot.getClass=function(e){return e.__class__},js.Boot.__string_rec=function(e,t){if(null==e)return"null";if(t.length>=5)return"<...>";var i=_typeof(e);switch("function"==i&&(e.__name__||e.__ename__)&&(i="object"),i){case"object":if(e instanceof Array){if(e.__enum__){if(2==e.length)return e[0];var n=e[0]+"(";t+="\t";for(var r=2,s=e.length;r0?",":"")+js.Boot.__string_rec(e[l],t)}return n+="]"}var c;try{c=e.toString}catch(e){return"???"}if(null!=c&&c!=Object.toString){var u=e.toString();if("[object Object]"!=u)return u}var h=null;n="{\n";t+="\t";var d=null!=e.hasOwnProperty;for(var h in e)d&&!e.hasOwnProperty(h)||"prototype"!=h&&"__class__"!=h&&"__super__"!=h&&"__interfaces__"!=h&&"__properties__"!=h&&(2!=n.length&&(n+=", \n"),n+=t+h+" : "+js.Boot.__string_rec(e[h],t));return n+="\n"+(t=t.substring(1))+"}";case"function":return"";case"string":return e;default:return String(e)}},js.Boot.__interfLoop=function(e,t){if(null==e)return!1;if(e==t)return!0;var i=e.__interfaces__;if(null!=i)for(var n=0,r=i.length;n=0&&l.splice(t,1)}function m(e){var t=document.createElement("style");if(void 0===e.attrs.type&&(e.attrs.type="text/css"),void 0===e.attrs.nonce){var n=function(){0;return i.nc}();n&&(e.attrs.nonce=n)}return g(t,e.attrs),d(e,t),t}function g(e,t){Object.keys(t).forEach(function(i){e.setAttribute(i,t[i])})}function p(e,t){var i,n,r,s;if(t.transform&&e.css){if(!(s=t.transform(e.css)))return function(){};e.css=s}if(t.singleton){var l=o++;i=a||(a=m(t)),n=b.bind(null,i,l,!1),r=b.bind(null,i,l,!0)}else e.sourceMap&&"function"==typeof URL&&"function"==typeof URL.createObjectURL&&"function"==typeof URL.revokeObjectURL&&"function"==typeof Blob&&"function"==typeof btoa?(i=function(e){var t=document.createElement("link");return void 0===e.attrs.type&&(e.attrs.type="text/css"),e.attrs.rel="stylesheet",g(t,e.attrs),d(e,t),t}(t),n=function(e,t,i){var n=i.css,r=i.sourceMap,s=void 0===t.convertToAbsoluteUrls&&r;(t.convertToAbsoluteUrls||s)&&(n=c(n));r&&(n+="\n/*# sourceMappingURL=data:application/json;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(r))))+" */");var a=new Blob([n],{type:"text/css"}),o=e.href;e.href=URL.createObjectURL(a),o&&URL.revokeObjectURL(o)}.bind(null,i,t),r=function(){f(i),i.href&&URL.revokeObjectURL(i.href)}):(i=m(t),n=function(e,t){var i=t.css,n=t.media;n&&e.setAttribute("media",n);if(e.styleSheet)e.styleSheet.cssText=i;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(i))}}.bind(null,i),r=function(){f(i)});return n(e),function(t){if(t){if(t.css===e.css&&t.media===e.media&&t.sourceMap===e.sourceMap)return;n(e=t)}else r()}}e.exports=function(e,t){if("undefined"!=typeof DEBUG&&DEBUG&&"object"!=typeof document)throw new Error("The style-loader cannot be used in a non-browser environment");(t=t||{}).attrs="object"==typeof t.attrs?t.attrs:{},t.singleton||"boolean"==typeof t.singleton||(t.singleton=r()),t.insertInto||(t.insertInto="head"),t.insertAt||(t.insertAt="bottom");var i=h(e,t);return u(i,t),function(e){for(var r=[],s=0;s«/mo»",ampElement:"«mo»&«/mo»"}}},{key:"safeGoodBlackboardCharacters",get:function(){return{ltElement:"«mo»§lt;«/mo»",gtElement:"«mo»§gt;«/mo»",ampElement:"«mo»§amp;«/mo»"}}}]),e}();function s(e,t){for(var i=0;i",doubleQuote:'"',ampersand:"&",quote:"'"},r.safeXmlCharacters={tagOpener:"«",tagCloser:"»",doubleQuote:"¨",ampersand:"§",quote:"`",realDoubleQuote:"¨"};var a=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}return function(e,t,i){t&&s(e.prototype,t),i&&s(e,i)}(e,null,[{key:"isMathmlInAttribute",value:function(e,t){var i=new RegExp("^['\"][\\s]*=[\\s]*[\\w-]+([\\s]*(\"[^\"]*\"|'[^']*')[\\s]*=[\\s]*[\\w-]+[\\s]*)*[\\s]+gmi<"),n=e.substring(0,t).split("").reverse().join("");return i.test(n)}},{key:"safeXmlDecode",value:function(e){e=(e=(e=(e=e.split(r.safeXmlCharactersEntities.tagOpener).join(r.safeXmlCharacters.tagOpener)).split(r.safeXmlCharactersEntities.tagCloser).join(r.safeXmlCharacters.tagCloser)).split(r.safeXmlCharactersEntities.doubleQuote).join(r.safeXmlCharacters.doubleQuote)).split(r.safeXmlCharactersEntities.realDoubleQuote).join(r.safeXmlCharacters.realDoubleQuote),"_wrs_blackboard"in window&&window._wrs_blackboard&&(e=(e=(e=e.split(r.safeBadBlackboardCharacters.ltElement).join(r.safeGoodBlackboardCharacters.ltElement)).split(r.safeBadBlackboardCharacters.gtElement).join(r.safeGoodBlackboardCharacters.gtElement)).split(r.safeBadBlackboardCharacters.ampElement).join(r.safeGoodBlackboardCharacters.ampElement)),e=(e=(e=(e=(e=e.split(r.safeXmlCharacters.tagOpener).join(r.xmlCharacters.tagOpener)).split(r.safeXmlCharacters.tagCloser).join(r.xmlCharacters.tagCloser)).split(r.safeXmlCharacters.doubleQuote).join(r.xmlCharacters.doubleQuote)).split(r.safeXmlCharacters.ampersand).join(r.xmlCharacters.ampersand)).split(r.safeXmlCharacters.quote).join(r.xmlCharacters.quote);for(var t="",i=null,n=0;n128)t+="&#"+e.codePointAt(i)+";",e.codePointAt(i)>65535&&i++;else if("&"==n){var r=e.indexOf(";",i+1);if(r>=0){var s=document.createElement("span");s.innerHTML=e.substring(i,r+1),t+="&#"+v.fixedCharCodeAt(s.innerText||s.textContent,0)+";",i=r}else t+=n}else t+=n}return t}},{key:"addCustomEditorClassAttribute",value:function(e,t){var i="",n=e.indexOf("");if(-1==e.indexOf("class"))return i=e.substr(n,r)+' class="wrs_'+t+'">',i+=e.substr(r+1,e.length)}return e}},{key:"removeCustomEditorClassAttribute",value:function(e,t){return-1===e.indexOf("class")||-1===e.indexOf("wrs_"+t)?e:-1!==e.indexOf('class="wrs_'+t+'"')?e.replace('class="wrs_'+t+'"',""):e.replace("wrs_"+t,"")}},{key:"insertSemanticsMathml",value:function(e,t,i){if(""==t)return e;var n='',r=e.indexOf(">"),s=e.indexOf(""),a=e.substring(e.indexOf("<"),e.indexOf(">")).indexOf("math");if(-1!=r&&-1!=s&&a){var o=e.substring(r+1,s);if(0!=o.indexOf(""))var l=""+o+""+n+t+"
";else l=""+o+n+t+"
";return e.replace(o,l)}return e}},{key:"removeSemantics",value:function(e,t){var i='',n=e,r=e.indexOf("");if(-1!=r){var s=e.indexOf(i,r+"".length);-1!=s&&(n=e.substring(0,r)+e.substring(r+"".length,s)+"")}return n}},{key:"removeSemanticsOcurrences",value:function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:r.xmlCharacters,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"application/json",n=t.tagOpener+"math",s=t.tagOpener+"/math"+t.tagCloser,a="/"+t.tagCloser,o=t.tagCloser,l=t.tagOpener+"semantics"+t.tagCloser,c=t.tagOpener+"annotation encoding="+t.doubleQuote+i+t.doubleQuote+t.tagCloser,u="",h=e.indexOf(n),d=0;-1!==h;){u+=e.substring(d,h);var f=e.indexOf(s,h),m=e.indexOf(a,h),g=e.indexOf(o,h);-1!==f?d=f:m===g-1&&(d=m);var p=e.indexOf(l,h);if(-1!==p){var v=e.substring(h,p),b=e.indexOf(c,h);if(-1!==b)u+=v+e.substring(p+l.length,b)+s,h=e.indexOf(n,h+n.length),d+=s.length;else d=h,h=e.indexOf(n,h+n.length)}else d=h,h=e.indexOf(n,h+n.length)}return u+=e.substring(d,e.length)}},{key:"containClass",value:function(e,t){var i=e.indexOf("class");if(-1==i)return!1;var n=e.indexOf(">",i);return-1!=e.substring(i,n).indexOf(t)}}]),e}();function o(e,t){for(var i=0;i=0;--n)if(i[n]==t)return!0;return!1}},{key:"removeClass",value:function(e,t){for(var i="",n=e.className.split(" "),r=0;r").join("").split("").join("")).split("").join("
").split("").join("
");var n=e.createElement("div",{},i);return n.innerHTML=t,function t(n){if(n.getAttribute&&"WirisParam"==n.getAttribute("wirisObject")){for(var r={},s=0;s0){i+=">";for(n=0;n"}else"DIV"==t.nodeName||"SCRIPT"==t.nodeName?i+=">":i+="/>";return i}return 3==t.nodeType?e.htmlEntities(t.nodeValue):""}}},{key:"concatenateUrl",value:function(e,t){var i="";return e.indexOf("/")!=e.length&&0!=t.indexOf("/")&&(i="/"),(e+i+t).replace(/([^:]\/)\/+/g,"$1")}},{key:"htmlEntities",value:function(e){return e.split("&").join("&").split("<").join("<").split(">").join(">").split('"').join(""")}},{key:"htmlEntitiesDecode",value:function(e){return e.split(""").join('"').split(">").join(">").split("<").join("<").split("&").join("&")}},{key:"createHttpRequest",value:function(){if("file://"==window.location.toString().substr(0,window.location.toString().lastIndexOf("/")+1).substr(0,7))throw Core.getStringManager().getString("exception_cross_site");if("undefined"!=typeof XMLHttpRequest)return new XMLHttpRequest;try{return new ActiveXObject("Msxml2.XMLHTTP")}catch(e){try{return new ActiveXObject("Microsoft.XMLHTTP")}catch(e){}}return!1}},{key:"httpBuildQuery",value:function(t){var i="";for(var n in t)null!=t[n]&&(i+=e.urlEncode(n)+"="+e.urlEncode(t[n])+"&");return"&"==i.substring(i.length-1)&&(i=i.substring(0,i.length-1)),i}},{key:"propertiesToString",value:function(t){var i=[];for(var n in t)t.hasOwnProperty(n)&&i.push(n);for(var r=i.length,s=0;s0&&(i[s]=l,i[a]=o)}var c="";for(s=0;ss?s:r;for(n=0;n0){var i=e.substring(t+1).split("&"),n=new Object;for(t=0;t1&&(n[r[0]]=decodeURIComponent(r[1].replace(/\+/g," ")))}return n}return new Object}},{key:"urlEncode",value:function(e){return encodeURIComponent(e)}},{key:"getWIRISImageOutput",value:function(t,i,n){var s=e.createObject(t);if(s){if(s.className==l.get("imageClassName")||s.getAttribute(l.get("imageMathmlAttribute"))){if(!i)return t;var o=s.getAttribute(l.get("imageMathmlAttribute"));return l.get("saveHandTraces")||(o=a.removeSemanticsOcurrences(o,r.safeXmlCharacters)),null==o&&(o=s.getAttribute("alt")),n||(o=a.safeXmlDecode(o)),o}if(s.className==l.get("CASClassName")){var c=s.getAttribute(l.get("CASMathmlAttribute"));c=a.safeXmlDecode(c);var u=e.createObject(c);u.setAttribute("src",s.src);var h=e.createObjectCode(u);return n&&(h=a.safeXmlEncode(h)),h}}return t}},{key:"getNodeLength",value:function(e){function t(t){return e.apply(this,arguments)}return t.toString=function(){return e.toString()},t}(function(e){if(3==e.nodeType)return e.nodeValue.length;if(1==e.nodeType){var t={IMG:1,BR:1}[e.nodeName.toUpperCase()];void 0===t&&(t=0);for(var i=0;i0)return 0==c.text.length?e.getSelectedItem(t,i,!0):null;r.document.execCommand("InsertImage",!1,"#");var s,a=c.parentElement();return"IMG"!=a.nodeName.toUpperCase()&&(c.pasteHTML(''),a=r.document.getElementById("wrs_openEditorWindow_temporalObject")),a.nextSibling&&3==a.nextSibling.nodeType?(o=a.nextSibling,s=0):a.previousSibling&&3==a.previousSibling.nodeType?s=(o=a.previousSibling).nodeValue.length:(o=r.document.createTextNode(""),a.parentNode.insertBefore(o,a),s=0),a.parentNode.removeChild(a),{node:o,caretPosition:s}}return c.length>1?null:{node:c.item(0)}}if(r.getSelection){var o,l=r.getSelection();try{var c=l.getRangeAt(0)}catch(e){c=r.document.createRange()}if(3==(o=c.startContainer).nodeType)return{node:o,caretPosition:c.startOffset};if(o!=c.endContainer)return null;if(1==o.nodeType){var u=c.startOffset;if(o.childNodes[u])return{node:o.childNodes[u]}}}return null}},{key:"getSelectedItemOnTextarea",value:function(e){var t=document.createTextNode(e.value),i=g.getLatexFromTextNode(t,e.selectionStart);return null===i?null:{node:t,caretPosition:e.selectionStart,startPosition:i.startPosition,endPosition:i.endPosition}}},{key:"getElementsByNameFromString",value:function(e,t,i){var n=[];e=e.toLowerCase();t=t.toLowerCase();for(var r=e.indexOf("<"+t+" ");-1!=r;){var s;s=i?">":"";var a=e.indexOf(s,r);-1!=a?(a+=s.length,n.push({start:r,end:a})):a=r+1,r=e.indexOf("<"+t+" ",a)}return n}},{key:"decode64",value:function(e){var t="+".charCodeAt(0),i="/".charCodeAt(0),n="0".charCodeAt(0),r="a".charCodeAt(0),s="A".charCodeAt(0),a="-".charCodeAt(0),o="_".charCodeAt(0),l=e.charCodeAt(0);return l===t||l===a?62:l===i||l===o?63:l0)throw new Error("Invalid string. Length must be a multiple of 4");var r=new Array;if(i)a=i;else var s="="===t.charAt(t.length-2)?2:"="===t.charAt(t.length-1)?1:0,a=s>0?t.length-4:t.length;for(var o=0;o>16&255),r.push(n>>8&255),r.push(255&n);return s&&(2===s?(n=e.decode64(t.charAt(o))<<2|e.decode64(t.charAt(o+1))>>4,r.push(255&n)):1===s&&(n=e.decode64(t.charAt(o))<<10|e.decode64(t.charAt(o+1))<<4|e.decode64(t.charAt(o+2))>>2,r.push(n>>8&255),r.push(255&n))),r}},{key:"readInt32",value:function(e){if(e.length<4)return!1;var t=e.splice(0,4);return t[0]<<24|t[1]<<16|t[2]<<8|t[3]<<0}},{key:"readByte",value:function(e){return e.shift()<<0}},{key:"readBytes",value:function(e,t,i){return e.splice(t,i)}},{key:"updateTextArea",value:function(e,t){if(e&&t)if(e.focus(),null!=e.selectionStart){var i=e.selectionEnd;e.value=e.value.substring(0,e.selectionStart)+t+e.value.substring(e.selectionEnd,e.value.length),e.selectionEnd=i+t.length}else{document.selection.createRange().text=t}}},{key:"updateExistingTextOnTextarea",value:function(e,t,i,n){e.focus(),e.value=e.value.substring(0,i)+t+e.value.substring(n,e.value.length),e.selectionEnd=i+t.length}},{key:"addArgument",value:function(e,t,i){return e+(e.indexOf("?")>0?"&":"?")+t+"="+i}}]),e}();function b(e,t){for(var i=0;i-1,this.deviceProperties.isIOS=this.ua.indexOf("ipad")>-1||this.ua.indexOf("iphone")>-1,this.toolbar=null,this.modalDialogInstance=null,this.listeners=new y,this.mathML=null,this.isNewElement=!0,this.integrationModel=null,this.isEditorLoaded=!1}return function(e,t,i){t&&E(e.prototype,t),i&&E(e,i)}(e,[{key:"addListener",value:function(e){this.listeners.add(e)}},{key:"setIntegrationModel",value:function(e){this.integrationModel=e}},{key:"setModalDialogInstance",value:function(e){this.modalDialogInstance=e}},{key:"insert",value:function(){this.updateTitle(this.modalDialogInstance),this.insertEditor(this.modalDialogInstance)}},{key:"insertEditor",value:function(){if("com"in window&&"wiris"in window.com&&"jsEditor"in window.com.wiris){if(this.editor=com.wiris.jsEditor.JsEditor.newInstance(this.editorAttributes),this.editor.insertInto(this.modalDialogInstance.contentContainer),this.editor.focus(),this.modalDialogInstance.rtl&&this.editor.action("rtl"),this.editor.getEditorModel().isRTL()&&(this.editor.element.style.direction="rtl"),this.editor.getEditorModel().addEditorListener(this.editorListener),this.modalDialogInstance.deviceProperties.isIOS){setTimeout(function(){this.modalDialogInstance.hideKeyboard()},400);var t=document.getElementsByClassName("wrs_formulaDisplay")[0];v.addEvent(t,"focus",this.modalDialogInstance.handleOpenedIosSoftkeyboard),v.addEvent(t,"blur",this.modalDialogInstance.handleClosedIosSoftkeyboard)}this.listeners.fire("onLoad",{}),this.isEditorLoaded=!0}else setTimeout(e.prototype.insertEditor.bind(this,this.modalDialogInstance),100)}},{key:"init",value:function(){for(var e=window.location.search.substring(1).split("&"),t=0;t=0&&(version=e[t].substring(2))}var i=document.createElement("script");i.type="text/javascript";var n=l.get("editorUrl"),r=document.createElement("a");r.href=n,0==window.location.href.indexOf("https://")&&"http:"==r.protocol&&(r.protocol="https:"),n="80"==r.port||"443"==r.port?r.protocol+"//"+r.hostname+"/"+r.pathname:r.protocol+"//"+r.hostname+":"+r.port+"/"+r.pathname;var s={};"editor"in this.environment?s.editor=this.environment.editor:s.editor="unknown","mode"in this.environment?s.mode=this.environment.mode:s.mode=l.get("saveMode"),"version"in this.environment?s.version=this.environment.version:s.version=l.get("version"),i.src=n+"?lang="+this.language+"&stats-editor="+s.editor+"&stats-mode="+s.mode+"&stats-version="+s.version,document.getElementsByTagName("head")[0].appendChild(i)}},{key:"setInitialContent",value:function(){this.isNewElement||this.setMathML(this.mathML)}},{key:"setMathML",value:function(e,t){void 0===t&&(t=!1),this.editor.setMathMLWithCallback(e,function(){this.editorListener.setWaitingForChanges(!0)}.bind(this)),setTimeout(function(){this.editorListener.setIsContentChanged(!1)}.bind(this),500),t||this.onFocus()}},{key:"onFocus",value:function(){void 0!==this.editor&&null!=this.editor&&this.editor.focus()}},{key:"submitAction",value:function(){if(this.editor.isFormulaEmpty())this.integrationModel.updateFormula(null);else{var e=this.editor.getMathMLWithSemantics();if(null!=this.customEditors.getActiveEditor())e=a.addCustomEditorClassAttribute(e,this.customEditors.getActiveEditor().toolbar);else for(var t in this.customEditors.editors)e=a.removeCustomEditorClassAttribute(e,t);var i=a.mathMLEntities(e);this.integrationModel.updateFormula(i)}this.customEditors.disable(),this.integrationModel.notifyWindowClosed(),this.setEmptyMathML(),this.customEditors.disable()}},{key:"setEmptyMathML",value:function(){this.deviceProperties.isAndroid||this.deviceProperties.isIOS?this.editor.getEditorModel().isRTL()?this.setMathML('[]"',!0):this.setMathML('[]"',!0):this.editor.getEditorModel().isRTL()?this.setMathML('',!0):this.setMathML("",!0)}},{key:"onOpen",value:function(){this.isNewElement?this.setEmptyMathML():this.setMathML(this.mathML),this.updateToolbar(),this.onFocus()}},{key:"updateToolbar",value:function(){var e;if(this.updateTitle(this.modalDialogInstance),e=this.customEditors.getActiveEditor()){var t=e.toolbar?e.toolbar:_wrs_int_wirisProperties.toolbar;null!=this.toolbar&&this.toolbar==t||this.setToolbar(t)}else{t=this.getToolbar();null!=this.toolbar&&this.toolbar==t||(this.setToolbar(t),this.customEditors.disable())}}},{key:"updateTitle",value:function(){var e;(e=this.customEditors.getActiveEditor())?this.modalDialogInstance.setTitle(e.title):this.modalDialogInstance.setTitle("MathType")}},{key:"getToolbar",value:function(){var e;return"general"==(e="toolbar"in this.editorAttributes?this.editorAttributes.toolbar:"general")&&(e="undefined"==typeof _wrs_int_wirisProperties||void 0===_wrs_int_wirisProperties.toolbar?"general":_wrs_int_wirisProperties.toolbar),e}},{key:"setToolbar",value:function(e){this.toolbar=e,this.editor.setParams({toolbar:this.toolbar})}},{key:"hasChanges",value:function(){return!this.editor.isFormulaEmpty()&&this.editorListener.getIsContentChanged()}}]),e}();function k(e,t){for(var i=0;i-1,r=i.indexOf("ipad")>-1||i.indexOf("iphone")>-1;this.iosSoftkeyboardOpened=!1,this.iosMeasureUnit=-1==i.indexOf("crios")?"%":"vh",this.iosDivHeight="100"+this.iosMeasureUnit;var s=window.outerWidth,a=window.outerHeight,o=s>a,l=sa||l&&this.attributes.width>s);this.instanceId=document.getElementsByClassName("wrs_modal_dialogContainer").length,this.deviceProperties={orientation:o?"landscape":"portait",isAndroid:!!n,isIOS:!!r,isMobile:c,isDesktop:!c&&!r&&!n},this.properties={created:!1,state:"",previousState:"",position:{bottom:0,right:10},size:{height:338,width:580}};var u={class:"wrs_modal_overlay"};u.id=this.getElementId(u.class),this.overlay=v.createElement("div",u),(u={}).class="wrs_modal_title_bar",u.id=this.getElementId(u.class),this.titleBar=v.createElement("div",u),(u={}).class="wrs_modal_title",u.id=this.getElementId(u.class),this.title=v.createElement("div",u),this.title.innerHTML="",(u={}).class="wrs_modal_close_button",u.id=this.getElementId(u.class),u.title=$.getStringManager().getString("close"),this.closeDiv=v.createElement("a",u),this.closeDiv.setAttribute("role","button"),(u={}).class="wrs_modal_stack_button",u.id=this.getElementId(u.class),u.title="Exit full-screen",this.stackDiv=v.createElement("a",u),this.stackDiv.setAttribute("role","button"),(u={}).class="wrs_modal_maximize_button",u.id=this.getElementId(u.class),u.title=$.getStringManager().getString("fullscreen"),this.maximizeDiv=v.createElement("a",u),this.maximizeDiv.setAttribute("role","button"),(u={}).class="wrs_modal_minimize_button",u.id=this.getElementId(u.class),u.title=$.getStringManager().getString("minimise"),this.minimizeDiv=v.createElement("a",u),this.minimizeDiv.setAttribute("role","button"),(u={}).class="wrs_modal_dialogContainer",u.id=this.getElementId(u.class),this.container=v.createElement("div",u),(u={}).class="wrs_modal_wrapper",u.id=this.getElementId(u.class),this.wrapper=v.createElement("div",u),(u={}).class="wrs_content_container",u.id=this.getElementId(u.class),this.contentContainer=v.createElement("div",u),(u={}).class="wrs_modal_controls",u.id=this.getElementId(u.class),this.controls=v.createElement("div",u),(u={}).class="wrs_modal_buttons_container",u.id=this.getElementId(u.class),this.buttonContainer=v.createElement("div",u),this.submitButton=this.createSubmitButton({id:this.getElementId("wrs_modal_button_accept"),class:"wrs_modal_button_accept",innerHTML:$.getStringManager().getString("accept")},this.submitAction.bind(this)),this.cancelButton=this.createSubmitButton({id:this.getElementId("wrs_modal_button_cancel"),class:"wrs_modal_button_cancel",innerHTML:$.getStringManager().getString("cancel")},this.cancelAction.bind(this)),this.contentManager=null;var h={cancelString:$.getStringManager().getString("cancel"),submitString:$.getStringManager().getString("close"),message:$.getStringManager().getString("close_modal_warning")},d={closeCallback:function(){this.close()}.bind(this),cancelCallback:function(){this.focus()}.bind(this)},f={overlayElement:this.container,callbacks:d,strings:h};this.popup=new O(f),this.rtl=!1,"rtl"in this.attributes&&(this.rtl=this.attributes.rtl),this.handleOpenedIosSoftkeyboard=this.handleOpenedIosSoftkeyboard.bind(this),this.handleClosedIosSoftkeyboard=this.handleClosedIosSoftkeyboard.bind(this)}return function(e,t,i){t&&S(e.prototype,t),i&&S(e,i)}(e,[{key:"setContentManager",value:function(e){this.contentManager=e}},{key:"getContentManager",value:function(){return this.contentManager}},{key:"submitAction",value:function(){void 0!==this.contentManager.submitAction&&this.contentManager.submitAction(),this.close()}},{key:"cancelAction",value:function(){void 0===this.contentManager.hasChanges?this.close():this.contentManager.hasChanges()?this.showPopUpMessage():this.close()}},{key:"createSubmitButton",value:function(e,t){function i(e,t){this.element=document.createElement("button"),this.element.id=e.id,this.element.className=e.class,this.element.innerHTML=e.innerHTML,v.addEvent(this.element,"click",t)}return i.prototype.getElement=function(){return this.element},new i(e,t).getElement()}},{key:"create",value:function(){this.titleBar.appendChild(this.closeDiv),this.titleBar.appendChild(this.stackDiv),this.titleBar.appendChild(this.maximizeDiv),this.titleBar.appendChild(this.minimizeDiv),this.titleBar.appendChild(this.title),this.deviceProperties.isDesktop&&this.container.appendChild(this.titleBar),this.wrapper.appendChild(this.contentContainer),this.wrapper.appendChild(this.controls),this.controls.appendChild(this.buttonContainer),this.buttonContainer.appendChild(this.submitButton),this.buttonContainer.appendChild(this.cancelButton),this.container.appendChild(this.wrapper),this.recalculateScrollBar(),document.body.appendChild(this.container),document.body.appendChild(this.overlay),this.deviceProperties.isDesktop?(this.createModalWindowDesktop(),this.createResizeButtons(),this.addListeners(),l.get("modalWindowFullScreen")&&this.maximize()):this.deviceProperties.isAndroid?this.createModalWindowAndroid():this.deviceProperties.isIOS&&!this.deviceProperties.isMobile&&this.createModalWindowIos(),null!=this.contentManager&&this.contentManager.insert(this),this.properties.open=!0,this.properties.created=!0,this.isRTL()&&(this.container.style.right=window.innerWidth-this.scrollbarWidth-this.container.offsetWidth+"px",this.container.className+=" wrs_modal_rtl")}},{key:"createResizeButtons",value:function(){this.resizerBR=document.createElement("div"),this.resizerBR.className="wrs_bottom_right_resizer",this.resizerBR.innerHTML="◢",this.resizerTL=document.createElement("div"),this.resizerTL.className="wrs_bottom_left_resizer",this.container.appendChild(this.resizerBR),this.titleBar.appendChild(this.resizerTL),v.addEvent(this.resizerBR,"mousedown",this.activateResizeStateBR.bind(this)),v.addEvent(this.resizerTL,"mousedown",this.activateResizeStateTL.bind(this))}},{key:"activateResizeStateBR",value:function(e){this.initializeResizeProperties(e,!1)}},{key:"activateResizeStateTL",value:function(e){this.initializeResizeProperties(e,!0)}},{key:"initializeResizeProperties",value:function(e,t){v.addClass(document.body,"wrs_noselect"),v.addClass(this.overlay,"wrs_overlay_active"),this.resizeDataObject={x:this.eventClient(e).X,y:this.eventClient(e).Y},this.initialWidth=parseInt(this.container.style.width),this.initialHeight=parseInt(this.container.style.height),t?this.leftScale=!0:(this.initialRight=parseInt(this.container.style.right),this.initialBottom=parseInt(this.container.style.bottom)),this.initialRight||(this.initialRight=0),this.initialBottom||(this.initialBottom=0),document.body.style["user-select"]="none"}},{key:"open",value:function(){if(this.removeClass("wrs_closed"),(this.deviceProperties.isIOS||this.deviceProperties.isAndroid||this.deviceProperties.isMobile)&&(this.restoreWebsiteScale(),this.blockWebsiteScroll(),setTimeout(function(){this.hideKeyboard()}.bind(this),400)),this.properties.created?(this.properties.open||(this.properties.open=!0,this.deviceProperties.isAndroid||this.deviceProperties.isIOS||this.restoreState()),this.deviceProperties.isDesktop&&l.get("modalWindowFullScreen")&&this.maximize(),this.deviceProperties.isIOS&&(this.iosSoftkeyboardOpened=!1,this.setContainerHeight("100"+this.iosMeasureUnit))):this.create(),!1===this.contentManager.isEditorLoaded){var e=y.newListener("onLoad",function(){this.contentManager.onOpen(this)}.bind(this));this.contentManager.addListener(e)}else this.contentManager.onOpen(this)}},{key:"close",value:function(){this.removeClass("wrs_maximized"),this.removeClass("wrs_minimized"),this.removeClass("wrs_stack"),this.addClass("wrs_closed"),this.saveModalProperties(),this.unblockWebsiteScroll(),this.properties.open=!1}},{key:"restoreWebsiteScale",value:function(){var e=document.querySelector("meta[name=viewport]"),t=["initial-scale=","minimum-scale=","maximum-scale="],i=["1.0","1.0","1.0"],n=function(e,t){var n=e.getAttribute("content");if(n){for(var r=n.split(","),s="",a=[],o=0;o=0||navigator.userAgent.search("Trident/")>=0||navigator.userAgent.search("Edge/")>=0}},{key:"isRTL",value:function(){return"ar"==this.attributes.language||"he"==this.attributes.language||this.rtl}},{key:"addClass",value:function(e){v.addClass(this.overlay,e),v.addClass(this.titleBar,e),v.addClass(this.overlay,e),v.addClass(this.container,e),v.addClass(this.contentContainer,e),v.addClass(this.stackDiv,e),v.addClass(this.minimizeDiv,e),v.addClass(this.maximizeDiv,e),v.addClass(this.wrapper,e)}},{key:"removeClass",value:function(e){v.removeClass(this.overlay,e),v.removeClass(this.titleBar,e),v.removeClass(this.overlay,e),v.removeClass(this.container,e),v.removeClass(this.contentContainer,e),v.removeClass(this.stackDiv,e),v.removeClass(this.minimizeDiv,e),v.removeClass(this.maximizeDiv,e),v.removeClass(this.wrapper,e)}},{key:"createModalWindowDesktop",value:function(){this.addClass("wrs_modal_desktop"),this.stack()}},{key:"createModalWindowAndroid",value:function(){this.addClass("wrs_modal_android"),window.addEventListener("resize",this.orientationChangeAndroidSoftkeyboard.bind(this))}},{key:"createModalWindowIos",value:function(){this.addClass("wrs_modal_ios"),window.addEventListener("resize",this.orientationChangeIosSoftkeyboard.bind(this))}},{key:"restoreState",value:function(){"maximized"==this.properties.state?this.maximize():"minimized"==this.properties.state?(this.properties.state=this.properties.previousState,this.properties.previousState="",this.minimize()):this.stack()}},{key:"stack",value:function(){this.properties.previousState=this.properties.state,this.properties.state="stack",this.removeClass("wrs_maximized"),this.minimizeDiv.title="Minimise",this.removeClass("wrs_minimized"),this.addClass("wrs_stack"),this.restoreModalProperties(),void 0!==this.resizerBR&&void 0!==this.resizerTL&&this.setResizeButtonsVisibility(),this.recalculateScrollBar(),this.recalculatePosition(),this.recalculateScale(),this.focus()}},{key:"minimize",value:function(){this.saveModalProperties(),"minimized"==this.properties.state&&"stack"==this.properties.previousState?this.stack():"minimized"==this.properties.state&&"maximized"==this.properties.previousState?this.maximize():(this.container.style.height="30px",this.container.style.width="250px",this.container.style.bottom="0px",this.container.style.right="10px",this.removeListeners(),this.properties.previousState=this.properties.state,this.properties.state="minimized",this.setResizeButtonsVisibility(),this.minimizeDiv.title="Maximise",v.containsClass(this.overlay,"wrs_stack")?this.removeClass("wrs_stack"):this.removeClass("wrs_maximized"),this.addClass("wrs_minimized"))}},{key:"maximize",value:function(){this.saveModalProperties(),"maximized"!=this.properties.state&&(this.properties.previousState=this.properties.state,this.properties.state="maximized"),this.setResizeButtonsVisibility(),v.containsClass(this.overlay,"wrs_minimized")?(this.minimizeDiv.title="Minimise",this.removeClass("wrs_minimized")):v.containsClass(this.overlay,"wrs_stack")&&(this.container.style.left=null,this.container.style.top=null,this.removeClass("wrs_stack")),this.addClass("wrs_maximized"),this.setSize(parseInt(.8*window.innerHeight),parseInt(.8*window.innerWidth));this.container.clientHeight>700&&(this.container.style.height="700px"),this.container.clientWidth>1200&&(this.container.style.width="1200px"),this.setPosition(window.innerHeight/2-this.container.offsetHeight/2,window.innerWidth/2-this.container.offsetWidth/2),this.recalculateScale(),this.recalculatePosition(),this.recalculateSize(),this.focus()}},{key:"setSize",value:function(e,t){this.container.style.height=e+"px",this.container.style.width=t+"px",this.recalculateSize()}},{key:"setPosition",value:function(e,t){this.container.style.bottom=e+"px",this.container.style.right=t+"px"}},{key:"saveModalProperties",value:function(){"stack"==this.properties.state&&(this.properties.position.bottom=parseInt(this.container.style.bottom),this.properties.position.right=parseInt(this.container.style.right),this.properties.size.width=parseInt(this.container.style.width),this.properties.size.height=parseInt(this.container.style.height))}},{key:"restoreModalProperties",value:function(){"stack"==this.properties.state&&(this.setPosition(this.properties.position.bottom,this.properties.position.right),this.setSize(this.properties.size.height,this.properties.size.width))}},{key:"recalculateSize",value:function(){this.wrapper.style.width=this.container.clientWidth-12+"px",this.wrapper.style.height=this.container.clientHeight-38+"px",this.contentContainer.style.height=parseInt(this.wrapper.offsetHeight-50)+"px"}},{key:"setResizeButtonsVisibility",value:function(){"stack"==this.properties.state?(this.resizerTL.style.visibility="visible",this.resizerBR.style.visibility="visible"):(this.resizerTL.style.visibility="hidden",this.resizerBR.style.visibility="hidden")}},{key:"addListeners",value:function(){this.maximizeDiv.addEventListener("click",this.maximize.bind(this),!0),this.stackDiv.addEventListener("click",this.stack.bind(this),!0),this.minimizeDiv.addEventListener("click",this.minimize.bind(this),!0),this.closeDiv.addEventListener("click",this.cancelAction.bind(this)),v.addEvent(window,"mousedown",this.startDrag.bind(this)),v.addEvent(window,"mouseup",this.stopDrag.bind(this)),v.addEvent(window,"mousemove",this.drag.bind(this)),v.addEvent(window,"resize",this.onWindowResize.bind(this)),v.addEvent(window,"keydown",this.onKeyDown.bind(this))}},{key:"removeListeners",value:function(){v.removeEvent(window,"mousedown",this.startDrag),v.removeEvent(window,"mouseup",this.stopDrag),v.removeEvent(window,"mousemove",this.drag),v.removeEvent(window,"resize",this.onWindowResize),v.removeEvent(window,"keydown",this.onKeyDown)}},{key:"eventClient",value:function(e){if(void 0===e.clientX&&e.changedTouches){var t={X:e.changedTouches[0].clientX,Y:e.changedTouches[0].clientY};return t}return t={X:e.clientX,Y:e.clientY}}},{key:"startDrag",value:function(e){"minimized"!=this.properties.state&&e.target===this.title&&(void 0!==this.dragDataObject&&null!==this.dragDataObject||(e=e||event,this.dragDataObject={x:this.eventClient(e).X,y:this.eventClient(e).Y},this.lastDrag={x:"0px",y:"0px"},""==this.container.style.right&&(this.container.style.right="0px"),""==this.container.style.bottom&&(this.container.style.bottom="0px"),this.isIE11(),v.addClass(document.body,"wrs_noselect"),v.addClass(this.overlay,"wrs_overlay_active"),this.limitWindow=this.getLimitWindow()))}},{key:"drag",value:function(e){if(this.dragDataObject){e.preventDefault(),e=e||event;var t=Math.min(this.eventClient(e).Y,this.limitWindow.minPointer.y);t=Math.max(this.limitWindow.maxPointer.y,t);var i=Math.min(this.eventClient(e).X,this.limitWindow.minPointer.x),n=(i=Math.max(this.limitWindow.maxPointer.x,i))-this.dragDataObject.x+"px",r=t-this.dragDataObject.y+"px";this.lastDrag={x:n,y:r},this.container.style.transform="translate3d("+n+","+r+",0)"}if(this.resizeDataObject){var s;i=Math.min(this.eventClient(e).X,window.innerWidth-this.scrollbarWidth-7),t=Math.min(this.eventClient(e).Y,window.innerHeight-7);i<0&&(i=0),t<0&&(t=0),s=this.leftScale?-1:1,this.container.style.width=this.initialWidth+s*(i-this.resizeDataObject.x)+"px",this.container.style.height=this.initialHeight+s*(t-this.resizeDataObject.y)+"px",this.leftScale||(this.resizeDataObject.x-i-this.initialWidth<-580?this.container.style.right=this.initialRight-(i-this.resizeDataObject.x)+"px":(this.container.style.right=this.initialRight+this.initialWidth-580+"px",this.container.style.width="580px"),this.resizeDataObject.y-t580?(this.container.style.width=Math.min(parseInt(this.container.style.width),window.innerWidth-this.scrollbarWidth)+"px",e=!0):(this.container.style.width="580px",e=!0),parseInt(this.container.style.height)>338?(this.container.style.height=Math.min(parseInt(this.container.style.height),window.innerHeight)+"px",e=!0):(this.container.style.height="338px",e=!0),e&&this.recalculateSize()}},{key:"recalculateScrollBar",value:function(){this.hasScrollBar=window.innerWidth>document.documentElement.clientWidth,this.hasScrollBar?this.scrollbarWidth=this.getScrollBarWidth():this.scrollbarWidth=0}},{key:"hideKeyboard",value:function(){document.activeElement.blur()}},{key:"focus",value:function(){null!=this.contentManager&&void 0!==this.contentManager.onFocus&&this.contentManager.onFocus()}},{key:"portraitMode",value:function(){return window.innerHeight>window.innerWidth}},{key:"handleOpenedIosSoftkeyboard",value:function(){this.iosSoftkeyboardOpened||null==this.iosDivHeight||this.iosDivHeight!="100"+this.iosMeasureUnit||(this.portraitMode()?this.setContainerHeight("63"+this.iosMeasureUnit):this.setContainerHeight("40"+this.iosMeasureUnit)),this.iosSoftkeyboardOpened=!0}},{key:"handleClosedIosSoftkeyboard",value:function(){this.iosSoftkeyboardOpened=!1,this.setContainerHeight("100"+this.iosMeasureUnit)}},{key:"orientationChangeIosSoftkeyboard",value:function(){this.iosSoftkeyboardOpened?this.portraitMode()?this.setContainerHeight("63"+this.iosMeasureUnit):this.setContainerHeight("40"+this.iosMeasureUnit):this.setContainerHeight("100"+this.iosMeasureUnit)}},{key:"orientationChangeAndroidSoftkeyboard",value:function(){this.setContainerHeight("100%")}},{key:"setContainerHeight",value:function(e){this.iosDivHeight=e,this.wrapper.style.height=e}},{key:"showPopUpMessage",value:function(){"minimized"==this.properties.state&&this.stack(),this.popup.show()}},{key:"setTitle",value:function(e){this.title.innerHTML=e}},{key:"getElementId",value:function(e){return e+"["+this.instanceId+"]"}}]),e}();function I(e){return(I="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function A(e,t){for(var i=0;i=4;){v.readInt32(e);var t=v.readInt32(e);if(1229472850==t){var i=v.readInt32(e),n=v.readInt32(e);v.readInt32(e),v.readByte(e)}else if(1650545477==t)var r=v.readInt32(e);else if(1883789683==t){var s=v.readInt32(e);s=Math.round(s/39.37),v.readInt32(e),v.readByte(e)}v.readInt32(e)}if(void 0!==i){var a=new Array;return a.cw=i,a.ch=n,a.dpi=s,r&&(a.cb=r),a}}}]),e}();function P(e,t){for(var i=0;i"),m=c.substring(0,f),p=m.split(" width=").join(' class="Wiriscas" width=');c=(c=c.split(m).join(p)).split("'").join('"')}}var b='';t=t.substring(0,n[o].start+s)+b+t.substring(n[o].end+s),s+=b.length-(n[o].end-n[o].start)}}return t}},{key:"initParseEditMode",value:function(e){if(-1!=l.get("parseModes").indexOf("latex"))for(var t=v.getElementsByNameFromString(e,"img",!0),i='encoding="LaTeX">',n=0,r=0;r",d),m=h.substring(d,f),g="$$"+v.htmlEntitiesDecode(m)+"$$";e=e.substring(0,t[r].start+n)+g+e.substring(t[r].end+n),n+=g.length-(t[r].end-t[r].start)}}}}return e}},{key:"endParse",value:function(t){var i=e.endParseEditMode(t);return e.endParseSaveMode(i)}},{key:"endParseEditMode",value:function(e){if(-1!=l.get("parseModes").indexOf("latex")){for(var t="",i=0,n=e.indexOf("$$");-1!=n;){if(t+=e.substring(i,n),-1!=(i=e.indexOf("$$",n+2))){var r=e.substring(n+2,i);r=v.htmlEntitiesDecode(r),t+=g.getMathMLFromLatex(r,!0),i+=2}else t+="$$",i=n+2;n=e.indexOf("$$",i)}e=t+=e.substring(i,e.length)}return e}},{key:"endParseSaveMode",value:function(t){return l.get("saveMode")&&("safeXml"==l.get("saveMode")?t=e.codeImgTransform(t,"img2mathml"):"xml"==l.get("saveMode")?t=e.codeImgTransform(t,"img2mathml"):"base64"==l.get("saveMode")&&"image"==l.get("editMode")&&(t=e.codeImgTransform(t,"img264"))),t}},{key:"createShowImageSrc",value:function(e,t){var i=[],n="mml,color,centerbaseline,zoom,dpi,fontSize,fontFamily,defaultStretchy,backgroundColor,format".split(",");for(var r in n){var s=n[r];void 0!==e[s]&&(i[s]=e[s])}var a={};for(var r in e)"mml"!=r&&(a[r]=e[r]);return a.formula=com.wiris.js.JsPluginTools.md5encode(v.propertiesToString(i)),a.lang=void 0===t?"en":t,a.version=l.get("version"),f.getService("showimage",v.httpBuildQuery(a),!0)}},{key:"codeImgTransform",value:function(t,i){for(var n="",r=0,s=/"==h&&(r=u+1);++u}if(r",u):c.length,a.isMathmlInAttribute(t,u)||-1!=d)s+=t.substring(u,h);else{var f=t.substring(u,h);f=i==r.safeXmlCharacters?a.safeXmlDecode(f):a.mathMLEntities(f),s+=v.createObjectCode(e.mathmlToImgObject(document,f,null,n))}u=t.indexOf(o,h)}return s+=t.substring(h,t.length)}}]),e}();if("undefined"!=typeof MutationObserver){var D=new MutationObserver(function(e){e.forEach(function(e){e.oldValue===l.get("imageClassName")&&"class"===e.attributeName&&-1==e.target.className.indexOf(l.get("imageClassName"))&&(e.target.className=l.get("imageClassName"))})});B.observer=Object.create(D),B.observer.Config={attributes:!0,attributeOldValue:!0},B.observer.observe=function(e){this.__proto__.observe(e,this.Config)}}function R(e,t){for(var i=0;i=0&&(t=e[i].src.substr(0,n-1))}return t}},{key:"setLanguage",value:function(e){this.language=e}},{key:"setCore",value:function(e){this.core=e,e.setIntegrationModel(this)}},{key:"getCore",value:function(){return this.core}},{key:"setTarget",value:function(e){this.target=e,this.isIframe="IFRAME"===this.target.tagName.toUpperCase()}},{key:"setEditorObject",value:function(e){this.editorObject=e}},{key:"openNewFormulaEditor",value:function(){this.core.editionProperties.isNewElement=!0,this.core.openModalDialog(this.target,this.isIframe)}},{key:"openExistingFormulaEditor",value:function(){this.core.editionProperties.isNewElement=!1,this.core.openModalDialog(this.target,this.isIframe)}},{key:"updateFormula",value:function(e){this.isIframe?this.core.updateFormula(this.target.contentWindow,this.target.contentWindow,e,null):this.core.updateFormula(this.target,window,e,null)}},{key:"getSelection",value:function(){return this.isIframe?(this.target.contentWindow.focus(),this.target.contentWindow.getSelection()):(this.target.focus(),window.getSelection())}},{key:"addEvents",value:function(){var e=this.isIframe?this.target.contentWindow.document:this.target;v.addElementEvents(e,function(e,t){this.doubleClickHandler(e,t)}.bind(this),function(e,t){this.mousedownHandler(e,t)}.bind(this),function(e,t){this.mouseupHandler(e,t)}.bind(this))}},{key:"doubleClickHandler",value:function(e){if("img"==e.nodeName.toLowerCase()){if(this.core.getCustomEditors().disable(),e.hasAttribute("data-custom-editor")){var t=e.getAttribute("data-custom-editor");this.core.getCustomEditors().enable(t)}v.containsClass(e,l.get("imageClassName"))&&(this.core.editionProperties.temporalImage=e,this.core.editionProperties.isNewElement=!0,this.openExistingFormulaEditor())}}},{key:"mouseupHandler",value:function(){this.temporalImageResizing&&setTimeout(function(){T.fixAfterResize(this.temporalImageResizing)}.bind(this),10)}},{key:"mousedownHandler",value:function(e){"img"==e.nodeName.toLowerCase()&&v.containsClass(e,l.get("imageClassName"))&&(this.temporalImageResizing=e)}},{key:"getLanguage",value:function(){return this.getBrowserLanguage()}},{key:"getBrowserLanguage",value:function(){return navigator.userLanguage?navigator.userLanguage.substring(0,2):navigator.language?navigator.language.substring(0,2):"en"}},{key:"callbackFunction",value:function(){var e=y.newListener("onTargetReady",function(){this.addEvents(this.target)}.bind(this));this.listeners.add(e)}},{key:"notifyWindowClosed",value:function(){}},{key:"getMathmlFromTextNode",value:function(e,t){}},{key:"fillNonLatexNode",value:function(e,t,i){}},{key:"getSelectedItem",value:function(e,t){}}]),e}();function J(e,t){for(var i=0;i=0?"EDGE":e.search("Chrome/")>=0?"CHROME":e.search("Trident/")>=0?"IE":e.search("Firefox/")>=0?"FIREFOX":e.search("Safari/")>=0?"SAFARI":void 0}(),this.listeners=new y}return function(e,t,i){t&&J(e.prototype,t),i&&J(e,i)}(e,[{key:"init",value:function(e){this.load(e)}},{key:"setIntegrationModel",value:function(e){this.integrationModel=e}},{key:"setEnvironment",value:function(e){"editor"in e&&(this.environment.editor=e.editor),"mode"in e&&(this.environment.mode=e.mode),"version"in e&&(this.environment.version=e.version)}},{key:"getModalDialog",value:function(){return this.modalDialog}},{key:"load",value:function(t){var i="undefined"!=typeof XMLHttpRequest?new XMLHttpRequest:new ActiveXObject("Microsoft.XMLHTTP");this.integrationPath=0==t.indexOf("/")||0==t.indexOf("http")?t:v.concatenateUrl(this.integrationModel.getPath(),t),i.open("GET",this.integrationPath,!1),i.onload=function(t){var n=this;if(4===i.readyState){var r=JSON.parse(i.responseText);Object.keys(r);if(l.addConfiguration(r),l.addConfiguration(H),this.loadServicePaths(),this.loadLangFile(),this.loadCSS(),null===e.stringManager){var s=y.newListener("onLoad",function(){n.listeners.fire("onLoad",{})});e.stringManager.addListener(s)}else this.listeners.fire("onLoad",{})}}.bind(this),i.send(null)}},{key:"loadServicePaths",value:function(){var e=this.integrationPath.replace("configurationjs","createimage"),t=this.integrationPath.replace("configurationjs","showimage"),i=(e=this.integrationPath.replace("configurationjs","createimage"),this.integrationPath.replace("configurationjs","getmathml")),n=this.integrationPath.replace("configurationjs","service");if(0==this.integrationPath.indexOf("/")){var r=this.getServerPath();t=r+t,e=r+e,i=r+i,n=r+n}f.setServicePath("showimage",t),f.setServicePath("createimage",e),f.setServicePath("service",n),f.setServicePath("getmathml",i)}},{key:"getServerPath",value:function(){var e=this.integrationModel.getPath(),t=e.indexOf("/",e.indexOf("/")+2);return e.substr(0,t)}},{key:"loadLangFile",value:function(){var t="ar,ca,cs,da,de,en,es,et,eu,fi,fr,gl,he,hr,hu,it,ja,ko,nl,no,pl,pt,pt_br,ru,sv,tr,zh,el".split(","),i=this.language;-1==t.indexOf(i)&&(i=i.substr(0,2)),-1==t.indexOf(i)&&(i="en");var n=document.createElement("script");n.type="text/javascript",n.src=this.integrationModel.getPath()+"/"+this.integrationModel.langFolderName+"/"+i+"/strings.js",n.onload=function(){e.getStringManager().loadStrings(wrs_strings)},document.getElementsByTagName("head")[0].appendChild(n)}},{key:"loadCSS",value:function(){var e=document.createElement("link");e.setAttribute("rel","stylesheet"),e.setAttribute("type","text/css"),e.setAttribute("href",v.concatenateUrl(this.integrationModel.getPath(),"/core/styles.css")),document.getElementsByTagName("head")[0].appendChild(e)}},{key:"addListener",value:function(e){this.listeners.add(e)}},{key:"updateFormula",value:function(t,i,n,r){var s=new F;for(var a in s.mathml=n,s.wirisProperties={},r)s.wirisProperties[a]=r[a];if(s.language=this.language,s.editMode=this.editMode,!this.listeners.fire("onBeforeFormulaInsertion",s)&&!e.globalListeners.fire("onBeforeFormulaInsertion",s)){n=s.mathml,r=s.wirisProperties;var o=new F;if(o.editMode=this.editMode,o.windowTarget=i,o.focusElement=t,n)if("latex"==this.editMode)o.latex=g.getLatexFromMathML(n),this.integrationModel.fillNonLatexNode&&!o.latex?this.integrationModel.fillNonLatexNode(o,i,n):o.node=i.document.createTextNode("$$"+o.latex+"$$"),this.insertElementOnSelection(o.node,t,i);else if("iframes"==this.editMode){var l=wrs_mathmlToIframeObject(i,n);this.insertElementOnSelection(l,t,i)}else o.node=B.mathmlToImgObject(i.document,n,r,this.language),this.insertElementOnSelection(o.node,t,i);else this.insertElementOnSelection(null,t,i);this.listeners.fire("onAfterFormulaInsertion",o)||e.globalListeners.fire("onAfterFormulaInsertion",o)}}},{key:"placeCaretAfterNode",value:function(e){this.integrationModel.getSelection();var t=e.ownerDocument;if(void 0!==t.getSelection&&e.parentElement){var i=t.createRange();i.setStartAfter(e),i.collapse(!0);var n=t.getSelection();n.removeAllRanges(),n.addRange(i),t.body.focus()}}},{key:"insertElementOnSelection",value:function(e,t,i){if(this.editionProperties.isNewElement)if(e)if("textarea"==t.type)v.updateTextArea(t,e.textContent);else if(document.selection&&0==document.getSelection){var n=i.document.selection.createRange();if(i.document.execCommand("InsertImage",!1,e.src),"parentElement"in n||(i.document.execCommand("delete",!1),n=i.document.selection.createRange(),i.document.execCommand("InsertImage",!1,e.src)),"parentElement"in n){var r=n.parentElement();"IMG"==r.nodeName.toUpperCase()?r.parentNode.replaceChild(e,r):n.pasteHTML(v.createObjectCode(e))}}else{var s,a=this.integrationModel.getSelection();this.editionProperties.range?(s=this.editionProperties.range,this.editionProperties.range=null):s=a.getRangeAt(0),s.deleteContents();var o=s.startContainer,l=s.startOffset;3==o.nodeType?(o=o.splitText(l)).parentNode.insertBefore(e,o):1==o.nodeType&&o.insertBefore(e,o.childNodes[l]),this.placeCaretAfterNode(e)}else if("textarea"==t.type)t.focus();else{var c=this.integrationModel.getSelection();if(c.removeAllRanges(),this.editionProperties.range){var u=this.editionProperties.range;this.editionProperties.range=null,c.addRange(u)}}else if(this.editionProperties.latexRange)document.selection&&0==document.getSelection?(this.editionProperties.isNewElement=!0,this.editionProperties.latexRange.select(),this.insertElementOnSelection(e,t,i)):(this.editionProperties.latexRange.deleteContents(),this.editionProperties.latexRange.insertNode(e),this.placeCaretAfterNode(e));else if("textarea"==t.type){var h;h=void 0!==this.integrationModel.getSelectedItem?this.integrationModel.getSelectedItem(t,!1):v.getSelectedItemOnTextarea(t),v.updateExistingTextOnTextarea(t,e.textContent,h.startPosition,h.endPosition)}else e&&"img"===e.nodeName.toLowerCase()?T.clone(e,this.editionProperties.temporalImage):this.editionProperties.temporalImage.remove(),this.placeCaretAfterNode(this.editionProperties.temporalImage)}},{key:"openModalDialog",value:function(e,t){this.editMode="images";try{if(t){e.contentWindow.focus();var i=e.contentWindow.getSelection();this.editionProperties.range=i.getRangeAt(0)}else{e.focus();var n=getSelection();this.editionProperties.range=n.getRangeAt(0)}}catch(e){this.editionProperties.range=null}var r;if(void 0===t&&(t=!0),this.editionProperties.latexRange=null,e)if(r=void 0!==this.integrationModel.getSelectedItem?this.integrationModel.getSelectedItem(e,t):v.getSelectedItem(e,t)){if(!r.caretPosition&&v.containsClass(r.node,l.get("imageClassName")))this.editionProperties.temporalImage=r.node,this.editionProperties.isNewElement=!1;else if(3===r.node.nodeType)if(this.integrationModel.getMathmlFromTextNode){var s=this.integrationModel.getMathmlFromTextNode(r.node,r.caretPosition);s&&(this.editMode="latex",this.editionProperties.isNewElement=!1,this.editionProperties.temporalImage=document.createElement("img"),this.editionProperties.temporalImage.setAttribute(l.get("imageMathmlAttribute"),a.safeXmlEncode(s)))}else{var o=g.getLatexFromTextNode(r.node,r.caretPosition);if(o){var c=g.getMathMLFromLatex(o.latex);this.editMode="latex",this.editionProperties.isNewElement=!1,this.editionProperties.temporalImage=document.createElement("img"),this.editionProperties.temporalImage.setAttribute(l.get("imageMathmlAttribute"),a.safeXmlEncode(c));var u=t?e.contentWindow:window;if("textarea"!==e.tagName.toLowerCase())if(document.selection){for(var h=0,d=o.startNode.previousSibling;d;)h+=v.getNodeLength(d),d=d.previousSibling;this.editionProperties.latexRange=u.document.selection.createRange(),this.editionProperties.latexRange.moveToElementText(o.startNode.parentNode),this.editionProperties.latexRange.move("character",h+o.startPosition),this.editionProperties.latexRange.moveEnd("character",o.latex.length+4)}else this.editionProperties.latexRange=u.document.createRange(),this.editionProperties.latexRange.setStart(o.startNode,o.startPosition),this.editionProperties.latexRange.setEnd(o.endNode,o.endPosition)}}}else"textarea"===e.tagName.toLowerCase()&&(this.editMode="latex");for(var f=l.get("editorAttributes").split(", "),m={},p=0,b=f.length;p=i)){var r,s=t.charCodeAt(n);return s>=55296&&s<=56319&&i>n+1&&(r=t.charCodeAt(n+1))>=56320&&r<=57343?1024*(s-55296)+r-56320+65536:s}};Object.defineProperty?Object.defineProperty(String.prototype,"codePointAt",{value:e,configurable:!0,writable:!0}):String.prototype.codePointAt=e}(),"function"!=typeof Object.assign&&Object.defineProperty(Object,"assign",{value:function(e,t){if(null==e)throw new TypeError("Cannot convert undefined or null to object");for(var i=Object(e),n=1;n=i)){var r,s=t.charCodeAt(n);return s>=55296&&s<=56319&&i>n+1&&(r=t.charCodeAt(n+1))>=56320&&r<=57343?1024*(s-55296)+r-56320+65536:s}};Object.defineProperty?Object.defineProperty(String.prototype,"codePointAt",{value:e,configurable:!0,writable:!0}):String.prototype.codePointAt=e}(),"function"!=typeof Object.assign&&Object.defineProperty(Object,"assign",{value:function(e,t){if(null==e)throw new TypeError("Cannot convert undefined or null to object");for(var i=Object(e),n=1;n'; var openSemantics = '<' + 'semantics' + '>'; var openAnnotation = ''; @@ -254,6 +254,67 @@ export default class MathML { return mathmlWithoutSemantics; } + /** + * Transforms all xml mathml ocurrences that contain semantics to the same + * xml mathml ocurrences without semantics. + * @param {string} text - string that can contain xml mathml ocurrences. + * @param {string} [encoding] - encoding name that semantics need to have to be removed. + * 'application/json' by default. 'application/json' removes hand traces. + * @param {Constants} [characters] - Constant object containing xmlCharacters or safeXmlCharacters relation. + * xmlCharacters by default. + * @returns {string} - 'text' with all xml mathml ocurrences without annotation tag. + */ + static removeSemanticsOcurrences(text, characters = Constants.xmlCharacters, encoding = 'application/json') { + const mathTagStart = characters.tagOpener + 'math'; + const mathTagEnd = characters.tagOpener + '/math' + characters.tagCloser; + const mathTagEndline = '/' + characters.tagCloser; + const tagCloser = characters.tagCloser; + const semanticsTagStart = characters.tagOpener + 'semantics' + characters.tagCloser; + const annotationTagStart = characters.tagOpener + 'annotation encoding=' + + characters.doubleQuote + encoding + characters.doubleQuote + characters.tagCloser; + + let output = ''; + let start = text.indexOf(mathTagStart); + let end = 0; + while (start !== -1) { + output += text.substring(end, start); + + // MathML can be written as '' or ''. + const mathTagEndIndex = text.indexOf(mathTagEnd, start); + const mathTagEndlineIndex = text.indexOf(mathTagEndline, start); + const firstTagCloser = text.indexOf(tagCloser, start); + if (mathTagEndIndex !== -1) { + end = mathTagEndIndex; + } + else if (mathTagEndlineIndex === firstTagCloser - 1) { + end = mathTagEndlineIndex; + } + + const semanticsIndex = text.indexOf(semanticsTagStart, start); + if (semanticsIndex !== -1) { + const mmlTagStart = text.substring(start, semanticsIndex); + const annotationIndex = text.indexOf(annotationTagStart, start); + if (annotationIndex !== -1) { + const mmlContent = text.substring(semanticsIndex + semanticsTagStart.length, annotationIndex); + output += mmlTagStart + mmlContent + mathTagEnd; + start = text.indexOf(mathTagStart, start + mathTagStart.length); + end += mathTagEnd.length; + } + else { + end = start; + start = text.indexOf(mathTagStart, start + mathTagStart.length); + } + } + else { + end = start; + start = text.indexOf(mathTagStart, start + mathTagStart.length); + } + } + + output += text.substring(end, text.length); + return output; + } + /** * Returns true if a MathML contains a certain class. * @param {string} mathML - input MathML. @@ -276,5 +337,4 @@ export default class MathML { } } } - } diff --git a/tinymce/core/src/modal.js b/tinymce/core/src/modal.js index 00df8e4..313aad6 100644 --- a/tinymce/core/src/modal.js +++ b/tinymce/core/src/modal.js @@ -176,6 +176,10 @@ export default class ModalDialog { if ('rtl' in this.attributes) { this.rtl = this.attributes.rtl; } + + // Event handlers need modal instance context. + this.handleOpenedIosSoftkeyboard = this.handleOpenedIosSoftkeyboard.bind(this); + this.handleClosedIosSoftkeyboard = this.handleClosedIosSoftkeyboard.bind(this); } /** * This method sets an ContentManager instance to ModalDialog. ContentManager @@ -1184,9 +1188,9 @@ export default class ModalDialog { } /** - * Change container sizes when the keyboard is opened on iOS. + * Event handler that change container size when IOS softkeyboard is opened. */ - openedIosSoftkeyboard() { + handleOpenedIosSoftkeyboard() { if (!this.iosSoftkeyboardOpened && this.iosDivHeight != null && this.iosDivHeight == "100" + this.iosMeasureUnit) { if (this.portraitMode()) { this.setContainerHeight("63" + this.iosMeasureUnit); @@ -1199,9 +1203,9 @@ export default class ModalDialog { } /** - * Change container sizes when the keyboard is closed on iOS. + * Event handler that change container size when IOS softkeyboard is closed. */ - closedIosSoftkeyboard() { + handleClosedIosSoftkeyboard() { this.iosSoftkeyboardOpened = false; this.setContainerHeight("100" + this.iosMeasureUnit); } diff --git a/tinymce/core/src/parser.js b/tinymce/core/src/parser.js index 4116d37..1454cec 100644 --- a/tinymce/core/src/parser.js +++ b/tinymce/core/src/parser.js @@ -270,8 +270,11 @@ export default class Parser { * @returns {string} the HTML code parsed. */ static endParse(code) { - code = Parser.endParseEditMode(code); - return Parser.endParseSaveMode(code); + // Transform LaTeX ocurrences to MathML elements. + const codeEndParsedEditMode = Parser.endParseEditMode(code); + // Transform img elements to MathML elements. + const codeEndParseSaveMode = Parser.endParseSaveMode(codeEndParsedEditMode); + return codeEndParseSaveMode; } /** @@ -383,7 +386,6 @@ export default class Parser { */ static codeImgTransform(code, mode) { var output = ''; - var endPosition = 0; var pattern = / -1;\n this.deviceProperties.isIOS = this.ua.indexOf(\"ipad\") > -1 || this.ua.indexOf(\"iphone\") > -1;\n /**\r\n * Custom editor toolbar.\r\n * @type {string} toolbar\r\n */\n\n this.toolbar = null;\n /**\r\n * Instance of the ModalDialog class associated to the ContentManager instance.\r\n * @type {ModalDialog}\r\n */\n\n this.modalDialogInstance = null;\n /**\r\n * ContentManager listeners.\r\n * @type {Listeners}\r\n */\n\n this.listeners = new _listeners_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"]();\n /**\r\n * MathML associated to the ContentManager instance.\r\n * @type {string}\r\n */\n\n this.mathML = null;\n /**\r\n * Indicates if the edited element is a new element or not.\r\n * @type {boolean}\r\n */\n\n this.isNewElement = true;\n /**\r\n * IntegrationModel instance. Needed to call wrapper methods.\r\n * @type {IntegrationModel}\r\n */\n\n this.integrationModel = null;\n /**\r\n * Indicates if the editor is loaded.\r\n * @type {boolean}\r\n */\n\n this.isEditorLoaded = false;\n }\n /**\r\n * Add a new listener to ContentManager class.\r\n * @param {Object} listener - listener to be added.\r\n */\n\n\n _createClass(ContentManager, [{\n key: \"addListener\",\n value: function addListener(listener) {\n this.listeners.add(listener);\n }\n /**\r\n * Sets an instance of an IntegrationModel\r\n * @param {IntegrationModel} integrationModel\r\n */\n\n }, {\n key: \"setIntegrationModel\",\n value: function setIntegrationModel(integrationModel) {\n this.integrationModel = integrationModel;\n }\n /**\r\n * Sets a modal dialog instance.\r\n * @param {ModalDialog} - a ModalDialog instance\r\n */\n\n }, {\n key: \"setModalDialogInstance\",\n value: function setModalDialogInstance(modalDialogInstance) {\n this.modalDialogInstance = modalDialogInstance;\n }\n /**\r\n * Mandatory method. Inserts editor into modal object content container.\r\n */\n\n }, {\n key: \"insert\",\n value: function insert() {\n // Before insert the editor we update the modal object title to avoid weird render display.\n this.updateTitle(this.modalDialogInstance);\n this.insertEditor(this.modalDialogInstance);\n }\n /**\r\n * Method to insert MathType into modal object. This method\r\n * waits until editor JavaScript is loaded to insert the editor into\r\n * contentContainer modal object element.\r\n */\n\n }, {\n key: \"insertEditor\",\n value: function insertEditor() {\n // To know if editor JavaScript is loaded we need to wait until com.wiris.jsEditor namespace is ready.\n if ('com' in window && 'wiris' in window.com && 'jsEditor' in window.com.wiris) {\n this.editor = com.wiris.jsEditor.JsEditor.newInstance(this.editorAttributes);\n this.editor.insertInto(this.modalDialogInstance.contentContainer);\n this.editor.focus();\n\n if (this.modalDialogInstance.rtl) {\n this.editor.action('rtl');\n } // Setting div in rtl in case of it's activated.\n\n\n if (this.editor.getEditorModel().isRTL()) {\n this.editor.element.style.direction = 'rtl';\n } // Editor listener: this object manages the changes logic of editor.\n\n\n this.editor.getEditorModel().addEditorListener(this.editorListener); // iOS events.\n\n if (this.modalDialogInstance.deviceProperties['isIOS']) {\n setTimeout(function () {\n this.modalDialogInstance.hideKeyboard();\n }, 400);\n var formulaDisplayDiv = document.getElementsByClassName('wrs_formulaDisplay')[0];\n _util_js__WEBPACK_IMPORTED_MODULE_4__[\"default\"].addEvent(formulaDisplayDiv, 'focus', this.modalDialogInstance.openedIosSoftkeyboard.bind());\n _util_js__WEBPACK_IMPORTED_MODULE_4__[\"default\"].addEvent(formulaDisplayDiv, 'blur', this.modalDialogInstance.closedIosSoftkeyboard.bind());\n } // Fire onLoad event. Necessary to set the MathML into the editor\n // after is loaded.\n\n\n this.listeners.fire('onLoad', {});\n this.isEditorLoaded = true;\n } else {\n setTimeout(ContentManager.prototype.insertEditor.bind(this, this.modalDialogInstance), 100);\n }\n }\n /**\r\n * Loads MathType script.\r\n */\n\n }, {\n key: \"init\",\n value: function init() {\n var queryParams = window.location.search.substring(1).split(\"&\");\n\n for (var i = 0; i < queryParams.length; i++) {\n var pos = queryParams[i].indexOf(\"v=\");\n\n if (pos >= 0) {\n version = queryParams[i].substring(2);\n }\n }\n\n var script = document.createElement('script');\n script.type = 'text/javascript';\n var editorUrl = _configuration_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get('editorUrl'); // We create an object url for parse url string and work more efficiently.\n\n var urlObject = document.createElement('a');\n urlObject.href = editorUrl; // Change to https if necessary.\n\n if (window.location.href.indexOf(\"https://\") == 0) {\n // It check if browser is https and configuration is http. If this is so, we will replace protocol.\n if (urlObject.protocol == 'http:') {\n urlObject.protocol = 'https:';\n }\n } // Check protocol and remove port if it's standard.\n\n\n if (urlObject.port == '80' || urlObject.port == '443') {\n editorUrl = urlObject.protocol + '//' + urlObject.hostname + '/' + urlObject.pathname;\n } else {\n editorUrl = urlObject.protocol + '//' + urlObject.hostname + ':' + urlObject.port + '/' + urlObject.pathname;\n } // Editor stats. Use environment property to set it.\n\n\n var stats = {};\n\n if ('editor' in this.environment) {\n stats.editor = this.environment.editor;\n } else {\n stats.editor = 'unknown';\n }\n\n if ('mode' in this.environment) {\n stats.mode = this.environment.mode;\n } else {\n stats.mode = _configuration_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get('saveMode');\n }\n\n if ('version' in this.environment) {\n stats.version = this.environment.version;\n } else {\n stats.version = _configuration_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get('version');\n } // Load editor URL. We add stats as GET params.\n\n\n script.src = editorUrl + \"?lang=\" + this.language + '&stats-editor=' + stats.editor + '&stats-mode=' + stats.mode + '&stats-version=' + stats.version;\n document.getElementsByTagName('head')[0].appendChild(script);\n }\n /**\r\n * Set the editor initial content: an existing formula or a blank MathML\r\n */\n\n }, {\n key: \"setInitialContent\",\n value: function setInitialContent() {\n if (!this.isNewElement) {\n this.setMathML(this.mathML);\n }\n }\n /**\r\n * Set a MathML into editor.\r\n * @param {string} mathml - MathML string.\r\n * @param {bool} focusDisabled - if true editor don't get focus after the MathML is set. false by default.\r\n */\n\n }, {\n key: \"setMathML\",\n value: function setMathML(mathml, focusDisabled) {\n // By default focus is enabled\n if (typeof focusDisabled === 'undefined') {\n focusDisabled = false;\n } // Using setMathML method is not a change produced by the user but for the API\n // so we set to false the contentChange property of editorListener.\n\n\n this.editor.setMathMLWithCallback(mathml, function () {\n this.editorListener.setWaitingForChanges(true);\n }.bind(this)); // We need to wait a little until the callback finish.\n\n setTimeout(function () {\n this.editorListener.setIsContentChanged(false);\n }.bind(this), 500); // In some scenarios - like closing modal object - editor mustn't be focused.\n\n if (!focusDisabled) {\n this.onFocus();\n }\n }\n /**\r\n * Set focus on editor.\r\n */\n\n }, {\n key: \"onFocus\",\n value: function onFocus() {\n if (typeof this.editor !== 'undefined' && this.editor != null) {\n this.editor.focus();\n }\n }\n /**\r\n * Mandatory method: modal object calls this method to execute a callback action\r\n * on submit.\r\n * This method updates the edition area (inserting a new formula or update an older one),\r\n * and focus the edition area too.\r\n */\n\n }, {\n key: \"submitAction\",\n value: function submitAction() {\n var mathML = this.editor.getMathML(); // Add class for custom editors.\n\n if (this.customEditors.getActiveEditor() != null) {\n mathML = _mathml_js__WEBPACK_IMPORTED_MODULE_3__[\"default\"].addCustomEditorClassAttribute(mathML, this.customEditors.getActiveEditor().toolbar);\n } else {\n // We need - if exists - the editor name from MathML\n // class attribute.\n for (var key in this.customEditors.editors) {\n mathML = _mathml_js__WEBPACK_IMPORTED_MODULE_3__[\"default\"].removeCustomEditorClassAttribute(mathML, key);\n }\n }\n\n var mathmlEntitiesEncoded = _mathml_js__WEBPACK_IMPORTED_MODULE_3__[\"default\"].mathMLEntities(mathML);\n this.integrationModel.updateFormula(mathmlEntitiesEncoded);\n this.customEditors.disable();\n this.integrationModel.notifyWindowClosed(); // Set disabled focus to prevent lost focus.\n\n this.setEmptyMathML();\n this.customEditors.disable(); // Recovering editing area focus.\n\n setTimeout(function () {\n if (typeof _wrs_currentEditor !== 'undefined' && _wrs_currentEditor) {\n _wrs_currentEditor.focus();\n }\n }, 100);\n }\n /**\r\n * Set an empty MathML into the editor in order to clean the edit area.\r\n */\n\n }, {\n key: \"setEmptyMathML\",\n value: function setEmptyMathML() {\n // As second argument we pass\n if (this.deviceProperties.isAndroid || this.deviceProperties.isIOS) {\n // We need to set a empty annotation in order to maintain editor in Hand mode.\n // Adding dir rtl in case of it's activated.\n if (this.editor.getEditorModel().isRTL()) {\n this.setMathML('[]\"', true);\n } else {\n this.setMathML('[]\"', true);\n }\n } else {\n if (this.editor.getEditorModel().isRTL()) {\n this.setMathML('', true);\n } else {\n this.setMathML('', true);\n }\n }\n }\n /**\r\n * Mandatory method: modal object calls this method when is updated, for example re-editing a formula when the\r\n * editor is open with another formula. This method updates the editor content (with an empty MathML or an existing formula),\r\n * updates - if needed - the editor toolbar (math --> chem or chem --> math) and recover the focus.\r\n */\n\n }, {\n key: \"onOpen\",\n value: function onOpen() {\n if (this.isNewElement) {\n this.setEmptyMathML();\n } else {\n this.setMathML(this.mathML);\n }\n\n this.updateToolbar();\n this.onFocus();\n }\n /**\r\n * Sets the correct toolbar depending if exist other custom toolbars at the same time (e.g: Chemistry)\r\n */\n\n }, {\n key: \"updateToolbar\",\n value: function updateToolbar() {\n this.updateTitle(this.modalDialogInstance);\n var customEditor;\n\n if (customEditor = this.customEditors.getActiveEditor()) {\n var toolbar = customEditor.toolbar ? customEditor.toolbar : _wrs_int_wirisProperties['toolbar'];\n\n if (this.toolbar == null || this.toolbar != toolbar) {\n this.setToolbar(toolbar);\n }\n } else {\n var toolbar = this.getToolbar();\n\n if (this.toolbar == null || this.toolbar != toolbar) {\n this.setToolbar(toolbar);\n this.customEditors.disable();\n }\n }\n }\n /**\r\n * Updates the modalObject title: if a custom editor (with a custom toolbar) is enabled\r\n * picks the custom editor title. Otherwise default title.\r\n */\n\n }, {\n key: \"updateTitle\",\n value: function updateTitle() {\n var customEditor;\n\n if (customEditor = this.customEditors.getActiveEditor()) {\n this.modalDialogInstance.setTitle(customEditor.title);\n } else {\n this.modalDialogInstance.setTitle('MathType');\n }\n }\n /**\r\n * Returns toolbar depending on the configuration local or server side.\r\n */\n\n }, {\n key: \"getToolbar\",\n value: function getToolbar() {\n var toolbar;\n\n if ('toolbar' in this.editorAttributes) {\n toolbar = this.editorAttributes.toolbar;\n } else {\n toolbar = \"general\";\n } // TODO: Change global integration variable for integration custom toolbar\n\n\n if (toolbar == 'general') {\n toolbar = typeof _wrs_int_wirisProperties == 'undefined' || typeof _wrs_int_wirisProperties['toolbar'] == 'undefined' ? 'general' : _wrs_int_wirisProperties['toolbar'];\n }\n\n return toolbar;\n }\n /**\r\n * Set a toolbar into editor.\r\n * @param {string} toolbar - toolbar name.\r\n */\n\n }, {\n key: \"setToolbar\",\n value: function setToolbar(toolbar) {\n this.toolbar = toolbar;\n this.editor.setParams({\n 'toolbar': this.toolbar\n });\n }\n /**\r\n * Returns true if the content of the editor has been changed. The logic of the changes\r\n * is delegated to editorListener object.\r\n */\n\n }, {\n key: \"hasChanges\",\n value: function hasChanges() {\n return !this.editor.isFormulaEmpty() && this.editorListener.getIsContentChanged();\n }\n }]);\n\n return ContentManager;\n}();\n\n\n\n//# sourceURL=webpack:///./core/src/contentmanager.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"default\", function() { return ContentManager; });\n/* harmony import */ var _configuration_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./configuration.js */ \"./core/src/configuration.js\");\n/* harmony import */ var _editorlistener_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./editorlistener.js */ \"./core/src/editorlistener.js\");\n/* harmony import */ var _listeners_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./listeners.js */ \"./core/src/listeners.js\");\n/* harmony import */ var _mathml_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./mathml.js */ \"./core/src/mathml.js\");\n/* harmony import */ var _util_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./util.js */ \"./core/src/util.js\");\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\n\n\n\n\n\n/**\r\n * This class represents the content of a ModalDialog class managing the following:\r\n * - Insertion in the ModalDialog.\r\n * - Actions to be done once the modal object has been submitted (submitAction() method).\r\n * - Updates itself when ModalDialog is updated, for example when ModalDialog\r\n * is re-opened (update(modalObject) method).\r\n * - Communicates ModalDialog if some changes have be done (hasChanges() method).\r\n */\n\nvar ContentManager =\n/*#__PURE__*/\nfunction () {\n /**\r\n * Class constructor\r\n * @param {Object} contentManagerAttributes - Object containing all attributes needed to\r\n * create a new instance of ContentManager class.\r\n * @param {Object} contentManagerAttributes.editorAttributes - Object containing MathType editor parameters.\r\n */\n function ContentManager(contentManagerAttributes) {\n _classCallCheck(this, ContentManager);\n\n /**\r\n * An object containing MathType editor parameters. See\r\n * http://docs.wiris.com/en/mathtype/mathtype_web/sdk-api/parameters for further information.\r\n * @type {Object}\r\n */\n this.contentManagerAttributes = {};\n\n if ('editorAttributes' in contentManagerAttributes) {\n this.editorAttributes = contentManagerAttributes.editorAttributes;\n } else {\n throw new Error('ContentManager constructor error: editorAttributes property missed.');\n }\n /**\r\n * CustomEditors instance. Contains the custom editors.\r\n * @type {CustomEditors}\r\n */\n\n\n this.customEditors = null;\n\n if ('customEditors' in contentManagerAttributes) {\n this.customEditors = contentManagerAttributes.customEditors;\n }\n /**\r\n * Environment properties. This object contains data about the integration platform.\r\n * @type {Object}\r\n * @property {string} editor - Editor name. Usually the HTML editor.\r\n * @property {string} mode - Save mode. Xml by default\r\n * @property {string} version - Plugin version.\r\n */\n\n\n this.environment = {};\n\n if ('environment' in contentManagerAttributes) {\n this.environment = contentManagerAttributes.environment;\n } else {\n throw new Error('ContentManager constructor error: environment property missed');\n }\n /**\r\n * ContentManager language.\r\n * @type {string}\r\n */\n\n\n this.language = '';\n\n if ('language' in contentManagerAttributes) {\n this.language = contentManagerAttributes.language;\n } else {\n throw new Error('ContentManager constructor error: language property missed');\n }\n /**\r\n * Editor listener. Needed to get control about editor changes.\r\n * @type {EditorListener}\r\n */\n\n\n this.editorListener = new _editorlistener_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"]();\n /**\r\n * MathType editor instance.\r\n * @type {JsEditor}\r\n */\n\n this.editor = null;\n /**\r\n * Navigator user agent.\r\n * @type {string}\r\n */\n\n this.ua = navigator.userAgent.toLowerCase();\n /**\r\n * Mobile device properties object\r\n * @type {Object}\r\n * @property {boolean} isAndroid - True if the device is android. False otherwise.\r\n * @property {boolean} isIOS - True if the device is iOS. False otherwise.\r\n */\n\n this.deviceProperties = {};\n this.deviceProperties.isAndroid = this.ua.indexOf(\"android\") > -1;\n this.deviceProperties.isIOS = this.ua.indexOf(\"ipad\") > -1 || this.ua.indexOf(\"iphone\") > -1;\n /**\r\n * Custom editor toolbar.\r\n * @type {string} toolbar\r\n */\n\n this.toolbar = null;\n /**\r\n * Instance of the ModalDialog class associated to the ContentManager instance.\r\n * @type {ModalDialog}\r\n */\n\n this.modalDialogInstance = null;\n /**\r\n * ContentManager listeners.\r\n * @type {Listeners}\r\n */\n\n this.listeners = new _listeners_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"]();\n /**\r\n * MathML associated to the ContentManager instance.\r\n * @type {string}\r\n */\n\n this.mathML = null;\n /**\r\n * Indicates if the edited element is a new element or not.\r\n * @type {boolean}\r\n */\n\n this.isNewElement = true;\n /**\r\n * IntegrationModel instance. Needed to call wrapper methods.\r\n * @type {IntegrationModel}\r\n */\n\n this.integrationModel = null;\n /**\r\n * Indicates if the editor is loaded.\r\n * @type {boolean}\r\n */\n\n this.isEditorLoaded = false;\n }\n /**\r\n * Add a new listener to ContentManager class.\r\n * @param {Object} listener - listener to be added.\r\n */\n\n\n _createClass(ContentManager, [{\n key: \"addListener\",\n value: function addListener(listener) {\n this.listeners.add(listener);\n }\n /**\r\n * Sets an instance of an IntegrationModel\r\n * @param {IntegrationModel} integrationModel\r\n */\n\n }, {\n key: \"setIntegrationModel\",\n value: function setIntegrationModel(integrationModel) {\n this.integrationModel = integrationModel;\n }\n /**\r\n * Sets a modal dialog instance.\r\n * @param {ModalDialog} - a ModalDialog instance\r\n */\n\n }, {\n key: \"setModalDialogInstance\",\n value: function setModalDialogInstance(modalDialogInstance) {\n this.modalDialogInstance = modalDialogInstance;\n }\n /**\r\n * Mandatory method. Inserts editor into modal object content container.\r\n */\n\n }, {\n key: \"insert\",\n value: function insert() {\n // Before insert the editor we update the modal object title to avoid weird render display.\n this.updateTitle(this.modalDialogInstance);\n this.insertEditor(this.modalDialogInstance);\n }\n /**\r\n * Method to insert MathType into modal object. This method\r\n * waits until editor JavaScript is loaded to insert the editor into\r\n * contentContainer modal object element.\r\n */\n\n }, {\n key: \"insertEditor\",\n value: function insertEditor() {\n // To know if editor JavaScript is loaded we need to wait until com.wiris.jsEditor namespace is ready.\n if ('com' in window && 'wiris' in window.com && 'jsEditor' in window.com.wiris) {\n this.editor = com.wiris.jsEditor.JsEditor.newInstance(this.editorAttributes);\n this.editor.insertInto(this.modalDialogInstance.contentContainer);\n this.editor.focus();\n\n if (this.modalDialogInstance.rtl) {\n this.editor.action('rtl');\n } // Setting div in rtl in case of it's activated.\n\n\n if (this.editor.getEditorModel().isRTL()) {\n this.editor.element.style.direction = 'rtl';\n } // Editor listener: this object manages the changes logic of editor.\n\n\n this.editor.getEditorModel().addEditorListener(this.editorListener); // iOS events.\n\n if (this.modalDialogInstance.deviceProperties['isIOS']) {\n setTimeout(function () {\n this.modalDialogInstance.hideKeyboard();\n }, 400);\n var formulaDisplayDiv = document.getElementsByClassName('wrs_formulaDisplay')[0];\n _util_js__WEBPACK_IMPORTED_MODULE_4__[\"default\"].addEvent(formulaDisplayDiv, 'focus', this.modalDialogInstance.handleOpenedIosSoftkeyboard);\n _util_js__WEBPACK_IMPORTED_MODULE_4__[\"default\"].addEvent(formulaDisplayDiv, 'blur', this.modalDialogInstance.handleClosedIosSoftkeyboard);\n } // Fire onLoad event. Necessary to set the MathML into the editor\n // after is loaded.\n\n\n this.listeners.fire('onLoad', {});\n this.isEditorLoaded = true;\n } else {\n setTimeout(ContentManager.prototype.insertEditor.bind(this, this.modalDialogInstance), 100);\n }\n }\n /**\r\n * Loads MathType script.\r\n */\n\n }, {\n key: \"init\",\n value: function init() {\n var queryParams = window.location.search.substring(1).split(\"&\");\n\n for (var i = 0; i < queryParams.length; i++) {\n var pos = queryParams[i].indexOf(\"v=\");\n\n if (pos >= 0) {\n version = queryParams[i].substring(2);\n }\n }\n\n var script = document.createElement('script');\n script.type = 'text/javascript';\n var editorUrl = _configuration_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get('editorUrl'); // We create an object url for parse url string and work more efficiently.\n\n var urlObject = document.createElement('a');\n urlObject.href = editorUrl; // Change to https if necessary.\n\n if (window.location.href.indexOf(\"https://\") == 0) {\n // It check if browser is https and configuration is http. If this is so, we will replace protocol.\n if (urlObject.protocol == 'http:') {\n urlObject.protocol = 'https:';\n }\n } // Check protocol and remove port if it's standard.\n\n\n if (urlObject.port == '80' || urlObject.port == '443') {\n editorUrl = urlObject.protocol + '//' + urlObject.hostname + '/' + urlObject.pathname;\n } else {\n editorUrl = urlObject.protocol + '//' + urlObject.hostname + ':' + urlObject.port + '/' + urlObject.pathname;\n } // Editor stats. Use environment property to set it.\n\n\n var stats = {};\n\n if ('editor' in this.environment) {\n stats.editor = this.environment.editor;\n } else {\n stats.editor = 'unknown';\n }\n\n if ('mode' in this.environment) {\n stats.mode = this.environment.mode;\n } else {\n stats.mode = _configuration_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get('saveMode');\n }\n\n if ('version' in this.environment) {\n stats.version = this.environment.version;\n } else {\n stats.version = _configuration_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get('version');\n } // Load editor URL. We add stats as GET params.\n\n\n script.src = editorUrl + \"?lang=\" + this.language + '&stats-editor=' + stats.editor + '&stats-mode=' + stats.mode + '&stats-version=' + stats.version;\n document.getElementsByTagName('head')[0].appendChild(script);\n }\n /**\r\n * Set the editor initial content: an existing formula or a blank MathML\r\n */\n\n }, {\n key: \"setInitialContent\",\n value: function setInitialContent() {\n if (!this.isNewElement) {\n this.setMathML(this.mathML);\n }\n }\n /**\r\n * Set a MathML into editor.\r\n * @param {string} mathml - MathML string.\r\n * @param {bool} focusDisabled - if true editor don't get focus after the MathML is set. false by default.\r\n */\n\n }, {\n key: \"setMathML\",\n value: function setMathML(mathml, focusDisabled) {\n // By default focus is enabled\n if (typeof focusDisabled === 'undefined') {\n focusDisabled = false;\n } // Using setMathML method is not a change produced by the user but for the API\n // so we set to false the contentChange property of editorListener.\n\n\n this.editor.setMathMLWithCallback(mathml, function () {\n this.editorListener.setWaitingForChanges(true);\n }.bind(this)); // We need to wait a little until the callback finish.\n\n setTimeout(function () {\n this.editorListener.setIsContentChanged(false);\n }.bind(this), 500); // In some scenarios - like closing modal object - editor mustn't be focused.\n\n if (!focusDisabled) {\n this.onFocus();\n }\n }\n /**\r\n * Set focus on editor.\r\n */\n\n }, {\n key: \"onFocus\",\n value: function onFocus() {\n if (typeof this.editor !== 'undefined' && this.editor != null) {\n this.editor.focus();\n }\n }\n /**\r\n * Mandatory method: modal object calls this method to execute a callback action\r\n * on submit.\r\n * This method updates the edition area (inserting a new formula or update an older one),\r\n * and focus the edition area too.\r\n */\n\n }, {\n key: \"submitAction\",\n value: function submitAction() {\n if (!this.editor.isFormulaEmpty()) {\n var mathML = this.editor.getMathMLWithSemantics(); // Add class for custom editors.\n\n if (this.customEditors.getActiveEditor() != null) {\n mathML = _mathml_js__WEBPACK_IMPORTED_MODULE_3__[\"default\"].addCustomEditorClassAttribute(mathML, this.customEditors.getActiveEditor().toolbar);\n } else {\n // We need - if exists - the editor name from MathML\n // class attribute.\n for (var key in this.customEditors.editors) {\n mathML = _mathml_js__WEBPACK_IMPORTED_MODULE_3__[\"default\"].removeCustomEditorClassAttribute(mathML, key);\n }\n }\n\n var mathmlEntitiesEncoded = _mathml_js__WEBPACK_IMPORTED_MODULE_3__[\"default\"].mathMLEntities(mathML);\n this.integrationModel.updateFormula(mathmlEntitiesEncoded);\n } else {\n this.integrationModel.updateFormula(null);\n }\n\n this.customEditors.disable();\n this.integrationModel.notifyWindowClosed(); // Set disabled focus to prevent lost focus.\n\n this.setEmptyMathML();\n this.customEditors.disable();\n }\n /**\r\n * Set an empty MathML into the editor in order to clean the edit area.\r\n */\n\n }, {\n key: \"setEmptyMathML\",\n value: function setEmptyMathML() {\n // As second argument we pass\n if (this.deviceProperties.isAndroid || this.deviceProperties.isIOS) {\n // We need to set a empty annotation in order to maintain editor in Hand mode.\n // Adding dir rtl in case of it's activated.\n if (this.editor.getEditorModel().isRTL()) {\n this.setMathML('[]\"', true);\n } else {\n this.setMathML('[]\"', true);\n }\n } else {\n if (this.editor.getEditorModel().isRTL()) {\n this.setMathML('', true);\n } else {\n this.setMathML('', true);\n }\n }\n }\n /**\r\n * Mandatory method: modal object calls this method when is updated, for example re-editing a formula when the\r\n * editor is open with another formula. This method updates the editor content (with an empty MathML or an existing formula),\r\n * updates - if needed - the editor toolbar (math --> chem or chem --> math) and recover the focus.\r\n */\n\n }, {\n key: \"onOpen\",\n value: function onOpen() {\n if (this.isNewElement) {\n this.setEmptyMathML();\n } else {\n this.setMathML(this.mathML);\n }\n\n this.updateToolbar();\n this.onFocus();\n }\n /**\r\n * Sets the correct toolbar depending if exist other custom toolbars at the same time (e.g: Chemistry)\r\n */\n\n }, {\n key: \"updateToolbar\",\n value: function updateToolbar() {\n this.updateTitle(this.modalDialogInstance);\n var customEditor;\n\n if (customEditor = this.customEditors.getActiveEditor()) {\n var toolbar = customEditor.toolbar ? customEditor.toolbar : _wrs_int_wirisProperties['toolbar'];\n\n if (this.toolbar == null || this.toolbar != toolbar) {\n this.setToolbar(toolbar);\n }\n } else {\n var toolbar = this.getToolbar();\n\n if (this.toolbar == null || this.toolbar != toolbar) {\n this.setToolbar(toolbar);\n this.customEditors.disable();\n }\n }\n }\n /**\r\n * Updates the modalObject title: if a custom editor (with a custom toolbar) is enabled\r\n * picks the custom editor title. Otherwise default title.\r\n */\n\n }, {\n key: \"updateTitle\",\n value: function updateTitle() {\n var customEditor;\n\n if (customEditor = this.customEditors.getActiveEditor()) {\n this.modalDialogInstance.setTitle(customEditor.title);\n } else {\n this.modalDialogInstance.setTitle('MathType');\n }\n }\n /**\r\n * Returns toolbar depending on the configuration local or server side.\r\n */\n\n }, {\n key: \"getToolbar\",\n value: function getToolbar() {\n var toolbar;\n\n if ('toolbar' in this.editorAttributes) {\n toolbar = this.editorAttributes.toolbar;\n } else {\n toolbar = \"general\";\n } // TODO: Change global integration variable for integration custom toolbar\n\n\n if (toolbar == 'general') {\n toolbar = typeof _wrs_int_wirisProperties == 'undefined' || typeof _wrs_int_wirisProperties['toolbar'] == 'undefined' ? 'general' : _wrs_int_wirisProperties['toolbar'];\n }\n\n return toolbar;\n }\n /**\r\n * Set a toolbar into editor.\r\n * @param {string} toolbar - toolbar name.\r\n */\n\n }, {\n key: \"setToolbar\",\n value: function setToolbar(toolbar) {\n this.toolbar = toolbar;\n this.editor.setParams({\n 'toolbar': this.toolbar\n });\n }\n /**\r\n * Returns true if the content of the editor has been changed. The logic of the changes\r\n * is delegated to editorListener object.\r\n */\n\n }, {\n key: \"hasChanges\",\n value: function hasChanges() {\n return !this.editor.isFormulaEmpty() && this.editorListener.getIsContentChanged();\n }\n }]);\n\n return ContentManager;\n}();\n\n\n\n//# sourceURL=webpack:///./core/src/contentmanager.js?"); /***/ }), @@ -166,7 +166,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) * /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"default\", function() { return Core; });\n/* harmony import */ var _util_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./util.js */ \"./core/src/util.js\");\n/* harmony import */ var _stringmanager_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./stringmanager.js */ \"./core/src/stringmanager.js\");\n/* harmony import */ var _contentmanager_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./contentmanager.js */ \"./core/src/contentmanager.js\");\n/* harmony import */ var _modal_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./modal.js */ \"./core/src/modal.js\");\n/* harmony import */ var _serviceprovider_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./serviceprovider.js */ \"./core/src/serviceprovider.js\");\n/* harmony import */ var _parser_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./parser.js */ \"./core/src/parser.js\");\n/* harmony import */ var _latex_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./latex.js */ \"./core/src/latex.js\");\n/* harmony import */ var _mathml_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./mathml.js */ \"./core/src/mathml.js\");\n/* harmony import */ var _customeditors_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./customeditors.js */ \"./core/src/customeditors.js\");\n/* harmony import */ var _configuration_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./configuration.js */ \"./core/src/configuration.js\");\n/* harmony import */ var _jsvariables_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./jsvariables.js */ \"./core/src/jsvariables.js\");\n/* harmony import */ var _event_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./event.js */ \"./core/src/event.js\");\n/* harmony import */ var _listeners_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./listeners.js */ \"./core/src/listeners.js\");\n/* harmony import */ var _integrationmodel_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./integrationmodel.js */ \"./core/src/integrationmodel.js\");\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n/**\n * Class representing MathType integration Core. This class is the integration entry point. Manages integration\n * initialization (services, languages), events, and the insertion of the formulas in the edit area.\n */\n\nvar Core =\n/*#__PURE__*/\nfunction () {\n /**\n * Core class constructor. Admits a string containing the configurationjs service\n * which loads all JavaScript configuration generated in the backend. This file is needed\n * to instantiate the serviceProvider class (all services lives in the same path).\n */\n function Core() {\n _classCallCheck(this, Core);\n\n /**\n * Language. Needed for accessibility and locales. 'en' by default.\n * @type {string}\n */\n this.language = 'en';\n /**\n * Edit mode. Admit 'images' and 'latex' values.\n * @type {string}\n */\n\n this.editMode = 'images';\n /**\n * Modal dialog instance.\n * @type {ModalDialog}\n */\n\n this.modalDialog = null;\n /**\n * Core custom editors. By default only chemistry editor.\n * @type {CustomEditors}\n */\n\n this.customEditors = new _customeditors_js__WEBPACK_IMPORTED_MODULE_8__[\"default\"]();\n var chemEditorParams = {\n name: 'Chemistry',\n toolbar: 'chemistry',\n icon: 'chem.png',\n confVariable: 'chemEnabled',\n title: 'ChemType',\n tooltip: 'Insert a chemistry formula - ChemType' // TODO: Localize tooltip.\n\n };\n this.customEditors.addEditor('chemistry', chemEditorParams);\n /**\n * Environment properties. This object contains data about the integration platform.\n * @type {Object}\n * @property {string} editor - Editor name. Usually the HTML editor.\n * @property {string} mode - Save mode. Xml by default\n * @property {string} version - Plugin version.\n */\n\n this.environment = {};\n /**\n * Edit properties.\n * @type {Object}\n * @property {boolean} isNewElement - Indicates if the edit formula is a new one or not.\n * @property {Img} temporalImage - Image of the formula edited. Null if the formula is a new one.\n * @property {Range} latexRange - LaTeX formula range.\n * @property {Range} range - Image range.\n * @property {string} editMode - Edition mode. Images by default.\n */\n\n this.editionProperties = {\n isNewElement: true,\n temporalImage: null,\n latexRange: null,\n range: null\n /**\n * Integration model instance.\n * @type {IntegrationModel}\n */\n\n };\n this.integrationModel = null;\n /**\n * ContentManager instance.\n * @type {ContentManager}\n */\n\n this.contentManager = null;\n /**\n * Information about the current browser.\n * @type {string}\n */\n\n this.browser = function get_browser() {\n var ua = navigator.userAgent;\n\n if (ua.search(\"Edge/\") >= 0) {\n return \"EDGE\";\n } else if (ua.search(\"Chrome/\") >= 0) {\n return \"CHROME\";\n } else if (ua.search(\"Trident/\") >= 0) {\n return \"IE\";\n } else if (ua.search(\"Firefox/\") >= 0) {\n return \"FIREFOX\";\n } else if (ua.search(\"Safari/\") >= 0) {\n return \"SAFARI\";\n }\n }();\n /**\n * Plugin listeners.\n * @type {Object[]}\n */\n\n\n this.listeners = new _listeners_js__WEBPACK_IMPORTED_MODULE_12__[\"default\"]();\n }\n /**\n * Initializes the core.\n * @param {string} integrationPath - integration root folder path.\n */\n\n\n _createClass(Core, [{\n key: \"init\",\n value: function init(integrationPath) {\n this.load(integrationPath);\n }\n /**\n * Sets the instance of the integration model object.\n * @param {IntegrationModel} integrationModel - integrationModel instance.\n */\n\n }, {\n key: \"setIntegrationModel\",\n value: function setIntegrationModel(integrationModel) {\n this.integrationModel = integrationModel;\n }\n /**\n * This method set an object containing environment properties. The structure for the an\n * environment object is the following:\n * @param {Object} environmentObject - And object containing environment properties.\n * @param {string} environmentObject.editor - Integration editor (usually HTML editor).\n * @param {string} environmentObject.mode - Save mode.\n * @param {string} environmentObject.version - Integration version.\n */\n\n }, {\n key: \"setEnvironment\",\n value: function setEnvironment(environmentObject) {\n if ('editor' in environmentObject) {\n this.environment.editor = environmentObject.editor;\n }\n\n if ('mode' in environmentObject) {\n this.environment.mode = environmentObject.mode;\n }\n\n if ('version' in environmentObject) {\n this.environment.version = environmentObject.version;\n }\n }\n /**\n * Get modal dialog\n * @returns {ModalDialog} Modal Window core instance.\n */\n\n }, {\n key: \"getModalDialog\",\n value: function getModalDialog() {\n return this.modalDialog;\n }\n /**\n * This method inits the Core class doing the following:\n * - Calls (async) to configurationjs service, converting the response JSON into javascript variables.\n * - Updates Configuration class with the previous configuration properties.\n * - Updates the ServiceProvider class using configurationjs service path as reference.\n * - Load lang strings and CSS.\n * - Once the previous is ready fires 'onLoad' event.\n */\n\n }, {\n key: \"load\",\n value: function load(integrationPath) {\n var httpRequest = typeof XMLHttpRequest != 'undefined' ? new XMLHttpRequest() : new ActiveXObject('Microsoft.XMLHTTP');\n this.integrationPath = integrationPath.indexOf(\"/\") == 0 || integrationPath.indexOf(\"http\") == 0 ? integrationPath : _util_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].concatenateUrl(this.integrationModel.getPath(), integrationPath);\n httpRequest.open('GET', this.integrationPath, false); // Async request.\n\n httpRequest.onload = function (e) {\n var _this = this;\n\n if (httpRequest.readyState === 4) {\n // Loading configuration variables.\n var jsonConfiguration = JSON.parse(httpRequest.responseText);\n var variables = Object.keys(jsonConfiguration);\n _configuration_js__WEBPACK_IMPORTED_MODULE_9__[\"default\"].addConfiguration(jsonConfiguration); // Adding JavaScript (not backend) configuration variables.\n\n _configuration_js__WEBPACK_IMPORTED_MODULE_9__[\"default\"].addConfiguration(_jsvariables_js__WEBPACK_IMPORTED_MODULE_10__[\"default\"]); // Load service paths.\n\n this.loadServicePaths(); // Load lang file.\n\n this.loadLangFile();\n this.loadCSS(); // Fire 'onLoad' event. All integration must listen this event in order to know if the plugin has been properly loaded.\n // We need to wait until stringManager has been loaded.\n\n if (Core.stringManager === null) {\n var stringManagerListener = _listeners_js__WEBPACK_IMPORTED_MODULE_12__[\"default\"].newListener('onLoad', function () {\n _this.listeners.fire('onLoad', {});\n });\n Core.stringManager.addListener(stringManagerListener);\n } else {\n this.listeners.fire('onLoad', {});\n }\n }\n }.bind(this);\n\n httpRequest.send(null);\n }\n /**\n * Instantiate a new ServiceProvider path (static) and calculate all the backend services\n * paths using Core integrationPath as base path.\n */\n\n }, {\n key: \"loadServicePaths\",\n value: function loadServicePaths() {\n // Services path (tech dependant).\n var createImagePath = this.integrationPath.replace('configurationjs', 'createimage');\n var showImagePath = this.integrationPath.replace('configurationjs', 'showimage');\n var createImagePath = this.integrationPath.replace('configurationjs', 'createimage');\n var getMathMLPath = this.integrationPath.replace('configurationjs', 'getmathml');\n var servicePath = this.integrationPath.replace('configurationjs', 'service'); // Some backend integrations (like Java o Ruby) have an absolute backend path,\n // for example: /app/service. For them we calculate the absolute URL path, i.e\n // protocol://domain:port/app/service\n\n if (this.integrationPath.indexOf(\"/\") == 0) {\n var serverPath = this.getServerPath();\n showImagePath = serverPath + showImagePath;\n createImagePath = serverPath + createImagePath;\n getMathMLPath = serverPath + getMathMLPath;\n servicePath = serverPath + servicePath;\n }\n\n _serviceprovider_js__WEBPACK_IMPORTED_MODULE_4__[\"default\"].setServicePath('showimage', showImagePath);\n _serviceprovider_js__WEBPACK_IMPORTED_MODULE_4__[\"default\"].setServicePath('createimage', createImagePath);\n _serviceprovider_js__WEBPACK_IMPORTED_MODULE_4__[\"default\"].setServicePath('service', servicePath);\n _serviceprovider_js__WEBPACK_IMPORTED_MODULE_4__[\"default\"].setServicePath('getmathml', getMathMLPath);\n }\n /**\n * Returns the client side server path on integration script lives.\n * @return {string} client side server path.\n */\n\n }, {\n key: \"getServerPath\",\n value: function getServerPath() {\n var url = this.integrationModel.getPath();\n var hostNameIndex = url.indexOf(\"/\", url.indexOf(\"/\") + 2);\n return url.substr(0, hostNameIndex);\n }\n /**\n * Loads language file using integration script path as base path. Then\n * load the string into the core StringManager instance.\n */\n\n }, {\n key: \"loadLangFile\",\n value: function loadLangFile() {\n // Translated languages.\n var languages = 'ar,ca,cs,da,de,en,es,et,eu,fi,fr,gl,he,hr,hu,it,ja,ko,nl,no,pl,pt,pt_br,ru,sv,tr,zh,el';\n var langArray = languages.split(',');\n var lang = this.language;\n\n if (langArray.indexOf(lang) == -1) {\n lang = lang.substr(0, 2);\n }\n\n if (langArray.indexOf(lang) == -1) {\n lang = 'en';\n }\n\n var script = document.createElement('script');\n script.type = 'text/javascript';\n script.src = this.integrationModel.getPath() + '/' + this.integrationModel.langFolderName + '/' + lang + '/strings.js'; // When strings are loaded, it loads into stringManager\n\n script.onload = function () {\n Core.getStringManager().loadStrings(wrs_strings);\n };\n\n document.getElementsByTagName('head')[0].appendChild(script);\n }\n /**\n * Appends CSS file to header.\n */\n\n }, {\n key: \"loadCSS\",\n value: function loadCSS() {\n var fileRef = document.createElement(\"link\");\n fileRef.setAttribute(\"rel\", \"stylesheet\");\n fileRef.setAttribute(\"type\", \"text/css\");\n fileRef.setAttribute(\"href\", _util_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].concatenateUrl(this.integrationModel.getPath(), '/core/styles.css'));\n document.getElementsByTagName(\"head\")[0].appendChild(fileRef);\n }\n /**\n * Adds a listener to Listeners core property.\n * @param {Object} listener - listener to be added.\n */\n\n }, {\n key: \"addListener\",\n value: function addListener(listener) {\n this.listeners.add(listener);\n }\n /**\n * Adds a listener to global core listeners.\n * @param {Object} listener - listener to be added.\n * @static\n */\n\n }, {\n key: \"updateFormula\",\n\n /**\n * Transform a MathML into a image formula. Then the image formula is inserted in the specified target, creating\n * a new image (new formula) or updating an existing one.\n * @param {Object} focusElement - element to be focused\n * @param {Object} windowTarget - window where the editable content is\n * @param {string} mathml - Mathml code\n * @param {Object[]} wirisProperties - extra attributes for the formula (like background color or font size).\n */\n value: function updateFormula(focusElement, windowTarget, mathml, wirisProperties) {\n /**\n * This event is fired after update the formula.\n * @type {Object}\n * @property {string} mathml - MathML to be transformed.\n * @property {string} editMode - edit mode.\n * @property {Object} wirisProperties - extra attributes for the formula.\n * @property {string} language - formula language.\n */\n var beforeUpdateEvent = new _event_js__WEBPACK_IMPORTED_MODULE_11__[\"default\"]();\n beforeUpdateEvent.mathml = mathml; // Cloning wirisProperties object\n // We don't want wirisProperties object modified.\n\n beforeUpdateEvent.wirisProperties = {};\n\n for (var attr in wirisProperties) {\n beforeUpdateEvent.wirisProperties[attr] = wirisProperties[attr];\n } // Read only.\n\n\n beforeUpdateEvent.language = this.language;\n beforeUpdateEvent.editMode = this.editMode;\n\n if (this.listeners.fire('onBeforeFormulaInsertion', beforeUpdateEvent)) {\n return;\n }\n\n if (Core.globalListeners.fire('onBeforeFormulaInsertion', beforeUpdateEvent)) {\n return;\n }\n\n mathml = beforeUpdateEvent.mathml;\n wirisProperties = beforeUpdateEvent.wirisProperties;\n /**\n * This event is fired after update the formula.\n * @type {Object}\n * @param {string} editMode - edit mode.\n * @param {Object} windowTarget - target window.\n * @param {Object} focusElement - target element to be focused after update.\n * @param {string} latex - LaTeX generated by the formula (editMode=latex).\n * @param {Object} node - node generated after update the formula (text if LaTeX img otherwise).\n */\n\n var afterUpdateEvent = new _event_js__WEBPACK_IMPORTED_MODULE_11__[\"default\"]();\n afterUpdateEvent.editMode = this.editMode;\n afterUpdateEvent.windowTarget = windowTarget;\n afterUpdateEvent.focusElement = focusElement;\n\n if (mathml.length == 0) {\n this.insertElementOnSelection(null, focusElement, windowTarget);\n } else if (this.editMode == 'latex') {\n afterUpdateEvent.latex = _latex_js__WEBPACK_IMPORTED_MODULE_6__[\"default\"].getLatexFromMathML(mathml); // this.integrationModel.getNonLatexNode is an integration wrapper to have special behaviours for nonLatex.\n // Not all the integrations have special behaviours for nonLatex.\n\n if (!!this.integrationModel.fillNonLatexNode && typeof afterUpdateEvent.latex === 'undefined') {\n this.integrationModel.fillNonLatexNode(afterUpdateEvent, windowTarget, mathml);\n } else {\n afterUpdateEvent.node = windowTarget.document.createTextNode('$$' + afterUpdateEvent.latex + '$$');\n }\n\n this.insertElementOnSelection(afterUpdateEvent.node, focusElement, windowTarget);\n } else if (this.editMode == 'iframes') {\n var iframe = wrs_mathmlToIframeObject(windowTarget, mathml);\n this.insertElementOnSelection(iframe, focusElement, windowTarget);\n } else {\n afterUpdateEvent.node = _parser_js__WEBPACK_IMPORTED_MODULE_5__[\"default\"].mathmlToImgObject(windowTarget.document, mathml, wirisProperties, this.language);\n this.insertElementOnSelection(afterUpdateEvent.node, focusElement, windowTarget);\n }\n\n if (this.listeners.fire('onAfterFormulaInsertion', afterUpdateEvent)) {\n return;\n }\n\n if (Core.globalListeners.fire('onAfterFormulaInsertion', afterUpdateEvent)) {\n return;\n }\n }\n /**\n * Sets the caret after 'node' and focus node owner document.\n * @param {Object} node - node that it will be behind the caret after the execution.\n */\n\n }, {\n key: \"placeCaretAfterNode\",\n value: function placeCaretAfterNode(node) {\n this.integrationModel.getSelection();\n var nodeDocument = node.ownerDocument;\n\n if (typeof nodeDocument.getSelection !== 'undefined') {\n var range = nodeDocument.createRange();\n range.setStartAfter(node);\n range.collapse(true);\n var selection = nodeDocument.getSelection();\n selection.removeAllRanges();\n selection.addRange(range);\n nodeDocument.body.focus();\n }\n }\n /**\n * Replaces a selection with an element.\n * @param {Object} element - element to replace the selection.\n * @param {Object} focusElement - element to be focused after the replace.\n * @param {Object} windowTarget - target window.\n */\n\n }, {\n key: \"insertElementOnSelection\",\n value: function insertElementOnSelection(element, focusElement, windowTarget) {\n if (this.editionProperties.isNewElement) {\n if (focusElement.type == \"textarea\") {\n _util_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].updateTextArea(focusElement, element.textContent);\n } else if (document.selection && document.getSelection == 0) {\n var range = windowTarget.document.selection.createRange();\n windowTarget.document.execCommand('InsertImage', false, element.src);\n\n if (!('parentElement' in range)) {\n windowTarget.document.execCommand('delete', false);\n range = windowTarget.document.selection.createRange();\n windowTarget.document.execCommand('InsertImage', false, element.src);\n }\n\n if ('parentElement' in range) {\n var temporalObject = range.parentElement();\n\n if (temporalObject.nodeName.toUpperCase() == 'IMG') {\n temporalObject.parentNode.replaceChild(element, temporalObject);\n } else {\n // IE9 fix: parentNode() does not return the IMG node, returns the parent DIV node. In IE < 9, pasteHTML does not work well.\n range.pasteHTML(_util_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].createObjectCode(element));\n }\n }\n } else {\n var editorSelection = this.integrationModel.getSelection();\n\n var _range; // In IE is needed keep the range due to after focus the modal window it can't be retrieved the last selection.\n\n\n if (this.editionProperties.range) {\n _range = this.editionProperties.range;\n this.editionProperties.range = null;\n } else {\n _range = editorSelection.getRangeAt(0);\n } // Delete if something was surrounded.\n\n\n _range.deleteContents();\n\n var node = _range.startContainer;\n var position = _range.startOffset;\n\n if (node.nodeType == 3) {\n // TEXT_NODE.\n node = node.splitText(position);\n node.parentNode.insertBefore(element, node);\n } else if (node.nodeType == 1) {\n // ELEMENT_NODE.\n node.insertBefore(element, node.childNodes[position]);\n }\n\n this.placeCaretAfterNode(element);\n }\n } else if (this.editionProperties.latexRange) {\n if (document.selection && document.getSelection == 0) {\n this.editionProperties.isNewElement = true;\n this.editionProperties.latexRange.select();\n this.insertElementOnSelection(element, focusElement, windowTarget);\n } else {\n var parentNode = this.editionProperties.latexRange.startContainer;\n this.editionProperties.latexRange.deleteContents();\n this.editionProperties.latexRange.insertNode(element);\n this.placeCaretAfterNode(element);\n }\n } else if (focusElement.type == \"textarea\") {\n var item; // Wrapper for some integrations that can have special behaviours to show latex.\n\n if (typeof this.integrationModel.getSelectedItem !== 'undefined') {\n item = this.integrationModel.getSelectedItem(focusElement, false);\n } else {\n item = _util_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].getSelectedItemOnTextarea(focusElement);\n }\n\n _util_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].updateExistingTextOnTextarea(focusElement, element.textContent, item.startPosition, item.endPosition);\n } else {\n if (!element) {\n // Editor empty, formula has been erased on edit.\n this.editionProperties.temporalImage.parentNode.removeChild(this.editionProperties.temporalImage);\n }\n\n this.editionProperties.temporalImage.parentNode.replaceChild(element, this.editionProperties.temporalImage);\n this.placeCaretAfterNode(element);\n }\n }\n /**\n * Opens a new modal dialog.\n * @param {object} target - target element.\n * @param {boolean} isIframe - specifies if the target is an iframe.\n */\n\n }, {\n key: \"openModalDialog\",\n value: function openModalDialog(target, isIframe) {\n // Textarea elements don't have normal document ranges. It only accepts latex edit.\n this.editMode = 'images'; // In IE is needed keep the range due to after focus the modal window it can't be retrieved the last selection.\n\n try {\n if (isIframe) {\n // Is needed focus the target first.\n target.contentWindow.focus();\n var selection = target.contentWindow.getSelection();\n this.editionProperties.range = selection.getRangeAt(0);\n } else {\n // Is needed focus the target first.\n target.focus();\n\n var _selection = getSelection();\n\n this.editionProperties.range = _selection.getRangeAt(0);\n }\n } catch (e) {\n this.editionProperties.range = null;\n }\n\n if (isIframe === undefined) {\n isIframe = true;\n }\n\n this.editionProperties.latexRange = null;\n\n if (target) {\n var selectedItem;\n\n if (typeof this.integrationModel.getSelectedItem !== 'undefined') {\n selectedItem = this.integrationModel.getSelectedItem(target, isIframe);\n } else {\n selectedItem = _util_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].getSelectedItem(target, isIframe);\n } // Check LaTeX if and only if the node is a text node (nodeType==3).\n\n\n if (selectedItem) {\n // Case when image was selected and button pressed.\n if (!selectedItem.caretPosition && _util_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].containsClass(selectedItem.node, _configuration_js__WEBPACK_IMPORTED_MODULE_9__[\"default\"].get('imageClassName'))) {\n this.editionProperties.temporalImage = selectedItem.node;\n this.editionProperties.isNewElement = false;\n } else if (selectedItem.node.nodeType === 3) {\n // If it's a text node means that editor is working with LaTeX.\n if (!!this.integrationModel.getMathmlFromTextNode) {\n // If integration has this function it isn't set range due to we don't\n // know if it will be put into a textarea as a text or image.\n var mathml = this.integrationModel.getMathmlFromTextNode(selectedItem.node, selectedItem.caretPosition);\n\n if (mathml) {\n this.editMode = 'latex';\n this.editionProperties.isNewElement = false;\n this.editionProperties.temporalImage = document.createElement('img');\n this.editionProperties.temporalImage.setAttribute(_configuration_js__WEBPACK_IMPORTED_MODULE_9__[\"default\"].get('imageMathmlAttribute'), _mathml_js__WEBPACK_IMPORTED_MODULE_7__[\"default\"].safeXmlEncode(mathml));\n }\n } else {\n var latexResult = _latex_js__WEBPACK_IMPORTED_MODULE_6__[\"default\"].getLatexFromTextNode(selectedItem.node, selectedItem.caretPosition);\n\n if (latexResult) {\n var _mathml = _latex_js__WEBPACK_IMPORTED_MODULE_6__[\"default\"].getMathMLFromLatex(latexResult.latex);\n\n this.editMode = 'latex';\n this.editionProperties.isNewElement = false;\n this.editionProperties.temporalImage = document.createElement('img');\n this.editionProperties.temporalImage.setAttribute(_configuration_js__WEBPACK_IMPORTED_MODULE_9__[\"default\"].get('imageMathmlAttribute'), _mathml_js__WEBPACK_IMPORTED_MODULE_7__[\"default\"].safeXmlEncode(_mathml));\n var windowTarget = isIframe ? target.contentWindow : window;\n\n if (target.tagName.toLowerCase() !== 'textarea') {\n if (document.selection) {\n var leftOffset = 0;\n var previousNode = latexResult.startNode.previousSibling;\n\n while (previousNode) {\n leftOffset += _util_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].getNodeLength(previousNode);\n previousNode = previousNode.previousSibling;\n }\n\n this.editionProperties.latexRange = windowTarget.document.selection.createRange();\n this.editionProperties.latexRange.moveToElementText(latexResult.startNode.parentNode);\n this.editionProperties.latexRange.move('character', leftOffset + latexResult.startPosition);\n this.editionProperties.latexRange.moveEnd('character', latexResult.latex.length + 4); // Plus 4 for the '$$' characters.\n } else {\n this.editionProperties.latexRange = windowTarget.document.createRange();\n this.editionProperties.latexRange.setStart(latexResult.startNode, latexResult.startPosition);\n this.editionProperties.latexRange.setEnd(latexResult.endNode, latexResult.endPosition);\n }\n }\n }\n }\n }\n } else if (target.tagName.toLowerCase() === 'textarea') {\n // By default editMode is 'images', but when target is a textarea it needs to be 'latex'.\n this.editMode = 'latex';\n }\n } // Setting an object with the editor parameters.\n // Editor parameters can be customized in several ways:\n // 1 - editorAttributes: Contains the default editor attributes, usually the metrics in a comma separated string. Always exists.\n // 2 - editorParameters: Object containing custom editor parameters. These parameters are defined in the backend. So they affects\n // all integration instances.\n // The backend send the default editor attributes in a coma separated with the following structure:\n // key1=value1,key2=value2...\n\n\n var defaultEditorAttributesArray = _configuration_js__WEBPACK_IMPORTED_MODULE_9__[\"default\"].get('editorAttributes').split(\", \");\n var defaultEditorAttributes = {};\n\n for (var i = 0, len = defaultEditorAttributesArray.length; i < len; i++) {\n var tempAttribute = defaultEditorAttributesArray[i].split('=');\n var key = tempAttribute[0];\n var value = tempAttribute[1];\n defaultEditorAttributes[key] = value;\n } // Custom editor parameters.\n\n\n var editorAttributes = {};\n Object.assign(editorAttributes, defaultEditorAttributes, _configuration_js__WEBPACK_IMPORTED_MODULE_9__[\"default\"].get('editorParameters'));\n editorAttributes.language = this.language;\n editorAttributes.rtl = this.integrationModel.rtl;\n var contentManagerAttributes = {};\n contentManagerAttributes.editorAttributes = editorAttributes;\n contentManagerAttributes.language = this.language;\n contentManagerAttributes.customEditors = this.customEditors;\n contentManagerAttributes.environment = this.environment;\n\n if (this.modalDialog == null) {\n this.modalDialog = new _modal_js__WEBPACK_IMPORTED_MODULE_3__[\"default\"](editorAttributes);\n this.contentManager = new _contentmanager_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"](contentManagerAttributes); // When an instance of ContentManager is created we need to wait until the ContentManager is ready\n // by listening 'onLoad' event.\n\n var listener = _listeners_js__WEBPACK_IMPORTED_MODULE_12__[\"default\"].newListener('onLoad', function () {\n this.contentManager.isNewElement = this.editionProperties.isNewElement;\n\n if (this.editionProperties.temporalImage != null) {\n var mathML = _mathml_js__WEBPACK_IMPORTED_MODULE_7__[\"default\"].safeXmlDecode(this.editionProperties.temporalImage.getAttribute(_configuration_js__WEBPACK_IMPORTED_MODULE_9__[\"default\"].get('imageMathmlAttribute')));\n this.contentManager.mathML = mathML;\n }\n }.bind(this));\n this.contentManager.addListener(listener);\n this.contentManager.init();\n this.modalDialog.setContentManager(this.contentManager);\n this.contentManager.setModalDialogInstance(this.modalDialog);\n } else {\n this.contentManager.isNewElement = this.editionProperties.isNewElement;\n\n if (this.editionProperties.temporalImage != null) {\n var mathML = _mathml_js__WEBPACK_IMPORTED_MODULE_7__[\"default\"].safeXmlDecode(this.editionProperties.temporalImage.getAttribute(_configuration_js__WEBPACK_IMPORTED_MODULE_9__[\"default\"].get('imageMathmlAttribute')));\n this.contentManager.mathML = mathML;\n }\n }\n\n this.contentManager.setIntegrationModel(this.integrationModel);\n this.modalDialog.open();\n }\n /**\n * Returns the instance of the ServiceProvider class.\n * @returns {ServiceProvider} ServiceProvider instance.\n * @static\n */\n\n }, {\n key: \"getCustomEditors\",\n\n /**\n * Return an object with all instance custom editors.\n * @return {CustomEditors}\n */\n value: function getCustomEditors() {\n return this.customEditors;\n }\n }], [{\n key: \"addGlobalListener\",\n value: function addGlobalListener(listener) {\n Core.globalListeners.add(listener);\n }\n }, {\n key: \"getServiceProvider\",\n value: function getServiceProvider() {\n return Core.serviceProvider;\n }\n /**\n * Returns the instance of the StringManager class.\n * @returns {StringManager} StringManager instance\n */\n\n }, {\n key: \"getStringManager\",\n value: function getStringManager() {\n return Core.stringManager;\n }\n }]);\n\n return Core;\n}();\n/**\n * Plugin static listeners.\n * @type {Object[]}\n * @static\n */\n\n\n\nCore.globalListeners = new _listeners_js__WEBPACK_IMPORTED_MODULE_12__[\"default\"]();\n/**\n * Class to manage plugin locales.\n * @type {StringManager}\n * @static\n */\n\nCore.stringManager = new _stringmanager_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"]();\n\n//# sourceURL=webpack:///./core/src/core.src.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"default\", function() { return Core; });\n/* harmony import */ var _util_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./util.js */ \"./core/src/util.js\");\n/* harmony import */ var _stringmanager_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./stringmanager.js */ \"./core/src/stringmanager.js\");\n/* harmony import */ var _contentmanager_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./contentmanager.js */ \"./core/src/contentmanager.js\");\n/* harmony import */ var _modal_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./modal.js */ \"./core/src/modal.js\");\n/* harmony import */ var _serviceprovider_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./serviceprovider.js */ \"./core/src/serviceprovider.js\");\n/* harmony import */ var _parser_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./parser.js */ \"./core/src/parser.js\");\n/* harmony import */ var _latex_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./latex.js */ \"./core/src/latex.js\");\n/* harmony import */ var _mathml_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./mathml.js */ \"./core/src/mathml.js\");\n/* harmony import */ var _customeditors_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./customeditors.js */ \"./core/src/customeditors.js\");\n/* harmony import */ var _configuration_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./configuration.js */ \"./core/src/configuration.js\");\n/* harmony import */ var _jsvariables_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./jsvariables.js */ \"./core/src/jsvariables.js\");\n/* harmony import */ var _event_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./event.js */ \"./core/src/event.js\");\n/* harmony import */ var _listeners_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./listeners.js */ \"./core/src/listeners.js\");\n/* harmony import */ var _integrationmodel_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./integrationmodel.js */ \"./core/src/integrationmodel.js\");\n/* harmony import */ var _image_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./image.js */ \"./core/src/image.js\");\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n/**\n * Class representing MathType integration Core. This class is the integration entry point. Manages integration\n * initialization (services, languages), events, and the insertion of the formulas in the edit area.\n */\n\nvar Core =\n/*#__PURE__*/\nfunction () {\n /**\n * Core class constructor. Admits a string containing the configurationjs service\n * which loads all JavaScript configuration generated in the backend. This file is needed\n * to instantiate the serviceProvider class (all services lives in the same path).\n */\n function Core() {\n _classCallCheck(this, Core);\n\n /**\n * Language. Needed for accessibility and locales. 'en' by default.\n * @type {string}\n */\n this.language = 'en';\n /**\n * Edit mode. Admit 'images' and 'latex' values.\n * @type {string}\n */\n\n this.editMode = 'images';\n /**\n * Modal dialog instance.\n * @type {ModalDialog}\n */\n\n this.modalDialog = null;\n /**\n * Core custom editors. By default only chemistry editor.\n * @type {CustomEditors}\n */\n\n this.customEditors = new _customeditors_js__WEBPACK_IMPORTED_MODULE_8__[\"default\"]();\n var chemEditorParams = {\n name: 'Chemistry',\n toolbar: 'chemistry',\n icon: 'chem.png',\n confVariable: 'chemEnabled',\n title: 'ChemType',\n tooltip: 'Insert a chemistry formula - ChemType' // TODO: Localize tooltip.\n\n };\n this.customEditors.addEditor('chemistry', chemEditorParams);\n /**\n * Environment properties. This object contains data about the integration platform.\n * @type {Object}\n * @property {string} editor - Editor name. Usually the HTML editor.\n * @property {string} mode - Save mode. Xml by default\n * @property {string} version - Plugin version.\n */\n\n this.environment = {};\n /**\n * Edit properties.\n * @type {Object}\n * @property {boolean} isNewElement - Indicates if the edit formula is a new one or not.\n * @property {Img} temporalImage - Image of the formula edited. Null if the formula is a new one.\n * @property {Range} latexRange - LaTeX formula range.\n * @property {Range} range - Image range.\n * @property {string} editMode - Edition mode. Images by default.\n */\n\n this.editionProperties = {\n isNewElement: true,\n temporalImage: null,\n latexRange: null,\n range: null\n /**\n * Integration model instance.\n * @type {IntegrationModel}\n */\n\n };\n this.integrationModel = null;\n /**\n * ContentManager instance.\n * @type {ContentManager}\n */\n\n this.contentManager = null;\n /**\n * Information about the current browser.\n * @type {string}\n */\n\n this.browser = function get_browser() {\n var ua = navigator.userAgent;\n\n if (ua.search(\"Edge/\") >= 0) {\n return \"EDGE\";\n } else if (ua.search(\"Chrome/\") >= 0) {\n return \"CHROME\";\n } else if (ua.search(\"Trident/\") >= 0) {\n return \"IE\";\n } else if (ua.search(\"Firefox/\") >= 0) {\n return \"FIREFOX\";\n } else if (ua.search(\"Safari/\") >= 0) {\n return \"SAFARI\";\n }\n }();\n /**\n * Plugin listeners.\n * @type {Object[]}\n */\n\n\n this.listeners = new _listeners_js__WEBPACK_IMPORTED_MODULE_12__[\"default\"]();\n }\n /**\n * Initializes the core.\n * @param {string} integrationPath - integration root folder path.\n */\n\n\n _createClass(Core, [{\n key: \"init\",\n value: function init(integrationPath) {\n this.load(integrationPath);\n }\n /**\n * Sets the instance of the integration model object.\n * @param {IntegrationModel} integrationModel - integrationModel instance.\n */\n\n }, {\n key: \"setIntegrationModel\",\n value: function setIntegrationModel(integrationModel) {\n this.integrationModel = integrationModel;\n }\n /**\n * This method set an object containing environment properties. The structure for the an\n * environment object is the following:\n * @param {Object} environmentObject - And object containing environment properties.\n * @param {string} environmentObject.editor - Integration editor (usually HTML editor).\n * @param {string} environmentObject.mode - Save mode.\n * @param {string} environmentObject.version - Integration version.\n */\n\n }, {\n key: \"setEnvironment\",\n value: function setEnvironment(environmentObject) {\n if ('editor' in environmentObject) {\n this.environment.editor = environmentObject.editor;\n }\n\n if ('mode' in environmentObject) {\n this.environment.mode = environmentObject.mode;\n }\n\n if ('version' in environmentObject) {\n this.environment.version = environmentObject.version;\n }\n }\n /**\n * Get modal dialog\n * @returns {ModalDialog} Modal Window core instance.\n */\n\n }, {\n key: \"getModalDialog\",\n value: function getModalDialog() {\n return this.modalDialog;\n }\n /**\n * This method inits the Core class doing the following:\n * - Calls (async) to configurationjs service, converting the response JSON into javascript variables.\n * - Updates Configuration class with the previous configuration properties.\n * - Updates the ServiceProvider class using configurationjs service path as reference.\n * - Load lang strings and CSS.\n * - Once the previous is ready fires 'onLoad' event.\n */\n\n }, {\n key: \"load\",\n value: function load(integrationPath) {\n var httpRequest = typeof XMLHttpRequest != 'undefined' ? new XMLHttpRequest() : new ActiveXObject('Microsoft.XMLHTTP');\n this.integrationPath = integrationPath.indexOf(\"/\") == 0 || integrationPath.indexOf(\"http\") == 0 ? integrationPath : _util_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].concatenateUrl(this.integrationModel.getPath(), integrationPath);\n httpRequest.open('GET', this.integrationPath, false); // Async request.\n\n httpRequest.onload = function (e) {\n var _this = this;\n\n if (httpRequest.readyState === 4) {\n // Loading configuration variables.\n var jsonConfiguration = JSON.parse(httpRequest.responseText);\n var variables = Object.keys(jsonConfiguration);\n _configuration_js__WEBPACK_IMPORTED_MODULE_9__[\"default\"].addConfiguration(jsonConfiguration); // Adding JavaScript (not backend) configuration variables.\n\n _configuration_js__WEBPACK_IMPORTED_MODULE_9__[\"default\"].addConfiguration(_jsvariables_js__WEBPACK_IMPORTED_MODULE_10__[\"default\"]); // Load service paths.\n\n this.loadServicePaths(); // Load lang file.\n\n this.loadLangFile();\n this.loadCSS(); // Fire 'onLoad' event. All integration must listen this event in order to know if the plugin has been properly loaded.\n // We need to wait until stringManager has been loaded.\n\n if (Core.stringManager === null) {\n var stringManagerListener = _listeners_js__WEBPACK_IMPORTED_MODULE_12__[\"default\"].newListener('onLoad', function () {\n _this.listeners.fire('onLoad', {});\n });\n Core.stringManager.addListener(stringManagerListener);\n } else {\n this.listeners.fire('onLoad', {});\n }\n }\n }.bind(this);\n\n httpRequest.send(null);\n }\n /**\n * Instantiate a new ServiceProvider path (static) and calculate all the backend services\n * paths using Core integrationPath as base path.\n */\n\n }, {\n key: \"loadServicePaths\",\n value: function loadServicePaths() {\n // Services path (tech dependant).\n var createImagePath = this.integrationPath.replace('configurationjs', 'createimage');\n var showImagePath = this.integrationPath.replace('configurationjs', 'showimage');\n var createImagePath = this.integrationPath.replace('configurationjs', 'createimage');\n var getMathMLPath = this.integrationPath.replace('configurationjs', 'getmathml');\n var servicePath = this.integrationPath.replace('configurationjs', 'service'); // Some backend integrations (like Java o Ruby) have an absolute backend path,\n // for example: /app/service. For them we calculate the absolute URL path, i.e\n // protocol://domain:port/app/service\n\n if (this.integrationPath.indexOf(\"/\") == 0) {\n var serverPath = this.getServerPath();\n showImagePath = serverPath + showImagePath;\n createImagePath = serverPath + createImagePath;\n getMathMLPath = serverPath + getMathMLPath;\n servicePath = serverPath + servicePath;\n }\n\n _serviceprovider_js__WEBPACK_IMPORTED_MODULE_4__[\"default\"].setServicePath('showimage', showImagePath);\n _serviceprovider_js__WEBPACK_IMPORTED_MODULE_4__[\"default\"].setServicePath('createimage', createImagePath);\n _serviceprovider_js__WEBPACK_IMPORTED_MODULE_4__[\"default\"].setServicePath('service', servicePath);\n _serviceprovider_js__WEBPACK_IMPORTED_MODULE_4__[\"default\"].setServicePath('getmathml', getMathMLPath);\n }\n /**\n * Returns the client side server path on integration script lives.\n * @return {string} client side server path.\n */\n\n }, {\n key: \"getServerPath\",\n value: function getServerPath() {\n var url = this.integrationModel.getPath();\n var hostNameIndex = url.indexOf(\"/\", url.indexOf(\"/\") + 2);\n return url.substr(0, hostNameIndex);\n }\n /**\n * Loads language file using integration script path as base path. Then\n * load the string into the core StringManager instance.\n */\n\n }, {\n key: \"loadLangFile\",\n value: function loadLangFile() {\n // Translated languages.\n var languages = 'ar,ca,cs,da,de,en,es,et,eu,fi,fr,gl,he,hr,hu,it,ja,ko,nl,no,pl,pt,pt_br,ru,sv,tr,zh,el';\n var langArray = languages.split(',');\n var lang = this.language;\n\n if (langArray.indexOf(lang) == -1) {\n lang = lang.substr(0, 2);\n }\n\n if (langArray.indexOf(lang) == -1) {\n lang = 'en';\n }\n\n var script = document.createElement('script');\n script.type = 'text/javascript';\n script.src = this.integrationModel.getPath() + '/' + this.integrationModel.langFolderName + '/' + lang + '/strings.js'; // When strings are loaded, it loads into stringManager\n\n script.onload = function () {\n Core.getStringManager().loadStrings(wrs_strings);\n };\n\n document.getElementsByTagName('head')[0].appendChild(script);\n }\n /**\n * Appends CSS file to header.\n */\n\n }, {\n key: \"loadCSS\",\n value: function loadCSS() {\n var fileRef = document.createElement(\"link\");\n fileRef.setAttribute(\"rel\", \"stylesheet\");\n fileRef.setAttribute(\"type\", \"text/css\");\n fileRef.setAttribute(\"href\", _util_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].concatenateUrl(this.integrationModel.getPath(), '/core/styles.css'));\n document.getElementsByTagName(\"head\")[0].appendChild(fileRef);\n }\n /**\n * Adds a listener to Listeners core property.\n * @param {Object} listener - listener to be added.\n */\n\n }, {\n key: \"addListener\",\n value: function addListener(listener) {\n this.listeners.add(listener);\n }\n /**\n * Adds a listener to global core listeners.\n * @param {Object} listener - listener to be added.\n * @static\n */\n\n }, {\n key: \"updateFormula\",\n\n /**\n * Transform a MathML into a image formula. Then the image formula is inserted in the specified target, creating\n * a new image (new formula) or updating an existing one.\n * @param {Object} focusElement - element to be focused\n * @param {Object} windowTarget - window where the editable content is\n * @param {string} mathml - Mathml code\n * @param {Object[]} wirisProperties - extra attributes for the formula (like background color or font size).\n */\n value: function updateFormula(focusElement, windowTarget, mathml, wirisProperties) {\n /**\n * This event is fired after update the formula.\n * @type {Object}\n * @property {string} mathml - MathML to be transformed.\n * @property {string} editMode - edit mode.\n * @property {Object} wirisProperties - extra attributes for the formula.\n * @property {string} language - formula language.\n */\n var beforeUpdateEvent = new _event_js__WEBPACK_IMPORTED_MODULE_11__[\"default\"]();\n beforeUpdateEvent.mathml = mathml; // Cloning wirisProperties object\n // We don't want wirisProperties object modified.\n\n beforeUpdateEvent.wirisProperties = {};\n\n for (var attr in wirisProperties) {\n beforeUpdateEvent.wirisProperties[attr] = wirisProperties[attr];\n } // Read only.\n\n\n beforeUpdateEvent.language = this.language;\n beforeUpdateEvent.editMode = this.editMode;\n\n if (this.listeners.fire('onBeforeFormulaInsertion', beforeUpdateEvent)) {\n return;\n }\n\n if (Core.globalListeners.fire('onBeforeFormulaInsertion', beforeUpdateEvent)) {\n return;\n }\n\n mathml = beforeUpdateEvent.mathml;\n wirisProperties = beforeUpdateEvent.wirisProperties;\n /**\n * This event is fired after update the formula.\n * @type {Object}\n * @param {string} editMode - edit mode.\n * @param {Object} windowTarget - target window.\n * @param {Object} focusElement - target element to be focused after update.\n * @param {string} latex - LaTeX generated by the formula (editMode=latex).\n * @param {Object} node - node generated after update the formula (text if LaTeX img otherwise).\n */\n\n var afterUpdateEvent = new _event_js__WEBPACK_IMPORTED_MODULE_11__[\"default\"]();\n afterUpdateEvent.editMode = this.editMode;\n afterUpdateEvent.windowTarget = windowTarget;\n afterUpdateEvent.focusElement = focusElement;\n\n if (!mathml) {\n this.insertElementOnSelection(null, focusElement, windowTarget);\n } else if (this.editMode == 'latex') {\n afterUpdateEvent.latex = _latex_js__WEBPACK_IMPORTED_MODULE_6__[\"default\"].getLatexFromMathML(mathml); // this.integrationModel.getNonLatexNode is an integration wrapper to have special behaviours for nonLatex.\n // Not all the integrations have special behaviours for nonLatex.\n\n if (!!this.integrationModel.fillNonLatexNode && !afterUpdateEvent.latex) {\n this.integrationModel.fillNonLatexNode(afterUpdateEvent, windowTarget, mathml);\n } else {\n afterUpdateEvent.node = windowTarget.document.createTextNode('$$' + afterUpdateEvent.latex + '$$');\n }\n\n this.insertElementOnSelection(afterUpdateEvent.node, focusElement, windowTarget);\n } else if (this.editMode == 'iframes') {\n var iframe = wrs_mathmlToIframeObject(windowTarget, mathml);\n this.insertElementOnSelection(iframe, focusElement, windowTarget);\n } else {\n afterUpdateEvent.node = _parser_js__WEBPACK_IMPORTED_MODULE_5__[\"default\"].mathmlToImgObject(windowTarget.document, mathml, wirisProperties, this.language);\n this.insertElementOnSelection(afterUpdateEvent.node, focusElement, windowTarget);\n }\n\n if (this.listeners.fire('onAfterFormulaInsertion', afterUpdateEvent)) {\n return;\n }\n\n if (Core.globalListeners.fire('onAfterFormulaInsertion', afterUpdateEvent)) {\n return;\n }\n }\n /**\n * Sets the caret after 'node' and focus node owner document.\n * @param {Object} node - node that it will be behind the caret after the execution.\n */\n\n }, {\n key: \"placeCaretAfterNode\",\n value: function placeCaretAfterNode(node) {\n this.integrationModel.getSelection();\n var nodeDocument = node.ownerDocument;\n\n if (typeof nodeDocument.getSelection !== 'undefined' && !!node.parentElement) {\n var range = nodeDocument.createRange();\n range.setStartAfter(node);\n range.collapse(true);\n var selection = nodeDocument.getSelection();\n selection.removeAllRanges();\n selection.addRange(range);\n nodeDocument.body.focus();\n }\n }\n /**\n * Replaces a selection with an element.\n * @param {Object} element - element to replace the selection.\n * @param {Object} focusElement - element to be focused after the replace.\n * @param {Object} windowTarget - target window.\n */\n\n }, {\n key: \"insertElementOnSelection\",\n value: function insertElementOnSelection(element, focusElement, windowTarget) {\n if (this.editionProperties.isNewElement) {\n if (element) {\n if (focusElement.type == 'textarea') {\n _util_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].updateTextArea(focusElement, element.textContent);\n } else if (document.selection && document.getSelection == 0) {\n var range = windowTarget.document.selection.createRange();\n windowTarget.document.execCommand('InsertImage', false, element.src);\n\n if (!('parentElement' in range)) {\n windowTarget.document.execCommand('delete', false);\n range = windowTarget.document.selection.createRange();\n windowTarget.document.execCommand('InsertImage', false, element.src);\n }\n\n if ('parentElement' in range) {\n var temporalObject = range.parentElement();\n\n if (temporalObject.nodeName.toUpperCase() == 'IMG') {\n temporalObject.parentNode.replaceChild(element, temporalObject);\n } else {\n // IE9 fix: parentNode() does not return the IMG node, returns the parent DIV node. In IE < 9, pasteHTML does not work well.\n range.pasteHTML(_util_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].createObjectCode(element));\n }\n }\n } else {\n var editorSelection = this.integrationModel.getSelection();\n\n var _range; // In IE is needed keep the range due to after focus the modal window it can't be retrieved the last selection.\n\n\n if (this.editionProperties.range) {\n _range = this.editionProperties.range;\n this.editionProperties.range = null;\n } else {\n _range = editorSelection.getRangeAt(0);\n } // Delete if something was surrounded.\n\n\n _range.deleteContents();\n\n var node = _range.startContainer;\n var position = _range.startOffset;\n\n if (node.nodeType == 3) {\n // TEXT_NODE.\n node = node.splitText(position);\n node.parentNode.insertBefore(element, node);\n } else if (node.nodeType == 1) {\n // ELEMENT_NODE.\n node.insertBefore(element, node.childNodes[position]);\n }\n\n this.placeCaretAfterNode(element);\n }\n } else if (focusElement.type == 'textarea') {\n focusElement.focus();\n } else {\n var _editorSelection = this.integrationModel.getSelection();\n\n _editorSelection.removeAllRanges();\n\n if (this.editionProperties.range) {\n var _range2 = this.editionProperties.range;\n this.editionProperties.range = null;\n\n _editorSelection.addRange(_range2);\n }\n }\n } else if (this.editionProperties.latexRange) {\n if (document.selection && document.getSelection == 0) {\n this.editionProperties.isNewElement = true;\n this.editionProperties.latexRange.select();\n this.insertElementOnSelection(element, focusElement, windowTarget);\n } else {\n this.editionProperties.latexRange.deleteContents();\n this.editionProperties.latexRange.insertNode(element);\n this.placeCaretAfterNode(element);\n }\n } else if (focusElement.type == \"textarea\") {\n var item; // Wrapper for some integrations that can have special behaviours to show latex.\n\n if (typeof this.integrationModel.getSelectedItem !== 'undefined') {\n item = this.integrationModel.getSelectedItem(focusElement, false);\n } else {\n item = _util_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].getSelectedItemOnTextarea(focusElement);\n }\n\n _util_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].updateExistingTextOnTextarea(focusElement, element.textContent, item.startPosition, item.endPosition);\n } else {\n if (element && element.nodeName.toLowerCase() === 'img') {\n // Editor empty, formula has been erased on edit.\n // Clone is needed to maintain event references to temporalImage.\n _image_js__WEBPACK_IMPORTED_MODULE_14__[\"default\"].clone(element, this.editionProperties.temporalImage);\n } else {\n this.editionProperties.temporalImage.remove();\n }\n\n this.placeCaretAfterNode(this.editionProperties.temporalImage);\n }\n }\n /**\n * Opens a new modal dialog.\n * @param {object} target - target element.\n * @param {boolean} isIframe - specifies if the target is an iframe.\n */\n\n }, {\n key: \"openModalDialog\",\n value: function openModalDialog(target, isIframe) {\n // Textarea elements don't have normal document ranges. It only accepts latex edit.\n this.editMode = 'images'; // In IE is needed keep the range due to after focus the modal window it can't be retrieved the last selection.\n\n try {\n if (isIframe) {\n // Is needed focus the target first.\n target.contentWindow.focus();\n var selection = target.contentWindow.getSelection();\n this.editionProperties.range = selection.getRangeAt(0);\n } else {\n // Is needed focus the target first.\n target.focus();\n\n var _selection = getSelection();\n\n this.editionProperties.range = _selection.getRangeAt(0);\n }\n } catch (e) {\n this.editionProperties.range = null;\n }\n\n if (isIframe === undefined) {\n isIframe = true;\n }\n\n this.editionProperties.latexRange = null;\n\n if (target) {\n var selectedItem;\n\n if (typeof this.integrationModel.getSelectedItem !== 'undefined') {\n selectedItem = this.integrationModel.getSelectedItem(target, isIframe);\n } else {\n selectedItem = _util_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].getSelectedItem(target, isIframe);\n } // Check LaTeX if and only if the node is a text node (nodeType==3).\n\n\n if (selectedItem) {\n // Case when image was selected and button pressed.\n if (!selectedItem.caretPosition && _util_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].containsClass(selectedItem.node, _configuration_js__WEBPACK_IMPORTED_MODULE_9__[\"default\"].get('imageClassName'))) {\n this.editionProperties.temporalImage = selectedItem.node;\n this.editionProperties.isNewElement = false;\n } else if (selectedItem.node.nodeType === 3) {\n // If it's a text node means that editor is working with LaTeX.\n if (!!this.integrationModel.getMathmlFromTextNode) {\n // If integration has this function it isn't set range due to we don't\n // know if it will be put into a textarea as a text or image.\n var mathml = this.integrationModel.getMathmlFromTextNode(selectedItem.node, selectedItem.caretPosition);\n\n if (mathml) {\n this.editMode = 'latex';\n this.editionProperties.isNewElement = false;\n this.editionProperties.temporalImage = document.createElement('img');\n this.editionProperties.temporalImage.setAttribute(_configuration_js__WEBPACK_IMPORTED_MODULE_9__[\"default\"].get('imageMathmlAttribute'), _mathml_js__WEBPACK_IMPORTED_MODULE_7__[\"default\"].safeXmlEncode(mathml));\n }\n } else {\n var latexResult = _latex_js__WEBPACK_IMPORTED_MODULE_6__[\"default\"].getLatexFromTextNode(selectedItem.node, selectedItem.caretPosition);\n\n if (latexResult) {\n var _mathml = _latex_js__WEBPACK_IMPORTED_MODULE_6__[\"default\"].getMathMLFromLatex(latexResult.latex);\n\n this.editMode = 'latex';\n this.editionProperties.isNewElement = false;\n this.editionProperties.temporalImage = document.createElement('img');\n this.editionProperties.temporalImage.setAttribute(_configuration_js__WEBPACK_IMPORTED_MODULE_9__[\"default\"].get('imageMathmlAttribute'), _mathml_js__WEBPACK_IMPORTED_MODULE_7__[\"default\"].safeXmlEncode(_mathml));\n var windowTarget = isIframe ? target.contentWindow : window;\n\n if (target.tagName.toLowerCase() !== 'textarea') {\n if (document.selection) {\n var leftOffset = 0;\n var previousNode = latexResult.startNode.previousSibling;\n\n while (previousNode) {\n leftOffset += _util_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].getNodeLength(previousNode);\n previousNode = previousNode.previousSibling;\n }\n\n this.editionProperties.latexRange = windowTarget.document.selection.createRange();\n this.editionProperties.latexRange.moveToElementText(latexResult.startNode.parentNode);\n this.editionProperties.latexRange.move('character', leftOffset + latexResult.startPosition);\n this.editionProperties.latexRange.moveEnd('character', latexResult.latex.length + 4); // Plus 4 for the '$$' characters.\n } else {\n this.editionProperties.latexRange = windowTarget.document.createRange();\n this.editionProperties.latexRange.setStart(latexResult.startNode, latexResult.startPosition);\n this.editionProperties.latexRange.setEnd(latexResult.endNode, latexResult.endPosition);\n }\n }\n }\n }\n }\n } else if (target.tagName.toLowerCase() === 'textarea') {\n // By default editMode is 'images', but when target is a textarea it needs to be 'latex'.\n this.editMode = 'latex';\n }\n } // Setting an object with the editor parameters.\n // Editor parameters can be customized in several ways:\n // 1 - editorAttributes: Contains the default editor attributes, usually the metrics in a comma separated string. Always exists.\n // 2 - editorParameters: Object containing custom editor parameters. These parameters are defined in the backend. So they affects\n // all integration instances.\n // The backend send the default editor attributes in a coma separated with the following structure:\n // key1=value1,key2=value2...\n\n\n var defaultEditorAttributesArray = _configuration_js__WEBPACK_IMPORTED_MODULE_9__[\"default\"].get('editorAttributes').split(\", \");\n var defaultEditorAttributes = {};\n\n for (var i = 0, len = defaultEditorAttributesArray.length; i < len; i++) {\n var tempAttribute = defaultEditorAttributesArray[i].split('=');\n var key = tempAttribute[0];\n var value = tempAttribute[1];\n defaultEditorAttributes[key] = value;\n } // Custom editor parameters.\n\n\n var editorAttributes = {};\n Object.assign(editorAttributes, defaultEditorAttributes, _configuration_js__WEBPACK_IMPORTED_MODULE_9__[\"default\"].get('editorParameters'));\n editorAttributes.language = this.language;\n editorAttributes.rtl = this.integrationModel.rtl;\n var contentManagerAttributes = {};\n contentManagerAttributes.editorAttributes = editorAttributes;\n contentManagerAttributes.language = this.language;\n contentManagerAttributes.customEditors = this.customEditors;\n contentManagerAttributes.environment = this.environment;\n\n if (this.modalDialog == null) {\n this.modalDialog = new _modal_js__WEBPACK_IMPORTED_MODULE_3__[\"default\"](editorAttributes);\n this.contentManager = new _contentmanager_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"](contentManagerAttributes); // When an instance of ContentManager is created we need to wait until the ContentManager is ready\n // by listening 'onLoad' event.\n\n var listener = _listeners_js__WEBPACK_IMPORTED_MODULE_12__[\"default\"].newListener('onLoad', function () {\n this.contentManager.isNewElement = this.editionProperties.isNewElement;\n\n if (this.editionProperties.temporalImage != null) {\n var mathML = _mathml_js__WEBPACK_IMPORTED_MODULE_7__[\"default\"].safeXmlDecode(this.editionProperties.temporalImage.getAttribute(_configuration_js__WEBPACK_IMPORTED_MODULE_9__[\"default\"].get('imageMathmlAttribute')));\n this.contentManager.mathML = mathML;\n }\n }.bind(this));\n this.contentManager.addListener(listener);\n this.contentManager.init();\n this.modalDialog.setContentManager(this.contentManager);\n this.contentManager.setModalDialogInstance(this.modalDialog);\n } else {\n this.contentManager.isNewElement = this.editionProperties.isNewElement;\n\n if (this.editionProperties.temporalImage != null) {\n var mathML = _mathml_js__WEBPACK_IMPORTED_MODULE_7__[\"default\"].safeXmlDecode(this.editionProperties.temporalImage.getAttribute(_configuration_js__WEBPACK_IMPORTED_MODULE_9__[\"default\"].get('imageMathmlAttribute')));\n this.contentManager.mathML = mathML;\n }\n }\n\n this.contentManager.setIntegrationModel(this.integrationModel);\n this.modalDialog.open();\n }\n /**\n * Returns the instance of the ServiceProvider class.\n * @returns {ServiceProvider} ServiceProvider instance.\n * @static\n */\n\n }, {\n key: \"getCustomEditors\",\n\n /**\n * Return an object with all instance custom editors.\n * @return {CustomEditors}\n */\n value: function getCustomEditors() {\n return this.customEditors;\n }\n }], [{\n key: \"addGlobalListener\",\n value: function addGlobalListener(listener) {\n Core.globalListeners.add(listener);\n }\n }, {\n key: \"getServiceProvider\",\n value: function getServiceProvider() {\n return Core.serviceProvider;\n }\n /**\n * Returns the instance of the StringManager class.\n * @returns {StringManager} StringManager instance\n */\n\n }, {\n key: \"getStringManager\",\n value: function getStringManager() {\n return Core.stringManager;\n }\n }]);\n\n return Core;\n}();\n/**\n * Plugin static listeners.\n * @type {Object[]}\n * @static\n */\n\n\n\nCore.globalListeners = new _listeners_js__WEBPACK_IMPORTED_MODULE_12__[\"default\"]();\n/**\n * Class to manage plugin locales.\n * @type {StringManager}\n * @static\n */\n\nCore.stringManager = new _stringmanager_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"]();\n\n//# sourceURL=webpack:///./core/src/core.src.js?"); /***/ }), @@ -214,7 +214,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) * /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"default\", function() { return Image; });\n/* harmony import */ var _configuration_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./configuration.js */ \"./core/src/configuration.js\");\n/* harmony import */ var _util_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./util.js */ \"./core/src/util.js\");\nfunction _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\n\n\n/**\r\n * This class contains all the logic related to image manipulation.\r\n */\n\nvar Image =\n/*#__PURE__*/\nfunction () {\n function Image() {\n _classCallCheck(this, Image);\n }\n\n _createClass(Image, null, [{\n key: \"setImgSize\",\n\n /**\r\n * Calculates the metrics of an img dom object given the response URI.\r\n * @param {Object} img - DOM image object.\r\n * @param {string} uri - URI generated by the image service: can be a data URI scheme or a URL.\r\n * @param {boolean} jsonResponse - indicates if the response of the image service is a JSON object.\r\n */\n value: function setImgSize(img, uri, jsonResponse) {\n if (jsonResponse) {\n // Cleaning data:image/png;base64.\n if (_configuration_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get('imageFormat') == 'svg') {\n // SVG format.\n // If SVG is encoded in base64 we need to convert the base64 bytes into a SVG string.\n if (_configuration_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get('saveMode') != 'base64') {\n var ar = Image.getMetricsFromSvgString(uri);\n } else {\n var base64String = img.src.substr(img.src.indexOf('base64,') + 7, img.src.length);\n var svgString = '';\n var bytes = _util_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].b64ToByteArray(base64String, base64String.length);\n\n for (var i = 0; i < bytes.length; i++) {\n svgString += String.fromCharCode(bytes[i]);\n }\n\n var ar = Image.getMetricsFromSvgString(svgString);\n } // PNG format: we store all metrics information in the first 88 bytes.\n\n } else {\n var base64String = img.src.substr(img.src.indexOf('base64,') + 7, img.src.length);\n var bytes = _util_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].b64ToByteArray(base64String, 88);\n var ar = Image.getMetricsFromBytes(bytes);\n } // Backwards compatibility: we store the metrics into createimage response.\n\n } else {\n var ar = _util_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].urlToAssArray(uri);\n }\n\n var width = ar['cw'];\n\n if (!width) {\n return;\n }\n\n var height = ar['ch'];\n var baseline = ar['cb'];\n var dpi = ar['dpi'];\n\n if (dpi) {\n width = width * 96 / dpi;\n height = height * 96 / dpi;\n baseline = baseline * 96 / dpi;\n }\n\n img.width = width;\n img.height = height;\n img.style.verticalAlign = \"-\" + (height - baseline) + \"px\";\n }\n /**\r\n * Re-calculates the metrics of a image which has been resized.\r\n * @param {Object} img - DOM image object.\r\n */\n\n }, {\n key: \"fixAfterResize\",\n value: function fixAfterResize(img) {\n img.removeAttribute('style');\n img.removeAttribute('width');\n img.removeAttribute('height'); // In order to avoid resize with max-width css property.\n\n img.style.maxWidth = 'none';\n\n if (img.src.indexOf(\"data:image\") != -1) {\n if (_configuration_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get('imageFormat') == 'svg') {\n // ...data:image/svg+xml;charset=utf8, = 32.\n var svg = decodeURIComponent(img.src.substring(32, img.src.length));\n Image.setImgSize(img, svg, true);\n } else {\n // ...data:image/png;base64, == 22.\n var base64 = img.src.substring(22, img.src.length);\n Image.setImgSize(img, base64, true);\n }\n } else {\n Image.setImgSize(img, img.src);\n }\n }\n /**\r\n * Returns the metrics (height, width and baseline) contained in SVG image generated\r\n * by the MathType image service. This image contains as an extra attribute the image baseline (wrs:baseline).\r\n * @param {string} svgString - a string containing an svg image.\r\n * @return {Object[]} - Array object containing the image metrics.\r\n */\n\n }, {\n key: \"getMetricsFromSvgString\",\n value: function getMetricsFromSvgString(svgString) {\n var first = svgString.indexOf('height=\"');\n var last = svgString.indexOf('\"', first + 8, svgString.length);\n var height = svgString.substring(first + 8, last);\n first = svgString.indexOf('width=\"');\n last = svgString.indexOf('\"', first + 7, svgString.length);\n var width = svgString.substring(first + 7, last);\n first = svgString.indexOf('wrs:baseline=\"');\n last = svgString.indexOf('\"', first + 14, svgString.length);\n var baseline = svgString.substring(first + 14, last);\n\n if (_typeof(width != 'undefined')) {\n var arr = new Array();\n arr['cw'] = width;\n arr['ch'] = height;\n\n if (typeof baseline != 'undefined') {\n arr['cb'] = baseline;\n }\n\n return arr;\n }\n }\n /**\r\n * Get metrics (width, height, baseline and dpi) from a png byte array.\r\n * @param {Object[]} bytes - png byte array.\r\n * @return {Object[]} a array containing the png metrics.\r\n * @static\r\n */\n\n }, {\n key: \"getMetricsFromBytes\",\n value: function getMetricsFromBytes(bytes) {\n _util_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].readBytes(bytes, 0, 8);\n var alloc = 10;\n var i = 0;\n\n while (bytes.length >= 4) {\n var len = _util_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].readInt32(bytes);\n var typ = _util_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].readInt32(bytes);\n\n if (typ == 0x49484452) {\n var width = _util_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].readInt32(bytes);\n var height = _util_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].readInt32(bytes); // Read 5 bytes.\n\n _util_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].readInt32(bytes);\n _util_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].readByte(bytes);\n } else if (typ == 0x62615345) {\n // Baseline: 'baSE'.\n var baseline = _util_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].readInt32(bytes);\n } else if (typ == 0x70485973) {\n // Dpis: 'pHYs'.\n var dpi = _util_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].readInt32(bytes);\n dpi = Math.round(dpi / 39.37);\n _util_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].readInt32(bytes);\n _util_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].readByte(bytes);\n }\n\n _util_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].readInt32(bytes);\n }\n\n if (typeof width != 'undefined') {\n var arr = new Array();\n arr['cw'] = width;\n arr['ch'] = height;\n arr['dpi'] = dpi;\n\n if (baseline) {\n arr['cb'] = baseline;\n }\n\n return arr;\n }\n }\n }]);\n\n return Image;\n}();\n\n\n\n//# sourceURL=webpack:///./core/src/image.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"default\", function() { return Image; });\n/* harmony import */ var _configuration_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./configuration.js */ \"./core/src/configuration.js\");\n/* harmony import */ var _util_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./util.js */ \"./core/src/util.js\");\nfunction _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\n\n\n/**\r\n * This class contains all the logic related to image manipulation.\r\n */\n\nvar Image =\n/*#__PURE__*/\nfunction () {\n function Image() {\n _classCallCheck(this, Image);\n }\n\n _createClass(Image, null, [{\n key: \"clone\",\n\n /**\r\n * Clone Wirisformula attributes from 'originImg' to 'destImg'.\r\n * @param {HTMLImageElement} originImg - formula to copy to 'destImg'. Is a Wirisformula.\r\n * @param {HTMLImageElement} destImg - formula where 'destImg' copies. Is a Wirisformula.\r\n */\n value: function clone(originImg, destImg) {\n var customEditorAttributeName = 'data-custom-editor';\n\n if (!originImg.hasAttribute(customEditorAttributeName)) {\n destImg.removeAttribute(customEditorAttributeName);\n }\n\n var mathmlAttributeName = _configuration_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get('imageMathmlAttribute');\n var imgAttributes = [mathmlAttributeName, customEditorAttributeName, 'alt', 'height', 'width', 'style', 'src', 'role'];\n\n for (var _i = 0; _i < imgAttributes.length; _i++) {\n var iterator = imgAttributes[_i];\n var originAttribute = originImg.getAttribute(iterator);\n\n if (originAttribute) {\n destImg.setAttribute(iterator, originAttribute);\n }\n }\n }\n /**\r\n * Calculates the metrics of an img dom object given the response URI.\r\n * @param {Object} img - DOM image object.\r\n * @param {string} uri - URI generated by the image service: can be a data URI scheme or a URL.\r\n * @param {boolean} jsonResponse - indicates if the response of the image service is a JSON object.\r\n */\n\n }, {\n key: \"setImgSize\",\n value: function setImgSize(img, uri, jsonResponse) {\n if (jsonResponse) {\n // Cleaning data:image/png;base64.\n if (_configuration_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get('imageFormat') == 'svg') {\n // SVG format.\n // If SVG is encoded in base64 we need to convert the base64 bytes into a SVG string.\n if (_configuration_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get('saveMode') != 'base64') {\n var ar = Image.getMetricsFromSvgString(uri);\n } else {\n var base64String = img.src.substr(img.src.indexOf('base64,') + 7, img.src.length);\n var svgString = '';\n var bytes = _util_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].b64ToByteArray(base64String, base64String.length);\n\n for (var i = 0; i < bytes.length; i++) {\n svgString += String.fromCharCode(bytes[i]);\n }\n\n var ar = Image.getMetricsFromSvgString(svgString);\n } // PNG format: we store all metrics information in the first 88 bytes.\n\n } else {\n var base64String = img.src.substr(img.src.indexOf('base64,') + 7, img.src.length);\n var bytes = _util_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].b64ToByteArray(base64String, 88);\n var ar = Image.getMetricsFromBytes(bytes);\n } // Backwards compatibility: we store the metrics into createimage response.\n\n } else {\n var ar = _util_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].urlToAssArray(uri);\n }\n\n var width = ar['cw'];\n\n if (!width) {\n return;\n }\n\n var height = ar['ch'];\n var baseline = ar['cb'];\n var dpi = ar['dpi'];\n\n if (dpi) {\n width = width * 96 / dpi;\n height = height * 96 / dpi;\n baseline = baseline * 96 / dpi;\n }\n\n img.width = width;\n img.height = height;\n img.style.verticalAlign = \"-\" + (height - baseline) + \"px\";\n }\n /**\r\n * Re-calculates the metrics of a image which has been resized.\r\n * @param {Object} img - DOM image object.\r\n */\n\n }, {\n key: \"fixAfterResize\",\n value: function fixAfterResize(img) {\n img.removeAttribute('style');\n img.removeAttribute('width');\n img.removeAttribute('height'); // In order to avoid resize with max-width css property.\n\n img.style.maxWidth = 'none';\n\n if (img.src.indexOf(\"data:image\") != -1) {\n if (_configuration_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get('imageFormat') == 'svg') {\n // ...data:image/svg+xml;charset=utf8, = 32.\n var svg = decodeURIComponent(img.src.substring(32, img.src.length));\n Image.setImgSize(img, svg, true);\n } else {\n // ...data:image/png;base64, == 22.\n var base64 = img.src.substring(22, img.src.length);\n Image.setImgSize(img, base64, true);\n }\n } else {\n Image.setImgSize(img, img.src);\n }\n }\n /**\r\n * Returns the metrics (height, width and baseline) contained in SVG image generated\r\n * by the MathType image service. This image contains as an extra attribute the image baseline (wrs:baseline).\r\n * @param {string} svgString - a string containing an svg image.\r\n * @return {Object[]} - Array object containing the image metrics.\r\n */\n\n }, {\n key: \"getMetricsFromSvgString\",\n value: function getMetricsFromSvgString(svgString) {\n var first = svgString.indexOf('height=\"');\n var last = svgString.indexOf('\"', first + 8, svgString.length);\n var height = svgString.substring(first + 8, last);\n first = svgString.indexOf('width=\"');\n last = svgString.indexOf('\"', first + 7, svgString.length);\n var width = svgString.substring(first + 7, last);\n first = svgString.indexOf('wrs:baseline=\"');\n last = svgString.indexOf('\"', first + 14, svgString.length);\n var baseline = svgString.substring(first + 14, last);\n\n if (_typeof(width != 'undefined')) {\n var arr = new Array();\n arr['cw'] = width;\n arr['ch'] = height;\n\n if (typeof baseline != 'undefined') {\n arr['cb'] = baseline;\n }\n\n return arr;\n }\n }\n /**\r\n * Get metrics (width, height, baseline and dpi) from a png byte array.\r\n * @param {Object[]} bytes - png byte array.\r\n * @return {Object[]} a array containing the png metrics.\r\n * @static\r\n */\n\n }, {\n key: \"getMetricsFromBytes\",\n value: function getMetricsFromBytes(bytes) {\n _util_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].readBytes(bytes, 0, 8);\n var alloc = 10;\n var i = 0;\n\n while (bytes.length >= 4) {\n var len = _util_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].readInt32(bytes);\n var typ = _util_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].readInt32(bytes);\n\n if (typ == 0x49484452) {\n var width = _util_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].readInt32(bytes);\n var height = _util_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].readInt32(bytes); // Read 5 bytes.\n\n _util_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].readInt32(bytes);\n _util_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].readByte(bytes);\n } else if (typ == 0x62615345) {\n // Baseline: 'baSE'.\n var baseline = _util_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].readInt32(bytes);\n } else if (typ == 0x70485973) {\n // Dpis: 'pHYs'.\n var dpi = _util_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].readInt32(bytes);\n dpi = Math.round(dpi / 39.37);\n _util_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].readInt32(bytes);\n _util_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].readByte(bytes);\n }\n\n _util_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].readInt32(bytes);\n }\n\n if (typeof width != 'undefined') {\n var arr = new Array();\n arr['cw'] = width;\n arr['ch'] = height;\n arr['dpi'] = dpi;\n\n if (baseline) {\n arr['cb'] = baseline;\n }\n\n return arr;\n }\n }\n }]);\n\n return Image;\n}();\n\n\n\n//# sourceURL=webpack:///./core/src/image.js?"); /***/ }), @@ -250,7 +250,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/**\r\n * Represents the conf /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"default\", function() { return Latex; });\n/* harmony import */ var _cache_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./cache.js */ \"./core/src/cache.js\");\n/* harmony import */ var _mathml_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./mathml.js */ \"./core/src/mathml.js\");\n/* harmony import */ var _serviceprovider_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./serviceprovider.js */ \"./core/src/serviceprovider.js\");\n/* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./constants.js */ \"./core/src/constants.js\");\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\n\n\n\n\n/**\r\n * This class represents a LaTeX parser. Manages the services which allows to convert\r\n * LaTeX into MathML and MathML into LaTeX.\r\n */\n\nvar Latex =\n/*#__PURE__*/\nfunction () {\n function Latex() {\n _classCallCheck(this, Latex);\n }\n\n _createClass(Latex, null, [{\n key: \"getLatexFromMathML\",\n\n /**\r\n * Converts MathML to LaTeX by calling mathml2latex service. For text services\r\n * we call a text service with the param mathml2latex.\r\n * @param {string} mathml - MathML String\r\n * @return {string} LaTeX string generated by the MathML argument.\r\n */\n value: function getLatexFromMathML(mathml) {\n /**\r\n * @type {TextCache}\r\n */\n var cache = Latex.cache;\n var data = {\n 'service': 'mathml2latex',\n 'mml': mathml\n };\n var jsonResponse = JSON.parse(_serviceprovider_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].getService('service', data)); //TODO: Error handling.\n\n var latex = '';\n\n if (jsonResponse.status == \"ok\") {\n latex = jsonResponse.result.text; // Inserting LaTeX semantics.\n\n mathml = _mathml_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].insertSemanticsMathml(mathml, latex, 'LaTeX');\n cache.populate(latex, mathml);\n }\n\n return latex;\n }\n /**\r\n * Converts LaTeX to MathML by calling latex2mathml service. For text services\r\n * we call a text service with the param latex2mathml.\r\n * @param {string} latex - string containing a LaTeX formula.\r\n * @param {boolean} includeLatexOnSemantics - if true LaTeX would me included into MathML semantics.\r\n * @return {string} MathML string generated by the LaTeX argument.\r\n */\n\n }, {\n key: \"getMathMLFromLatex\",\n value: function getMathMLFromLatex(latex, includeLatexOnSemantics) {\n /**\r\n * @type {TextCache}\r\n */\n var latexCache = Latex.cache;\n\n if (Latex.cache.get(latex)) {\n return Latex.cache.get(latex);\n }\n\n var data = {\n 'service': 'latex2mathml',\n 'latex': latex\n };\n\n if (includeLatexOnSemantics) {\n data['saveLatex'] = '';\n }\n\n var jsonResponse = JSON.parse(_serviceprovider_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].getService('service', data));\n var output;\n\n if (jsonResponse.status == \"ok\") {\n var mathml = jsonResponse.result.text;\n mathml = mathml.split(\"\\r\").join('').split(\"\\n\").join(' '); // Populate LatexCache.\n\n if (mathml.indexOf('semantics') == -1 && mathml.indexOf('annotation') == -1) {\n mathml = _mathml_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].insertSemanticsMathml(mathml, latex, 'LaTeX');\n output = mathml;\n }\n\n if (!latexCache.get(latex)) {\n latexCache.populate(latex, mathml);\n }\n } else {\n output = \"$$\" + latex + \"$$\";\n }\n\n return output;\n }\n /**\r\n * Converts all occurrences of MathML code to LaTeX. The MathML code should containing to be converted.\r\n * @param {string} content - a string containing MathML valid code.\r\n * @param {Object} characters - an object containing special characters.\r\n * @return {string} a string containing all MathML annotated occurrences replaced by the corresponding LaTeX code.\r\n */\n\n }, {\n key: \"parseMathmlToLatex\",\n value: function parseMathmlToLatex(content, characters) {\n var output = '';\n var mathTagBegin = characters.tagOpener + 'math';\n var mathTagEnd = characters.tagOpener + '/math' + characters.tagCloser;\n var openTarget = characters.tagOpener + 'annotation encoding=' + characters.doubleQuote + 'LaTeX' + characters.doubleQuote + characters.tagCloser;\n var closeTarget = characters.tagOpener + '/annotation' + characters.tagCloser;\n var start = content.indexOf(mathTagBegin);\n var end = 0;\n var mathml, startAnnotation, closeAnnotation;\n\n while (start != -1) {\n output += content.substring(end, start);\n end = content.indexOf(mathTagEnd, start);\n\n if (end == -1) {\n end = content.length - 1;\n } else {\n end += mathTagEnd.length;\n }\n\n mathml = content.substring(start, end);\n startAnnotation = mathml.indexOf(openTarget);\n\n if (startAnnotation != -1) {\n startAnnotation += openTarget.length;\n closeAnnotation = mathml.indexOf(closeTarget);\n var latex = mathml.substring(startAnnotation, closeAnnotation);\n\n if (characters == _constants_js__WEBPACK_IMPORTED_MODULE_3__[\"default\"].safeXmlCharacters) {\n latex = _mathml_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].safeXmlDecode(latex);\n }\n\n output += '$$' + latex + '$$'; // Populate latex into cache.\n\n Latex.cache.populate(latex, mathml);\n } else {\n output += mathml;\n }\n\n start = content.indexOf(mathTagBegin, end);\n }\n\n output += content.substring(end, content.length);\n return output;\n }\n /**\r\n * Extracts the latex of a determined position in a text.\r\n * @param {Node} textNode - textNode to extract the LaTeX\r\n * @param {number} caretPosition - starting position to find LaTeX.\r\n * @param {Object} latexTags - optional parameter representing tags between latex is inserted. It has the 'open' attribute for the open tag and the 'close' attribute for the close tag.\r\n * \"$$\" by default.\r\n * @return {Object} An object with 3 keys: 'latex', 'start' and 'end'. Null if latex is not found.\r\n * @static\r\n */\n\n }, {\n key: \"getLatexFromTextNode\",\n value: function getLatexFromTextNode(textNode, caretPosition, latexTags) {\n // TODO: Set LaTeX Tags as Core variable. Fix the call to this function (third argument).\n // Tags used for LaTeX formulas.\n var defaultLatexTags = {\n 'open': '$$',\n 'close': '$$'\n }; // latexTags is an optional parameter. If is not set, use default latexTags.\n\n if (typeof latexTags == 'undefined' || latexTags == null) {\n latexTags = defaultLatexTags;\n } // Looking for the first textNode.\n\n\n var startNode = textNode;\n\n while (startNode.previousSibling && startNode.previousSibling.nodeType == 3) {\n // TEXT_NODE.\n startNode = startNode.previousSibling;\n } // Finding latex.\n\n /**\r\n * Returns the next latex position and node from a specific node and position.\r\n * @param {Node} currentNode - node where searching latex.\r\n * @param {number} currentPosition - current position inside the currentNode.\r\n * @param {Object} latexTagsToUse - tags used at latex beginning and latex final. \"$$\" by default.\r\n * @param {boolean} tag - tag containing the current search.\r\n * @returns {object} object containing the current node and the position.\r\n */\n\n\n function getNextLatexPosition(currentNode, currentPosition, tag) {\n var position = currentNode.nodeValue.indexOf(tag, currentPosition);\n\n while (position == -1) {\n currentNode = currentNode.nextSibling;\n\n if (!currentNode) {\n // TEXT_NODE.\n return null; // Not found.\n }\n\n position = currentNode.nodeValue ? currentNode.nodeValue.indexOf(latexTags.close) : -1;\n }\n\n return {\n 'node': currentNode,\n 'position': position\n };\n }\n /**\r\n * Determines if a node is previous, or not, to a second one.\r\n * @param {Node} node - start node.\r\n * @param {number} position - start node position.\r\n * @param {Node} endNode - end node.\r\n * @param {number} endPosition - end node position.\r\n * @returns {boolean} true if the starting node is previous thant the en node. false otherwise.\r\n */\n\n\n function isPrevious(node, position, endNode, endPosition) {\n if (node == endNode) {\n return position <= endPosition;\n }\n\n while (node && node != endNode) {\n node = node.nextSibling;\n }\n\n return node == endNode;\n }\n\n var start;\n var end = {\n 'node': startNode,\n 'position': 0\n }; // Is supposed that open and close tags has the same length.\n\n var tagLength = latexTags.open.length;\n\n do {\n var start = getNextLatexPosition(end.node, end.position, latexTags.open);\n\n if (start == null || isPrevious(textNode, caretPosition, start.node, start.position)) {\n return null;\n }\n\n var end = getNextLatexPosition(start.node, start.position + tagLength, latexTags.close);\n\n if (end == null) {\n return null;\n }\n\n end.position += tagLength;\n } while (isPrevious(end.node, end.position, textNode, caretPosition)); // Isolating latex.\n\n\n var latex;\n\n if (start.node == end.node) {\n latex = start.node.nodeValue.substring(start.position + tagLength, end.position - tagLength);\n } else {\n latex = start.node.nodeValue.substring(start.position + tagLength, start.node.nodeValue.length);\n var currentNode = start.node;\n\n do {\n currentNode = currentNode.nextSibling;\n\n if (currentNode == end.node) {\n latex += end.node.nodeValue.substring(0, end.position - tagLength);\n } else {\n latex += currentNode.nodeValue ? currentNode.nodeValue : '';\n }\n } while (currentNode != end.node);\n }\n\n return {\n 'latex': latex,\n 'startNode': start.node,\n 'startPosition': start.position,\n 'endNode': end.node,\n 'endPosition': end.position\n };\n }\n }]);\n\n return Latex;\n}();\n/**\r\n * Text cache. Stores all processed LaTeX strings and it's correspondent MathML string.\r\n * @type {Cache}\r\n * @static\r\n */\n\n\n\nLatex.cache = new _cache_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"]();\n\n//# sourceURL=webpack:///./core/src/latex.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"default\", function() { return Latex; });\n/* harmony import */ var _cache_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./cache.js */ \"./core/src/cache.js\");\n/* harmony import */ var _mathml_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./mathml.js */ \"./core/src/mathml.js\");\n/* harmony import */ var _serviceprovider_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./serviceprovider.js */ \"./core/src/serviceprovider.js\");\n/* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./constants.js */ \"./core/src/constants.js\");\n/* harmony import */ var _util_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./util.js */ \"./core/src/util.js\");\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\n\n\n\n\n\n/**\r\n * This class represents a LaTeX parser. Manages the services which allows to convert\r\n * LaTeX into MathML and MathML into LaTeX.\r\n */\n\nvar Latex =\n/*#__PURE__*/\nfunction () {\n function Latex() {\n _classCallCheck(this, Latex);\n }\n\n _createClass(Latex, null, [{\n key: \"getLatexFromMathML\",\n\n /**\r\n * Converts MathML to LaTeX by calling mathml2latex service. For text services\r\n * we call a text service with the param mathml2latex.\r\n * @param {string} mathml - MathML String\r\n * @return {string} LaTeX string generated by the MathML argument.\r\n */\n value: function getLatexFromMathML(mathml) {\n /**\r\n * @type {TextCache}\r\n */\n var cache = Latex.cache;\n var data = {\n 'service': 'mathml2latex',\n 'mml': mathml\n };\n var jsonResponse = JSON.parse(_serviceprovider_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].getService('service', data)); //TODO: Error handling.\n\n var latex = '';\n\n if (jsonResponse.status == \"ok\") {\n latex = jsonResponse.result.text;\n var latexHtmlEntitiesEncoded = _util_js__WEBPACK_IMPORTED_MODULE_4__[\"default\"].htmlEntities(latex); // Inserting LaTeX semantics.\n\n mathml = _mathml_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].insertSemanticsMathml(mathml, latexHtmlEntitiesEncoded, 'LaTeX');\n cache.populate(latex, mathml);\n }\n\n return latex;\n }\n /**\r\n * Converts LaTeX to MathML by calling latex2mathml service. For text services\r\n * we call a text service with the param latex2mathml.\r\n * @param {string} latex - string containing a LaTeX formula.\r\n * @param {boolean} includeLatexOnSemantics - if true LaTeX would me included into MathML semantics.\r\n * @return {string} MathML string generated by the LaTeX argument.\r\n */\n\n }, {\n key: \"getMathMLFromLatex\",\n value: function getMathMLFromLatex(latex, includeLatexOnSemantics) {\n /**\r\n * @type {TextCache}\r\n */\n var latexCache = Latex.cache;\n\n if (Latex.cache.get(latex)) {\n return Latex.cache.get(latex);\n }\n\n var data = {\n 'service': 'latex2mathml',\n 'latex': latex\n };\n\n if (includeLatexOnSemantics) {\n data['saveLatex'] = '';\n }\n\n var jsonResponse = JSON.parse(_serviceprovider_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].getService('service', data));\n var output;\n\n if (jsonResponse.status == \"ok\") {\n var mathml = jsonResponse.result.text;\n mathml = mathml.split(\"\\r\").join('').split(\"\\n\").join(' '); // Populate LatexCache.\n\n if (mathml.indexOf('semantics') == -1 && mathml.indexOf('annotation') == -1) {\n mathml = _mathml_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].insertSemanticsMathml(mathml, latex, 'LaTeX');\n output = mathml;\n }\n\n if (!latexCache.get(latex)) {\n latexCache.populate(latex, mathml);\n }\n } else {\n output = \"$$\" + latex + \"$$\";\n }\n\n return output;\n }\n /**\r\n * Converts all occurrences of MathML code to LaTeX. The MathML code should containing to be converted.\r\n * @param {string} content - a string containing MathML valid code.\r\n * @param {Object} characters - an object containing special characters.\r\n * @return {string} a string containing all MathML annotated occurrences replaced by the corresponding LaTeX code.\r\n */\n\n }, {\n key: \"parseMathmlToLatex\",\n value: function parseMathmlToLatex(content, characters) {\n var output = '';\n var mathTagBegin = characters.tagOpener + 'math';\n var mathTagEnd = characters.tagOpener + '/math' + characters.tagCloser;\n var openTarget = characters.tagOpener + 'annotation encoding=' + characters.doubleQuote + 'LaTeX' + characters.doubleQuote + characters.tagCloser;\n var closeTarget = characters.tagOpener + '/annotation' + characters.tagCloser;\n var start = content.indexOf(mathTagBegin);\n var end = 0;\n var mathml, startAnnotation, closeAnnotation;\n\n while (start != -1) {\n output += content.substring(end, start);\n end = content.indexOf(mathTagEnd, start);\n\n if (end == -1) {\n end = content.length - 1;\n } else {\n end += mathTagEnd.length;\n }\n\n mathml = content.substring(start, end);\n startAnnotation = mathml.indexOf(openTarget);\n\n if (startAnnotation != -1) {\n startAnnotation += openTarget.length;\n closeAnnotation = mathml.indexOf(closeTarget);\n var latex = mathml.substring(startAnnotation, closeAnnotation);\n\n if (characters == _constants_js__WEBPACK_IMPORTED_MODULE_3__[\"default\"].safeXmlCharacters) {\n latex = _mathml_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].safeXmlDecode(latex);\n }\n\n output += '$$' + latex + '$$'; // Populate latex into cache.\n\n Latex.cache.populate(latex, mathml);\n } else {\n output += mathml;\n }\n\n start = content.indexOf(mathTagBegin, end);\n }\n\n output += content.substring(end, content.length);\n return output;\n }\n /**\r\n * Extracts the latex of a determined position in a text.\r\n * @param {Node} textNode - textNode to extract the LaTeX\r\n * @param {number} caretPosition - starting position to find LaTeX.\r\n * @param {Object} latexTags - optional parameter representing tags between latex is inserted. It has the 'open' attribute for the open tag and the 'close' attribute for the close tag.\r\n * \"$$\" by default.\r\n * @return {Object} An object with 3 keys: 'latex', 'start' and 'end'. Null if latex is not found.\r\n * @static\r\n */\n\n }, {\n key: \"getLatexFromTextNode\",\n value: function getLatexFromTextNode(textNode, caretPosition, latexTags) {\n // TODO: Set LaTeX Tags as Core variable. Fix the call to this function (third argument).\n // Tags used for LaTeX formulas.\n var defaultLatexTags = {\n 'open': '$$',\n 'close': '$$'\n }; // latexTags is an optional parameter. If is not set, use default latexTags.\n\n if (typeof latexTags == 'undefined' || latexTags == null) {\n latexTags = defaultLatexTags;\n } // Looking for the first textNode.\n\n\n var startNode = textNode;\n\n while (startNode.previousSibling && startNode.previousSibling.nodeType == 3) {\n // TEXT_NODE.\n startNode = startNode.previousSibling;\n } // Finding latex.\n\n /**\r\n * Returns the next latex position and node from a specific node and position.\r\n * @param {Node} currentNode - node where searching latex.\r\n * @param {number} currentPosition - current position inside the currentNode.\r\n * @param {Object} latexTagsToUse - tags used at latex beginning and latex final. \"$$\" by default.\r\n * @param {boolean} tag - tag containing the current search.\r\n * @returns {object} object containing the current node and the position.\r\n */\n\n\n function getNextLatexPosition(currentNode, currentPosition, tag) {\n var position = currentNode.nodeValue.indexOf(tag, currentPosition);\n\n while (position == -1) {\n currentNode = currentNode.nextSibling;\n\n if (!currentNode) {\n // TEXT_NODE.\n return null; // Not found.\n }\n\n position = currentNode.nodeValue ? currentNode.nodeValue.indexOf(latexTags.close) : -1;\n }\n\n return {\n 'node': currentNode,\n 'position': position\n };\n }\n /**\r\n * Determines if a node is previous, or not, to a second one.\r\n * @param {Node} node - start node.\r\n * @param {number} position - start node position.\r\n * @param {Node} endNode - end node.\r\n * @param {number} endPosition - end node position.\r\n * @returns {boolean} true if the starting node is previous thant the en node. false otherwise.\r\n */\n\n\n function isPrevious(node, position, endNode, endPosition) {\n if (node == endNode) {\n return position <= endPosition;\n }\n\n while (node && node != endNode) {\n node = node.nextSibling;\n }\n\n return node == endNode;\n }\n\n var start;\n var end = {\n 'node': startNode,\n 'position': 0\n }; // Is supposed that open and close tags has the same length.\n\n var tagLength = latexTags.open.length;\n\n do {\n var start = getNextLatexPosition(end.node, end.position, latexTags.open);\n\n if (start == null || isPrevious(textNode, caretPosition, start.node, start.position)) {\n return null;\n }\n\n var end = getNextLatexPosition(start.node, start.position + tagLength, latexTags.close);\n\n if (end == null) {\n return null;\n }\n\n end.position += tagLength;\n } while (isPrevious(end.node, end.position, textNode, caretPosition)); // Isolating latex.\n\n\n var latex;\n\n if (start.node == end.node) {\n latex = start.node.nodeValue.substring(start.position + tagLength, end.position - tagLength);\n } else {\n latex = start.node.nodeValue.substring(start.position + tagLength, start.node.nodeValue.length);\n var currentNode = start.node;\n\n do {\n currentNode = currentNode.nextSibling;\n\n if (currentNode == end.node) {\n latex += end.node.nodeValue.substring(0, end.position - tagLength);\n } else {\n latex += currentNode.nodeValue ? currentNode.nodeValue : '';\n }\n } while (currentNode != end.node);\n }\n\n return {\n 'latex': latex,\n 'startNode': start.node,\n 'startPosition': start.position,\n 'endNode': end.node,\n 'endPosition': end.position\n };\n }\n }]);\n\n return Latex;\n}();\n/**\r\n * Text cache. Stores all processed LaTeX strings and it's correspondent MathML string.\r\n * @type {Cache}\r\n * @static\r\n */\n\n\n\nLatex.cache = new _cache_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"]();\n\n//# sourceURL=webpack:///./core/src/latex.js?"); /***/ }), @@ -274,7 +274,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) * /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"default\", function() { return MathML; });\n/* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./constants.js */ \"./core/src/constants.js\");\n/* harmony import */ var _util_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./util.js */ \"./core/src/util.js\");\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\n\n\n/**\r\n * This class represents a class to manage MathML objects.\r\n */\n\nvar MathML =\n/*#__PURE__*/\nfunction () {\n function MathML() {\n _classCallCheck(this, MathML);\n }\n\n _createClass(MathML, null, [{\n key: \"isMathmlInAttribute\",\n\n /**\r\n * Checks if the mathml at position i is inside an HTML attribute or not.\r\n * @param {string} content - a string containing MathML code.\r\n * @param {number} i - search index.\r\n * @return {boolean} true if is inside an HTML attribute. false otherwise.\r\n */\n value: function isMathmlInAttribute(content, i) {\n // Regex = '^[\\'\"][\\\\s]*=[\\\\s]*[\\\\w-]+([\\\\s]*(\"[^\"]*\"|\\'[^\\']*\\')[\\\\s]*=[\\\\s]*[\\\\w-]+[\\\\s]*)*[\\\\s]+gmi<';\n var math_att = '[\\'\"][\\\\s]*=[\\\\s]*[\\\\w-]+'; // \"=att OR '=att\n\n var att_content = '\"[^\"]*\"|\\'[^\\']*\\''; // \"blabla\" OR 'blabla'\n\n var att = '[\\\\s]*(' + att_content + ')[\\\\s]*=[\\\\s]*[\\\\w-]+[\\\\s]*'; // \"blabla\"=att OR 'blabla'=att\n\n var atts = '(' + att + ')*'; // \"blabla\"=att1 \"blabla\"=att2\n\n var regex = '^' + math_att + atts + '[\\\\s]+gmi<'; // \"=att \"blabla\"=att1 \"blabla\"=att2 gmi< .\n\n var expression = new RegExp(regex);\n var actual_content = content.substring(0, i);\n var reversed = actual_content.split('').reverse().join('');\n var exists = expression.test(reversed);\n return exists;\n }\n /**\r\n * Decodes an encoded MathML with standard XML tags.\r\n * We use these entities because IE doesn't support html entities on its attributes sometimes. Yes, sometimes.\r\n * @param {string} input - string to be decoded.\r\n * @return {string} decoded string.\r\n */\n\n }, {\n key: \"safeXmlDecode\",\n value: function safeXmlDecode(input) {\n // Decoding entities.\n input = input.split(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlCharactersEntities.tagOpener).join(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlCharacters.tagOpener);\n input = input.split(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlCharactersEntities.tagCloser).join(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlCharacters.tagCloser);\n input = input.split(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlCharactersEntities.doubleQuote).join(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlCharacters.doubleQuote); // Added to fix problem due to import from 1.9.x.\n\n input = input.split(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlCharactersEntities.realDoubleQuote).join(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlCharacters.realDoubleQuote); // Blackboard.\n\n if ('_wrs_blackboard' in window && window._wrs_blackboard) {\n input = input.split(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeBadBlackboardCharacters.ltElement).join(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeGoodBlackboardCharacters.ltElement);\n input = input.split(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeBadBlackboardCharacters.gtElement).join(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeGoodBlackboardCharacters.gtElement);\n input = input.split(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeBadBlackboardCharacters.ampElement).join(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeGoodBlackboardCharacters.ampElement);\n } // Decoding characters.\n\n\n input = input.split(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlCharacters.tagOpener).join(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].xmlCharacters.tagOpener);\n input = input.split(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlCharacters.tagCloser).join(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].xmlCharacters.tagCloser);\n input = input.split(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlCharacters.doubleQuote).join(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].xmlCharacters.doubleQuote);\n input = input.split(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlCharacters.ampersand).join(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].xmlCharacters.ampersand);\n input = input.split(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlCharacters.quote).join(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].xmlCharacters.quote); // We are replacing $ by & when its part of an entity for retrocompatibility. Now, the standard is replace § by &.\n\n var returnValue = '';\n var currentEntity = null;\n\n for (var i = 0; i < input.length; ++i) {\n var character = input.charAt(i);\n\n if (currentEntity == null) {\n if (character == '$') {\n currentEntity = '';\n } else {\n returnValue += character;\n }\n } else {\n if (character == ';') {\n returnValue += '&' + currentEntity + ';';\n currentEntity = null;\n } else if (character.match(/([a-zA-Z0-9#._-] | '-')/)) {\n // Character is part of an entity.\n currentEntity += character;\n } else {\n returnValue += '$' + currentEntity; // Is not an entity.\n\n currentEntity = null;\n --i; // Parse again the current character.\n }\n }\n }\n\n return returnValue;\n }\n /**\r\n * Encodes a MathML with standard XML tags to a MMathML encoded with safe XML tags.\r\n * We use these entities because IE doesn't support html entities on its attributes sometimes. Yes, sometimes.\r\n * @param {string} input - input string to be encoded\r\n * @returns {string} encoded string.\r\n */\n\n }, {\n key: \"safeXmlEncode\",\n value: function safeXmlEncode(input) {\n input = input.split(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].xmlCharacters.tagOpener).join(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlCharacters.tagOpener);\n input = input.split(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].xmlCharacters.tagCloser).join(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlCharacters.tagCloser);\n input = input.split(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].xmlCharacters.doubleQuote).join(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlCharacters.doubleQuote);\n input = input.split(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].xmlCharacters.ampersand).join(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlCharacters.ampersand);\n input = input.split(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].xmlCharacters.quote).join(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlCharacters.quote);\n return input;\n }\n /**\r\n * Converts special symbols (> 128) to entities and replaces all textual entities by its number entities.\r\n * @param {string} mathml - MathML string containing - or not - special symbols\r\n * @returns {string} MathML with all textual entities replaced.\r\n */\n\n }, {\n key: \"mathMLEntities\",\n value: function mathMLEntities(mathml) {\n var toReturn = '';\n\n for (var i = 0; i < mathml.length; ++i) {\n var character = mathml.charAt(i); // Parsing > 128 characters.\n\n if (mathml.codePointAt(i) > 128) {\n toReturn += '&#' + mathml.codePointAt(i) + ';'; // For UTF-32 characters we need to move the index one position.\n\n if (mathml.codePointAt(i) > 0xffff) {\n i++;\n }\n } else if (character == '&') {\n var end = mathml.indexOf(';', i + 1);\n\n if (end >= 0) {\n var container = document.createElement('span');\n container.innerHTML = mathml.substring(i, end + 1);\n toReturn += '&#' + _util_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].fixedCharCodeAt(container.innerText || container.textContent, 0) + ';';\n i = end;\n } else {\n toReturn += character;\n }\n } else {\n toReturn += character;\n }\n }\n\n return toReturn;\n }\n /**\r\n * Add a custom editor name with the prefix wrs_ to a MathML class attribute.\r\n * @param {string} mathml - a MathML string created with a custom editor, like chemistry.\r\n * @param {string} customEditor - custom editor name.\r\n * @returns {string} MathML string with his class containing the editor toolbar string.\r\n */\n\n }, {\n key: \"addCustomEditorClassAttribute\",\n value: function addCustomEditorClassAttribute(mathml, customEditor) {\n var toReturn = '';\n var start = mathml.indexOf('');\n\n if (mathml.indexOf(\"class\") == -1) {\n // Adding custom editor type.\n toReturn = mathml.substr(start, end) + ' class=\"wrs_' + customEditor + '\">';\n toReturn += mathml.substr(end + 1, mathml.length);\n return toReturn;\n }\n }\n\n return mathml;\n }\n /**\r\n * Remove a custom editor name from the MathML class attribute.\r\n * @param {string} mathml - a MathML string.\r\n * @param {string} customEditor - custom editor name.\r\n * @returns {string} The input MathML without customEditor name in his class.\r\n */\n\n }, {\n key: \"removeCustomEditorClassAttribute\",\n value: function removeCustomEditorClassAttribute(mathml, customEditor) {\n // Discard MathML without the specified class.\n if (mathml.indexOf('class') == -1 || mathml.indexOf('wrs_' + customEditor)) {\n return mathml;\n } // Trivial case: class attribute value equal to editor name. Then\n // class attribute is removed.\n\n\n if (mathml.indexOf('class=\"wrs_' + customEditor + '\"') !== -1) {\n return mathml.replace('class=\"wrs_' + customEditor + '\"', '');\n } // Non Trivial case: class attribute contains editor name.\n\n\n return mathml.replace('wrs_' + customEditor, '');\n }\n /**\r\n * Add annotation tag to mathml without it (mathml comes from LaTeX string)\r\n * @param {string} mathml - MathML code generated by a LaTeX string.\r\n * @param {string} latex - original LaTeX string\r\n * @param {string} withoutLatexTranslate - true if not exists latex translation from mathml. false otherwise.\r\n * @param {string} encoding - encoding attribute.\r\n * @returns {string} MathML containing LaTeX code on annotation tag.\r\n */\n\n }, {\n key: \"insertSemanticsMathml\",\n value: function insertSemanticsMathml(mathml, latex, encoding) {\n // If latex is empty, insert semantics doesn't provide information. We can avoid semantics insertion and return the mathml.\n if (latex == \"\") {\n return mathml;\n }\n\n var firstEndTag = '>';\n var mathTagEnd = '<' + '/math' + '>';\n var openSemantics = '<' + 'semantics' + '>';\n var closeSemantics = '<' + '/semantics' + '>';\n var openTarget = '';\n var closeTarget = '<' + '/annotation' + '>';\n var mrowOpen = '';\n var mrowClose = '';\n var indexMathBegin = mathml.indexOf(firstEndTag);\n var indexMathEnd = mathml.indexOf(mathTagEnd);\n var mathBeginExists = mathml.substring(mathml.indexOf('<'), mathml.indexOf('>')).indexOf('math');\n\n if (indexMathBegin != -1 && indexMathEnd != -1 && mathBeginExists) {\n var mathmlContent = mathml.substring(indexMathBegin + 1, indexMathEnd);\n\n if (mathmlContent.indexOf(mrowOpen) != 0) {\n var mathmlContentSemantics = openSemantics + mrowOpen + mathmlContent + mrowClose + openTarget + latex + closeTarget + closeSemantics;\n } else {\n var mathmlContentSemantics = openSemantics + mathmlContent + openTarget + latex + closeTarget + closeSemantics;\n }\n\n return mathml.replace(mathmlContent, mathmlContentSemantics);\n } else {\n return mathml;\n }\n }\n /**\r\n * Removes annotation tag to mathml.\r\n * @param {string} mathml - MathML string\r\n * @param {string} encoding - string containing annotation encoding.\r\n * @returns {string} MathML with an annotation tag.\r\n */\n\n }, {\n key: \"removeSemanticsMathml\",\n value: function removeSemanticsMathml(mathml, encoding) {\n var mathTagEnd = '<' + '/math' + '>';\n var openSemantics = '<' + 'semantics' + '>';\n var openAnnotation = '';\n var mathmlWithoutSemantics = mathml;\n var startSemantics = mathml.indexOf(openSemantics);\n\n if (startSemantics != -1) {\n var startAnnotation = mathml.indexOf(openAnnotation, startSemantics + openSemantics.length);\n\n if (startAnnotation != -1) {\n mathmlWithoutSemantics = mathml.substring(0, startSemantics) + mathml.substring(startSemantics + openSemantics.length, startAnnotation) + mathTagEnd;\n }\n }\n\n return mathmlWithoutSemantics;\n }\n /**\r\n * Returns true if a MathML contains a certain class.\r\n * @param {string} mathML - input MathML.\r\n * @param {string} className - className.\r\n * @returns {boolean} true if the input MathML contains the input class.\r\n * false otherwise.\r\n * @static\r\n */\n\n }, {\n key: \"containClass\",\n value: function containClass(mathML, className) {\n var classIndex = mathML.indexOf('class');\n\n if (classIndex == -1) {\n return false;\n } else {\n var classTagEndIndex = mathML.indexOf('>', classIndex);\n var classTag = mathML.substring(classIndex, classTagEndIndex);\n\n if (classTag.indexOf(className) != -1) {\n return true;\n } else {\n return false;\n }\n }\n }\n }]);\n\n return MathML;\n}();\n\n\n\n//# sourceURL=webpack:///./core/src/mathml.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"default\", function() { return MathML; });\n/* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./constants.js */ \"./core/src/constants.js\");\n/* harmony import */ var _util_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./util.js */ \"./core/src/util.js\");\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\n\n\n/**\r\n * This class represents a class to manage MathML objects.\r\n */\n\nvar MathML =\n/*#__PURE__*/\nfunction () {\n function MathML() {\n _classCallCheck(this, MathML);\n }\n\n _createClass(MathML, null, [{\n key: \"isMathmlInAttribute\",\n\n /**\r\n * Checks if the mathml at position i is inside an HTML attribute or not.\r\n * @param {string} content - a string containing MathML code.\r\n * @param {number} i - search index.\r\n * @return {boolean} true if is inside an HTML attribute. false otherwise.\r\n */\n value: function isMathmlInAttribute(content, i) {\n // Regex = '^[\\'\"][\\\\s]*=[\\\\s]*[\\\\w-]+([\\\\s]*(\"[^\"]*\"|\\'[^\\']*\\')[\\\\s]*=[\\\\s]*[\\\\w-]+[\\\\s]*)*[\\\\s]+gmi<';\n var math_att = '[\\'\"][\\\\s]*=[\\\\s]*[\\\\w-]+'; // \"=att OR '=att\n\n var att_content = '\"[^\"]*\"|\\'[^\\']*\\''; // \"blabla\" OR 'blabla'\n\n var att = '[\\\\s]*(' + att_content + ')[\\\\s]*=[\\\\s]*[\\\\w-]+[\\\\s]*'; // \"blabla\"=att OR 'blabla'=att\n\n var atts = '(' + att + ')*'; // \"blabla\"=att1 \"blabla\"=att2\n\n var regex = '^' + math_att + atts + '[\\\\s]+gmi<'; // \"=att \"blabla\"=att1 \"blabla\"=att2 gmi< .\n\n var expression = new RegExp(regex);\n var actual_content = content.substring(0, i);\n var reversed = actual_content.split('').reverse().join('');\n var exists = expression.test(reversed);\n return exists;\n }\n /**\r\n * Decodes an encoded MathML with standard XML tags.\r\n * We use these entities because IE doesn't support html entities on its attributes sometimes. Yes, sometimes.\r\n * @param {string} input - string to be decoded.\r\n * @return {string} decoded string.\r\n */\n\n }, {\n key: \"safeXmlDecode\",\n value: function safeXmlDecode(input) {\n // Decoding entities.\n input = input.split(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlCharactersEntities.tagOpener).join(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlCharacters.tagOpener);\n input = input.split(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlCharactersEntities.tagCloser).join(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlCharacters.tagCloser);\n input = input.split(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlCharactersEntities.doubleQuote).join(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlCharacters.doubleQuote); // Added to fix problem due to import from 1.9.x.\n\n input = input.split(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlCharactersEntities.realDoubleQuote).join(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlCharacters.realDoubleQuote); // Blackboard.\n\n if ('_wrs_blackboard' in window && window._wrs_blackboard) {\n input = input.split(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeBadBlackboardCharacters.ltElement).join(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeGoodBlackboardCharacters.ltElement);\n input = input.split(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeBadBlackboardCharacters.gtElement).join(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeGoodBlackboardCharacters.gtElement);\n input = input.split(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeBadBlackboardCharacters.ampElement).join(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeGoodBlackboardCharacters.ampElement);\n } // Decoding characters.\n\n\n input = input.split(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlCharacters.tagOpener).join(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].xmlCharacters.tagOpener);\n input = input.split(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlCharacters.tagCloser).join(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].xmlCharacters.tagCloser);\n input = input.split(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlCharacters.doubleQuote).join(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].xmlCharacters.doubleQuote);\n input = input.split(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlCharacters.ampersand).join(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].xmlCharacters.ampersand);\n input = input.split(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlCharacters.quote).join(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].xmlCharacters.quote); // We are replacing $ by & when its part of an entity for retrocompatibility. Now, the standard is replace § by &.\n\n var returnValue = '';\n var currentEntity = null;\n\n for (var i = 0; i < input.length; ++i) {\n var character = input.charAt(i);\n\n if (currentEntity == null) {\n if (character == '$') {\n currentEntity = '';\n } else {\n returnValue += character;\n }\n } else {\n if (character == ';') {\n returnValue += '&' + currentEntity + ';';\n currentEntity = null;\n } else if (character.match(/([a-zA-Z0-9#._-] | '-')/)) {\n // Character is part of an entity.\n currentEntity += character;\n } else {\n returnValue += '$' + currentEntity; // Is not an entity.\n\n currentEntity = null;\n --i; // Parse again the current character.\n }\n }\n }\n\n return returnValue;\n }\n /**\r\n * Encodes a MathML with standard XML tags to a MMathML encoded with safe XML tags.\r\n * We use these entities because IE doesn't support html entities on its attributes sometimes. Yes, sometimes.\r\n * @param {string} input - input string to be encoded\r\n * @returns {string} encoded string.\r\n */\n\n }, {\n key: \"safeXmlEncode\",\n value: function safeXmlEncode(input) {\n input = input.split(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].xmlCharacters.tagOpener).join(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlCharacters.tagOpener);\n input = input.split(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].xmlCharacters.tagCloser).join(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlCharacters.tagCloser);\n input = input.split(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].xmlCharacters.doubleQuote).join(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlCharacters.doubleQuote);\n input = input.split(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].xmlCharacters.ampersand).join(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlCharacters.ampersand);\n input = input.split(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].xmlCharacters.quote).join(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlCharacters.quote);\n return input;\n }\n /**\r\n * Converts special symbols (> 128) to entities and replaces all textual entities by its number entities.\r\n * @param {string} mathml - MathML string containing - or not - special symbols\r\n * @returns {string} MathML with all textual entities replaced.\r\n */\n\n }, {\n key: \"mathMLEntities\",\n value: function mathMLEntities(mathml) {\n var toReturn = '';\n\n for (var i = 0; i < mathml.length; ++i) {\n var character = mathml.charAt(i); // Parsing > 128 characters.\n\n if (mathml.codePointAt(i) > 128) {\n toReturn += '&#' + mathml.codePointAt(i) + ';'; // For UTF-32 characters we need to move the index one position.\n\n if (mathml.codePointAt(i) > 0xffff) {\n i++;\n }\n } else if (character == '&') {\n var end = mathml.indexOf(';', i + 1);\n\n if (end >= 0) {\n var container = document.createElement('span');\n container.innerHTML = mathml.substring(i, end + 1);\n toReturn += '&#' + _util_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].fixedCharCodeAt(container.innerText || container.textContent, 0) + ';';\n i = end;\n } else {\n toReturn += character;\n }\n } else {\n toReturn += character;\n }\n }\n\n return toReturn;\n }\n /**\r\n * Add a custom editor name with the prefix wrs_ to a MathML class attribute.\r\n * @param {string} mathml - a MathML string created with a custom editor, like chemistry.\r\n * @param {string} customEditor - custom editor name.\r\n * @returns {string} MathML string with his class containing the editor toolbar string.\r\n */\n\n }, {\n key: \"addCustomEditorClassAttribute\",\n value: function addCustomEditorClassAttribute(mathml, customEditor) {\n var toReturn = '';\n var start = mathml.indexOf('');\n\n if (mathml.indexOf(\"class\") == -1) {\n // Adding custom editor type.\n toReturn = mathml.substr(start, end) + ' class=\"wrs_' + customEditor + '\">';\n toReturn += mathml.substr(end + 1, mathml.length);\n return toReturn;\n }\n }\n\n return mathml;\n }\n /**\r\n * Remove a custom editor name from the MathML class attribute.\r\n * @param {string} mathml - a MathML string.\r\n * @param {string} customEditor - custom editor name.\r\n * @returns {string} The input MathML without customEditor name in his class.\r\n */\n\n }, {\n key: \"removeCustomEditorClassAttribute\",\n value: function removeCustomEditorClassAttribute(mathml, customEditor) {\n // Discard MathML without the specified class.\n if (mathml.indexOf('class') === -1 || mathml.indexOf('wrs_' + customEditor) === -1) {\n return mathml;\n } // Trivial case: class attribute value equal to editor name. Then\n // class attribute is removed.\n\n\n if (mathml.indexOf('class=\"wrs_' + customEditor + '\"') !== -1) {\n return mathml.replace('class=\"wrs_' + customEditor + '\"', '');\n } // Non Trivial case: class attribute contains editor name.\n\n\n return mathml.replace('wrs_' + customEditor, '');\n }\n /**\r\n * Add annotation tag to mathml without it (mathml comes from LaTeX string)\r\n * @param {string} mathml - MathML code generated by a LaTeX string.\r\n * @param {string} latex - original LaTeX string\r\n * @param {string} withoutLatexTranslate - true if not exists latex translation from mathml. false otherwise.\r\n * @param {string} encoding - encoding attribute.\r\n * @returns {string} MathML containing LaTeX code on annotation tag.\r\n */\n\n }, {\n key: \"insertSemanticsMathml\",\n value: function insertSemanticsMathml(mathml, latex, encoding) {\n // If latex is empty, insert semantics doesn't provide information. We can avoid semantics insertion and return the mathml.\n if (latex == \"\") {\n return mathml;\n }\n\n var firstEndTag = '>';\n var mathTagEnd = '<' + '/math' + '>';\n var openSemantics = '<' + 'semantics' + '>';\n var closeSemantics = '<' + '/semantics' + '>';\n var openTarget = '';\n var closeTarget = '<' + '/annotation' + '>';\n var mrowOpen = '';\n var mrowClose = '';\n var indexMathBegin = mathml.indexOf(firstEndTag);\n var indexMathEnd = mathml.indexOf(mathTagEnd);\n var mathBeginExists = mathml.substring(mathml.indexOf('<'), mathml.indexOf('>')).indexOf('math');\n\n if (indexMathBegin != -1 && indexMathEnd != -1 && mathBeginExists) {\n var mathmlContent = mathml.substring(indexMathBegin + 1, indexMathEnd);\n\n if (mathmlContent.indexOf(mrowOpen) != 0) {\n var mathmlContentSemantics = openSemantics + mrowOpen + mathmlContent + mrowClose + openTarget + latex + closeTarget + closeSemantics;\n } else {\n var mathmlContentSemantics = openSemantics + mathmlContent + openTarget + latex + closeTarget + closeSemantics;\n }\n\n return mathml.replace(mathmlContent, mathmlContentSemantics);\n } else {\n return mathml;\n }\n }\n /**\r\n * Removes annotation tag to mathml.\r\n * @param {string} mathml - MathML string\r\n * @param {string} encoding - string containing annotation encoding.\r\n * @returns {string} MathML with an annotation tag.\r\n */\n\n }, {\n key: \"removeSemantics\",\n value: function removeSemantics(mathml, encoding) {\n var mathTagEnd = '<' + '/math' + '>';\n var openSemantics = '<' + 'semantics' + '>';\n var openAnnotation = '';\n var mathmlWithoutSemantics = mathml;\n var startSemantics = mathml.indexOf(openSemantics);\n\n if (startSemantics != -1) {\n var startAnnotation = mathml.indexOf(openAnnotation, startSemantics + openSemantics.length);\n\n if (startAnnotation != -1) {\n mathmlWithoutSemantics = mathml.substring(0, startSemantics) + mathml.substring(startSemantics + openSemantics.length, startAnnotation) + mathTagEnd;\n }\n }\n\n return mathmlWithoutSemantics;\n }\n /**\r\n * Transforms all xml mathml ocurrences that contain semantics to the same\r\n * xml mathml ocurrences without semantics.\r\n * @param {string} text - string that can contain xml mathml ocurrences.\r\n * @param {string} [encoding] - encoding name that semantics need to have to be removed.\r\n * 'application/json' by default. 'application/json' removes hand traces.\r\n * @param {Constants} [characters] - Constant object containing xmlCharacters or safeXmlCharacters relation.\r\n * xmlCharacters by default.\r\n * @returns {string} - 'text' with all xml mathml ocurrences without annotation tag.\r\n */\n\n }, {\n key: \"removeSemanticsOcurrences\",\n value: function removeSemanticsOcurrences(text) {\n var characters = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].xmlCharacters;\n var encoding = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'application/json';\n var mathTagStart = characters.tagOpener + 'math';\n var mathTagEnd = characters.tagOpener + '/math' + characters.tagCloser;\n var mathTagEndline = '/' + characters.tagCloser;\n var tagCloser = characters.tagCloser;\n var semanticsTagStart = characters.tagOpener + 'semantics' + characters.tagCloser;\n var annotationTagStart = characters.tagOpener + 'annotation encoding=' + characters.doubleQuote + encoding + characters.doubleQuote + characters.tagCloser;\n var output = '';\n var start = text.indexOf(mathTagStart);\n var end = 0;\n\n while (start !== -1) {\n output += text.substring(end, start); // MathML can be written as '' or ''.\n\n var mathTagEndIndex = text.indexOf(mathTagEnd, start);\n var mathTagEndlineIndex = text.indexOf(mathTagEndline, start);\n var firstTagCloser = text.indexOf(tagCloser, start);\n\n if (mathTagEndIndex !== -1) {\n end = mathTagEndIndex;\n } else if (mathTagEndlineIndex === firstTagCloser - 1) {\n end = mathTagEndlineIndex;\n }\n\n var semanticsIndex = text.indexOf(semanticsTagStart, start);\n\n if (semanticsIndex !== -1) {\n var mmlTagStart = text.substring(start, semanticsIndex);\n var annotationIndex = text.indexOf(annotationTagStart, start);\n\n if (annotationIndex !== -1) {\n var mmlContent = text.substring(semanticsIndex + semanticsTagStart.length, annotationIndex);\n output += mmlTagStart + mmlContent + mathTagEnd;\n start = text.indexOf(mathTagStart, start + mathTagStart.length);\n end += mathTagEnd.length;\n } else {\n end = start;\n start = text.indexOf(mathTagStart, start + mathTagStart.length);\n }\n } else {\n end = start;\n start = text.indexOf(mathTagStart, start + mathTagStart.length);\n }\n }\n\n output += text.substring(end, text.length);\n return output;\n }\n /**\r\n * Returns true if a MathML contains a certain class.\r\n * @param {string} mathML - input MathML.\r\n * @param {string} className - className.\r\n * @returns {boolean} true if the input MathML contains the input class.\r\n * false otherwise.\r\n * @static\r\n */\n\n }, {\n key: \"containClass\",\n value: function containClass(mathML, className) {\n var classIndex = mathML.indexOf('class');\n\n if (classIndex == -1) {\n return false;\n } else {\n var classTagEndIndex = mathML.indexOf('>', classIndex);\n var classTag = mathML.substring(classIndex, classTagEndIndex);\n\n if (classTag.indexOf(className) != -1) {\n return true;\n } else {\n return false;\n }\n }\n }\n }]);\n\n return MathML;\n}();\n\n\n\n//# sourceURL=webpack:///./core/src/mathml.js?"); /***/ }), @@ -298,7 +298,7 @@ eval("__webpack_require__.r(__webpack_exports__);\nfunction _typeof(obj) { if (t /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"default\", function() { return ModalDialog; });\n/* harmony import */ var _popupmessage_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./popupmessage.js */ \"./core/src/popupmessage.js\");\n/* harmony import */ var _core_src_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./core.src.js */ \"./core/src/core.src.js\");\n/* harmony import */ var _util_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./util.js */ \"./core/src/util.js\");\n/* harmony import */ var _configuration_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./configuration.js */ \"./core/src/configuration.js\");\n/* harmony import */ var _listeners__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./listeners */ \"./core/src/listeners.js\");\n/* harmony import */ var _contentmanager_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./contentmanager.js */ \"./core/src/contentmanager.js\");\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\n\n\n\n\n\n\n/**\r\n * This class represents a modal dialog. The modal dialog admits a ContentManager instance in order\r\n * to manage the content of the dialog.\r\n */\n\nvar ModalDialog =\n/*#__PURE__*/\nfunction () {\n /**\r\n * Modal dialog constructor\r\n * @param {Object} modalDialogAttributes - An object containing all modal dialog attributes.\r\n */\n function ModalDialog(modalDialogAttributes) {\n _classCallCheck(this, ModalDialog);\n\n this.attributes = modalDialogAttributes; // Metrics\n\n var ua = navigator.userAgent.toLowerCase();\n var isAndroid = ua.indexOf(\"android\") > -1;\n var isIOS = ua.indexOf(\"ipad\") > -1 || ua.indexOf(\"iphone\") > -1;\n this.iosSoftkeyboardOpened = false;\n this.iosMeasureUnit = ua.indexOf(\"crios\") == -1 ? \"%\" : \"vh\";\n this.iosDivHeight = \"100\" + this.iosMeasureUnit;\n var deviceWidth = window.outerWidth;\n var deviceHeight = window.outerHeight;\n var landscape = deviceWidth > deviceHeight;\n var portrait = deviceWidth < deviceHeight; // TODO: Detect isMobile without using editor metrics.\n\n var isMobile = landscape && this.attributes.height > deviceHeight || portrait && this.attributes.width > deviceWidth ? true : false; // Obtain number of current instance\n\n this.instanceId = document.getElementsByClassName(\"wrs_modal_dialogContainer\").length; // Device object properties.\n\n this.deviceProperties = {\n orientation: landscape ? 'landscape' : 'portait',\n isAndroid: isAndroid ? true : false,\n isIOS: isIOS ? true : false,\n isMobile: isMobile,\n isDesktop: !isMobile && !isIOS && !isAndroid\n };\n this.properties = {\n created: false,\n state: '',\n previousState: '',\n position: {\n bottom: 0,\n right: 10\n },\n size: {\n height: 338,\n width: 580\n }\n };\n var attributes = {};\n attributes.class = 'wrs_modal_overlay';\n attributes.id = this.getElementId(attributes.class);\n this.overlay = _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].createElement('div', attributes);\n attributes = {};\n attributes.class = 'wrs_modal_title_bar';\n attributes.id = this.getElementId(attributes.class);\n this.titleBar = _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].createElement('div', attributes);\n attributes = {};\n attributes.class = 'wrs_modal_title';\n attributes.id = this.getElementId(attributes.class);\n this.title = _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].createElement('div', attributes);\n this.title.innerHTML = '';\n attributes = {};\n attributes.class = 'wrs_modal_close_button';\n attributes.id = this.getElementId(attributes.class);\n attributes.title = _core_src_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].getStringManager().getString('close');\n this.closeDiv = _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].createElement('a', attributes);\n ;\n this.closeDiv.setAttribute('role', 'button');\n attributes = {};\n attributes.class = 'wrs_modal_stack_button';\n attributes.id = this.getElementId(attributes.class);\n attributes.title = \"Exit full-screen\";\n this.stackDiv = _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].createElement('a', attributes);\n this.stackDiv.setAttribute('role', 'button');\n attributes = {};\n attributes.class = 'wrs_modal_maximize_button';\n attributes.id = this.getElementId(attributes.class);\n attributes.title = _core_src_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].getStringManager().getString('fullscreen');\n this.maximizeDiv = _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].createElement('a', attributes);\n this.maximizeDiv.setAttribute('role', 'button');\n attributes = {};\n attributes.class = 'wrs_modal_minimize_button';\n attributes.id = this.getElementId(attributes.class);\n attributes.title = _core_src_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].getStringManager().getString('minimise');\n this.minimizeDiv = _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].createElement('a', attributes);\n this.minimizeDiv.setAttribute('role', 'button');\n attributes = {};\n attributes.class = 'wrs_modal_dialogContainer';\n attributes.id = this.getElementId(attributes.class);\n this.container = _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].createElement('div', attributes);\n attributes = {};\n attributes.class = 'wrs_modal_wrapper';\n attributes.id = this.getElementId(attributes.class);\n this.wrapper = _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].createElement('div', attributes);\n attributes = {};\n attributes.class = 'wrs_content_container';\n attributes.id = this.getElementId(attributes.class);\n this.contentContainer = _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].createElement('div', attributes);\n attributes = {};\n attributes.class = 'wrs_modal_controls';\n attributes.id = this.getElementId(attributes.class);\n this.controls = _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].createElement('div', attributes);\n attributes = {};\n attributes.class = 'wrs_modal_buttons_container';\n attributes.id = this.getElementId(attributes.class);\n this.buttonContainer = _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].createElement('div', attributes); // Buttons: all button must be created using createSubmitButton method.\n\n this.submitButton = this.createSubmitButton({\n id: this.getElementId('wrs_modal_button_accept'),\n class: 'wrs_modal_button_accept',\n innerHTML: _core_src_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].getStringManager().getString('accept')\n }, this.submitAction.bind(this));\n this.cancelButton = this.createSubmitButton({\n id: this.getElementId('wrs_modal_button_cancel'),\n class: 'wrs_modal_button_cancel',\n innerHTML: _core_src_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].getStringManager().getString('cancel')\n }, this.cancelAction.bind(this));\n this.contentManager = null; // Overlay popup.\n\n var popupStrings = {\n 'cancelString': _core_src_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].getStringManager().getString('cancel'),\n 'submitString': _core_src_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].getStringManager().getString('close'),\n 'message': _core_src_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].getStringManager().getString('close_modal_warning')\n };\n var callbacks = {\n 'closeCallback': function () {\n this.close();\n }.bind(this),\n 'cancelCallback': function () {\n this.focus();\n }.bind(this)\n };\n var popupupProperties = {\n 'overlayElement': this.container,\n 'callbacks': callbacks,\n 'strings': popupStrings\n };\n this.popup = new _popupmessage_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"](popupupProperties);\n /**\r\n * Indicates if directionality of the modal dialog is RTL. false by default.\r\n * @type {boolean}\r\n */\n\n this.rtl = false;\n\n if ('rtl' in this.attributes) {\n this.rtl = this.attributes.rtl;\n }\n }\n /**\r\n * This method sets an ContentManager instance to ModalDialog. ContentManager\r\n * manages the logic of ModalDialog content: submit, update, close and changes.\r\n * @param {ContentManager} contentManager - ContentManager instance.\r\n */\n\n\n _createClass(ModalDialog, [{\n key: \"setContentManager\",\n value: function setContentManager(contentManager) {\n this.contentManager = contentManager;\n }\n /**\r\n * Returns the modal contentElement object.\r\n * @returns {ContentManager} the instance of the ContentManager class.\r\n */\n\n }, {\n key: \"getContentManager\",\n value: function getContentManager() {\n return this.contentManager;\n }\n /**\r\n * This method is called when the modal object has been submitted. Calls\r\n * contentElement submitAction method - if exists - and closes the modal\r\n * object. No logic about the content should be placed here,\r\n * contentElement.submitAction is the responsible of the content logic.\r\n */\n\n }, {\n key: \"submitAction\",\n value: function submitAction() {\n if (typeof this.contentManager.submitAction !== 'undefined') {\n this.contentManager.submitAction();\n }\n\n this.close();\n }\n /**\r\n * This method is called when the modal object has been cancelled. If\r\n * contentElement has implemented hasChanges method, a confirm popup\r\n * will be shown if hasChanges returns true.\r\n */\n\n }, {\n key: \"cancelAction\",\n value: function cancelAction() {\n if (typeof this.contentManager.hasChanges === 'undefined') {\n this.close();\n } else if (!this.contentManager.hasChanges()) {\n this.close();\n } else {\n this.showPopUpMessage();\n }\n }\n /**\r\n * Returns a button element.\r\n * @param {Object} properties - input button properties.\r\n * @param {string} properties.class - input button class.\r\n * @param {string} properties.innerHTML - input button innerHTML.\r\n * @param {Object} callback - callback function associated to click event.\r\n * @returns {HTMLButtonElement} the button element.\r\n *\r\n */\n\n }, {\n key: \"createSubmitButton\",\n value: function createSubmitButton(properties, callback) {\n function SubmitButton(properties, callback) {\n this.element = document.createElement('button');\n this.element.id = properties.id;\n this.element.className = properties.class;\n this.element.innerHTML = properties.innerHTML;\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addEvent(this.element, 'click', callback);\n }\n\n SubmitButton.prototype.getElement = function () {\n return this.element;\n };\n\n return new SubmitButton(properties, callback).getElement();\n }\n /**\r\n * Creates the modal window object inserting a contentElement object.\r\n */\n\n }, {\n key: \"create\",\n value: function create() {\n /*Modal Window Structure\r\n _____________________________________________________________________________________\r\n |wrs_modal_dialog_Container |\r\n | _________________________________________________________________________________ |\r\n | |title_bar minimize_button stack_button close_button | |\r\n | |_______________________________________________________________________________| |\r\n | |wrapper | |\r\n | | _____________________________________________________________________________ | |\r\n | | |content | | |\r\n | | | | | |\r\n | | | | | |\r\n | | |___________________________________________________________________________| | |\r\n | | _____________________________________________________________________________ | |\r\n | | |controls | | |\r\n | | | ___________________________________ | | |\r\n | | | |buttonContainer | | | |\r\n | | | | _______________________________ | | | |\r\n | | | | |button_accept | button_cancel| | | | |\r\n | | | |_|_____________ |______________|_| | | |\r\n | | |___________________________________________________________________________| | |\r\n | |_______________________________________________________________________________| |\r\n |___________________________________________________________________________________|*/\n this.titleBar.appendChild(this.closeDiv);\n this.titleBar.appendChild(this.stackDiv);\n this.titleBar.appendChild(this.maximizeDiv);\n this.titleBar.appendChild(this.minimizeDiv);\n this.titleBar.appendChild(this.title);\n\n if (this.deviceProperties['isDesktop']) {\n this.container.appendChild(this.titleBar);\n }\n\n this.wrapper.appendChild(this.contentContainer);\n this.wrapper.appendChild(this.controls);\n this.controls.appendChild(this.buttonContainer);\n this.buttonContainer.appendChild(this.submitButton);\n this.buttonContainer.appendChild(this.cancelButton);\n this.container.appendChild(this.wrapper); // Check if browser has scrollBar before modal has modified.\n\n this.recalculateScrollBar();\n document.body.appendChild(this.container);\n document.body.appendChild(this.overlay);\n\n if (this.deviceProperties['isDesktop']) {\n // Desktop.\n this.createModalWindowDesktop();\n this.createResizeButtons();\n this.addListeners(); // Maximize window only when the configuration is set and the device is not iOS or Android.\n\n if (_configuration_js__WEBPACK_IMPORTED_MODULE_3__[\"default\"].get('modalWindowFullScreen')) {\n this.maximize();\n }\n } else if (this.deviceProperties['isAndroid']) {\n this.createModalWindowAndroid();\n } else if (this.deviceProperties['isIOS'] && !this.deviceProperties['isMobile']) {\n this.createModalWindowIos();\n }\n\n if (this.contentManager != null) {\n this.contentManager.insert(this);\n }\n\n this.properties.open = true;\n this.properties.created = true; // Checks language directionality.\n\n if (this.isRTL()) {\n this.container.style.right = window.innerWidth - this.scrollbarWidth - this.container.offsetWidth + 'px';\n this.container.className += ' wrs_modal_rtl';\n }\n }\n /**\r\n * Creates a button in the modal object to resize it.\r\n */\n\n }, {\n key: \"createResizeButtons\",\n value: function createResizeButtons() {\n // This is a definition of Resize Button Bottom-Right\n this.resizerBR = document.createElement('div');\n this.resizerBR.className = 'wrs_bottom_right_resizer';\n this.resizerBR.innerHTML = '◢'; // This is a definition of Resize Button Top-Left\n\n this.resizerTL = document.createElement('div');\n this.resizerTL.className = 'wrs_bottom_left_resizer'; // Append resize buttons to modal\n\n this.container.appendChild(this.resizerBR);\n this.titleBar.appendChild(this.resizerTL); // Add events to resize on click and drag\n\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addEvent(this.resizerBR, 'mousedown', this.activateResizeStateBR.bind(this));\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addEvent(this.resizerTL, 'mousedown', this.activateResizeStateTL.bind(this));\n }\n /**\r\n * Initialize variables for Bottom-Right resize button\r\n * @param {MouseEvent} mouseEvent - mouse event.\r\n */\n\n }, {\n key: \"activateResizeStateBR\",\n value: function activateResizeStateBR(mouseEvent) {\n this.initializeResizeProperties(mouseEvent, false);\n }\n /**\r\n * Initialize variables for Top-Left resize button\r\n * @param {MouseEvent} mouseEvent - mouse event.\r\n */\n\n }, {\n key: \"activateResizeStateTL\",\n value: function activateResizeStateTL(mouseEvent) {\n this.initializeResizeProperties(mouseEvent, true);\n }\n /**\r\n * Common method to initialize variables at resize\r\n * @param {MouseEvent} mouseEvent - mouse event.\r\n */\n\n }, {\n key: \"initializeResizeProperties\",\n value: function initializeResizeProperties(mouseEvent, leftOption) {\n // Apply class for disable involuntary select text when drag.\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addClass(document.body, 'wrs_noselect');\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addClass(this.overlay, 'wrs_overlay_active');\n this.resizeDataObject = {\n x: this.eventClient(mouseEvent).X,\n y: this.eventClient(mouseEvent).Y\n }; // Save Initial state of modal to compare on drag and obtain the difference.\n\n this.initialWidth = parseInt(this.container.style.width);\n this.initialHeight = parseInt(this.container.style.height);\n\n if (!leftOption) {\n this.initialRight = parseInt(this.container.style.right);\n this.initialBottom = parseInt(this.container.style.bottom);\n } else {\n this.leftScale = true;\n }\n\n if (!this.initialRight) {\n this.initialRight = 0;\n }\n\n if (!this.initialBottom) {\n this.initialBottom = 0;\n } // Disable mouse events on editor when we start to drag modal.\n\n\n document.body.style['user-select'] = 'none';\n }\n /**\r\n * This method opens the modal window, restoring the previous state, position and metrics,\r\n * if exists. By default the modal object opens in stack mode.\r\n */\n\n }, {\n key: \"open\",\n value: function open() {\n //Removing close class.\n this.removeClass('wrs_closed'); // Hiding keyboard for mobile devices.\n\n if (this.deviceProperties['isIOS'] || this.deviceProperties['isAndroid'] || this.deviceProperties['isMobile']) {\n // Restore scale to 1\n this.restoreWebsiteScale();\n this.blockWebsiteScroll(); // Due to editor wait we need to wait until editor focus.\n\n setTimeout(function () {\n this.hideKeyboard();\n }.bind(this), 400);\n } // New modal window. He need to create the whole object.\n\n\n if (!this.properties.created) {\n this.create();\n } else {\n // Previous state closed. Open method can be called even the previous state is open,\n // for example updating the content of the modal object.\n if (!this.properties.open) {\n this.properties.open = true; // Restoring the previous open state: if the modal object has been closed\n // re-open it should preserve the state and the metrics.\n\n if (!this.deviceProperties.isAndroid && !this.deviceProperties.isIOS) {\n this.restoreState();\n }\n } // Maximize window only when the configuration is set and the device is not iOs or Android.\n\n\n if (this.deviceProperties['isDesktop'] && _configuration_js__WEBPACK_IMPORTED_MODULE_3__[\"default\"].get('modalWindowFullScreen')) {\n this.maximize();\n } // In iOS we need to recalculate the size of the modal object because\n // iOS keyboard is a float div which can overlay the modal object.\n\n\n if (this.deviceProperties['isIOS']) {\n this.iosSoftkeyboardOpened = false;\n this.setContainerHeight(\"100\" + this.iosMeasureUnit);\n }\n }\n\n if (this.contentManager.isEditorLoaded === false) {\n var listener = _listeners__WEBPACK_IMPORTED_MODULE_4__[\"default\"].newListener('onLoad', function () {\n this.contentManager.onOpen(this);\n }.bind(this));\n this.contentManager.addListener(listener);\n } else {\n this.contentManager.onOpen(this);\n }\n }\n /**\r\n * Closes modal window and restores viewport header.\r\n */\n\n }, {\n key: \"close\",\n value: function close() {\n this.removeClass('wrs_maximized');\n this.removeClass('wrs_minimized');\n this.removeClass('wrs_stack');\n this.addClass('wrs_closed');\n this.saveModalProperties();\n this.unblockWebsiteScroll();\n this.properties.open = false;\n }\n /**\r\n * Sets the website scale to one.\r\n */\n\n }, {\n key: \"restoreWebsiteScale\",\n value: function restoreWebsiteScale() {\n var viewportmeta = document.querySelector('meta[name=viewport]'); // Let the equal symbols in order to search and make meta's final content.\n\n var contentAttrsToUpdate = ['initial-scale=', 'minimum-scale=', 'maximum-scale='];\n var contentAttrsValuesToUpdate = ['1.0', '1.0', '1.0'];\n\n var setMetaAttrFunc = function setMetaAttrFunc(viewportelement, contentAttrsToUpdate) {\n var contentAttr = viewportelement.getAttribute('content'); // If it exists, we need to maintain old values and put our values.\n\n if (contentAttr) {\n var attrArray = contentAttr.split(',');\n var finalContentMeta = \"\";\n var oldAttrs = [];\n\n for (var i = 0; i < attrArray.length; i++) {\n var isAttrToUpdate = false;\n var j = 0;\n\n while (!isAttrToUpdate && j < contentAttrsToUpdate.length) {\n if (attrArray[i].indexOf(contentAttrsToUpdate[j])) {\n isAttrToUpdate = true;\n }\n\n j++;\n }\n\n if (!isAttrToUpdate) {\n oldAttrs.push(attrArray[i]);\n }\n }\n\n for (var _i = 0; _i < contentAttrsToUpdate.length; _i++) {\n var attr = contentAttrsToUpdate[_i] + contentAttrsValuesToUpdate[_i];\n finalContentMeta += _i == 0 ? attr : ',' + attr;\n }\n\n for (var _i2 = 0; _i2 < oldAttrs.length; _i2++) {\n finalContentMeta += ',' + oldAttrs[_i2];\n }\n\n viewportelement.setAttribute('content', finalContentMeta);\n viewportelement.setAttribute('content', contentAttr);\n } else {\n viewportelement.setAttribute('content', 'initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0');\n viewportelement.removeAttribute('content');\n }\n };\n\n if (!viewportmeta) {\n viewportmeta = document.createElement('meta');\n document.getElementsByTagName('head')[0].appendChild(viewportmeta);\n setMetaAttrFunc(viewportmeta, contentAttrsToUpdate, contentAttrsValuesToUpdate);\n viewportmeta.remove();\n } else {\n setMetaAttrFunc(viewportmeta, contentAttrsToUpdate, contentAttrsValuesToUpdate);\n }\n }\n /**\r\n * Adds an event to avoid touch scrolling.\r\n */\n\n }, {\n key: \"blockWebsiteScroll\",\n value: function blockWebsiteScroll() {\n document.body.addEventListener('touchmove', this.disableTouchMove, {\n passive: false\n });\n }\n /**\r\n * Removes the event to avoid touch scrolling.\r\n */\n\n }, {\n key: \"unblockWebsiteScroll\",\n value: function unblockWebsiteScroll() {\n document.body.removeEventListener('touchmove', this.disableTouchMove, {\n passive: false\n });\n }\n /**\r\n * Prevents the default event behavior to a MouseEvent.\r\n * @param {MouseEvent} mouseEvent - mouse event.\r\n */\n\n }, {\n key: \"disableTouchMove\",\n value: function disableTouchMove(mouseEvent) {\n mouseEvent.preventDefault();\n }\n /**\r\n * Util function to known if browser is IE11.\r\n * @returns {boolean} true if the browser is IE11. false otherwise.\r\n */\n\n }, {\n key: \"isIE11\",\n value: function isIE11() {\n if (navigator.userAgent.search(\"Msie/\") >= 0 || navigator.userAgent.search(\"Trident/\") >= 0 || navigator.userAgent.search(\"Edge/\") >= 0) {\n return true;\n }\n\n return false;\n }\n /**\r\n * Returns if the current language type is RTL.\r\n * @return {boolean} true if current language is RTL. false otherwise.\r\n */\n\n }, {\n key: \"isRTL\",\n value: function isRTL() {\n if (this.attributes.language == 'ar' || this.attributes.language == 'he') {\n return true;\n } else {\n return this.rtl;\n }\n\n ;\n }\n /**\r\n * Adds a class to all modal ModalDialog DOM elements.\r\n * @param {string} className - class name.\r\n */\n\n }, {\n key: \"addClass\",\n value: function addClass(className) {\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addClass(this.overlay, className);\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addClass(this.titleBar, className);\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addClass(this.overlay, className);\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addClass(this.container, className);\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addClass(this.contentContainer, className);\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addClass(this.stackDiv, className);\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addClass(this.minimizeDiv, className);\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addClass(this.maximizeDiv, className);\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addClass(this.wrapper, className);\n }\n /**\r\n * Remove a class from all modal DOM elements.\r\n * @param {string} className - class name.\r\n */\n\n }, {\n key: \"removeClass\",\n value: function removeClass(className) {\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].removeClass(this.overlay, className);\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].removeClass(this.titleBar, className);\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].removeClass(this.overlay, className);\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].removeClass(this.container, className);\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].removeClass(this.contentContainer, className);\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].removeClass(this.stackDiv, className);\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].removeClass(this.minimizeDiv, className);\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].removeClass(this.maximizeDiv, className);\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].removeClass(this.wrapper, className);\n }\n /**\r\n * Create modal dialog for desktop.\r\n */\n\n }, {\n key: \"createModalWindowDesktop\",\n value: function createModalWindowDesktop() {\n this.addClass('wrs_modal_desktop');\n this.stack();\n }\n /**\r\n * Create modal dialog for non android devices.\r\n */\n\n }, {\n key: \"createModalWindowAndroid\",\n value: function createModalWindowAndroid() {\n this.addClass('wrs_modal_android');\n window.addEventListener('resize', this.orientationChangeAndroidSoftkeyboard.bind(this));\n }\n /**\r\n * Create modal dialog for iOS devices.\r\n */\n\n }, {\n key: \"createModalWindowIos\",\n value: function createModalWindowIos() {\n this.addClass('wrs_modal_ios'); // Refresh the size when the orientation is changed\n\n window.addEventListener('resize', this.orientationChangeIosSoftkeyboard.bind(this));\n }\n /**\r\n * Restore previous state, position and size of previous stacked modal dialog.\r\n */\n\n }, {\n key: \"restoreState\",\n value: function restoreState() {\n if (this.properties.state == 'maximized') {\n // Reset states for prevent return to stack state.\n this.maximize();\n } else if (this.properties.state == 'minimized') {\n // Reset states for prevent return to stack state.\n this.properties.state = this.properties.previousState;\n this.properties.previousState = '';\n this.minimize();\n } else {\n this.stack();\n }\n }\n /**\r\n * Stacks the modal object.\r\n */\n\n }, {\n key: \"stack\",\n value: function stack() {\n this.properties.previousState = this.properties.state;\n this.properties.state = 'stack';\n this.removeClass('wrs_maximized');\n this.minimizeDiv.title = \"Minimise\";\n this.removeClass('wrs_minimized');\n this.addClass('wrs_stack');\n this.restoreModalProperties();\n\n if (typeof this.resizerBR !== 'undefined' && typeof this.resizerTL !== 'undefined') {\n this.setResizeButtonsVisibility();\n } // Need recalculate position of actual modal because window can was changed in fullscreenmode\n\n\n this.recalculateScrollBar();\n this.recalculatePosition();\n this.recalculateScale();\n this.focus();\n }\n /**\r\n * Minimizes the modal object\r\n */\n\n }, {\n key: \"minimize\",\n value: function minimize() {\n // Saving width, height, top and bottom parameters to restore when open\n this.saveModalProperties();\n\n if (this.properties.state == 'minimized' && this.properties.previousState == 'stack') {\n this.stack();\n } else if (this.properties.state == 'minimized' && this.properties.previousState == 'maximized') {\n this.maximize();\n } else {\n // Setting css to prevent important tag into css style\n this.container.style.height = \"30px\";\n this.container.style.width = \"250px\";\n this.container.style.bottom = \"0px\";\n this.container.style.right = \"10px\";\n this.removeListeners();\n this.properties.previousState = this.properties.state;\n this.properties.state = \"minimized\";\n this.setResizeButtonsVisibility();\n this.minimizeDiv.title = \"Maximise\";\n\n if (_util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].containsClass(this.overlay, 'wrs_stack')) {\n this.removeClass('wrs_stack');\n } else {\n this.removeClass('wrs_maximized');\n }\n\n this.addClass('wrs_minimized');\n }\n }\n /**\r\n * Maximizes the modal object.\r\n */\n\n }, {\n key: \"maximize\",\n value: function maximize() {\n // Saving width, height, top and bottom parameters to restore when open\n this.saveModalProperties();\n\n if (this.properties.state != 'maximized') {\n this.properties.previousState = this.properties.state;\n this.properties.state = 'maximized';\n } // Don't permit resize on maximize mode.\n\n\n this.setResizeButtonsVisibility();\n\n if (_util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].containsClass(this.overlay, 'wrs_minimized')) {\n this.minimizeDiv.title = \"Minimise\";\n this.removeClass('wrs_minimized');\n } else if (_util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].containsClass(this.overlay, 'wrs_stack')) {\n this.container.style.left = null;\n this.container.style.top = null;\n this.removeClass('wrs_stack');\n }\n\n this.addClass('wrs_maximized'); // Set size to 80% screen with a max size.\n\n this.setSize(parseInt(window.innerHeight * 0.8), parseInt(window.innerWidth * 0.8));\n var sizeModificated = false;\n\n if (this.container.clientHeight > 700) {\n this.container.style.height = '700px';\n sizeModificated = true;\n }\n\n if (this.container.clientWidth > 1200) {\n this.container.style.width = '1200px';\n sizeModificated = true;\n } // Setting modal position in center on screen.\n\n\n this.setPosition(window.innerHeight / 2 - this.container.offsetHeight / 2, window.innerWidth / 2 - this.container.offsetWidth / 2);\n this.recalculateScale();\n this.recalculatePosition();\n this.recalculateSize();\n this.focus();\n }\n /**\r\n * Sets modal size.\r\n * @param {number} height - height of the ModalDialog\r\n * @param {number} width - width of the ModalDialog.\r\n */\n\n }, {\n key: \"setSize\",\n value: function setSize(height, width) {\n this.container.style.height = height + 'px';\n this.container.style.width = width + 'px';\n this.recalculateSize();\n }\n /**\r\n * Sets modal position using bottom and right style attributes.\r\n * @param {number} bottom - bottom attribute.\r\n * @param {number} right - right attribute.\r\n */\n\n }, {\n key: \"setPosition\",\n value: function setPosition(bottom, right) {\n this.container.style.bottom = bottom + 'px';\n this.container.style.right = right + 'px';\n }\n /**\r\n * Saves position and size parameters of and open ModalDialog. This attributes\r\n * are needed to restore it on re-open.\r\n */\n\n }, {\n key: \"saveModalProperties\",\n value: function saveModalProperties() {\n // Saving values of modal only when modal is in stack state.\n if (this.properties.state == 'stack') {\n this.properties.position.bottom = parseInt(this.container.style.bottom);\n this.properties.position.right = parseInt(this.container.style.right);\n this.properties.size.width = parseInt(this.container.style.width);\n this.properties.size.height = parseInt(this.container.style.height);\n }\n }\n /**\r\n * Restore ModalDialog position and size parameters.\r\n */\n\n }, {\n key: \"restoreModalProperties\",\n value: function restoreModalProperties() {\n if (this.properties.state == 'stack') {\n // Restoring Bottom and Right values from last modal\n this.setPosition(this.properties.position.bottom, this.properties.position.right); // Restoring Height and Left values from last modal\n\n this.setSize(this.properties.size.height, this.properties.size.width);\n }\n }\n /**\r\n * Sets the modal dialog initial size.\r\n */\n\n }, {\n key: \"recalculateSize\",\n value: function recalculateSize() {\n this.wrapper.style.width = this.container.clientWidth - 12 + 'px';\n this.wrapper.style.height = this.container.clientHeight - 38 + 'px';\n this.contentContainer.style.height = parseInt(this.wrapper.offsetHeight - 50) + 'px';\n }\n /**\r\n * Enable or disable visibility of resize buttons in modal window depend on state.\r\n */\n\n }, {\n key: \"setResizeButtonsVisibility\",\n value: function setResizeButtonsVisibility() {\n if (this.properties.state == 'stack') {\n this.resizerTL.style.visibility = 'visible';\n this.resizerBR.style.visibility = 'visible';\n } else {\n this.resizerTL.style.visibility = 'hidden';\n this.resizerBR.style.visibility = 'hidden';\n }\n }\n /**\r\n * Makes an object draggable adding mouse and touch events.\r\n */\n\n }, {\n key: \"addListeners\",\n value: function addListeners() {\n // Button events (maximize, minimize, stack and close).\n this.maximizeDiv.addEventListener('click', this.maximize.bind(this), true);\n this.stackDiv.addEventListener('click', this.stack.bind(this), true);\n this.minimizeDiv.addEventListener('click', this.minimize.bind(this), true);\n this.closeDiv.addEventListener('click', this.cancelAction.bind(this)); // Mouse events.\n\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addEvent(window, 'mousedown', this.startDrag.bind(this));\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addEvent(window, 'mouseup', this.stopDrag.bind(this));\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addEvent(window, 'mousemove', this.drag.bind(this));\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addEvent(window, 'resize', this.onWindowResize.bind(this)); // Key events.\n\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addEvent(window, 'keydown', this.onKeyDown.bind(this));\n }\n /**\r\n * Removes draggable events from an object.\r\n */\n\n }, {\n key: \"removeListeners\",\n value: function removeListeners() {\n // Mouse events.\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].removeEvent(window, 'mousedown', this.startDrag);\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].removeEvent(window, 'mouseup', this.stopDrag);\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].removeEvent(window, 'mousemove', this.drag);\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].removeEvent(window, 'resize', this.onWindowResize); // Key events\n\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].removeEvent(window, 'keydown', this.onKeyDown);\n }\n /**\r\n * Returns mouse or touch coordinates (on touch events ev.ClientX doesn't exists)\r\n * @param {MouseEvent} mouseEvent - mouse event.\r\n * @return {Object} with the X and Y coordinates.\r\n */\n\n }, {\n key: \"eventClient\",\n value: function eventClient(mouseEvent) {\n if (typeof mouseEvent.clientX == 'undefined' && mouseEvent.changedTouches) {\n var client = {\n X: mouseEvent.changedTouches[0].clientX,\n Y: mouseEvent.changedTouches[0].clientY\n };\n return client;\n } else {\n client = {\n X: mouseEvent.clientX,\n Y: mouseEvent.clientY\n };\n return client;\n }\n }\n /**\r\n * Start drag function: set the object dragDataObject with the draggable object offsets coordinates.\r\n * when drag starts (on touchstart or mousedown events).\r\n * @param {MouseEvent} mouseEvent - touchstart or mousedown event.\r\n */\n\n }, {\n key: \"startDrag\",\n value: function startDrag(mouseEvent) {\n if (this.properties.state == 'minimized') {\n return;\n }\n\n if (mouseEvent.target === this.title) {\n if (typeof this.dragDataObject === 'undefined' || this.dragDataObject === null) {\n mouseEvent = mouseEvent || event; // Save first click mouse point on screen\n\n this.dragDataObject = {\n x: this.eventClient(mouseEvent).X,\n y: this.eventClient(mouseEvent).Y\n }; // Reset last drag position when start drag\n\n this.lastDrag = {\n x: \"0px\",\n y: \"0px\"\n }; // Init right and bottom values for window modal if it isn't exist.\n\n if (this.container.style.right == '') {\n this.container.style.right = \"0px\";\n }\n\n if (this.container.style.bottom == '') {\n this.container.style.bottom = \"0px\";\n } // Needed for IE11 for apply disabled mouse events on editor because iexplorer need a dinamic object to apply this property.\n\n\n if (this.isIE11()) {} // this.iframe.style['position'] = 'relative';\n // Apply class for disable involuntary select text when drag.\n\n\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addClass(document.body, 'wrs_noselect');\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addClass(this.overlay, 'wrs_overlay_active'); // Obtain screen limits for prevent overflow.\n\n this.limitWindow = this.getLimitWindow();\n }\n }\n }\n /**\r\n * Updates dragDataObject with the draggable object coordinates when the draggable object is being moved.\r\n * @param {MouseEvent} mouseEvent - the mouse event.\r\n */\n\n }, {\n key: \"drag\",\n value: function drag(mouseEvent) {\n if (this.dragDataObject) {\n mouseEvent.preventDefault();\n mouseEvent = mouseEvent || event; // Calculate max and min between actual mouse position and limit of screeen. It restric the movement of modal into window.\n\n var limitY = Math.min(this.eventClient(mouseEvent).Y, this.limitWindow.minPointer.y);\n limitY = Math.max(this.limitWindow.maxPointer.y, limitY);\n var limitX = Math.min(this.eventClient(mouseEvent).X, this.limitWindow.minPointer.x);\n limitX = Math.max(this.limitWindow.maxPointer.x, limitX); // Substract limit with first position to obtain relative pixels increment to the anchor point.\n\n var dragX = limitX - this.dragDataObject.x + \"px\";\n var dragY = limitY - this.dragDataObject.y + \"px\"; // Save last valid position of modal before window overflow.\n\n this.lastDrag = {\n x: dragX,\n y: dragY\n }; // This move modal with hadware acceleration.\n\n this.container.style.transform = \"translate3d(\" + dragX + \",\" + dragY + \",0)\";\n }\n\n if (this.resizeDataObject) {\n var limitX = Math.min(this.eventClient(mouseEvent).X, window.innerWidth - this.scrollbarWidth - 7);\n var limitY = Math.min(this.eventClient(mouseEvent).Y, window.innerHeight - 7);\n\n if (limitX < 0) {\n limitX = 0;\n }\n\n if (limitY < 0) {\n limitY = 0;\n }\n\n var scaleMultiplier;\n\n if (this.leftScale) {\n scaleMultiplier = -1;\n } else {\n scaleMultiplier = 1;\n }\n\n this.container.style.width = this.initialWidth + scaleMultiplier * (limitX - this.resizeDataObject.x) + 'px';\n this.container.style.height = this.initialHeight + scaleMultiplier * (limitY - this.resizeDataObject.y) + 'px';\n\n if (!this.leftScale) {\n if (this.resizeDataObject.x - limitX - this.initialWidth < -580) {\n this.container.style.right = this.initialRight - (limitX - this.resizeDataObject.x) + 'px';\n } else {\n this.container.style.right = this.initialRight + this.initialWidth - 580 + \"px\";\n this.container.style.width = \"580px\";\n }\n\n if (this.resizeDataObject.y - limitY < this.initialHeight - 338) {\n this.container.style.bottom = this.initialBottom - (limitY - this.resizeDataObject.y) + 'px';\n } else {\n this.container.style.bottom = this.initialBottom + this.initialHeight - 338 + \"px\";\n this.container.style.height = \"338px\";\n }\n }\n\n this.recalculateScale();\n this.recalculatePosition();\n }\n }\n /**\r\n * Returns the boundaries of actual window to limit modal movement.\r\n * @return {Object} Object containing mouseX and mouseY coordinates of actual mouse on screen.\r\n */\n\n }, {\n key: \"getLimitWindow\",\n value: function getLimitWindow() {\n // Obtain dimensions of window page.\n var maxWidth = window.innerWidth;\n var maxHeight = window.innerHeight; // Calculate relative position of mouse point into window.\n\n var offSetToolbarY = this.container.offsetHeight + parseInt(this.container.style.bottom) - (maxHeight - (this.dragDataObject.y - window.pageXOffset));\n var offSetToolbarX = maxWidth - this.scrollbarWidth - (this.dragDataObject.x - window.pageXOffset) - parseInt(this.container.style.right); // Calculate limits with sizes of window, modal and mouse position.\n\n var minPointerY = maxHeight - this.container.offsetHeight + offSetToolbarY;\n var maxPointerY = this.title.offsetHeight - (this.title.offsetHeight - offSetToolbarY);\n var minPointerX = maxWidth - offSetToolbarX - this.scrollbarWidth;\n var maxPointerX = this.container.offsetWidth - offSetToolbarX;\n var minPointer = {\n x: minPointerX,\n y: minPointerY\n };\n var maxPointer = {\n x: maxPointerX,\n y: maxPointerY\n };\n return {\n minPointer: minPointer,\n maxPointer: maxPointer\n };\n }\n /**\r\n * Returns the scrollbar width size of browser\r\n * @returns {number} the scrollbar width.\r\n */\n\n }, {\n key: \"getScrollBarWidth\",\n value: function getScrollBarWidth() {\n // Create a paragraph with full width of page.\n var inner = document.createElement('p');\n inner.style.width = \"100%\";\n inner.style.height = \"200px\"; // Create a hidden div to compare sizes.\n\n var outer = document.createElement('div');\n outer.style.position = \"absolute\";\n outer.style.top = \"0px\";\n outer.style.left = \"0px\";\n outer.style.visibility = \"hidden\";\n outer.style.width = \"200px\";\n outer.style.height = \"150px\";\n outer.style.overflow = \"hidden\";\n outer.appendChild(inner);\n document.body.appendChild(outer);\n var widthOuter = inner.offsetWidth; // Change type overflow of paragraph for measure scrollbar.\n\n outer.style.overflow = 'scroll';\n var widthInner = inner.offsetWidth; // If measure is the same, we compare with internal div.\n\n if (widthOuter == widthInner) {\n widthInner = outer.clientWidth;\n }\n\n document.body.removeChild(outer);\n return widthOuter - widthInner;\n }\n /**\r\n * Set the dragDataObject to null.\r\n */\n\n }, {\n key: \"stopDrag\",\n value: function stopDrag() {\n // Due to we have multiple events that call this function, we need only to execute the next modifiers one time,\n // when the user stops to drag and dragDataObject is not null (the object to drag is attached).\n if (this.dragDataObject || this.resizeDataObject) {\n // If modal doesn't change, it's not necessary to set position with interpolation\n this.container.style.transform = '';\n\n if (this.dragDataObject) {\n this.container.style.right = parseInt(this.container.style.right) - parseInt(this.lastDrag.x) + \"px\";\n this.container.style.bottom = parseInt(this.container.style.bottom) - parseInt(this.lastDrag.y) + \"px\";\n } // We make focus on editor after drag modal windows to prevent lose focus.\n\n\n this.focus(); // Restore mouse events on iframe\n // this.iframe.style['pointer-events'] = 'auto';\n\n document.body.style['user-select'] = ''; // Restore static state of iframe if we use Internet Explorer.\n\n if (this.isIE11()) {} // this.iframe.style['position'] = null;\n // Active text select event\n\n\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].removeClass(document.body, 'wrs_noselect');\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].removeClass(this.overlay, 'wrs_overlay_active');\n }\n\n this.dragDataObject = null;\n this.resizeDataObject = null;\n this.initialWidth = null;\n this.leftScale = null;\n }\n /**\r\n * Recalculates scale for modal when resize browser window.\r\n */\n\n }, {\n key: \"onWindowResize\",\n value: function onWindowResize() {\n this.recalculateScrollBar();\n this.recalculatePosition();\n this.recalculateScale();\n }\n /**\r\n * Triggers keyboard events:\r\n * - Tab key tab to go to submit button.\r\n * - Esc key to close the modal dialog.\r\n * @param {KeyboardEvent} keyboardEvent - the keyboard event.\r\n */\n\n }, {\n key: \"onKeyDown\",\n value: function onKeyDown(keyboardEvent) {\n if (keyboardEvent.key !== undefined && keyboardEvent.repeat === false) {\n // Code for detect Esc event\n if (keyboardEvent.key === \"Escape\" || keyboardEvent.key === 'Esc') {\n if (this.properties.open) {\n this.cancelAction();\n }\n } // Code for detect Tab event\n\n\n if (keyboardEvent.key === \"Tab\") {\n this.submitButton.focus();\n keyboardEvent.preventDefault();\n }\n }\n }\n /**\r\n * Recalculating position for modal dialog when the browser is resized.\r\n */\n\n }, {\n key: \"recalculatePosition\",\n value: function recalculatePosition() {\n this.container.style.right = Math.min(parseInt(this.container.style.right), window.innerWidth - this.scrollbarWidth - this.container.offsetWidth) + \"px\";\n\n if (parseInt(this.container.style.right) < 0) {\n this.container.style.right = \"0px\";\n }\n\n this.container.style.bottom = Math.min(parseInt(this.container.style.bottom), window.innerHeight - this.container.offsetHeight) + \"px\";\n\n if (parseInt(this.container.style.bottom) < 0) {\n this.container.style.bottom = \"0px\";\n }\n }\n /**\r\n * Recalculating scale for modal when the browser is resized.\r\n */\n\n }, {\n key: \"recalculateScale\",\n value: function recalculateScale() {\n var sizeModificated = false;\n\n if (parseInt(this.container.style.width) > 580) {\n this.container.style.width = Math.min(parseInt(this.container.style.width), window.innerWidth - this.scrollbarWidth) + \"px\";\n sizeModificated = true;\n } else {\n this.container.style.width = \"580px\";\n sizeModificated = true;\n }\n\n if (parseInt(this.container.style.height) > 338) {\n this.container.style.height = Math.min(parseInt(this.container.style.height), window.innerHeight) + \"px\";\n sizeModificated = true;\n } else {\n this.container.style.height = \"338px\";\n sizeModificated = true;\n }\n\n if (sizeModificated) {\n this.recalculateSize();\n }\n }\n /**\r\n * Recalculating width of browser scroll bar.\r\n */\n\n }, {\n key: \"recalculateScrollBar\",\n value: function recalculateScrollBar() {\n this.hasScrollBar = window.innerWidth > document.documentElement.clientWidth;\n\n if (this.hasScrollBar) {\n this.scrollbarWidth = this.getScrollBarWidth();\n } else {\n this.scrollbarWidth = 0;\n }\n }\n /**\r\n * Hide soft keyboards on iOS devices.\r\n */\n\n }, {\n key: \"hideKeyboard\",\n value: function hideKeyboard() {\n document.activeElement.blur();\n }\n /**\r\n * Focus to contentManager object.\r\n */\n\n }, {\n key: \"focus\",\n value: function focus() {\n if (this.contentManager != null && typeof this.contentManager.onFocus !== 'undefined') {\n this.contentManager.onFocus();\n }\n }\n /**\r\n * Returns true when the device is on portrait mode.\r\n */\n\n }, {\n key: \"portraitMode\",\n value: function portraitMode() {\n return window.innerHeight > window.innerWidth;\n }\n /**\r\n * Change container sizes when the keyboard is opened on iOS.\r\n */\n\n }, {\n key: \"openedIosSoftkeyboard\",\n value: function openedIosSoftkeyboard() {\n if (!this.iosSoftkeyboardOpened && this.iosDivHeight != null && this.iosDivHeight == \"100\" + this.iosMeasureUnit) {\n if (this.portraitMode()) {\n this.setContainerHeight(\"63\" + this.iosMeasureUnit);\n } else {\n this.setContainerHeight(\"40\" + this.iosMeasureUnit);\n }\n }\n\n this.iosSoftkeyboardOpened = true;\n }\n /**\r\n * Change container sizes when the keyboard is closed on iOS.\r\n */\n\n }, {\n key: \"closedIosSoftkeyboard\",\n value: function closedIosSoftkeyboard() {\n this.iosSoftkeyboardOpened = false;\n this.setContainerHeight(\"100\" + this.iosMeasureUnit);\n }\n /**\r\n * Change container sizes when orientation is changed on iOS.\r\n */\n\n }, {\n key: \"orientationChangeIosSoftkeyboard\",\n value: function orientationChangeIosSoftkeyboard() {\n if (this.iosSoftkeyboardOpened) {\n if (this.portraitMode()) {\n this.setContainerHeight(\"63\" + this.iosMeasureUnit);\n } else {\n this.setContainerHeight(\"40\" + this.iosMeasureUnit);\n }\n } else {\n this.setContainerHeight(\"100\" + this.iosMeasureUnit);\n }\n }\n /**\r\n * Change container sizes when orientation is changed on Android.\r\n */\n\n }, {\n key: \"orientationChangeAndroidSoftkeyboard\",\n value: function orientationChangeAndroidSoftkeyboard() {\n this.setContainerHeight(\"100%\");\n }\n /**\r\n * Set iframe container height.\r\n * @param {number} height - new height.\r\n */\n\n }, {\n key: \"setContainerHeight\",\n value: function setContainerHeight(height) {\n this.iosDivHeight = height;\n this.wrapper.style.height = height;\n }\n /**\r\n * Check content of editor before close action.\r\n */\n\n }, {\n key: \"showPopUpMessage\",\n value: function showPopUpMessage() {\n if (this.properties.state == 'minimized') {\n this.stack();\n }\n\n this.popup.show();\n }\n /**\r\n * Sets the tithle of the modal dialog.\r\n * @param {string} title - modal dialog title.\r\n */\n\n }, {\n key: \"setTitle\",\n value: function setTitle(title) {\n this.title.innerHTML = title;\n }\n /**\r\n * Returns the id of an element, adding the instance number to\r\n * the element class name:\r\n * className --> className[idNumber]\r\n * @param {string} className - the element class name.\r\n * @returns {string} a string appending the instance id to the className.\r\n */\n\n }, {\n key: \"getElementId\",\n value: function getElementId(className) {\n return className + \"[\" + this.instanceId + \"]\";\n }\n }]);\n\n return ModalDialog;\n}();\n\n\n\n//# sourceURL=webpack:///./core/src/modal.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"default\", function() { return ModalDialog; });\n/* harmony import */ var _popupmessage_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./popupmessage.js */ \"./core/src/popupmessage.js\");\n/* harmony import */ var _core_src_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./core.src.js */ \"./core/src/core.src.js\");\n/* harmony import */ var _util_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./util.js */ \"./core/src/util.js\");\n/* harmony import */ var _configuration_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./configuration.js */ \"./core/src/configuration.js\");\n/* harmony import */ var _listeners__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./listeners */ \"./core/src/listeners.js\");\n/* harmony import */ var _contentmanager_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./contentmanager.js */ \"./core/src/contentmanager.js\");\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\n\n\n\n\n\n\n/**\r\n * This class represents a modal dialog. The modal dialog admits a ContentManager instance in order\r\n * to manage the content of the dialog.\r\n */\n\nvar ModalDialog =\n/*#__PURE__*/\nfunction () {\n /**\r\n * Modal dialog constructor\r\n * @param {Object} modalDialogAttributes - An object containing all modal dialog attributes.\r\n */\n function ModalDialog(modalDialogAttributes) {\n _classCallCheck(this, ModalDialog);\n\n this.attributes = modalDialogAttributes; // Metrics\n\n var ua = navigator.userAgent.toLowerCase();\n var isAndroid = ua.indexOf(\"android\") > -1;\n var isIOS = ua.indexOf(\"ipad\") > -1 || ua.indexOf(\"iphone\") > -1;\n this.iosSoftkeyboardOpened = false;\n this.iosMeasureUnit = ua.indexOf(\"crios\") == -1 ? \"%\" : \"vh\";\n this.iosDivHeight = \"100\" + this.iosMeasureUnit;\n var deviceWidth = window.outerWidth;\n var deviceHeight = window.outerHeight;\n var landscape = deviceWidth > deviceHeight;\n var portrait = deviceWidth < deviceHeight; // TODO: Detect isMobile without using editor metrics.\n\n var isMobile = landscape && this.attributes.height > deviceHeight || portrait && this.attributes.width > deviceWidth ? true : false; // Obtain number of current instance\n\n this.instanceId = document.getElementsByClassName(\"wrs_modal_dialogContainer\").length; // Device object properties.\n\n this.deviceProperties = {\n orientation: landscape ? 'landscape' : 'portait',\n isAndroid: isAndroid ? true : false,\n isIOS: isIOS ? true : false,\n isMobile: isMobile,\n isDesktop: !isMobile && !isIOS && !isAndroid\n };\n this.properties = {\n created: false,\n state: '',\n previousState: '',\n position: {\n bottom: 0,\n right: 10\n },\n size: {\n height: 338,\n width: 580\n }\n };\n var attributes = {};\n attributes.class = 'wrs_modal_overlay';\n attributes.id = this.getElementId(attributes.class);\n this.overlay = _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].createElement('div', attributes);\n attributes = {};\n attributes.class = 'wrs_modal_title_bar';\n attributes.id = this.getElementId(attributes.class);\n this.titleBar = _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].createElement('div', attributes);\n attributes = {};\n attributes.class = 'wrs_modal_title';\n attributes.id = this.getElementId(attributes.class);\n this.title = _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].createElement('div', attributes);\n this.title.innerHTML = '';\n attributes = {};\n attributes.class = 'wrs_modal_close_button';\n attributes.id = this.getElementId(attributes.class);\n attributes.title = _core_src_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].getStringManager().getString('close');\n this.closeDiv = _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].createElement('a', attributes);\n ;\n this.closeDiv.setAttribute('role', 'button');\n attributes = {};\n attributes.class = 'wrs_modal_stack_button';\n attributes.id = this.getElementId(attributes.class);\n attributes.title = \"Exit full-screen\";\n this.stackDiv = _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].createElement('a', attributes);\n this.stackDiv.setAttribute('role', 'button');\n attributes = {};\n attributes.class = 'wrs_modal_maximize_button';\n attributes.id = this.getElementId(attributes.class);\n attributes.title = _core_src_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].getStringManager().getString('fullscreen');\n this.maximizeDiv = _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].createElement('a', attributes);\n this.maximizeDiv.setAttribute('role', 'button');\n attributes = {};\n attributes.class = 'wrs_modal_minimize_button';\n attributes.id = this.getElementId(attributes.class);\n attributes.title = _core_src_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].getStringManager().getString('minimise');\n this.minimizeDiv = _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].createElement('a', attributes);\n this.minimizeDiv.setAttribute('role', 'button');\n attributes = {};\n attributes.class = 'wrs_modal_dialogContainer';\n attributes.id = this.getElementId(attributes.class);\n this.container = _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].createElement('div', attributes);\n attributes = {};\n attributes.class = 'wrs_modal_wrapper';\n attributes.id = this.getElementId(attributes.class);\n this.wrapper = _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].createElement('div', attributes);\n attributes = {};\n attributes.class = 'wrs_content_container';\n attributes.id = this.getElementId(attributes.class);\n this.contentContainer = _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].createElement('div', attributes);\n attributes = {};\n attributes.class = 'wrs_modal_controls';\n attributes.id = this.getElementId(attributes.class);\n this.controls = _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].createElement('div', attributes);\n attributes = {};\n attributes.class = 'wrs_modal_buttons_container';\n attributes.id = this.getElementId(attributes.class);\n this.buttonContainer = _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].createElement('div', attributes); // Buttons: all button must be created using createSubmitButton method.\n\n this.submitButton = this.createSubmitButton({\n id: this.getElementId('wrs_modal_button_accept'),\n class: 'wrs_modal_button_accept',\n innerHTML: _core_src_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].getStringManager().getString('accept')\n }, this.submitAction.bind(this));\n this.cancelButton = this.createSubmitButton({\n id: this.getElementId('wrs_modal_button_cancel'),\n class: 'wrs_modal_button_cancel',\n innerHTML: _core_src_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].getStringManager().getString('cancel')\n }, this.cancelAction.bind(this));\n this.contentManager = null; // Overlay popup.\n\n var popupStrings = {\n 'cancelString': _core_src_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].getStringManager().getString('cancel'),\n 'submitString': _core_src_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].getStringManager().getString('close'),\n 'message': _core_src_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].getStringManager().getString('close_modal_warning')\n };\n var callbacks = {\n 'closeCallback': function () {\n this.close();\n }.bind(this),\n 'cancelCallback': function () {\n this.focus();\n }.bind(this)\n };\n var popupupProperties = {\n 'overlayElement': this.container,\n 'callbacks': callbacks,\n 'strings': popupStrings\n };\n this.popup = new _popupmessage_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"](popupupProperties);\n /**\r\n * Indicates if directionality of the modal dialog is RTL. false by default.\r\n * @type {boolean}\r\n */\n\n this.rtl = false;\n\n if ('rtl' in this.attributes) {\n this.rtl = this.attributes.rtl;\n } // Event handlers need modal instance context.\n\n\n this.handleOpenedIosSoftkeyboard = this.handleOpenedIosSoftkeyboard.bind(this);\n this.handleClosedIosSoftkeyboard = this.handleClosedIosSoftkeyboard.bind(this);\n }\n /**\r\n * This method sets an ContentManager instance to ModalDialog. ContentManager\r\n * manages the logic of ModalDialog content: submit, update, close and changes.\r\n * @param {ContentManager} contentManager - ContentManager instance.\r\n */\n\n\n _createClass(ModalDialog, [{\n key: \"setContentManager\",\n value: function setContentManager(contentManager) {\n this.contentManager = contentManager;\n }\n /**\r\n * Returns the modal contentElement object.\r\n * @returns {ContentManager} the instance of the ContentManager class.\r\n */\n\n }, {\n key: \"getContentManager\",\n value: function getContentManager() {\n return this.contentManager;\n }\n /**\r\n * This method is called when the modal object has been submitted. Calls\r\n * contentElement submitAction method - if exists - and closes the modal\r\n * object. No logic about the content should be placed here,\r\n * contentElement.submitAction is the responsible of the content logic.\r\n */\n\n }, {\n key: \"submitAction\",\n value: function submitAction() {\n if (typeof this.contentManager.submitAction !== 'undefined') {\n this.contentManager.submitAction();\n }\n\n this.close();\n }\n /**\r\n * This method is called when the modal object has been cancelled. If\r\n * contentElement has implemented hasChanges method, a confirm popup\r\n * will be shown if hasChanges returns true.\r\n */\n\n }, {\n key: \"cancelAction\",\n value: function cancelAction() {\n if (typeof this.contentManager.hasChanges === 'undefined') {\n this.close();\n } else if (!this.contentManager.hasChanges()) {\n this.close();\n } else {\n this.showPopUpMessage();\n }\n }\n /**\r\n * Returns a button element.\r\n * @param {Object} properties - input button properties.\r\n * @param {string} properties.class - input button class.\r\n * @param {string} properties.innerHTML - input button innerHTML.\r\n * @param {Object} callback - callback function associated to click event.\r\n * @returns {HTMLButtonElement} the button element.\r\n *\r\n */\n\n }, {\n key: \"createSubmitButton\",\n value: function createSubmitButton(properties, callback) {\n function SubmitButton(properties, callback) {\n this.element = document.createElement('button');\n this.element.id = properties.id;\n this.element.className = properties.class;\n this.element.innerHTML = properties.innerHTML;\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addEvent(this.element, 'click', callback);\n }\n\n SubmitButton.prototype.getElement = function () {\n return this.element;\n };\n\n return new SubmitButton(properties, callback).getElement();\n }\n /**\r\n * Creates the modal window object inserting a contentElement object.\r\n */\n\n }, {\n key: \"create\",\n value: function create() {\n /*Modal Window Structure\r\n _____________________________________________________________________________________\r\n |wrs_modal_dialog_Container |\r\n | _________________________________________________________________________________ |\r\n | |title_bar minimize_button stack_button close_button | |\r\n | |_______________________________________________________________________________| |\r\n | |wrapper | |\r\n | | _____________________________________________________________________________ | |\r\n | | |content | | |\r\n | | | | | |\r\n | | | | | |\r\n | | |___________________________________________________________________________| | |\r\n | | _____________________________________________________________________________ | |\r\n | | |controls | | |\r\n | | | ___________________________________ | | |\r\n | | | |buttonContainer | | | |\r\n | | | | _______________________________ | | | |\r\n | | | | |button_accept | button_cancel| | | | |\r\n | | | |_|_____________ |______________|_| | | |\r\n | | |___________________________________________________________________________| | |\r\n | |_______________________________________________________________________________| |\r\n |___________________________________________________________________________________|*/\n this.titleBar.appendChild(this.closeDiv);\n this.titleBar.appendChild(this.stackDiv);\n this.titleBar.appendChild(this.maximizeDiv);\n this.titleBar.appendChild(this.minimizeDiv);\n this.titleBar.appendChild(this.title);\n\n if (this.deviceProperties['isDesktop']) {\n this.container.appendChild(this.titleBar);\n }\n\n this.wrapper.appendChild(this.contentContainer);\n this.wrapper.appendChild(this.controls);\n this.controls.appendChild(this.buttonContainer);\n this.buttonContainer.appendChild(this.submitButton);\n this.buttonContainer.appendChild(this.cancelButton);\n this.container.appendChild(this.wrapper); // Check if browser has scrollBar before modal has modified.\n\n this.recalculateScrollBar();\n document.body.appendChild(this.container);\n document.body.appendChild(this.overlay);\n\n if (this.deviceProperties['isDesktop']) {\n // Desktop.\n this.createModalWindowDesktop();\n this.createResizeButtons();\n this.addListeners(); // Maximize window only when the configuration is set and the device is not iOS or Android.\n\n if (_configuration_js__WEBPACK_IMPORTED_MODULE_3__[\"default\"].get('modalWindowFullScreen')) {\n this.maximize();\n }\n } else if (this.deviceProperties['isAndroid']) {\n this.createModalWindowAndroid();\n } else if (this.deviceProperties['isIOS'] && !this.deviceProperties['isMobile']) {\n this.createModalWindowIos();\n }\n\n if (this.contentManager != null) {\n this.contentManager.insert(this);\n }\n\n this.properties.open = true;\n this.properties.created = true; // Checks language directionality.\n\n if (this.isRTL()) {\n this.container.style.right = window.innerWidth - this.scrollbarWidth - this.container.offsetWidth + 'px';\n this.container.className += ' wrs_modal_rtl';\n }\n }\n /**\r\n * Creates a button in the modal object to resize it.\r\n */\n\n }, {\n key: \"createResizeButtons\",\n value: function createResizeButtons() {\n // This is a definition of Resize Button Bottom-Right\n this.resizerBR = document.createElement('div');\n this.resizerBR.className = 'wrs_bottom_right_resizer';\n this.resizerBR.innerHTML = '◢'; // This is a definition of Resize Button Top-Left\n\n this.resizerTL = document.createElement('div');\n this.resizerTL.className = 'wrs_bottom_left_resizer'; // Append resize buttons to modal\n\n this.container.appendChild(this.resizerBR);\n this.titleBar.appendChild(this.resizerTL); // Add events to resize on click and drag\n\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addEvent(this.resizerBR, 'mousedown', this.activateResizeStateBR.bind(this));\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addEvent(this.resizerTL, 'mousedown', this.activateResizeStateTL.bind(this));\n }\n /**\r\n * Initialize variables for Bottom-Right resize button\r\n * @param {MouseEvent} mouseEvent - mouse event.\r\n */\n\n }, {\n key: \"activateResizeStateBR\",\n value: function activateResizeStateBR(mouseEvent) {\n this.initializeResizeProperties(mouseEvent, false);\n }\n /**\r\n * Initialize variables for Top-Left resize button\r\n * @param {MouseEvent} mouseEvent - mouse event.\r\n */\n\n }, {\n key: \"activateResizeStateTL\",\n value: function activateResizeStateTL(mouseEvent) {\n this.initializeResizeProperties(mouseEvent, true);\n }\n /**\r\n * Common method to initialize variables at resize\r\n * @param {MouseEvent} mouseEvent - mouse event.\r\n */\n\n }, {\n key: \"initializeResizeProperties\",\n value: function initializeResizeProperties(mouseEvent, leftOption) {\n // Apply class for disable involuntary select text when drag.\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addClass(document.body, 'wrs_noselect');\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addClass(this.overlay, 'wrs_overlay_active');\n this.resizeDataObject = {\n x: this.eventClient(mouseEvent).X,\n y: this.eventClient(mouseEvent).Y\n }; // Save Initial state of modal to compare on drag and obtain the difference.\n\n this.initialWidth = parseInt(this.container.style.width);\n this.initialHeight = parseInt(this.container.style.height);\n\n if (!leftOption) {\n this.initialRight = parseInt(this.container.style.right);\n this.initialBottom = parseInt(this.container.style.bottom);\n } else {\n this.leftScale = true;\n }\n\n if (!this.initialRight) {\n this.initialRight = 0;\n }\n\n if (!this.initialBottom) {\n this.initialBottom = 0;\n } // Disable mouse events on editor when we start to drag modal.\n\n\n document.body.style['user-select'] = 'none';\n }\n /**\r\n * This method opens the modal window, restoring the previous state, position and metrics,\r\n * if exists. By default the modal object opens in stack mode.\r\n */\n\n }, {\n key: \"open\",\n value: function open() {\n //Removing close class.\n this.removeClass('wrs_closed'); // Hiding keyboard for mobile devices.\n\n if (this.deviceProperties['isIOS'] || this.deviceProperties['isAndroid'] || this.deviceProperties['isMobile']) {\n // Restore scale to 1\n this.restoreWebsiteScale();\n this.blockWebsiteScroll(); // Due to editor wait we need to wait until editor focus.\n\n setTimeout(function () {\n this.hideKeyboard();\n }.bind(this), 400);\n } // New modal window. He need to create the whole object.\n\n\n if (!this.properties.created) {\n this.create();\n } else {\n // Previous state closed. Open method can be called even the previous state is open,\n // for example updating the content of the modal object.\n if (!this.properties.open) {\n this.properties.open = true; // Restoring the previous open state: if the modal object has been closed\n // re-open it should preserve the state and the metrics.\n\n if (!this.deviceProperties.isAndroid && !this.deviceProperties.isIOS) {\n this.restoreState();\n }\n } // Maximize window only when the configuration is set and the device is not iOs or Android.\n\n\n if (this.deviceProperties['isDesktop'] && _configuration_js__WEBPACK_IMPORTED_MODULE_3__[\"default\"].get('modalWindowFullScreen')) {\n this.maximize();\n } // In iOS we need to recalculate the size of the modal object because\n // iOS keyboard is a float div which can overlay the modal object.\n\n\n if (this.deviceProperties['isIOS']) {\n this.iosSoftkeyboardOpened = false;\n this.setContainerHeight(\"100\" + this.iosMeasureUnit);\n }\n }\n\n if (this.contentManager.isEditorLoaded === false) {\n var listener = _listeners__WEBPACK_IMPORTED_MODULE_4__[\"default\"].newListener('onLoad', function () {\n this.contentManager.onOpen(this);\n }.bind(this));\n this.contentManager.addListener(listener);\n } else {\n this.contentManager.onOpen(this);\n }\n }\n /**\r\n * Closes modal window and restores viewport header.\r\n */\n\n }, {\n key: \"close\",\n value: function close() {\n this.removeClass('wrs_maximized');\n this.removeClass('wrs_minimized');\n this.removeClass('wrs_stack');\n this.addClass('wrs_closed');\n this.saveModalProperties();\n this.unblockWebsiteScroll();\n this.properties.open = false;\n }\n /**\r\n * Sets the website scale to one.\r\n */\n\n }, {\n key: \"restoreWebsiteScale\",\n value: function restoreWebsiteScale() {\n var viewportmeta = document.querySelector('meta[name=viewport]'); // Let the equal symbols in order to search and make meta's final content.\n\n var contentAttrsToUpdate = ['initial-scale=', 'minimum-scale=', 'maximum-scale='];\n var contentAttrsValuesToUpdate = ['1.0', '1.0', '1.0'];\n\n var setMetaAttrFunc = function setMetaAttrFunc(viewportelement, contentAttrsToUpdate) {\n var contentAttr = viewportelement.getAttribute('content'); // If it exists, we need to maintain old values and put our values.\n\n if (contentAttr) {\n var attrArray = contentAttr.split(',');\n var finalContentMeta = \"\";\n var oldAttrs = [];\n\n for (var i = 0; i < attrArray.length; i++) {\n var isAttrToUpdate = false;\n var j = 0;\n\n while (!isAttrToUpdate && j < contentAttrsToUpdate.length) {\n if (attrArray[i].indexOf(contentAttrsToUpdate[j])) {\n isAttrToUpdate = true;\n }\n\n j++;\n }\n\n if (!isAttrToUpdate) {\n oldAttrs.push(attrArray[i]);\n }\n }\n\n for (var _i = 0; _i < contentAttrsToUpdate.length; _i++) {\n var attr = contentAttrsToUpdate[_i] + contentAttrsValuesToUpdate[_i];\n finalContentMeta += _i == 0 ? attr : ',' + attr;\n }\n\n for (var _i2 = 0; _i2 < oldAttrs.length; _i2++) {\n finalContentMeta += ',' + oldAttrs[_i2];\n }\n\n viewportelement.setAttribute('content', finalContentMeta);\n viewportelement.setAttribute('content', contentAttr);\n } else {\n viewportelement.setAttribute('content', 'initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0');\n viewportelement.removeAttribute('content');\n }\n };\n\n if (!viewportmeta) {\n viewportmeta = document.createElement('meta');\n document.getElementsByTagName('head')[0].appendChild(viewportmeta);\n setMetaAttrFunc(viewportmeta, contentAttrsToUpdate, contentAttrsValuesToUpdate);\n viewportmeta.remove();\n } else {\n setMetaAttrFunc(viewportmeta, contentAttrsToUpdate, contentAttrsValuesToUpdate);\n }\n }\n /**\r\n * Adds an event to avoid touch scrolling.\r\n */\n\n }, {\n key: \"blockWebsiteScroll\",\n value: function blockWebsiteScroll() {\n document.body.addEventListener('touchmove', this.disableTouchMove, {\n passive: false\n });\n }\n /**\r\n * Removes the event to avoid touch scrolling.\r\n */\n\n }, {\n key: \"unblockWebsiteScroll\",\n value: function unblockWebsiteScroll() {\n document.body.removeEventListener('touchmove', this.disableTouchMove, {\n passive: false\n });\n }\n /**\r\n * Prevents the default event behavior to a MouseEvent.\r\n * @param {MouseEvent} mouseEvent - mouse event.\r\n */\n\n }, {\n key: \"disableTouchMove\",\n value: function disableTouchMove(mouseEvent) {\n mouseEvent.preventDefault();\n }\n /**\r\n * Util function to known if browser is IE11.\r\n * @returns {boolean} true if the browser is IE11. false otherwise.\r\n */\n\n }, {\n key: \"isIE11\",\n value: function isIE11() {\n if (navigator.userAgent.search(\"Msie/\") >= 0 || navigator.userAgent.search(\"Trident/\") >= 0 || navigator.userAgent.search(\"Edge/\") >= 0) {\n return true;\n }\n\n return false;\n }\n /**\r\n * Returns if the current language type is RTL.\r\n * @return {boolean} true if current language is RTL. false otherwise.\r\n */\n\n }, {\n key: \"isRTL\",\n value: function isRTL() {\n if (this.attributes.language == 'ar' || this.attributes.language == 'he') {\n return true;\n } else {\n return this.rtl;\n }\n\n ;\n }\n /**\r\n * Adds a class to all modal ModalDialog DOM elements.\r\n * @param {string} className - class name.\r\n */\n\n }, {\n key: \"addClass\",\n value: function addClass(className) {\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addClass(this.overlay, className);\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addClass(this.titleBar, className);\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addClass(this.overlay, className);\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addClass(this.container, className);\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addClass(this.contentContainer, className);\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addClass(this.stackDiv, className);\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addClass(this.minimizeDiv, className);\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addClass(this.maximizeDiv, className);\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addClass(this.wrapper, className);\n }\n /**\r\n * Remove a class from all modal DOM elements.\r\n * @param {string} className - class name.\r\n */\n\n }, {\n key: \"removeClass\",\n value: function removeClass(className) {\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].removeClass(this.overlay, className);\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].removeClass(this.titleBar, className);\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].removeClass(this.overlay, className);\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].removeClass(this.container, className);\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].removeClass(this.contentContainer, className);\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].removeClass(this.stackDiv, className);\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].removeClass(this.minimizeDiv, className);\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].removeClass(this.maximizeDiv, className);\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].removeClass(this.wrapper, className);\n }\n /**\r\n * Create modal dialog for desktop.\r\n */\n\n }, {\n key: \"createModalWindowDesktop\",\n value: function createModalWindowDesktop() {\n this.addClass('wrs_modal_desktop');\n this.stack();\n }\n /**\r\n * Create modal dialog for non android devices.\r\n */\n\n }, {\n key: \"createModalWindowAndroid\",\n value: function createModalWindowAndroid() {\n this.addClass('wrs_modal_android');\n window.addEventListener('resize', this.orientationChangeAndroidSoftkeyboard.bind(this));\n }\n /**\r\n * Create modal dialog for iOS devices.\r\n */\n\n }, {\n key: \"createModalWindowIos\",\n value: function createModalWindowIos() {\n this.addClass('wrs_modal_ios'); // Refresh the size when the orientation is changed\n\n window.addEventListener('resize', this.orientationChangeIosSoftkeyboard.bind(this));\n }\n /**\r\n * Restore previous state, position and size of previous stacked modal dialog.\r\n */\n\n }, {\n key: \"restoreState\",\n value: function restoreState() {\n if (this.properties.state == 'maximized') {\n // Reset states for prevent return to stack state.\n this.maximize();\n } else if (this.properties.state == 'minimized') {\n // Reset states for prevent return to stack state.\n this.properties.state = this.properties.previousState;\n this.properties.previousState = '';\n this.minimize();\n } else {\n this.stack();\n }\n }\n /**\r\n * Stacks the modal object.\r\n */\n\n }, {\n key: \"stack\",\n value: function stack() {\n this.properties.previousState = this.properties.state;\n this.properties.state = 'stack';\n this.removeClass('wrs_maximized');\n this.minimizeDiv.title = \"Minimise\";\n this.removeClass('wrs_minimized');\n this.addClass('wrs_stack');\n this.restoreModalProperties();\n\n if (typeof this.resizerBR !== 'undefined' && typeof this.resizerTL !== 'undefined') {\n this.setResizeButtonsVisibility();\n } // Need recalculate position of actual modal because window can was changed in fullscreenmode\n\n\n this.recalculateScrollBar();\n this.recalculatePosition();\n this.recalculateScale();\n this.focus();\n }\n /**\r\n * Minimizes the modal object\r\n */\n\n }, {\n key: \"minimize\",\n value: function minimize() {\n // Saving width, height, top and bottom parameters to restore when open\n this.saveModalProperties();\n\n if (this.properties.state == 'minimized' && this.properties.previousState == 'stack') {\n this.stack();\n } else if (this.properties.state == 'minimized' && this.properties.previousState == 'maximized') {\n this.maximize();\n } else {\n // Setting css to prevent important tag into css style\n this.container.style.height = \"30px\";\n this.container.style.width = \"250px\";\n this.container.style.bottom = \"0px\";\n this.container.style.right = \"10px\";\n this.removeListeners();\n this.properties.previousState = this.properties.state;\n this.properties.state = \"minimized\";\n this.setResizeButtonsVisibility();\n this.minimizeDiv.title = \"Maximise\";\n\n if (_util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].containsClass(this.overlay, 'wrs_stack')) {\n this.removeClass('wrs_stack');\n } else {\n this.removeClass('wrs_maximized');\n }\n\n this.addClass('wrs_minimized');\n }\n }\n /**\r\n * Maximizes the modal object.\r\n */\n\n }, {\n key: \"maximize\",\n value: function maximize() {\n // Saving width, height, top and bottom parameters to restore when open\n this.saveModalProperties();\n\n if (this.properties.state != 'maximized') {\n this.properties.previousState = this.properties.state;\n this.properties.state = 'maximized';\n } // Don't permit resize on maximize mode.\n\n\n this.setResizeButtonsVisibility();\n\n if (_util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].containsClass(this.overlay, 'wrs_minimized')) {\n this.minimizeDiv.title = \"Minimise\";\n this.removeClass('wrs_minimized');\n } else if (_util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].containsClass(this.overlay, 'wrs_stack')) {\n this.container.style.left = null;\n this.container.style.top = null;\n this.removeClass('wrs_stack');\n }\n\n this.addClass('wrs_maximized'); // Set size to 80% screen with a max size.\n\n this.setSize(parseInt(window.innerHeight * 0.8), parseInt(window.innerWidth * 0.8));\n var sizeModificated = false;\n\n if (this.container.clientHeight > 700) {\n this.container.style.height = '700px';\n sizeModificated = true;\n }\n\n if (this.container.clientWidth > 1200) {\n this.container.style.width = '1200px';\n sizeModificated = true;\n } // Setting modal position in center on screen.\n\n\n this.setPosition(window.innerHeight / 2 - this.container.offsetHeight / 2, window.innerWidth / 2 - this.container.offsetWidth / 2);\n this.recalculateScale();\n this.recalculatePosition();\n this.recalculateSize();\n this.focus();\n }\n /**\r\n * Sets modal size.\r\n * @param {number} height - height of the ModalDialog\r\n * @param {number} width - width of the ModalDialog.\r\n */\n\n }, {\n key: \"setSize\",\n value: function setSize(height, width) {\n this.container.style.height = height + 'px';\n this.container.style.width = width + 'px';\n this.recalculateSize();\n }\n /**\r\n * Sets modal position using bottom and right style attributes.\r\n * @param {number} bottom - bottom attribute.\r\n * @param {number} right - right attribute.\r\n */\n\n }, {\n key: \"setPosition\",\n value: function setPosition(bottom, right) {\n this.container.style.bottom = bottom + 'px';\n this.container.style.right = right + 'px';\n }\n /**\r\n * Saves position and size parameters of and open ModalDialog. This attributes\r\n * are needed to restore it on re-open.\r\n */\n\n }, {\n key: \"saveModalProperties\",\n value: function saveModalProperties() {\n // Saving values of modal only when modal is in stack state.\n if (this.properties.state == 'stack') {\n this.properties.position.bottom = parseInt(this.container.style.bottom);\n this.properties.position.right = parseInt(this.container.style.right);\n this.properties.size.width = parseInt(this.container.style.width);\n this.properties.size.height = parseInt(this.container.style.height);\n }\n }\n /**\r\n * Restore ModalDialog position and size parameters.\r\n */\n\n }, {\n key: \"restoreModalProperties\",\n value: function restoreModalProperties() {\n if (this.properties.state == 'stack') {\n // Restoring Bottom and Right values from last modal\n this.setPosition(this.properties.position.bottom, this.properties.position.right); // Restoring Height and Left values from last modal\n\n this.setSize(this.properties.size.height, this.properties.size.width);\n }\n }\n /**\r\n * Sets the modal dialog initial size.\r\n */\n\n }, {\n key: \"recalculateSize\",\n value: function recalculateSize() {\n this.wrapper.style.width = this.container.clientWidth - 12 + 'px';\n this.wrapper.style.height = this.container.clientHeight - 38 + 'px';\n this.contentContainer.style.height = parseInt(this.wrapper.offsetHeight - 50) + 'px';\n }\n /**\r\n * Enable or disable visibility of resize buttons in modal window depend on state.\r\n */\n\n }, {\n key: \"setResizeButtonsVisibility\",\n value: function setResizeButtonsVisibility() {\n if (this.properties.state == 'stack') {\n this.resizerTL.style.visibility = 'visible';\n this.resizerBR.style.visibility = 'visible';\n } else {\n this.resizerTL.style.visibility = 'hidden';\n this.resizerBR.style.visibility = 'hidden';\n }\n }\n /**\r\n * Makes an object draggable adding mouse and touch events.\r\n */\n\n }, {\n key: \"addListeners\",\n value: function addListeners() {\n // Button events (maximize, minimize, stack and close).\n this.maximizeDiv.addEventListener('click', this.maximize.bind(this), true);\n this.stackDiv.addEventListener('click', this.stack.bind(this), true);\n this.minimizeDiv.addEventListener('click', this.minimize.bind(this), true);\n this.closeDiv.addEventListener('click', this.cancelAction.bind(this)); // Mouse events.\n\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addEvent(window, 'mousedown', this.startDrag.bind(this));\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addEvent(window, 'mouseup', this.stopDrag.bind(this));\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addEvent(window, 'mousemove', this.drag.bind(this));\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addEvent(window, 'resize', this.onWindowResize.bind(this)); // Key events.\n\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addEvent(window, 'keydown', this.onKeyDown.bind(this));\n }\n /**\r\n * Removes draggable events from an object.\r\n */\n\n }, {\n key: \"removeListeners\",\n value: function removeListeners() {\n // Mouse events.\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].removeEvent(window, 'mousedown', this.startDrag);\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].removeEvent(window, 'mouseup', this.stopDrag);\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].removeEvent(window, 'mousemove', this.drag);\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].removeEvent(window, 'resize', this.onWindowResize); // Key events\n\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].removeEvent(window, 'keydown', this.onKeyDown);\n }\n /**\r\n * Returns mouse or touch coordinates (on touch events ev.ClientX doesn't exists)\r\n * @param {MouseEvent} mouseEvent - mouse event.\r\n * @return {Object} with the X and Y coordinates.\r\n */\n\n }, {\n key: \"eventClient\",\n value: function eventClient(mouseEvent) {\n if (typeof mouseEvent.clientX == 'undefined' && mouseEvent.changedTouches) {\n var client = {\n X: mouseEvent.changedTouches[0].clientX,\n Y: mouseEvent.changedTouches[0].clientY\n };\n return client;\n } else {\n client = {\n X: mouseEvent.clientX,\n Y: mouseEvent.clientY\n };\n return client;\n }\n }\n /**\r\n * Start drag function: set the object dragDataObject with the draggable object offsets coordinates.\r\n * when drag starts (on touchstart or mousedown events).\r\n * @param {MouseEvent} mouseEvent - touchstart or mousedown event.\r\n */\n\n }, {\n key: \"startDrag\",\n value: function startDrag(mouseEvent) {\n if (this.properties.state == 'minimized') {\n return;\n }\n\n if (mouseEvent.target === this.title) {\n if (typeof this.dragDataObject === 'undefined' || this.dragDataObject === null) {\n mouseEvent = mouseEvent || event; // Save first click mouse point on screen\n\n this.dragDataObject = {\n x: this.eventClient(mouseEvent).X,\n y: this.eventClient(mouseEvent).Y\n }; // Reset last drag position when start drag\n\n this.lastDrag = {\n x: \"0px\",\n y: \"0px\"\n }; // Init right and bottom values for window modal if it isn't exist.\n\n if (this.container.style.right == '') {\n this.container.style.right = \"0px\";\n }\n\n if (this.container.style.bottom == '') {\n this.container.style.bottom = \"0px\";\n } // Needed for IE11 for apply disabled mouse events on editor because iexplorer need a dinamic object to apply this property.\n\n\n if (this.isIE11()) {} // this.iframe.style['position'] = 'relative';\n // Apply class for disable involuntary select text when drag.\n\n\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addClass(document.body, 'wrs_noselect');\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addClass(this.overlay, 'wrs_overlay_active'); // Obtain screen limits for prevent overflow.\n\n this.limitWindow = this.getLimitWindow();\n }\n }\n }\n /**\r\n * Updates dragDataObject with the draggable object coordinates when the draggable object is being moved.\r\n * @param {MouseEvent} mouseEvent - the mouse event.\r\n */\n\n }, {\n key: \"drag\",\n value: function drag(mouseEvent) {\n if (this.dragDataObject) {\n mouseEvent.preventDefault();\n mouseEvent = mouseEvent || event; // Calculate max and min between actual mouse position and limit of screeen. It restric the movement of modal into window.\n\n var limitY = Math.min(this.eventClient(mouseEvent).Y, this.limitWindow.minPointer.y);\n limitY = Math.max(this.limitWindow.maxPointer.y, limitY);\n var limitX = Math.min(this.eventClient(mouseEvent).X, this.limitWindow.minPointer.x);\n limitX = Math.max(this.limitWindow.maxPointer.x, limitX); // Substract limit with first position to obtain relative pixels increment to the anchor point.\n\n var dragX = limitX - this.dragDataObject.x + \"px\";\n var dragY = limitY - this.dragDataObject.y + \"px\"; // Save last valid position of modal before window overflow.\n\n this.lastDrag = {\n x: dragX,\n y: dragY\n }; // This move modal with hadware acceleration.\n\n this.container.style.transform = \"translate3d(\" + dragX + \",\" + dragY + \",0)\";\n }\n\n if (this.resizeDataObject) {\n var limitX = Math.min(this.eventClient(mouseEvent).X, window.innerWidth - this.scrollbarWidth - 7);\n var limitY = Math.min(this.eventClient(mouseEvent).Y, window.innerHeight - 7);\n\n if (limitX < 0) {\n limitX = 0;\n }\n\n if (limitY < 0) {\n limitY = 0;\n }\n\n var scaleMultiplier;\n\n if (this.leftScale) {\n scaleMultiplier = -1;\n } else {\n scaleMultiplier = 1;\n }\n\n this.container.style.width = this.initialWidth + scaleMultiplier * (limitX - this.resizeDataObject.x) + 'px';\n this.container.style.height = this.initialHeight + scaleMultiplier * (limitY - this.resizeDataObject.y) + 'px';\n\n if (!this.leftScale) {\n if (this.resizeDataObject.x - limitX - this.initialWidth < -580) {\n this.container.style.right = this.initialRight - (limitX - this.resizeDataObject.x) + 'px';\n } else {\n this.container.style.right = this.initialRight + this.initialWidth - 580 + \"px\";\n this.container.style.width = \"580px\";\n }\n\n if (this.resizeDataObject.y - limitY < this.initialHeight - 338) {\n this.container.style.bottom = this.initialBottom - (limitY - this.resizeDataObject.y) + 'px';\n } else {\n this.container.style.bottom = this.initialBottom + this.initialHeight - 338 + \"px\";\n this.container.style.height = \"338px\";\n }\n }\n\n this.recalculateScale();\n this.recalculatePosition();\n }\n }\n /**\r\n * Returns the boundaries of actual window to limit modal movement.\r\n * @return {Object} Object containing mouseX and mouseY coordinates of actual mouse on screen.\r\n */\n\n }, {\n key: \"getLimitWindow\",\n value: function getLimitWindow() {\n // Obtain dimensions of window page.\n var maxWidth = window.innerWidth;\n var maxHeight = window.innerHeight; // Calculate relative position of mouse point into window.\n\n var offSetToolbarY = this.container.offsetHeight + parseInt(this.container.style.bottom) - (maxHeight - (this.dragDataObject.y - window.pageXOffset));\n var offSetToolbarX = maxWidth - this.scrollbarWidth - (this.dragDataObject.x - window.pageXOffset) - parseInt(this.container.style.right); // Calculate limits with sizes of window, modal and mouse position.\n\n var minPointerY = maxHeight - this.container.offsetHeight + offSetToolbarY;\n var maxPointerY = this.title.offsetHeight - (this.title.offsetHeight - offSetToolbarY);\n var minPointerX = maxWidth - offSetToolbarX - this.scrollbarWidth;\n var maxPointerX = this.container.offsetWidth - offSetToolbarX;\n var minPointer = {\n x: minPointerX,\n y: minPointerY\n };\n var maxPointer = {\n x: maxPointerX,\n y: maxPointerY\n };\n return {\n minPointer: minPointer,\n maxPointer: maxPointer\n };\n }\n /**\r\n * Returns the scrollbar width size of browser\r\n * @returns {number} the scrollbar width.\r\n */\n\n }, {\n key: \"getScrollBarWidth\",\n value: function getScrollBarWidth() {\n // Create a paragraph with full width of page.\n var inner = document.createElement('p');\n inner.style.width = \"100%\";\n inner.style.height = \"200px\"; // Create a hidden div to compare sizes.\n\n var outer = document.createElement('div');\n outer.style.position = \"absolute\";\n outer.style.top = \"0px\";\n outer.style.left = \"0px\";\n outer.style.visibility = \"hidden\";\n outer.style.width = \"200px\";\n outer.style.height = \"150px\";\n outer.style.overflow = \"hidden\";\n outer.appendChild(inner);\n document.body.appendChild(outer);\n var widthOuter = inner.offsetWidth; // Change type overflow of paragraph for measure scrollbar.\n\n outer.style.overflow = 'scroll';\n var widthInner = inner.offsetWidth; // If measure is the same, we compare with internal div.\n\n if (widthOuter == widthInner) {\n widthInner = outer.clientWidth;\n }\n\n document.body.removeChild(outer);\n return widthOuter - widthInner;\n }\n /**\r\n * Set the dragDataObject to null.\r\n */\n\n }, {\n key: \"stopDrag\",\n value: function stopDrag() {\n // Due to we have multiple events that call this function, we need only to execute the next modifiers one time,\n // when the user stops to drag and dragDataObject is not null (the object to drag is attached).\n if (this.dragDataObject || this.resizeDataObject) {\n // If modal doesn't change, it's not necessary to set position with interpolation\n this.container.style.transform = '';\n\n if (this.dragDataObject) {\n this.container.style.right = parseInt(this.container.style.right) - parseInt(this.lastDrag.x) + \"px\";\n this.container.style.bottom = parseInt(this.container.style.bottom) - parseInt(this.lastDrag.y) + \"px\";\n } // We make focus on editor after drag modal windows to prevent lose focus.\n\n\n this.focus(); // Restore mouse events on iframe\n // this.iframe.style['pointer-events'] = 'auto';\n\n document.body.style['user-select'] = ''; // Restore static state of iframe if we use Internet Explorer.\n\n if (this.isIE11()) {} // this.iframe.style['position'] = null;\n // Active text select event\n\n\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].removeClass(document.body, 'wrs_noselect');\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].removeClass(this.overlay, 'wrs_overlay_active');\n }\n\n this.dragDataObject = null;\n this.resizeDataObject = null;\n this.initialWidth = null;\n this.leftScale = null;\n }\n /**\r\n * Recalculates scale for modal when resize browser window.\r\n */\n\n }, {\n key: \"onWindowResize\",\n value: function onWindowResize() {\n this.recalculateScrollBar();\n this.recalculatePosition();\n this.recalculateScale();\n }\n /**\r\n * Triggers keyboard events:\r\n * - Tab key tab to go to submit button.\r\n * - Esc key to close the modal dialog.\r\n * @param {KeyboardEvent} keyboardEvent - the keyboard event.\r\n */\n\n }, {\n key: \"onKeyDown\",\n value: function onKeyDown(keyboardEvent) {\n if (keyboardEvent.key !== undefined && keyboardEvent.repeat === false) {\n // Code for detect Esc event\n if (keyboardEvent.key === \"Escape\" || keyboardEvent.key === 'Esc') {\n if (this.properties.open) {\n this.cancelAction();\n }\n } // Code for detect Tab event\n\n\n if (keyboardEvent.key === \"Tab\") {\n this.submitButton.focus();\n keyboardEvent.preventDefault();\n }\n }\n }\n /**\r\n * Recalculating position for modal dialog when the browser is resized.\r\n */\n\n }, {\n key: \"recalculatePosition\",\n value: function recalculatePosition() {\n this.container.style.right = Math.min(parseInt(this.container.style.right), window.innerWidth - this.scrollbarWidth - this.container.offsetWidth) + \"px\";\n\n if (parseInt(this.container.style.right) < 0) {\n this.container.style.right = \"0px\";\n }\n\n this.container.style.bottom = Math.min(parseInt(this.container.style.bottom), window.innerHeight - this.container.offsetHeight) + \"px\";\n\n if (parseInt(this.container.style.bottom) < 0) {\n this.container.style.bottom = \"0px\";\n }\n }\n /**\r\n * Recalculating scale for modal when the browser is resized.\r\n */\n\n }, {\n key: \"recalculateScale\",\n value: function recalculateScale() {\n var sizeModificated = false;\n\n if (parseInt(this.container.style.width) > 580) {\n this.container.style.width = Math.min(parseInt(this.container.style.width), window.innerWidth - this.scrollbarWidth) + \"px\";\n sizeModificated = true;\n } else {\n this.container.style.width = \"580px\";\n sizeModificated = true;\n }\n\n if (parseInt(this.container.style.height) > 338) {\n this.container.style.height = Math.min(parseInt(this.container.style.height), window.innerHeight) + \"px\";\n sizeModificated = true;\n } else {\n this.container.style.height = \"338px\";\n sizeModificated = true;\n }\n\n if (sizeModificated) {\n this.recalculateSize();\n }\n }\n /**\r\n * Recalculating width of browser scroll bar.\r\n */\n\n }, {\n key: \"recalculateScrollBar\",\n value: function recalculateScrollBar() {\n this.hasScrollBar = window.innerWidth > document.documentElement.clientWidth;\n\n if (this.hasScrollBar) {\n this.scrollbarWidth = this.getScrollBarWidth();\n } else {\n this.scrollbarWidth = 0;\n }\n }\n /**\r\n * Hide soft keyboards on iOS devices.\r\n */\n\n }, {\n key: \"hideKeyboard\",\n value: function hideKeyboard() {\n document.activeElement.blur();\n }\n /**\r\n * Focus to contentManager object.\r\n */\n\n }, {\n key: \"focus\",\n value: function focus() {\n if (this.contentManager != null && typeof this.contentManager.onFocus !== 'undefined') {\n this.contentManager.onFocus();\n }\n }\n /**\r\n * Returns true when the device is on portrait mode.\r\n */\n\n }, {\n key: \"portraitMode\",\n value: function portraitMode() {\n return window.innerHeight > window.innerWidth;\n }\n /**\r\n * Event handler that change container size when IOS softkeyboard is opened.\r\n */\n\n }, {\n key: \"handleOpenedIosSoftkeyboard\",\n value: function handleOpenedIosSoftkeyboard() {\n if (!this.iosSoftkeyboardOpened && this.iosDivHeight != null && this.iosDivHeight == \"100\" + this.iosMeasureUnit) {\n if (this.portraitMode()) {\n this.setContainerHeight(\"63\" + this.iosMeasureUnit);\n } else {\n this.setContainerHeight(\"40\" + this.iosMeasureUnit);\n }\n }\n\n this.iosSoftkeyboardOpened = true;\n }\n /**\r\n * Event handler that change container size when IOS softkeyboard is closed.\r\n */\n\n }, {\n key: \"handleClosedIosSoftkeyboard\",\n value: function handleClosedIosSoftkeyboard() {\n this.iosSoftkeyboardOpened = false;\n this.setContainerHeight(\"100\" + this.iosMeasureUnit);\n }\n /**\r\n * Change container sizes when orientation is changed on iOS.\r\n */\n\n }, {\n key: \"orientationChangeIosSoftkeyboard\",\n value: function orientationChangeIosSoftkeyboard() {\n if (this.iosSoftkeyboardOpened) {\n if (this.portraitMode()) {\n this.setContainerHeight(\"63\" + this.iosMeasureUnit);\n } else {\n this.setContainerHeight(\"40\" + this.iosMeasureUnit);\n }\n } else {\n this.setContainerHeight(\"100\" + this.iosMeasureUnit);\n }\n }\n /**\r\n * Change container sizes when orientation is changed on Android.\r\n */\n\n }, {\n key: \"orientationChangeAndroidSoftkeyboard\",\n value: function orientationChangeAndroidSoftkeyboard() {\n this.setContainerHeight(\"100%\");\n }\n /**\r\n * Set iframe container height.\r\n * @param {number} height - new height.\r\n */\n\n }, {\n key: \"setContainerHeight\",\n value: function setContainerHeight(height) {\n this.iosDivHeight = height;\n this.wrapper.style.height = height;\n }\n /**\r\n * Check content of editor before close action.\r\n */\n\n }, {\n key: \"showPopUpMessage\",\n value: function showPopUpMessage() {\n if (this.properties.state == 'minimized') {\n this.stack();\n }\n\n this.popup.show();\n }\n /**\r\n * Sets the tithle of the modal dialog.\r\n * @param {string} title - modal dialog title.\r\n */\n\n }, {\n key: \"setTitle\",\n value: function setTitle(title) {\n this.title.innerHTML = title;\n }\n /**\r\n * Returns the id of an element, adding the instance number to\r\n * the element class name:\r\n * className --> className[idNumber]\r\n * @param {string} className - the element class name.\r\n * @returns {string} a string appending the instance id to the className.\r\n */\n\n }, {\n key: \"getElementId\",\n value: function getElementId(className) {\n return className + \"[\" + this.instanceId + \"]\";\n }\n }]);\n\n return ModalDialog;\n}();\n\n\n\n//# sourceURL=webpack:///./core/src/modal.js?"); /***/ }), @@ -310,7 +310,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) * /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"default\", function() { return Parser; });\n/* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./util */ \"./core/src/util.js\");\n/* harmony import */ var _core_src__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./core.src */ \"./core/src/core.src.js\");\n/* harmony import */ var _latex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./latex */ \"./core/src/latex.js\");\n/* harmony import */ var _mathml__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./mathml */ \"./core/src/mathml.js\");\n/* harmony import */ var _image__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./image */ \"./core/src/image.js\");\n/* harmony import */ var _accessibility__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./accessibility */ \"./core/src/accessibility.js\");\n/* harmony import */ var _serviceprovider__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./serviceprovider */ \"./core/src/serviceprovider.js\");\n/* harmony import */ var _configuration__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./configuration */ \"./core/src/configuration.js\");\n/* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./constants */ \"./core/src/constants.js\");\n/* harmony import */ var _md5__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./md5 */ \"./core/src/md5.js\");\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\n\n\n\n\n\n\n\n\n\n\n/**\r\n * This class represent a MahML parser. Converts MathML into formulas depending on the\r\n * image format (SVG, PNG, base64) and the save mode (XML, safeXML, Image) configured in the backend.\r\n */\n\nvar Parser =\n/*#__PURE__*/\nfunction () {\n function Parser() {\n _classCallCheck(this, Parser);\n }\n\n _createClass(Parser, null, [{\n key: \"mathmlToImgObject\",\n\n /**\r\n * Converts a MathML string to an img element.\r\n * @param {Document} creator - Document object to call createElement method.\r\n * @param {string} mathml - MathML code\r\n * @param {Object[]} wirisProperties - object containing WIRIS custom properties\r\n * @param {language} language - custom language for accessibility.\r\n * @returns {HTMLImageElement} the formula image corresponding to initial MathML string.\r\n * @static\r\n */\n value: function mathmlToImgObject(creator, mathml, wirisProperties, language) {\n var width;\n var height;\n var baseline;\n var imgObject = creator.createElement('img');\n imgObject.align = 'middle';\n imgObject.style.maxWidth = 'none';\n var data = wirisProperties ? wirisProperties : {};\n data['mml'] = mathml;\n data['lang'] = language; // Request metrics of the generated image.\n\n data['metrics'] = 'true';\n data['centerbaseline'] = 'false'; // Full base64 method (edit & save).\n\n if (_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('saveMode') == 'base64' && _configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('editMode') == 'default') {\n data['base64'] = true;\n } // Render js params: _wrs_int_wirisProperties contains some js render params. Since mathml can support render params, js params should be send only to editor, not to render.\n\n\n imgObject.className = _configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('imageClassName');\n\n if (mathml.indexOf('class=\"') != -1) {\n // We check here if the MathML has been created from a customEditor (such chemistry)\n // to add data-custom-editor attribute to img object (if necessary).\n var mathmlSubstring = mathml.substring(mathml.indexOf('class=\"') + 'class=\"'.length, mathml.length);\n mathmlSubstring = mathmlSubstring.substring(0, mathmlSubstring.indexOf('\"'));\n mathmlSubstring = mathmlSubstring.substring(4, mathmlSubstring.length);\n imgObject.setAttribute('data-custom-editor', mathmlSubstring);\n } // Performance enabled.\n\n\n if (_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('wirisPluginPerformance') && (_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('saveMode') == 'xml' || _configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('saveMode') == 'safeXml')) {\n var result = JSON.parse(Parser.createShowImageSrc(data, language));\n\n if (result[\"status\"] == 'warning') {\n // POST call.\n // if the mathml is malformed, this function will throw an exception.\n try {\n result = JSON.parse(_serviceprovider__WEBPACK_IMPORTED_MODULE_6__[\"default\"].getService('showimage', data));\n } catch (e) {\n return;\n }\n }\n\n result = result.result;\n\n if (result['format'] == 'png') {\n imgObject.src = 'data:image/png;base64,' + result['content'];\n } else {\n imgObject.src = 'data:image/svg+xml;charset=utf8,' + _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].urlEncode(result['content']);\n }\n\n imgObject.setAttribute(_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('imageMathmlAttribute'), _mathml__WEBPACK_IMPORTED_MODULE_3__[\"default\"].safeXmlEncode(mathml));\n _image__WEBPACK_IMPORTED_MODULE_4__[\"default\"].setImgSize(imgObject, result['content'], true);\n\n if (_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('enableAccessibility')) {\n if (typeof result.alt == 'undefined') {\n imgObject.alt = _accessibility__WEBPACK_IMPORTED_MODULE_5__[\"default\"].mathMLToAccessible(mathml, language, data);\n } else {\n imgObject.alt = result.alt;\n }\n }\n } else {\n var result = Parser.createImageSrc(mathml, data);\n imgObject.setAttribute(_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('imageMathmlAttribute'), _mathml__WEBPACK_IMPORTED_MODULE_3__[\"default\"].safeXmlEncode(mathml));\n imgObject.src = result;\n _image__WEBPACK_IMPORTED_MODULE_4__[\"default\"].setImgSize(imgObject, result, _configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('saveMode') == 'base64' && _configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('editMode') == 'default' ? true : false);\n\n if (_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('enableAccessibility')) {\n imgObject.alt = _accessibility__WEBPACK_IMPORTED_MODULE_5__[\"default\"].mathMLToAccessible(mathml, language, data);\n }\n }\n\n if (typeof Parser.observer != 'undefined') {\n Parser.observer.observe(imgObject);\n } // Role math https://www.w3.org/TR/wai-aria/roles#math.\n\n\n imgObject.setAttribute('role', 'math');\n return imgObject;\n }\n /**\r\n * Returns the source to showimage service by calling createimage service. The\r\n * output of the createimage service is a URL path pointing to showimage service.\r\n * This method is called when performance is disabled.\r\n * @param {string} mathml - MathML code.\r\n * @param {Object[]} data - data object containing service parameters.\r\n * @returns {string} the showimage path.\r\n */\n\n }, {\n key: \"createImageSrc\",\n value: function createImageSrc(mathml, data) {\n // Full base64 method (edit & save).\n if (_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('saveMode') == 'base64' && _configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('editMode') == 'default') {\n data['base64'] = true;\n }\n\n var result = _serviceprovider__WEBPACK_IMPORTED_MODULE_6__[\"default\"].getService('createimage', data);\n\n if (result.indexOf('@BASE@') != -1) {\n // Replacing '@BASE@' with the base URL of createimage.\n var baseParts = _core_src__WEBPACK_IMPORTED_MODULE_1__[\"default\"].getServiceProvider().getServicePath('createimage').split('/');\n baseParts.pop();\n result = result.split('@BASE@').join(baseParts.join('/'));\n }\n\n return result;\n }\n /**\r\n * Parses initial HTML code. If the HTML contains data generated by WIRIS, this data would be converted as following:\r\n *
\r\n     * MathML code: Image containing the corresponding MathML formulas.\r\n     * MathML code with LaTeX annotation : LaTeX string.\r\n     * 
\r\n * @param {string} code - HTML code containing MathML data.\r\n * @param {string} language - language to create image alt text.\r\n * @returns {string} HTML code with the original MathML converted into LaTeX and images.\r\n */\n\n }, {\n key: \"initParse\",\n value: function initParse(code, language) {\n /* Note: The code inside this function has been inverted.\r\n If you invert again the code then you cannot use correctly LaTeX\r\n in Moodle.\r\n */\n code = Parser.initParseSaveMode(code, language);\n return Parser.initParseEditMode(code);\n }\n /**\r\n * Parses initial HTML code depending on the save mode. Transforms all MathML\r\n * occurrences for it's correspondent image or LaTeX.\r\n * @param {string} code - HTML code to be parsed\r\n * @param {string} language - language to create image alt text.\r\n * @returns {string} HTML code parsed.\r\n */\n\n }, {\n key: \"initParseSaveMode\",\n value: function initParseSaveMode(code, language) {\n if (_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('saveMode')) {\n // Converting XML to tags.\n code = _latex__WEBPACK_IMPORTED_MODULE_2__[\"default\"].parseMathmlToLatex(code, _constants__WEBPACK_IMPORTED_MODULE_8__[\"default\"].safeXmlCharacters);\n code = _latex__WEBPACK_IMPORTED_MODULE_2__[\"default\"].parseMathmlToLatex(code, _constants__WEBPACK_IMPORTED_MODULE_8__[\"default\"].xmlCharacters); // Safe XML and XML must be parsed regardeless of save mode.\n // Order is important here, safeXml must be parsed first in order to avoid conflicts with data-mathml img attribute.\n\n code = Parser.parseSafeAppletsToObjects(code);\n code = Parser.parseMathmlToImg(code, _constants__WEBPACK_IMPORTED_MODULE_8__[\"default\"].safeXmlCharacters, language);\n code = Parser.parseMathmlToImg(code, _constants__WEBPACK_IMPORTED_MODULE_8__[\"default\"].xmlCharacters, language);\n\n if (_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('saveMode') == 'base64' && _configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('editMode') == 'image') {\n code = Parser.codeImgTransform(code, 'base642showimage');\n }\n }\n\n var appletList = _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].getElementsByNameFromString(code, 'applet', false);\n var carry = 0; // While replacing applets with images, the indexes of the found applets changes respecting the original code, so this carry is needed.\n\n for (var i = 0; i < appletList.length; ++i) {\n var appletCode = code.substring(appletList[i].start + carry, appletList[i].end + carry); // The second control in the if is used to find WIRIS applet which don't have Wiriscas class (as it was in old CAS applets).\n\n if (appletCode.indexOf(' class=\"' + _configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('CASClassName') + '\"') != -1 || appletCode.toUpperCase().indexOf('WIRIS') != -1) {\n if (appletCode.indexOf(' src=\"') != -1) {\n var srcStart = appletCode.indexOf(' src=\"') + ' src=\"'.length;\n var srcEnd = appletCode.indexOf('\"', srcStart);\n var src = appletCode.substring(srcStart, srcEnd);\n } else {\n // This should happen only with old CAS imported from Moodle 1 to Moodle 2.\n if (typeof _wrs_conf_pluginBasePath != 'undefined') {\n var src = _wrs_conf_pluginBasePath + '/integration/showcasimage.php?formula=noimage';\n } else {\n var src = '';\n }\n\n if (appletCode.indexOf(' class=\"' + _configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('CASClassName') + '\"') == -1) {\n var closeSymbol = appletCode.indexOf('>');\n var appletTag = appletCode.substring(0, closeSymbol);\n var newAppletTag = appletTag.split(' width=').join(' class=\"Wiriscas\" width=');\n appletCode = appletCode.split(appletTag).join(newAppletTag);\n appletCode = appletCode.split('\\'').join('\"');\n }\n } // Double click to edit has been removed here.\n\n\n var imgCode = '';\n code = code.substring(0, appletList[i].start + carry) + imgCode + code.substring(appletList[i].end + carry);\n carry += imgCode.length - (appletList[i].end - appletList[i].start);\n }\n }\n\n return code;\n }\n /**\r\n * Parses initial HTML code depending on the edit mode.\r\n * If 'latex' parseMode is enabled all MathML containing an annotation with encoding='LaTeX' will\r\n * be converted into a LaTeX string instead of an image.\r\n * @param {string} code - HTML code containing MathML.\r\n * @returns {string} parsed HTML code.\r\n */\n\n }, {\n key: \"initParseEditMode\",\n value: function initParseEditMode(code) {\n if (_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('parseModes').indexOf('latex') != -1) {\n var imgList = _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].getElementsByNameFromString(code, 'img', true);\n var token = 'encoding=\"LaTeX\">';\n var carry = 0;\n 4; // While replacing images with latex, the indexes of the found images changes respecting the original code, so this carry is needed.\n\n for (var i = 0; i < imgList.length; ++i) {\n var imgCode = code.substring(imgList[i].start + carry, imgList[i].end + carry);\n\n if (imgCode.indexOf(' class=\"' + _configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('imageClassName') + '\"') != -1) {\n var mathmlStartToken = ' ' + _configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('imageMathmlAttribute') + '=\"';\n var mathmlStart = imgCode.indexOf(mathmlStartToken);\n\n if (mathmlStart == -1) {\n mathmlStartToken = ' alt=\"';\n mathmlStart = imgCode.indexOf(mathmlStartToken);\n }\n\n if (mathmlStart != -1) {\n mathmlStart += mathmlStartToken.length;\n var mathmlEnd = imgCode.indexOf('\"', mathmlStart);\n var mathml = _mathml__WEBPACK_IMPORTED_MODULE_3__[\"default\"].safeXmlDecode(imgCode.substring(mathmlStart, mathmlEnd));\n var latexStartPosition = mathml.indexOf(token);\n\n if (latexStartPosition != -1) {\n latexStartPosition += token.length;\n var latexEndPosition = mathml.indexOf('
', latexStartPosition);\n var latex = mathml.substring(latexStartPosition, latexEndPosition);\n var replaceText = '$$' + _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].htmlEntitiesDecode(latex) + '$$';\n code = code.substring(0, imgList[i].start + carry) + replaceText + code.substring(imgList[i].end + carry);\n carry += replaceText.length - (imgList[i].end - imgList[i].start);\n }\n }\n }\n }\n }\n\n return code;\n }\n /**\r\n * Parses end HTML code. The end HTML code is HTML code with embedded images or LaTeX formulas created with MathType.
\r\n * By default this method converts the formula images and LaTeX strings in MathML.
\r\n * If image mode is enabled the images will not be converted into MathML. For further information see {@link http://www.wiris.com/plugins/docs/full-mathml-mode}.\r\n * @param {string} code - HTML to be parsed\r\n * @returns {string} the HTML code parsed.\r\n */\n\n }, {\n key: \"endParse\",\n value: function endParse(code) {\n code = Parser.endParseEditMode(code);\n return Parser.endParseSaveMode(code);\n }\n /**\r\n * Parses end HTML code depending on the edit mode.\r\n * - LaTeX is an enabled parse mode, all LaTeX occurrences will be converted into MathML.\r\n * @param {string} code - HTML code to be parsed.\r\n * @returns {string} HTML code parsed.\r\n */\n\n }, {\n key: \"endParseEditMode\",\n value: function endParseEditMode(code) {\n // Converting LaTeX to images.\n if (_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('parseModes').indexOf('latex') != -1) {\n var output = '';\n var endPosition = 0;\n var startPosition = code.indexOf('$$');\n\n while (startPosition != -1) {\n output += code.substring(endPosition, startPosition);\n endPosition = code.indexOf('$$', startPosition + 2);\n\n if (endPosition != -1) {\n // Before, it was a condition here to execute the next codelines 'latex.indexOf('<') == -1'.\n // We don't know why it was used, but seems to have a conflict with latex formulas that contains '<'.\n var latex = code.substring(startPosition + 2, endPosition);\n latex = _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].htmlEntitiesDecode(latex);\n var mathml = _latex__WEBPACK_IMPORTED_MODULE_2__[\"default\"].getMathMLFromLatex(latex, true);\n output += mathml;\n endPosition += 2;\n } else {\n output += '$$';\n endPosition = startPosition + 2;\n }\n\n startPosition = code.indexOf('$$', endPosition);\n }\n\n output += code.substring(endPosition, code.length);\n code = output;\n }\n\n return code;\n }\n /**\r\n * Parses end HTML code depending on the save mode. Converts all\r\n * images into the element determined by the save mode:\r\n * - xml: Parses images formulas into MathML.\r\n * - safeXml: Parses images formulas into safeMAthML\r\n * - base64: Parses images into base64 images.\r\n * - image: Parse images into images (no parsing)\r\n * @param {string} code - HTML code to be parsed\r\n * @returns {string} HTML code parsed.\r\n */\n\n }, {\n key: \"endParseSaveMode\",\n value: function endParseSaveMode(code) {\n if (_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('saveMode')) {\n if (_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('saveMode') == 'safeXml') {\n code = Parser.codeImgTransform(code, 'img2mathml');\n } else if (_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('saveMode') == 'xml') {\n code = Parser.codeImgTransform(code, 'img2mathml');\n } else if (_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('saveMode') == 'base64' && _configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('editMode') == 'image') {\n code = Parser.codeImgTransform(code, 'img264');\n }\n }\n\n return code;\n }\n /**\r\n * Returns the result to call showimage service with the formula md5 as parameter.\r\n * The result could be:\r\n * - {'status' : warning'} : The image associated to the MathML md5 is not in cache.\r\n * - {'status' : 'ok' ...} : The image associated to the MathML md5 is in cache.\r\n * @param {Object[]} data - object containing showimage service parameters.\r\n * @param {string} language - string containing the language of the formula.\r\n * @returns {Object} JSON object containing showimage response.\r\n */\n\n }, {\n key: \"createShowImageSrc\",\n value: function createShowImageSrc(data, language) {\n var dataMd5 = [];\n var renderParams = 'mml,color,centerbaseline,zoom,dpi,fontSize,fontFamily,defaultStretchy,backgroundColor,format';\n var renderParamsArray = renderParams.split(',');\n\n for (var key in renderParamsArray) {\n var param = renderParamsArray[key];\n\n if (typeof data[param] != 'undefined') {\n dataMd5[param] = data[param];\n }\n } // Data variables to get.\n\n\n var dataObject = {};\n\n for (var key in data) {\n // We don't need mathml in this request we try to get cached so we only need the formula md5 calculated before.\n if (key != 'mml') {\n dataObject[key] = data[key];\n }\n }\n\n dataObject.formula = com.wiris.js.JsPluginTools.md5encode(_util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].propertiesToString(dataMd5));\n dataObject.lang = typeof language == 'undefined' ? 'en' : language;\n dataObject.version = _configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('version');\n var result = _serviceprovider__WEBPACK_IMPORTED_MODULE_6__[\"default\"].getService('showimage', _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].httpBuildQuery(dataObject), true);\n return result;\n }\n /**\r\n * Transform html img tags inside a html code to mathml, base64 img tags (i.e with base64 on src) or showimage img tags (i.e with showimage.php on src)\r\n * @param {string} code - HTML code\r\n * @param {string} mode - base642showimage or img2mathml or img264 transform.\r\n * @returns {string} html - code transformed.\r\n */\n\n }, {\n key: \"codeImgTransform\",\n value: function codeImgTransform(code, mode) {\n var output = '';\n var endPosition = 0;\n var pattern = /') {\n endPosition = i + 1;\n }\n\n ++i;\n }\n\n if (endPosition < startPosition) {\n // The img tag is stripped.\n output += code.substring(startPosition, code.length);\n return output;\n }\n\n var imgCode = code.substring(startPosition, endPosition);\n var imgObject = _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].createObject(imgCode);\n var xmlCode = imgObject.getAttribute(_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('imageMathmlAttribute'));\n var convertToXml;\n var convertToSafeXml;\n\n if (mode == 'base642showimage') {\n if (xmlCode == null) {\n xmlCode = imgObject.getAttribute('alt');\n }\n\n xmlCode = _mathml__WEBPACK_IMPORTED_MODULE_3__[\"default\"].safeXmlDecode(xmlCode);\n imgCode = Parser.mathmlToImgObject(document, xmlCode, null, null);\n output += _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].createObjectCode(imgCode);\n } else if (mode == 'img2mathml') {\n if (_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('saveMode')) {\n if (_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('saveMode') == 'safeXml') {\n convertToXml = true;\n convertToSafeXml = true;\n } else if (_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('saveMode') == 'xml') {\n convertToXml = true;\n convertToSafeXml = false;\n }\n }\n\n output += _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].getWIRISImageOutput(imgCode, convertToXml, convertToSafeXml);\n } else if (mode == 'img264') {\n if (xmlCode == null) {\n xmlCode = imgObject.getAttribute('alt');\n }\n\n xmlCode = _mathml__WEBPACK_IMPORTED_MODULE_3__[\"default\"].safeXmlDecode(xmlCode);\n var properties = {};\n properties['base64'] = 'true';\n imgCode = Parser.mathmlToImgObject(document, xmlCode, properties, null); // Metrics.\n\n _image__WEBPACK_IMPORTED_MODULE_4__[\"default\"].setImgSize(imgCode, imgCode.src, true);\n output += _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].createObjectCode(imgCode);\n }\n }\n\n output += code.substring(endPosition, code.length);\n return output;\n }\n /**\r\n * Converts all occurrences of safe applet code to the corresponding code.\r\n * @param {string} content - String containing valid applet code ...\r\n * @returns {string} content with all the applet code converted to safe tags.\r\n */\n\n }, {\n key: \"parseSafeAppletsToObjects\",\n value: function parseSafeAppletsToObjects(content) {\n var output = '';\n var appletTagBegin = _constants__WEBPACK_IMPORTED_MODULE_8__[\"default\"].safeXmlCharacters.tagOpener + 'APPLET';\n var appletTagEnd = _constants__WEBPACK_IMPORTED_MODULE_8__[\"default\"].safeXmlCharacters.tagOpener + '/APPLET' + _constants__WEBPACK_IMPORTED_MODULE_8__[\"default\"].safeXmlCharacters.tagCloser;\n var upperCaseContent = content.toUpperCase();\n var start = upperCaseContent.indexOf(appletTagBegin);\n var end = 0;\n var applet;\n\n while (start != -1) {\n output += content.substring(end, start);\n end = upperCaseContent.indexOf(appletTagEnd, start);\n\n if (end == -1) {\n end = content.length - 1;\n } else {\n end += appletTagEnd.length;\n }\n\n applet = _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].convertOldXmlinitialtextAttribute(content.substring(start, end));\n output += _mathml__WEBPACK_IMPORTED_MODULE_3__[\"default\"].safeXmlDecode(applet);\n start = upperCaseContent.indexOf(appletTagBegin, end);\n }\n\n output += content.substring(end, content.length);\n return output;\n }\n /**\r\n * Converts all occurrences of MathML to the corresponding image.\r\n * @param {string} content - string with valid MathML code. The MathML code doesn't contain semantics.\r\n * @param {Constants} characters - Constant object containing xmlCharacters or safeXmlCharacters relation.\r\n * @param {string} language - a valid language code in order to generate formula accessibility.\r\n * @returns {string} The input string with all the MathML occurrences replaced by the corresponding image.\r\n */\n\n }, {\n key: \"parseMathmlToImg\",\n value: function parseMathmlToImg(content, characters, language) {\n var output = '';\n var mathTagBegin = characters.tagOpener + 'math';\n var mathTagEnd = characters.tagOpener + '/math' + characters.tagCloser;\n var start = content.indexOf(mathTagBegin);\n var end = 0;\n\n while (start != -1) {\n output += content.substring(end, start); // Avoid WIRIS images to be parsed.\n\n var imageMathmlAtrribute = content.indexOf(_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('imageMathmlAttribute'));\n end = content.indexOf(mathTagEnd, start);\n\n if (end == -1) {\n end = content.length - 1;\n } else if (imageMathmlAtrribute != -1) {\n // First close tag of img attribute\n // If a mathmlAttribute exists should be inside a img tag.\n end += content.indexOf(\"/>\", start);\n } else {\n end += mathTagEnd.length;\n }\n\n if (!_mathml__WEBPACK_IMPORTED_MODULE_3__[\"default\"].isMathmlInAttribute(content, start) && imageMathmlAtrribute == -1) {\n var mathml = content.substring(start, end);\n mathml = characters == _constants__WEBPACK_IMPORTED_MODULE_8__[\"default\"].safeXmlCharacters ? _mathml__WEBPACK_IMPORTED_MODULE_3__[\"default\"].safeXmlDecode(mathml) : _mathml__WEBPACK_IMPORTED_MODULE_3__[\"default\"].mathMLEntities(mathml);\n output += _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].createObjectCode(Parser.mathmlToImgObject(document, mathml, null, language));\n } else {\n output += content.substring(start, end);\n }\n\n start = content.indexOf(mathTagBegin, end);\n }\n\n output += content.substring(end, content.length);\n return output;\n }\n }]);\n\n return Parser;\n}(); // Mutation observers to avoid wiris image formulas class be removed.\n\n\n\n\nif (typeof MutationObserver !== 'undefined') {\n var mutationObserver = new MutationObserver(function (mutations) {\n mutations.forEach(function (mutation) {\n if (mutation.oldValue === _configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('imageClassName') && mutation.attributeName === 'class' && mutation.target.className.indexOf(_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('imageClassName')) == -1) {\n mutation.target.className = _configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('imageClassName');\n }\n });\n });\n Parser.observer = Object.create(mutationObserver);\n Parser.observer.Config = {\n attributes: true,\n attributeOldValue: true\n }; // We use own default config.\n\n Parser.observer.observe = function name(target) {\n this.__proto__.observe(target, this.Config);\n };\n}\n\n//# sourceURL=webpack:///./core/src/parser.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"default\", function() { return Parser; });\n/* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./util */ \"./core/src/util.js\");\n/* harmony import */ var _core_src__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./core.src */ \"./core/src/core.src.js\");\n/* harmony import */ var _latex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./latex */ \"./core/src/latex.js\");\n/* harmony import */ var _mathml__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./mathml */ \"./core/src/mathml.js\");\n/* harmony import */ var _image__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./image */ \"./core/src/image.js\");\n/* harmony import */ var _accessibility__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./accessibility */ \"./core/src/accessibility.js\");\n/* harmony import */ var _serviceprovider__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./serviceprovider */ \"./core/src/serviceprovider.js\");\n/* harmony import */ var _configuration__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./configuration */ \"./core/src/configuration.js\");\n/* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./constants */ \"./core/src/constants.js\");\n/* harmony import */ var _md5__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./md5 */ \"./core/src/md5.js\");\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\n\n\n\n\n\n\n\n\n\n\n/**\r\n * This class represent a MahML parser. Converts MathML into formulas depending on the\r\n * image format (SVG, PNG, base64) and the save mode (XML, safeXML, Image) configured in the backend.\r\n */\n\nvar Parser =\n/*#__PURE__*/\nfunction () {\n function Parser() {\n _classCallCheck(this, Parser);\n }\n\n _createClass(Parser, null, [{\n key: \"mathmlToImgObject\",\n\n /**\r\n * Converts a MathML string to an img element.\r\n * @param {Document} creator - Document object to call createElement method.\r\n * @param {string} mathml - MathML code\r\n * @param {Object[]} wirisProperties - object containing WIRIS custom properties\r\n * @param {language} language - custom language for accessibility.\r\n * @returns {HTMLImageElement} the formula image corresponding to initial MathML string.\r\n * @static\r\n */\n value: function mathmlToImgObject(creator, mathml, wirisProperties, language) {\n var width;\n var height;\n var baseline;\n var imgObject = creator.createElement('img');\n imgObject.align = 'middle';\n imgObject.style.maxWidth = 'none';\n var data = wirisProperties ? wirisProperties : {};\n data['mml'] = mathml;\n data['lang'] = language; // Request metrics of the generated image.\n\n data['metrics'] = 'true';\n data['centerbaseline'] = 'false'; // Full base64 method (edit & save).\n\n if (_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('saveMode') == 'base64' && _configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('editMode') == 'default') {\n data['base64'] = true;\n } // Render js params: _wrs_int_wirisProperties contains some js render params. Since mathml can support render params, js params should be send only to editor, not to render.\n\n\n imgObject.className = _configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('imageClassName');\n\n if (mathml.indexOf('class=\"') != -1) {\n // We check here if the MathML has been created from a customEditor (such chemistry)\n // to add data-custom-editor attribute to img object (if necessary).\n var mathmlSubstring = mathml.substring(mathml.indexOf('class=\"') + 'class=\"'.length, mathml.length);\n mathmlSubstring = mathmlSubstring.substring(0, mathmlSubstring.indexOf('\"'));\n mathmlSubstring = mathmlSubstring.substring(4, mathmlSubstring.length);\n imgObject.setAttribute('data-custom-editor', mathmlSubstring);\n } // Performance enabled.\n\n\n if (_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('wirisPluginPerformance') && (_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('saveMode') == 'xml' || _configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('saveMode') == 'safeXml')) {\n var result = JSON.parse(Parser.createShowImageSrc(data, language));\n\n if (result[\"status\"] == 'warning') {\n // POST call.\n // if the mathml is malformed, this function will throw an exception.\n try {\n result = JSON.parse(_serviceprovider__WEBPACK_IMPORTED_MODULE_6__[\"default\"].getService('showimage', data));\n } catch (e) {\n return;\n }\n }\n\n result = result.result;\n\n if (result['format'] == 'png') {\n imgObject.src = 'data:image/png;base64,' + result['content'];\n } else {\n imgObject.src = 'data:image/svg+xml;charset=utf8,' + _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].urlEncode(result['content']);\n }\n\n imgObject.setAttribute(_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('imageMathmlAttribute'), _mathml__WEBPACK_IMPORTED_MODULE_3__[\"default\"].safeXmlEncode(mathml));\n _image__WEBPACK_IMPORTED_MODULE_4__[\"default\"].setImgSize(imgObject, result['content'], true);\n\n if (_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('enableAccessibility')) {\n if (typeof result.alt == 'undefined') {\n imgObject.alt = _accessibility__WEBPACK_IMPORTED_MODULE_5__[\"default\"].mathMLToAccessible(mathml, language, data);\n } else {\n imgObject.alt = result.alt;\n }\n }\n } else {\n var result = Parser.createImageSrc(mathml, data);\n imgObject.setAttribute(_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('imageMathmlAttribute'), _mathml__WEBPACK_IMPORTED_MODULE_3__[\"default\"].safeXmlEncode(mathml));\n imgObject.src = result;\n _image__WEBPACK_IMPORTED_MODULE_4__[\"default\"].setImgSize(imgObject, result, _configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('saveMode') == 'base64' && _configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('editMode') == 'default' ? true : false);\n\n if (_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('enableAccessibility')) {\n imgObject.alt = _accessibility__WEBPACK_IMPORTED_MODULE_5__[\"default\"].mathMLToAccessible(mathml, language, data);\n }\n }\n\n if (typeof Parser.observer != 'undefined') {\n Parser.observer.observe(imgObject);\n } // Role math https://www.w3.org/TR/wai-aria/roles#math.\n\n\n imgObject.setAttribute('role', 'math');\n return imgObject;\n }\n /**\r\n * Returns the source to showimage service by calling createimage service. The\r\n * output of the createimage service is a URL path pointing to showimage service.\r\n * This method is called when performance is disabled.\r\n * @param {string} mathml - MathML code.\r\n * @param {Object[]} data - data object containing service parameters.\r\n * @returns {string} the showimage path.\r\n */\n\n }, {\n key: \"createImageSrc\",\n value: function createImageSrc(mathml, data) {\n // Full base64 method (edit & save).\n if (_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('saveMode') == 'base64' && _configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('editMode') == 'default') {\n data['base64'] = true;\n }\n\n var result = _serviceprovider__WEBPACK_IMPORTED_MODULE_6__[\"default\"].getService('createimage', data);\n\n if (result.indexOf('@BASE@') != -1) {\n // Replacing '@BASE@' with the base URL of createimage.\n var baseParts = _core_src__WEBPACK_IMPORTED_MODULE_1__[\"default\"].getServiceProvider().getServicePath('createimage').split('/');\n baseParts.pop();\n result = result.split('@BASE@').join(baseParts.join('/'));\n }\n\n return result;\n }\n /**\r\n * Parses initial HTML code. If the HTML contains data generated by WIRIS, this data would be converted as following:\r\n *
\r\n     * MathML code: Image containing the corresponding MathML formulas.\r\n     * MathML code with LaTeX annotation : LaTeX string.\r\n     * 
\r\n * @param {string} code - HTML code containing MathML data.\r\n * @param {string} language - language to create image alt text.\r\n * @returns {string} HTML code with the original MathML converted into LaTeX and images.\r\n */\n\n }, {\n key: \"initParse\",\n value: function initParse(code, language) {\n /* Note: The code inside this function has been inverted.\r\n If you invert again the code then you cannot use correctly LaTeX\r\n in Moodle.\r\n */\n code = Parser.initParseSaveMode(code, language);\n return Parser.initParseEditMode(code);\n }\n /**\r\n * Parses initial HTML code depending on the save mode. Transforms all MathML\r\n * occurrences for it's correspondent image or LaTeX.\r\n * @param {string} code - HTML code to be parsed\r\n * @param {string} language - language to create image alt text.\r\n * @returns {string} HTML code parsed.\r\n */\n\n }, {\n key: \"initParseSaveMode\",\n value: function initParseSaveMode(code, language) {\n if (_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('saveMode')) {\n // Converting XML to tags.\n code = _latex__WEBPACK_IMPORTED_MODULE_2__[\"default\"].parseMathmlToLatex(code, _constants__WEBPACK_IMPORTED_MODULE_8__[\"default\"].safeXmlCharacters);\n code = _latex__WEBPACK_IMPORTED_MODULE_2__[\"default\"].parseMathmlToLatex(code, _constants__WEBPACK_IMPORTED_MODULE_8__[\"default\"].xmlCharacters); // Safe XML and XML must be parsed regardeless of save mode.\n // Order is important here, safeXml must be parsed first in order to avoid conflicts with data-mathml img attribute.\n\n code = Parser.parseSafeAppletsToObjects(code);\n code = Parser.parseMathmlToImg(code, _constants__WEBPACK_IMPORTED_MODULE_8__[\"default\"].safeXmlCharacters, language);\n code = Parser.parseMathmlToImg(code, _constants__WEBPACK_IMPORTED_MODULE_8__[\"default\"].xmlCharacters, language);\n\n if (_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('saveMode') == 'base64' && _configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('editMode') == 'image') {\n code = Parser.codeImgTransform(code, 'base642showimage');\n }\n }\n\n var appletList = _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].getElementsByNameFromString(code, 'applet', false);\n var carry = 0; // While replacing applets with images, the indexes of the found applets changes respecting the original code, so this carry is needed.\n\n for (var i = 0; i < appletList.length; ++i) {\n var appletCode = code.substring(appletList[i].start + carry, appletList[i].end + carry); // The second control in the if is used to find WIRIS applet which don't have Wiriscas class (as it was in old CAS applets).\n\n if (appletCode.indexOf(' class=\"' + _configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('CASClassName') + '\"') != -1 || appletCode.toUpperCase().indexOf('WIRIS') != -1) {\n if (appletCode.indexOf(' src=\"') != -1) {\n var srcStart = appletCode.indexOf(' src=\"') + ' src=\"'.length;\n var srcEnd = appletCode.indexOf('\"', srcStart);\n var src = appletCode.substring(srcStart, srcEnd);\n } else {\n // This should happen only with old CAS imported from Moodle 1 to Moodle 2.\n if (typeof _wrs_conf_pluginBasePath != 'undefined') {\n var src = _wrs_conf_pluginBasePath + '/integration/showcasimage.php?formula=noimage';\n } else {\n var src = '';\n }\n\n if (appletCode.indexOf(' class=\"' + _configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('CASClassName') + '\"') == -1) {\n var closeSymbol = appletCode.indexOf('>');\n var appletTag = appletCode.substring(0, closeSymbol);\n var newAppletTag = appletTag.split(' width=').join(' class=\"Wiriscas\" width=');\n appletCode = appletCode.split(appletTag).join(newAppletTag);\n appletCode = appletCode.split('\\'').join('\"');\n }\n } // Double click to edit has been removed here.\n\n\n var imgCode = '';\n code = code.substring(0, appletList[i].start + carry) + imgCode + code.substring(appletList[i].end + carry);\n carry += imgCode.length - (appletList[i].end - appletList[i].start);\n }\n }\n\n return code;\n }\n /**\r\n * Parses initial HTML code depending on the edit mode.\r\n * If 'latex' parseMode is enabled all MathML containing an annotation with encoding='LaTeX' will\r\n * be converted into a LaTeX string instead of an image.\r\n * @param {string} code - HTML code containing MathML.\r\n * @returns {string} parsed HTML code.\r\n */\n\n }, {\n key: \"initParseEditMode\",\n value: function initParseEditMode(code) {\n if (_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('parseModes').indexOf('latex') != -1) {\n var imgList = _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].getElementsByNameFromString(code, 'img', true);\n var token = 'encoding=\"LaTeX\">';\n var carry = 0;\n 4; // While replacing images with latex, the indexes of the found images changes respecting the original code, so this carry is needed.\n\n for (var i = 0; i < imgList.length; ++i) {\n var imgCode = code.substring(imgList[i].start + carry, imgList[i].end + carry);\n\n if (imgCode.indexOf(' class=\"' + _configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('imageClassName') + '\"') != -1) {\n var mathmlStartToken = ' ' + _configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('imageMathmlAttribute') + '=\"';\n var mathmlStart = imgCode.indexOf(mathmlStartToken);\n\n if (mathmlStart == -1) {\n mathmlStartToken = ' alt=\"';\n mathmlStart = imgCode.indexOf(mathmlStartToken);\n }\n\n if (mathmlStart != -1) {\n mathmlStart += mathmlStartToken.length;\n var mathmlEnd = imgCode.indexOf('\"', mathmlStart);\n var mathml = _mathml__WEBPACK_IMPORTED_MODULE_3__[\"default\"].safeXmlDecode(imgCode.substring(mathmlStart, mathmlEnd));\n var latexStartPosition = mathml.indexOf(token);\n\n if (latexStartPosition != -1) {\n latexStartPosition += token.length;\n var latexEndPosition = mathml.indexOf('
', latexStartPosition);\n var latex = mathml.substring(latexStartPosition, latexEndPosition);\n var replaceText = '$$' + _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].htmlEntitiesDecode(latex) + '$$';\n code = code.substring(0, imgList[i].start + carry) + replaceText + code.substring(imgList[i].end + carry);\n carry += replaceText.length - (imgList[i].end - imgList[i].start);\n }\n }\n }\n }\n }\n\n return code;\n }\n /**\r\n * Parses end HTML code. The end HTML code is HTML code with embedded images or LaTeX formulas created with MathType.
\r\n * By default this method converts the formula images and LaTeX strings in MathML.
\r\n * If image mode is enabled the images will not be converted into MathML. For further information see {@link http://www.wiris.com/plugins/docs/full-mathml-mode}.\r\n * @param {string} code - HTML to be parsed\r\n * @returns {string} the HTML code parsed.\r\n */\n\n }, {\n key: \"endParse\",\n value: function endParse(code) {\n // Transform LaTeX ocurrences to MathML elements.\n var codeEndParsedEditMode = Parser.endParseEditMode(code); // Transform img elements to MathML elements.\n\n var codeEndParseSaveMode = Parser.endParseSaveMode(codeEndParsedEditMode);\n return codeEndParseSaveMode;\n }\n /**\r\n * Parses end HTML code depending on the edit mode.\r\n * - LaTeX is an enabled parse mode, all LaTeX occurrences will be converted into MathML.\r\n * @param {string} code - HTML code to be parsed.\r\n * @returns {string} HTML code parsed.\r\n */\n\n }, {\n key: \"endParseEditMode\",\n value: function endParseEditMode(code) {\n // Converting LaTeX to images.\n if (_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('parseModes').indexOf('latex') != -1) {\n var output = '';\n var endPosition = 0;\n var startPosition = code.indexOf('$$');\n\n while (startPosition != -1) {\n output += code.substring(endPosition, startPosition);\n endPosition = code.indexOf('$$', startPosition + 2);\n\n if (endPosition != -1) {\n // Before, it was a condition here to execute the next codelines 'latex.indexOf('<') == -1'.\n // We don't know why it was used, but seems to have a conflict with latex formulas that contains '<'.\n var latex = code.substring(startPosition + 2, endPosition);\n latex = _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].htmlEntitiesDecode(latex);\n var mathml = _latex__WEBPACK_IMPORTED_MODULE_2__[\"default\"].getMathMLFromLatex(latex, true);\n output += mathml;\n endPosition += 2;\n } else {\n output += '$$';\n endPosition = startPosition + 2;\n }\n\n startPosition = code.indexOf('$$', endPosition);\n }\n\n output += code.substring(endPosition, code.length);\n code = output;\n }\n\n return code;\n }\n /**\r\n * Parses end HTML code depending on the save mode. Converts all\r\n * images into the element determined by the save mode:\r\n * - xml: Parses images formulas into MathML.\r\n * - safeXml: Parses images formulas into safeMAthML\r\n * - base64: Parses images into base64 images.\r\n * - image: Parse images into images (no parsing)\r\n * @param {string} code - HTML code to be parsed\r\n * @returns {string} HTML code parsed.\r\n */\n\n }, {\n key: \"endParseSaveMode\",\n value: function endParseSaveMode(code) {\n if (_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('saveMode')) {\n if (_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('saveMode') == 'safeXml') {\n code = Parser.codeImgTransform(code, 'img2mathml');\n } else if (_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('saveMode') == 'xml') {\n code = Parser.codeImgTransform(code, 'img2mathml');\n } else if (_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('saveMode') == 'base64' && _configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('editMode') == 'image') {\n code = Parser.codeImgTransform(code, 'img264');\n }\n }\n\n return code;\n }\n /**\r\n * Returns the result to call showimage service with the formula md5 as parameter.\r\n * The result could be:\r\n * - {'status' : warning'} : The image associated to the MathML md5 is not in cache.\r\n * - {'status' : 'ok' ...} : The image associated to the MathML md5 is in cache.\r\n * @param {Object[]} data - object containing showimage service parameters.\r\n * @param {string} language - string containing the language of the formula.\r\n * @returns {Object} JSON object containing showimage response.\r\n */\n\n }, {\n key: \"createShowImageSrc\",\n value: function createShowImageSrc(data, language) {\n var dataMd5 = [];\n var renderParams = 'mml,color,centerbaseline,zoom,dpi,fontSize,fontFamily,defaultStretchy,backgroundColor,format';\n var renderParamsArray = renderParams.split(',');\n\n for (var key in renderParamsArray) {\n var param = renderParamsArray[key];\n\n if (typeof data[param] != 'undefined') {\n dataMd5[param] = data[param];\n }\n } // Data variables to get.\n\n\n var dataObject = {};\n\n for (var key in data) {\n // We don't need mathml in this request we try to get cached so we only need the formula md5 calculated before.\n if (key != 'mml') {\n dataObject[key] = data[key];\n }\n }\n\n dataObject.formula = com.wiris.js.JsPluginTools.md5encode(_util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].propertiesToString(dataMd5));\n dataObject.lang = typeof language == 'undefined' ? 'en' : language;\n dataObject.version = _configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('version');\n var result = _serviceprovider__WEBPACK_IMPORTED_MODULE_6__[\"default\"].getService('showimage', _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].httpBuildQuery(dataObject), true);\n return result;\n }\n /**\r\n * Transform html img tags inside a html code to mathml, base64 img tags (i.e with base64 on src) or showimage img tags (i.e with showimage.php on src)\r\n * @param {string} code - HTML code\r\n * @param {string} mode - base642showimage or img2mathml or img264 transform.\r\n * @returns {string} html - code transformed.\r\n */\n\n }, {\n key: \"codeImgTransform\",\n value: function codeImgTransform(code, mode) {\n var output = '';\n var endPosition = 0;\n var pattern = /') {\n endPosition = i + 1;\n }\n\n ++i;\n }\n\n if (endPosition < startPosition) {\n // The img tag is stripped.\n output += code.substring(startPosition, code.length);\n return output;\n }\n\n var imgCode = code.substring(startPosition, endPosition);\n var imgObject = _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].createObject(imgCode);\n var xmlCode = imgObject.getAttribute(_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('imageMathmlAttribute'));\n var convertToXml;\n var convertToSafeXml;\n\n if (mode == 'base642showimage') {\n if (xmlCode == null) {\n xmlCode = imgObject.getAttribute('alt');\n }\n\n xmlCode = _mathml__WEBPACK_IMPORTED_MODULE_3__[\"default\"].safeXmlDecode(xmlCode);\n imgCode = Parser.mathmlToImgObject(document, xmlCode, null, null);\n output += _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].createObjectCode(imgCode);\n } else if (mode == 'img2mathml') {\n if (_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('saveMode')) {\n if (_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('saveMode') == 'safeXml') {\n convertToXml = true;\n convertToSafeXml = true;\n } else if (_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('saveMode') == 'xml') {\n convertToXml = true;\n convertToSafeXml = false;\n }\n }\n\n output += _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].getWIRISImageOutput(imgCode, convertToXml, convertToSafeXml);\n } else if (mode == 'img264') {\n if (xmlCode == null) {\n xmlCode = imgObject.getAttribute('alt');\n }\n\n xmlCode = _mathml__WEBPACK_IMPORTED_MODULE_3__[\"default\"].safeXmlDecode(xmlCode);\n var properties = {};\n properties['base64'] = 'true';\n imgCode = Parser.mathmlToImgObject(document, xmlCode, properties, null); // Metrics.\n\n _image__WEBPACK_IMPORTED_MODULE_4__[\"default\"].setImgSize(imgCode, imgCode.src, true);\n output += _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].createObjectCode(imgCode);\n }\n }\n\n output += code.substring(endPosition, code.length);\n return output;\n }\n /**\r\n * Converts all occurrences of safe applet code to the corresponding code.\r\n * @param {string} content - String containing valid applet code ...\r\n * @returns {string} content with all the applet code converted to safe tags.\r\n */\n\n }, {\n key: \"parseSafeAppletsToObjects\",\n value: function parseSafeAppletsToObjects(content) {\n var output = '';\n var appletTagBegin = _constants__WEBPACK_IMPORTED_MODULE_8__[\"default\"].safeXmlCharacters.tagOpener + 'APPLET';\n var appletTagEnd = _constants__WEBPACK_IMPORTED_MODULE_8__[\"default\"].safeXmlCharacters.tagOpener + '/APPLET' + _constants__WEBPACK_IMPORTED_MODULE_8__[\"default\"].safeXmlCharacters.tagCloser;\n var upperCaseContent = content.toUpperCase();\n var start = upperCaseContent.indexOf(appletTagBegin);\n var end = 0;\n var applet;\n\n while (start != -1) {\n output += content.substring(end, start);\n end = upperCaseContent.indexOf(appletTagEnd, start);\n\n if (end == -1) {\n end = content.length - 1;\n } else {\n end += appletTagEnd.length;\n }\n\n applet = _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].convertOldXmlinitialtextAttribute(content.substring(start, end));\n output += _mathml__WEBPACK_IMPORTED_MODULE_3__[\"default\"].safeXmlDecode(applet);\n start = upperCaseContent.indexOf(appletTagBegin, end);\n }\n\n output += content.substring(end, content.length);\n return output;\n }\n /**\r\n * Converts all occurrences of MathML to the corresponding image.\r\n * @param {string} content - string with valid MathML code. The MathML code doesn't contain semantics.\r\n * @param {Constants} characters - Constant object containing xmlCharacters or safeXmlCharacters relation.\r\n * @param {string} language - a valid language code in order to generate formula accessibility.\r\n * @returns {string} The input string with all the MathML occurrences replaced by the corresponding image.\r\n */\n\n }, {\n key: \"parseMathmlToImg\",\n value: function parseMathmlToImg(content, characters, language) {\n var output = '';\n var mathTagBegin = characters.tagOpener + 'math';\n var mathTagEnd = characters.tagOpener + '/math' + characters.tagCloser;\n var start = content.indexOf(mathTagBegin);\n var end = 0;\n\n while (start != -1) {\n output += content.substring(end, start); // Avoid WIRIS images to be parsed.\n\n var imageMathmlAtrribute = content.indexOf(_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('imageMathmlAttribute'));\n end = content.indexOf(mathTagEnd, start);\n\n if (end == -1) {\n end = content.length - 1;\n } else if (imageMathmlAtrribute != -1) {\n // First close tag of img attribute\n // If a mathmlAttribute exists should be inside a img tag.\n end += content.indexOf(\"/>\", start);\n } else {\n end += mathTagEnd.length;\n }\n\n if (!_mathml__WEBPACK_IMPORTED_MODULE_3__[\"default\"].isMathmlInAttribute(content, start) && imageMathmlAtrribute == -1) {\n var mathml = content.substring(start, end);\n mathml = characters == _constants__WEBPACK_IMPORTED_MODULE_8__[\"default\"].safeXmlCharacters ? _mathml__WEBPACK_IMPORTED_MODULE_3__[\"default\"].safeXmlDecode(mathml) : _mathml__WEBPACK_IMPORTED_MODULE_3__[\"default\"].mathMLEntities(mathml);\n output += _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].createObjectCode(Parser.mathmlToImgObject(document, mathml, null, language));\n } else {\n output += content.substring(start, end);\n }\n\n start = content.indexOf(mathTagBegin, end);\n }\n\n output += content.substring(end, content.length);\n return output;\n }\n }]);\n\n return Parser;\n}(); // Mutation observers to avoid wiris image formulas class be removed.\n\n\n\n\nif (typeof MutationObserver !== 'undefined') {\n var mutationObserver = new MutationObserver(function (mutations) {\n mutations.forEach(function (mutation) {\n if (mutation.oldValue === _configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('imageClassName') && mutation.attributeName === 'class' && mutation.target.className.indexOf(_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('imageClassName')) == -1) {\n mutation.target.className = _configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('imageClassName');\n }\n });\n });\n Parser.observer = Object.create(mutationObserver);\n Parser.observer.Config = {\n attributes: true,\n attributeOldValue: true\n }; // We use own default config.\n\n Parser.observer.observe = function name(target) {\n this.__proto__.observe(target, this.Config);\n };\n}\n\n//# sourceURL=webpack:///./core/src/parser.js?"); /***/ }), @@ -370,7 +370,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) * /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"default\", function() { return Util; });\n/* harmony import */ var _mathml__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./mathml */ \"./core/src/mathml.js\");\n/* harmony import */ var _configuration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./configuration */ \"./core/src/configuration.js\");\n/* harmony import */ var _latex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./latex */ \"./core/src/latex.js\");\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\n\n\n\n/**\r\n * This class represents an utility class.\r\n */\n\nvar Util =\n/*#__PURE__*/\nfunction () {\n function Util() {\n _classCallCheck(this, Util);\n }\n\n _createClass(Util, null, [{\n key: \"fireEvent\",\n\n /**\r\n * Fires an event in a target.\r\n * @param {EventTarget} eventTarget - target where event should be fired.\r\n * @param {string} eventName event to fire.\r\n * @static\r\n */\n value: function fireEvent(eventTarget, eventName) {\n if (document.createEvent) {\n var eventObject = document.createEvent('HTMLEvents');\n eventObject.initEvent(eventName, true, true);\n return !eventTarget.dispatchEvent(eventObject);\n }\n\n var eventObject = document.createEventObject();\n return eventTarget.fireEvent('on' + eventName, eventObject);\n }\n /**\r\n * Cross-browser addEventListener/attachEvent function.\r\n * @param {EventTarget} eventTarget - target to add the event.\r\n * @param {string} eventName - specifies the type of event.\r\n * @param {Function} callBackFunction - callback function.\r\n * @static\r\n */\n\n }, {\n key: \"addEvent\",\n value: function addEvent(eventTarget, eventName, callBackFunction) {\n if (eventTarget.addEventListener) {\n eventTarget.addEventListener(eventName, callBackFunction, true);\n } else if (eventTarget.attachEvent) {\n // Backwards compatibility.\n eventTarget.attachEvent('on' + eventName, callBackFunction);\n }\n }\n /**\r\n * Cross-browser removeEventListener/detachEvent function.\r\n * @param {EventTarget} eventTarget - target to add the event.\r\n * @param {string} eventName - specifies the type of event.\r\n * @param {Function} callBackFunction - function to remove from the event target.\r\n * @static\r\n */\n\n }, {\n key: \"removeEvent\",\n value: function removeEvent(eventTarget, eventName, callBackFunction) {\n if (eventTarget.removeEventListener) {\n eventTarget.removeEventListener(eventName, callBackFunction, true);\n } else if (eventTarget.detachEvent) {\n eventTarget.detachEvent('on' + eventName, callBackFunction);\n }\n }\n /**\r\n * Adds the a callback function, for a certain event target, to the following event types:\r\n * - dblclick\r\n * - mousedown\r\n * - mouseup\r\n * @param {EventTarget} eventTarget - event target.\r\n * @param {Function} doubleClickHandler - function to run when on dblclick event.\r\n * @param {Function} mousedownHandler - function to run when on mousedown event.\r\n * @param {Function} mouseupHandler - function to run when on mouseup event.\r\n * @static\r\n */\n\n }, {\n key: \"addElementEvents\",\n value: function addElementEvents(eventTarget, doubleClickHandler, mousedownHandler, mouseupHandler) {\n if (doubleClickHandler) {\n Util.addEvent(eventTarget, 'dblclick', function (event) {\n var realEvent = event ? event : window.event;\n var element = realEvent.srcElement ? realEvent.srcElement : realEvent.target;\n doubleClickHandler(element, realEvent);\n });\n }\n\n if (mousedownHandler) {\n Util.addEvent(eventTarget, 'mousedown', function (event) {\n var realEvent = event ? event : window.event;\n var element = realEvent.srcElement ? realEvent.srcElement : realEvent.target;\n mousedownHandler(element, realEvent);\n });\n }\n\n if (mouseupHandler) {\n Util.addEvent(eventTarget, 'mouseup', function (event) {\n var realEvent = event ? event : window.event;\n var element = realEvent.srcElement ? realEvent.srcElement : realEvent.target;\n mouseupHandler(element, realEvent);\n });\n }\n }\n /**\r\n * Adds a class name to a HTMLElement.\r\n * @param {HTMLElement} element - the HTML element.\r\n * @param {string} className - the class name.\r\n * @static\r\n */\n\n }, {\n key: \"addClass\",\n value: function addClass(element, className) {\n if (!Util.containsClass(element, className)) {\n element.className += \" \" + className;\n }\n }\n /**\r\n * Checks if a HTMLElement contains a certain class.\r\n * @param {HTMLElement} element - the HTML element.\r\n * @param {string} className - the className.\r\n * @returns {boolean} true if the HTMLElement contains the class name. false otherwise.\r\n * @static\r\n */\n\n }, {\n key: \"containsClass\",\n value: function containsClass(element, className) {\n if (element == null || !('className' in element)) {\n return false;\n }\n\n var currentClasses = element.className.split(' ');\n\n for (var i = currentClasses.length - 1; i >= 0; --i) {\n if (currentClasses[i] == className) {\n return true;\n }\n }\n\n return false;\n }\n /**\r\n * Remove a certain class for a HTMLElement.\r\n * @param {HTMLElement} element - the HTML element.\r\n * @param {string} className - the class name.\r\n * @static\r\n */\n\n }, {\n key: \"removeClass\",\n value: function removeClass(element, className) {\n var newClassName = '';\n var classes = element.className.split(\" \");\n\n for (var i = 0; i < classes.length; i++) {\n if (classes[i] != className) {\n newClassName += classes[i] + \" \";\n }\n }\n\n element.className = newClassName.trim();\n }\n /**\r\n * Converts old xml initial text attribute (with «») to the correct one(with §lt;§gt;). It's\r\n * used to parse old applets.\r\n * @param {string} text - string containing safeXml characters\r\n * @returns {string} a string with safeXml characters parsed.\r\n * @static\r\n */\n\n }, {\n key: \"convertOldXmlinitialtextAttribute\",\n value: function convertOldXmlinitialtextAttribute(text) {\n // Used to fix a bug with Cas imported from Moodle 1.9 to Moodle 2.x.\n // This could be removed in future.\n var val = 'value=';\n var xitpos = text.indexOf('xmlinitialtext');\n var valpos = text.indexOf(val, xitpos);\n var quote = text.charAt(valpos + val.length);\n var startquote = valpos + val.length + 1;\n var endquote = text.indexOf(quote, startquote);\n var value = text.substring(startquote, endquote);\n var newvalue = value.split('«').join('§lt;');\n newvalue = newvalue.split('»').join('§gt;');\n newvalue = newvalue.split('&').join('§');\n newvalue = newvalue.split('¨').join('§quot;');\n text = text.split(value).join(newvalue);\n return text;\n }\n /**\r\n * Cross-browser solution for creating new elements.\r\n * @param {string} tagName - tag name of the wished element.\r\n * @param {Object} attributes - an object where each key is a wished attribute name and each value is its value.\r\n * @param {Object} [creator] - if supplied, this function will use the \"createElement\" method from this param. Otherwise\r\n * document will be used as creator.\r\n * @returns {Element} The DOM element with the specified attributes assigned.\r\n * @static\r\n */\n\n }, {\n key: \"createElement\",\n value: function createElement(tagName, attributes, creator) {\n if (attributes === undefined) {\n attributes = {};\n }\n\n if (creator === undefined) {\n creator = document;\n }\n\n var element;\n /*\r\n * Internet Explorer fix:\r\n * If you create a new object dynamically, you can't set a non-standard attribute.\r\n * For example, you can't set the \"src\" attribute on an \"applet\" object.\r\n * Other browsers will throw an exception and will run the standard code.\r\n */\n\n try {\n var html = '<' + tagName;\n\n for (var attributeName in attributes) {\n html += ' ' + attributeName + '=\"' + Util.htmlEntities(attributes[attributeName]) + '\"';\n }\n\n html += '>';\n element = creator.createElement(html);\n } catch (e) {\n element = creator.createElement(tagName);\n\n for (var attributeName in attributes) {\n element.setAttribute(attributeName, attributes[attributeName]);\n }\n }\n\n return element;\n }\n /**\r\n * Creates new HTML from it's HTML code as string.\r\n * @param {string} objectCode - html code\r\n * @returns {Element} the HTML element.\r\n * @static\r\n */\n\n }, {\n key: \"createObject\",\n value: function createObject(objectCode, creator) {\n if (creator === undefined) {\n creator = document;\n } // Internet Explorer can't include \"param\" tag when is setting an innerHTML property.\n\n\n objectCode = objectCode.split('').join('').split('').join('');\n objectCode = objectCode.split('').join('
').split('').join('
');\n var container = Util.createElement('div', {}, creator);\n container.innerHTML = objectCode;\n\n function recursiveParamsFix(object) {\n if (object.getAttribute && object.getAttribute('wirisObject') == 'WirisParam') {\n var attributesParsed = {};\n\n for (var i = 0; i < object.attributes.length; ++i) {\n if (object.attributes[i].nodeValue !== null) {\n attributesParsed[object.attributes[i].nodeName] = object.attributes[i].nodeValue;\n }\n }\n\n var param = Util.createElement('param', attributesParsed, creator); // IE fix.\n\n if (param.NAME) {\n param.name = param.NAME;\n param.value = param.VALUE;\n }\n\n param.removeAttribute('wirisObject');\n object.parentNode.replaceChild(param, object);\n } else if (object.getAttribute && object.getAttribute('wirisObject') == 'WirisApplet') {\n var attributesParsed = {};\n\n for (var i = 0; i < object.attributes.length; ++i) {\n if (object.attributes[i].nodeValue !== null) {\n attributesParsed[object.attributes[i].nodeName] = object.attributes[i].nodeValue;\n }\n }\n\n var applet = Util.createElement('applet', attributesParsed, creator);\n applet.removeAttribute('wirisObject');\n\n for (var i = 0; i < object.childNodes.length; ++i) {\n recursiveParamsFix(object.childNodes[i]);\n\n if (object.childNodes[i].nodeName.toLowerCase() == 'param') {\n applet.appendChild(object.childNodes[i]);\n --i; // When we insert the object child into the applet, object loses one child.\n }\n }\n\n object.parentNode.replaceChild(applet, object);\n } else {\n for (var i = 0; i < object.childNodes.length; ++i) {\n recursiveParamsFix(object.childNodes[i]);\n }\n }\n }\n\n recursiveParamsFix(container);\n return container.firstChild;\n }\n /**\r\n * Converts an Element to its HTML code.\r\n * @param {Element} element - entry element.\r\n * @return {string} the HTML code of the input element.\r\n * @static\r\n */\n\n }, {\n key: \"createObjectCode\",\n value: function createObjectCode(element) {\n // In case that the image was not created, the object can be null or undefined.\n if (typeof element == 'undefined' || element == null) {\n return;\n }\n\n if (element.nodeType == 1) {\n // ELEMENT_NODE.\n var output = '<' + element.tagName;\n\n for (var i = 0; i < element.attributes.length; ++i) {\n if (element.attributes[i].specified) {\n output += ' ' + element.attributes[i].name + '=\"' + Util.htmlEntities(element.attributes[i].value) + '\"';\n }\n }\n\n if (element.childNodes.length > 0) {\n output += '>';\n\n for (var i = 0; i < element.childNodes.length; ++i) {\n output += Util.createObject(element.childNodes[i]);\n }\n\n output += '';\n } else if (element.nodeName == 'DIV' || element.nodeName == 'SCRIPT') {\n output += '>';\n } else {\n output += '/>';\n }\n\n return output;\n }\n\n if (element.nodeType == 3) {\n // TEXT_NODE.\n return Util.htmlEntities(element.nodeValue);\n }\n\n return '';\n }\n /**\r\n * Concatenates two URL paths.\r\n * @param {string} path1 - first URL path\r\n * @param {string} path2 - second URL path\r\n * @returns {string} new URL.\r\n */\n\n }, {\n key: \"concatenateUrl\",\n value: function concatenateUrl(path1, path2) {\n var separator = \"\";\n\n if (path1.indexOf(\"/\") != path1.length && path2.indexOf(\"/\") != 0) {\n separator = \"/\";\n }\n\n return (path1 + separator + path2).replace(/([^:]\\/)\\/+/g, \"$1\");\n }\n /**\r\n * Parses a text and replaces all HTML special characters by their correspondent entities.\r\n * @param {string} input - text to be parsed.\r\n * @returns {string} the input text with all their special characters replaced by their entities.\r\n * @static\r\n */\n\n }, {\n key: \"htmlEntities\",\n value: function htmlEntities(input) {\n return input.split('&').join('&').split('<').join('<').split('>').join('>').split('\"').join('"');\n }\n /**\r\n * Parses a text and replaces all the HTML entities by their characters.\r\n * @param {string} input - text to be parsed\r\n * @returns {string} the input text with all their entities replaced by characters.\r\n * @static\r\n */\n\n }, {\n key: \"htmlEntitiesDecode\",\n value: function htmlEntitiesDecode(input) {\n return input.split('"').join('\"').split('>').join('>').split('<').join('<').split('&').join('&');\n }\n /**\r\n * Returns a cross-browser http request.\r\n * @return {object} httpRequest request object.\r\n * @returns {XMLHttpRequest|ActiveXObject} the proper request object.\r\n */\n\n }, {\n key: \"createHttpRequest\",\n value: function createHttpRequest() {\n var currentPath = window.location.toString().substr(0, window.location.toString().lastIndexOf('/') + 1);\n\n if (currentPath.substr(0, 7) == 'file://') {\n throw Core.getStringManager().getString('exception_cross_site');\n }\n\n if (typeof XMLHttpRequest != 'undefined') {\n return new XMLHttpRequest();\n }\n\n try {\n return new ActiveXObject('Msxml2.XMLHTTP');\n } catch (e) {\n try {\n return new ActiveXObject('Microsoft.XMLHTTP');\n } catch (oc) {}\n }\n\n return false;\n }\n /**\r\n * Converts a hash to a HTTP query.\r\n * @param {Object[]} properties - a key/value object.\r\n * @returns {string} a HTTP query containing all the key value pairs with all the special characters replaced by their entities.\r\n * @static\r\n */\n\n }, {\n key: \"httpBuildQuery\",\n value: function httpBuildQuery(properties) {\n var result = '';\n\n for (var i in properties) {\n if (properties[i] != null) {\n result += Util.urlEncode(i) + '=' + Util.urlEncode(properties[i]) + '&';\n }\n } // Deleting last '&' empty character.\n\n\n if (result.substring(result.length - 1) == '&') {\n result = result.substring(0, result.length - 1);\n }\n\n return result;\n }\n /**\r\n * Convert a hash to string sorting keys to get a deterministic output\r\n * @param {Object[]} hash - a key/value object.\r\n * @returns {string} a string with the form key1=value1...keyn=valuen\r\n * @static\r\n */\n\n }, {\n key: \"propertiesToString\",\n value: function propertiesToString(hash) {\n // 1. Sort keys. We sort the keys because we want a deterministic output.\n var keys = [];\n\n for (var key in hash) {\n if (hash.hasOwnProperty(key)) {\n keys.push(key);\n }\n }\n\n var n = keys.length;\n\n for (var i = 0; i < n; i++) {\n for (var j = i + 1; j < n; j++) {\n var s1 = keys[i];\n var s2 = keys[j];\n\n if (Util.compareStrings(s1, s2) > 0) {\n // Swap.\n keys[i] = s2;\n keys[j] = s1;\n }\n }\n } // 2. Generate output.\n\n\n var output = '';\n\n for (var i = 0; i < n; i++) {\n var key = keys[i];\n output += key;\n output += \"=\";\n var value = hash[key];\n value = value.replace(\"\\\\\", \"\\\\\\\\\");\n value = value.replace(\"\\n\", \"\\\\n\");\n value = value.replace(\"\\r\", \"\\\\r\");\n value = value.replace(\"\\t\", \"\\\\t\");\n output += value;\n output += \"\\n\";\n }\n\n return output;\n }\n /**\r\n * Compare two strings using charCodeAt method\r\n * @param {string} a - first string to compare.\r\n * @param {string} b - second string to compare.\r\n * @returns {number} the difference between a and b\r\n * @static\r\n */\n\n }, {\n key: \"compareStrings\",\n value: function compareStrings(a, b) {\n var i;\n var an = a.length;\n var bn = b.length;\n var n = an > bn ? bn : an;\n\n for (i = 0; i < n; i++) {\n var c = Util.fixedCharCodeAt(a, i) - Util.fixedCharCodeAt(b, i);\n\n if (c != 0) {\n return c;\n }\n }\n\n return a.length - b.length;\n }\n /**\r\n * Fix charCodeAt() JavaScript function to handle non-Basic-Multilingual-Plane characters.\r\n * @param {string} string - input string\r\n * @param {number} idx - an integer greater than or equal to 0 and less than the length of the string\r\n * @returns {number} an integer representing the UTF-16 code of the string at the given index.\r\n * @static\r\n */\n\n }, {\n key: \"fixedCharCodeAt\",\n value: function fixedCharCodeAt(string, idx) {\n idx = idx || 0;\n var code = string.charCodeAt(idx);\n var hi, low;\n /* High surrogate (could change last hex to 0xDB7F to treat high\r\n private surrogates as single characters) */\n\n if (0xD800 <= code && code <= 0xDBFF) {\n hi = code;\n low = string.charCodeAt(idx + 1);\n\n if (isNaN(low)) {\n throw Core.getStringManager().getString('exception_high_surrogate');\n }\n\n return (hi - 0xD800) * 0x400 + (low - 0xDC00) + 0x10000;\n }\n\n if (0xDC00 <= code && code <= 0xDFFF) {\n // Low surrogate.\n\n /* We return false to allow loops to skip this iteration since should have\r\n already handled high surrogate above in the previous iteration. */\n return false;\n }\n\n return code;\n }\n /**\r\n * Returns an URL with it's query params converted into array.\r\n * @param {string} url - input URL.\r\n * @returns {Object[]} an array containing all URL query params.\r\n * @static\r\n */\n\n }, {\n key: \"urlToAssArray\",\n value: function urlToAssArray(url) {\n var i;\n i = url.indexOf(\"?\");\n\n if (i > 0) {\n var query = url.substring(i + 1);\n var ss = query.split(\"&\");\n var h = new Object();\n\n for (i = 0; i < ss.length; i++) {\n var s = ss[i];\n var kv = s.split(\"=\");\n\n if (kv.length > 1) {\n h[kv[0]] = decodeURIComponent(kv[1].replace(/\\+/g, ' '));\n }\n }\n\n return h;\n } else {\n return new Object();\n }\n }\n /**\r\n * Returns an encoded URL by replacing each instance of certain characters by\r\n * one, two, three or four escape sequences using encodeURIComponent method.\r\n * !'()* . will not be encoded.\r\n *\r\n * @param {string} clearString - URL string to be encoded\r\n * @returns {string} URL with it's special characters replaced.\r\n * @static\r\n */\n\n }, {\n key: \"urlEncode\",\n value: function urlEncode(clearString) {\n var output = ''; // Method encodeURIComponent doesn't encode !'()*~ .\n\n output = encodeURIComponent(clearString);\n return output;\n } // TODO: To parser?\n\n /**\r\n * Converts the HTML of a image into the output code that WIRIS must return.\r\n * By default returns the MathML stored on data-mahml attribute (if imgCode is a formula)\r\n * or the Wiriscas attribute of a WIRIS applet.\r\n * @param {string} imgCode - the html code from a formula or a CAS image.\r\n * @param {boolean} convertToXml - true if the image should be converted to XML.\r\n * @param {boolean} convertToSafeXml - true if the image should be converted to safeXML.\r\n * @returns {string} the XML or safeXML of a WIRIS image.\r\n * @static\r\n */\n\n }, {\n key: \"getWIRISImageOutput\",\n value: function getWIRISImageOutput(imgCode, convertToXml, convertToSafeXml) {\n var imgObject = Util.createObject(imgCode);\n\n if (imgObject) {\n if (imgObject.className == _configuration__WEBPACK_IMPORTED_MODULE_1__[\"default\"].get('imageClassName') || imgObject.getAttribute(_configuration__WEBPACK_IMPORTED_MODULE_1__[\"default\"].get('imageMathmlAttribute'))) {\n if (!convertToXml) {\n return imgCode;\n }\n\n var xmlCode = imgObject.getAttribute(_configuration__WEBPACK_IMPORTED_MODULE_1__[\"default\"].get('imageMathmlAttribute'));\n\n if (xmlCode == null) {\n xmlCode = imgObject.getAttribute('alt');\n }\n\n if (!convertToSafeXml) {\n xmlCode = _mathml__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlDecode(xmlCode);\n }\n\n return xmlCode;\n } else if (imgObject.className == _configuration__WEBPACK_IMPORTED_MODULE_1__[\"default\"].get('CASClassName')) {\n var appletCode = imgObject.getAttribute(_configuration__WEBPACK_IMPORTED_MODULE_1__[\"default\"].get('CASMathmlAttribute'));\n appletCode = _mathml__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlDecode(appletCode);\n var appletObject = Util.createObject(appletCode);\n appletObject.setAttribute('src', imgObject.src);\n var object = appletObject;\n var appletCodeToBeInserted = Util.createObjectCode(appletObject);\n\n if (convertToSafeXml) {\n appletCodeToBeInserted = _mathml__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlEncode(appletCodeToBeInserted);\n }\n\n return appletCodeToBeInserted;\n }\n }\n\n return imgCode;\n }\n /**\r\n * Gets the node length in characters.\r\n * @param {Node} node - HTML node.\r\n * @returns {number} node length.\r\n * @static\r\n */\n\n }, {\n key: \"getNodeLength\",\n value: function (_getNodeLength) {\n function getNodeLength(_x) {\n return _getNodeLength.apply(this, arguments);\n }\n\n getNodeLength.toString = function () {\n return _getNodeLength.toString();\n };\n\n return getNodeLength;\n }(function (node) {\n var staticNodeLengths = {\n 'IMG': 1,\n 'BR': 1\n };\n\n if (node.nodeType == 3) {\n // TEXT_NODE.\n return node.nodeValue.length;\n }\n\n if (node.nodeType == 1) {\n // ELEMENT_NODE.\n var length = staticNodeLengths[node.nodeName.toUpperCase()];\n\n if (length === undefined) {\n length = 0;\n }\n\n for (var i = 0; i < node.childNodes.length; ++i) {\n length += getNodeLength(node.childNodes[i]);\n }\n\n return length;\n }\n\n return 0;\n })\n /**\r\n * Gets a selected node or text from an editable HTMLElement.\r\n * If the caret is on a text node, concatenates it with all the previous and next text nodes.\r\n * @param {HTMLElement} target - the editable HTMLElement.\r\n * @param {boolean} isIframe - specifies if the target is an iframe or not\r\n * @param {boolean} forceGetSelection - if true, ignores IE system to get the current selection and uses window.getSelection()\r\n * @returns {object} an object with the 'node' key set if the item is an element or the keys 'node' and 'caretPosition' if the element is text.\r\n * @static\r\n */\n\n }, {\n key: \"getSelectedItem\",\n value: function getSelectedItem(target, isIframe, forceGetSelection) {\n var windowTarget;\n\n if (isIframe) {\n windowTarget = target.contentWindow;\n windowTarget.focus();\n } else {\n windowTarget = window;\n target.focus();\n }\n\n if (document.selection && !forceGetSelection) {\n var range = windowTarget.document.selection.createRange();\n\n if (range.parentElement) {\n if (range.htmlText.length > 0) {\n if (range.text.length == 0) {\n return Util.getSelectedItem(target, isIframe, true);\n }\n\n return null;\n }\n\n windowTarget.document.execCommand('InsertImage', false, '#');\n var temporalObject = range.parentElement();\n\n if (temporalObject.nodeName.toUpperCase() != 'IMG') {\n // IE9 fix: parentElement() does not return the IMG node, returns the parent DIV node. In IE < 9, pasteHTML does not work well.\n range.pasteHTML('');\n temporalObject = windowTarget.document.getElementById('wrs_openEditorWindow_temporalObject');\n }\n\n var node;\n var caretPosition;\n\n if (temporalObject.nextSibling && temporalObject.nextSibling.nodeType == 3) {\n // TEXT_NODE.\n node = temporalObject.nextSibling;\n caretPosition = 0;\n } else if (temporalObject.previousSibling && temporalObject.previousSibling.nodeType == 3) {\n // TEXT_NODE.\n node = temporalObject.previousSibling;\n caretPosition = node.nodeValue.length;\n } else {\n node = windowTarget.document.createTextNode('');\n temporalObject.parentNode.insertBefore(node, temporalObject);\n caretPosition = 0;\n }\n\n temporalObject.parentNode.removeChild(temporalObject);\n return {\n 'node': node,\n 'caretPosition': caretPosition\n };\n }\n\n if (range.length > 1) {\n return null;\n }\n\n return {\n 'node': range.item(0)\n };\n }\n\n if (windowTarget.getSelection) {\n var selection = windowTarget.getSelection();\n\n try {\n var range = selection.getRangeAt(0);\n } catch (e) {\n var range = windowTarget.document.createRange();\n }\n\n var node = range.startContainer;\n\n if (node.nodeType == 3) {\n // TEXT_NODE.\n return {\n 'node': node,\n 'caretPosition': range.startOffset\n };\n }\n\n if (node != range.endContainer) {\n return null;\n }\n\n if (node.nodeType == 1) {\n // ELEMENT_NODE.\n var position = range.startOffset;\n\n if (node.childNodes[position]) {\n return {\n 'node': node.childNodes[position]\n };\n }\n }\n }\n\n return null;\n }\n /**\r\n * Returns null if there isn't any item or if it is malformed.\r\n * Otherwise returns an object containing the node with the MathML image\r\n * and the cursor position inside the textarea.\r\n * @param {HTMLTextAreaElement} textarea - textarea element.\r\n * @returns {Object} An object containing the node, the index of the\r\n * beginning of the selected text, caret position and the start and end position of the\r\n * text node.\r\n * @static\r\n */\n\n }, {\n key: \"getSelectedItemOnTextarea\",\n value: function getSelectedItemOnTextarea(textarea) {\n var textNode = document.createTextNode(textarea.value);\n var textNodeValues = _latex__WEBPACK_IMPORTED_MODULE_2__[\"default\"].getLatexFromTextNode(textNode, textarea.selectionStart);\n\n if (textNodeValues === null) {\n return null;\n }\n\n ;\n return {\n 'node': textNode,\n 'caretPosition': textarea.selectionStart,\n 'startPosition': textNodeValues.startPosition,\n 'endPosition': textNodeValues.endPosition\n };\n }\n /**\r\n * Looks for elements that match the given name in a HTML code string.\r\n * Important: this function is very concrete for WIRIS code. It takes as preconditions lots of behaviors that are not the general case.\r\n * @param {string} code - HTML code.\r\n * @param {string} name - element name.\r\n * @param {boolean} autoClosed - true if the elements are autoClosed.\r\n * @return {Object[]} an object containing all HTML elements of code matching the name argument.\r\n * @static\r\n */\n\n }, {\n key: \"getElementsByNameFromString\",\n value: function getElementsByNameFromString(code, name, autoClosed) {\n var elements = [];\n var code = code.toLowerCase();\n name = name.toLowerCase();\n var start = code.indexOf('<' + name + ' ');\n\n while (start != -1) {\n // Look for nodes.\n var endString;\n\n if (autoClosed) {\n endString = '>';\n } else {\n endString = '';\n }\n\n var end = code.indexOf(endString, start);\n\n if (end != -1) {\n end += endString.length;\n elements.push({\n 'start': start,\n 'end': end\n });\n } else {\n end = start + 1;\n }\n\n start = code.indexOf('<' + name + ' ', end);\n }\n\n return elements;\n }\n /**\r\n * Returns the numeric value of a base64 character.\r\n * @param {string} character - base64 character.\r\n * @returns {number} base64 character numeric value.\r\n * @static\r\n */\n\n }, {\n key: \"decode64\",\n value: function decode64(character) {\n var PLUS = '+'.charCodeAt(0);\n var SLASH = '/'.charCodeAt(0);\n var NUMBER = '0'.charCodeAt(0);\n var LOWER = 'a'.charCodeAt(0);\n var UPPER = 'A'.charCodeAt(0);\n var PLUS_URL_SAFE = '-'.charCodeAt(0);\n var SLASH_URL_SAFE = '_'.charCodeAt(0);\n var code = character.charCodeAt(0);\n\n if (code === PLUS || code === PLUS_URL_SAFE) {\n return 62; // Char '+'.\n }\n\n if (code === SLASH || code === SLASH_URL_SAFE) {\n return 63; // Char '/'.\n }\n\n if (code < NUMBER) {\n return -1; // No match.\n }\n\n if (code < NUMBER + 10) {\n return code - NUMBER + 26 + 26;\n }\n\n if (code < UPPER + 26) {\n return code - UPPER;\n }\n\n if (code < LOWER + 26) {\n return code - LOWER + 26;\n }\n }\n /**\r\n * Converts a base64 string to a array of bytes.\r\n * @param {string} b64String - base64 string.\r\n * @param {number} length - dimension of byte array (by default whole string).\r\n * @return {Object[]} the resultant byte array.\r\n * @static\r\n */\n\n }, {\n key: \"b64ToByteArray\",\n value: function b64ToByteArray(b64String, length) {\n var tmp;\n\n if (b64String.length % 4 > 0) {\n throw new Error('Invalid string. Length must be a multiple of 4'); // Tipped base64. Length is fixed.\n }\n\n var arr = new Array();\n\n if (!length) {\n // All b64String string.\n var placeHolders = b64String.charAt(b64String.length - 2) === '=' ? 2 : b64String.charAt(b64String.length - 1) === '=' ? 1 : 0;\n var l = placeHolders > 0 ? b64String.length - 4 : b64String.length;\n } else {\n var l = length;\n }\n\n for (var i = 0; i < l; i += 4) {\n // Ignoring code checker standards (bitewise operators).\n // See https://tracker.moodle.org/browse/CONTRIB-5862 for further information.\n // @codingStandardsIgnoreStart\n tmp = Util.decode64(b64String.charAt(i)) << 18 | Util.decode64(b64String.charAt(i + 1)) << 12 | Util.decode64(b64String.charAt(i + 2)) << 6 | Util.decode64(b64String.charAt(i + 3));\n arr.push(tmp >> 16 & 0xFF);\n arr.push(tmp >> 8 & 0xFF);\n arr.push(tmp & 0xFF); // @codingStandardsIgnoreEnd\n }\n\n if (placeHolders) {\n if (placeHolders === 2) {\n // Ignoring code checker standards (bitewise operators).\n // @codingStandardsIgnoreStart\n tmp = Util.decode64(b64String.charAt(i)) << 2 | Util.decode64(b64String.charAt(i + 1)) >> 4;\n arr.push(tmp & 0xFF);\n } else if (placeHolders === 1) {\n tmp = Util.decode64(b64String.charAt(i)) << 10 | Util.decode64(b64String.charAt(i + 1)) << 4 | Util.decode64(b64String.charAt(i + 2)) >> 2;\n arr.push(tmp >> 8 & 0xFF);\n arr.push(tmp & 0xFF); // @codingStandardsIgnoreEnd\n }\n }\n\n return arr;\n }\n /**\r\n * Returns the first 32-bit signed integer from a byte array.\r\n * @param {Object[]} bytes - array of bytes.\r\n * @returns {number} the 32-bit signed integer.\r\n * @static\r\n */\n\n }, {\n key: \"readInt32\",\n value: function readInt32(bytes) {\n if (bytes.length < 4) {\n return false;\n }\n\n var int32 = bytes.splice(0, 4); // @codingStandardsIgnoreStart\n\n return int32[0] << 24 | int32[1] << 16 | int32[2] << 8 | int32[3] << 0; // @codingStandardsIgnoreEnd\n }\n /**\r\n * Read the first byte from a byte array.\r\n * @param {Object} bytes - input byte array.\r\n * @returns {number} first byte of the byte array.\r\n * @static\r\n */\n\n }, {\n key: \"readByte\",\n value: function readByte(bytes) {\n // @codingStandardsIgnoreStart\n return bytes.shift() << 0; // @codingStandardsIgnoreEnd\n }\n /**\r\n * Read an arbitrary number of bytes, from a fixed position on a byte array.\r\n * @param {Object[]} bytes - byte array.\r\n * @param {number} pos - start position.\r\n * @param {number} len - number of bytes to read.\r\n * @returns {Object[]} the byte array.\r\n * @static\r\n */\n\n }, {\n key: \"readBytes\",\n value: function readBytes(bytes, pos, len) {\n return bytes.splice(pos, len);\n }\n /**\r\n * Inserts or modifies formulas or CAS on a textarea.\r\n * @param {HTMLTextAreaElement} textarea - textarea target.\r\n * @param {string} text - text to add in the textarea. For example, to add the link to the image,\r\n * call this function as (textarea, Parser.createImageSrc(mathml));\r\n * @static\r\n */\n\n }, {\n key: \"updateTextArea\",\n value: function updateTextArea(textarea, text) {\n if (textarea && text) {\n textarea.focus();\n\n if (textarea.selectionStart != null) {\n var selectionEnd = textarea.selectionEnd;\n textarea.value = textarea.value.substring(0, textarea.selectionStart) + text + textarea.value.substring(textarea.selectionEnd, textarea.value.length);\n textarea.selectionEnd = selectionEnd + text.length;\n } else {\n var selection = document.selection.createRange();\n selection.text = text;\n }\n }\n }\n /**\r\n * Modifies existing formula on a textarea.\r\n * @param {HTMLTextAreaElement} textarea - text area target.\r\n * @param {string} text - text to add in the textarea. For example, if you want to add the link to the image, you can call this function as Util.updateTextarea(textarea, Parser.createImageSrc(mathml));\r\n * @param {number} start - beginning index from textarea where it needs to be replaced by text.\r\n * @param {number} end - ending index from textarea where it needs to be replaced by text\r\n * @static\r\n */\n\n }, {\n key: \"updateExistingTextOnTextarea\",\n value: function updateExistingTextOnTextarea(textarea, text, start, end) {\n textarea.focus();\n textarea.value = textarea.value.substring(0, start) + text + textarea.value.substring(end, textarea.value.length);\n textarea.selectionEnd = start + text.length;\n }\n /**\r\n * Add a parameter with it's correspondent value to an URL (GET).\r\n * @param {string} path - URL path\r\n * @param {string} parameter - parameter\r\n * @param {string} value - value\r\n * @static\r\n */\n\n }, {\n key: \"addArgument\",\n value: function addArgument(path, parameter, value) {\n var sep;\n\n if (path.indexOf(\"?\") > 0) {\n sep = \"&\";\n } else {\n sep = \"?\";\n }\n\n return path + sep + parameter + \"=\" + value;\n }\n }]);\n\n return Util;\n}();\n\n\n\n//# sourceURL=webpack:///./core/src/util.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"default\", function() { return Util; });\n/* harmony import */ var _mathml__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./mathml */ \"./core/src/mathml.js\");\n/* harmony import */ var _configuration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./configuration */ \"./core/src/configuration.js\");\n/* harmony import */ var _latex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./latex */ \"./core/src/latex.js\");\n/* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./constants */ \"./core/src/constants.js\");\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\n\n\n\n\n/**\r\n * This class represents an utility class.\r\n */\n\nvar Util =\n/*#__PURE__*/\nfunction () {\n function Util() {\n _classCallCheck(this, Util);\n }\n\n _createClass(Util, null, [{\n key: \"fireEvent\",\n\n /**\r\n * Fires an event in a target.\r\n * @param {EventTarget} eventTarget - target where event should be fired.\r\n * @param {string} eventName event to fire.\r\n * @static\r\n */\n value: function fireEvent(eventTarget, eventName) {\n if (document.createEvent) {\n var eventObject = document.createEvent('HTMLEvents');\n eventObject.initEvent(eventName, true, true);\n return !eventTarget.dispatchEvent(eventObject);\n }\n\n var eventObject = document.createEventObject();\n return eventTarget.fireEvent('on' + eventName, eventObject);\n }\n /**\r\n * Cross-browser addEventListener/attachEvent function.\r\n * @param {EventTarget} eventTarget - target to add the event.\r\n * @param {string} eventName - specifies the type of event.\r\n * @param {Function} callBackFunction - callback function.\r\n * @static\r\n */\n\n }, {\n key: \"addEvent\",\n value: function addEvent(eventTarget, eventName, callBackFunction) {\n if (eventTarget.addEventListener) {\n eventTarget.addEventListener(eventName, callBackFunction, true);\n } else if (eventTarget.attachEvent) {\n // Backwards compatibility.\n eventTarget.attachEvent('on' + eventName, callBackFunction);\n }\n }\n /**\r\n * Cross-browser removeEventListener/detachEvent function.\r\n * @param {EventTarget} eventTarget - target to add the event.\r\n * @param {string} eventName - specifies the type of event.\r\n * @param {Function} callBackFunction - function to remove from the event target.\r\n * @static\r\n */\n\n }, {\n key: \"removeEvent\",\n value: function removeEvent(eventTarget, eventName, callBackFunction) {\n if (eventTarget.removeEventListener) {\n eventTarget.removeEventListener(eventName, callBackFunction, true);\n } else if (eventTarget.detachEvent) {\n eventTarget.detachEvent('on' + eventName, callBackFunction);\n }\n }\n /**\r\n * Adds the a callback function, for a certain event target, to the following event types:\r\n * - dblclick\r\n * - mousedown\r\n * - mouseup\r\n * @param {EventTarget} eventTarget - event target.\r\n * @param {Function} doubleClickHandler - function to run when on dblclick event.\r\n * @param {Function} mousedownHandler - function to run when on mousedown event.\r\n * @param {Function} mouseupHandler - function to run when on mouseup event.\r\n * @static\r\n */\n\n }, {\n key: \"addElementEvents\",\n value: function addElementEvents(eventTarget, doubleClickHandler, mousedownHandler, mouseupHandler) {\n if (doubleClickHandler) {\n Util.addEvent(eventTarget, 'dblclick', function (event) {\n var realEvent = event ? event : window.event;\n var element = realEvent.srcElement ? realEvent.srcElement : realEvent.target;\n doubleClickHandler(element, realEvent);\n });\n }\n\n if (mousedownHandler) {\n Util.addEvent(eventTarget, 'mousedown', function (event) {\n var realEvent = event ? event : window.event;\n var element = realEvent.srcElement ? realEvent.srcElement : realEvent.target;\n mousedownHandler(element, realEvent);\n });\n }\n\n if (mouseupHandler) {\n Util.addEvent(eventTarget, 'mouseup', function (event) {\n var realEvent = event ? event : window.event;\n var element = realEvent.srcElement ? realEvent.srcElement : realEvent.target;\n mouseupHandler(element, realEvent);\n });\n }\n }\n /**\r\n * Adds a class name to a HTMLElement.\r\n * @param {HTMLElement} element - the HTML element.\r\n * @param {string} className - the class name.\r\n * @static\r\n */\n\n }, {\n key: \"addClass\",\n value: function addClass(element, className) {\n if (!Util.containsClass(element, className)) {\n element.className += \" \" + className;\n }\n }\n /**\r\n * Checks if a HTMLElement contains a certain class.\r\n * @param {HTMLElement} element - the HTML element.\r\n * @param {string} className - the className.\r\n * @returns {boolean} true if the HTMLElement contains the class name. false otherwise.\r\n * @static\r\n */\n\n }, {\n key: \"containsClass\",\n value: function containsClass(element, className) {\n if (element == null || !('className' in element)) {\n return false;\n }\n\n var currentClasses = element.className.split(' ');\n\n for (var i = currentClasses.length - 1; i >= 0; --i) {\n if (currentClasses[i] == className) {\n return true;\n }\n }\n\n return false;\n }\n /**\r\n * Remove a certain class for a HTMLElement.\r\n * @param {HTMLElement} element - the HTML element.\r\n * @param {string} className - the class name.\r\n * @static\r\n */\n\n }, {\n key: \"removeClass\",\n value: function removeClass(element, className) {\n var newClassName = '';\n var classes = element.className.split(\" \");\n\n for (var i = 0; i < classes.length; i++) {\n if (classes[i] != className) {\n newClassName += classes[i] + \" \";\n }\n }\n\n element.className = newClassName.trim();\n }\n /**\r\n * Converts old xml initial text attribute (with «») to the correct one(with §lt;§gt;). It's\r\n * used to parse old applets.\r\n * @param {string} text - string containing safeXml characters\r\n * @returns {string} a string with safeXml characters parsed.\r\n * @static\r\n */\n\n }, {\n key: \"convertOldXmlinitialtextAttribute\",\n value: function convertOldXmlinitialtextAttribute(text) {\n // Used to fix a bug with Cas imported from Moodle 1.9 to Moodle 2.x.\n // This could be removed in future.\n var val = 'value=';\n var xitpos = text.indexOf('xmlinitialtext');\n var valpos = text.indexOf(val, xitpos);\n var quote = text.charAt(valpos + val.length);\n var startquote = valpos + val.length + 1;\n var endquote = text.indexOf(quote, startquote);\n var value = text.substring(startquote, endquote);\n var newvalue = value.split('«').join('§lt;');\n newvalue = newvalue.split('»').join('§gt;');\n newvalue = newvalue.split('&').join('§');\n newvalue = newvalue.split('¨').join('§quot;');\n text = text.split(value).join(newvalue);\n return text;\n }\n /**\r\n * Cross-browser solution for creating new elements.\r\n * @param {string} tagName - tag name of the wished element.\r\n * @param {Object} attributes - an object where each key is a wished attribute name and each value is its value.\r\n * @param {Object} [creator] - if supplied, this function will use the \"createElement\" method from this param. Otherwise\r\n * document will be used as creator.\r\n * @returns {Element} The DOM element with the specified attributes assigned.\r\n * @static\r\n */\n\n }, {\n key: \"createElement\",\n value: function createElement(tagName, attributes, creator) {\n if (attributes === undefined) {\n attributes = {};\n }\n\n if (creator === undefined) {\n creator = document;\n }\n\n var element;\n /*\r\n * Internet Explorer fix:\r\n * If you create a new object dynamically, you can't set a non-standard attribute.\r\n * For example, you can't set the \"src\" attribute on an \"applet\" object.\r\n * Other browsers will throw an exception and will run the standard code.\r\n */\n\n try {\n var html = '<' + tagName;\n\n for (var attributeName in attributes) {\n html += ' ' + attributeName + '=\"' + Util.htmlEntities(attributes[attributeName]) + '\"';\n }\n\n html += '>';\n element = creator.createElement(html);\n } catch (e) {\n element = creator.createElement(tagName);\n\n for (var attributeName in attributes) {\n element.setAttribute(attributeName, attributes[attributeName]);\n }\n }\n\n return element;\n }\n /**\r\n * Creates new HTML from it's HTML code as string.\r\n * @param {string} objectCode - html code\r\n * @returns {Element} the HTML element.\r\n * @static\r\n */\n\n }, {\n key: \"createObject\",\n value: function createObject(objectCode, creator) {\n if (creator === undefined) {\n creator = document;\n } // Internet Explorer can't include \"param\" tag when is setting an innerHTML property.\n\n\n objectCode = objectCode.split('').join('').split('').join('');\n objectCode = objectCode.split('').join('
').split('').join('
');\n var container = Util.createElement('div', {}, creator);\n container.innerHTML = objectCode;\n\n function recursiveParamsFix(object) {\n if (object.getAttribute && object.getAttribute('wirisObject') == 'WirisParam') {\n var attributesParsed = {};\n\n for (var i = 0; i < object.attributes.length; ++i) {\n if (object.attributes[i].nodeValue !== null) {\n attributesParsed[object.attributes[i].nodeName] = object.attributes[i].nodeValue;\n }\n }\n\n var param = Util.createElement('param', attributesParsed, creator); // IE fix.\n\n if (param.NAME) {\n param.name = param.NAME;\n param.value = param.VALUE;\n }\n\n param.removeAttribute('wirisObject');\n object.parentNode.replaceChild(param, object);\n } else if (object.getAttribute && object.getAttribute('wirisObject') == 'WirisApplet') {\n var attributesParsed = {};\n\n for (var i = 0; i < object.attributes.length; ++i) {\n if (object.attributes[i].nodeValue !== null) {\n attributesParsed[object.attributes[i].nodeName] = object.attributes[i].nodeValue;\n }\n }\n\n var applet = Util.createElement('applet', attributesParsed, creator);\n applet.removeAttribute('wirisObject');\n\n for (var i = 0; i < object.childNodes.length; ++i) {\n recursiveParamsFix(object.childNodes[i]);\n\n if (object.childNodes[i].nodeName.toLowerCase() == 'param') {\n applet.appendChild(object.childNodes[i]);\n --i; // When we insert the object child into the applet, object loses one child.\n }\n }\n\n object.parentNode.replaceChild(applet, object);\n } else {\n for (var i = 0; i < object.childNodes.length; ++i) {\n recursiveParamsFix(object.childNodes[i]);\n }\n }\n }\n\n recursiveParamsFix(container);\n return container.firstChild;\n }\n /**\r\n * Converts an Element to its HTML code.\r\n * @param {Element} element - entry element.\r\n * @return {string} the HTML code of the input element.\r\n * @static\r\n */\n\n }, {\n key: \"createObjectCode\",\n value: function createObjectCode(element) {\n // In case that the image was not created, the object can be null or undefined.\n if (typeof element == 'undefined' || element == null) {\n return;\n }\n\n if (element.nodeType == 1) {\n // ELEMENT_NODE.\n var output = '<' + element.tagName;\n\n for (var i = 0; i < element.attributes.length; ++i) {\n if (element.attributes[i].specified) {\n output += ' ' + element.attributes[i].name + '=\"' + Util.htmlEntities(element.attributes[i].value) + '\"';\n }\n }\n\n if (element.childNodes.length > 0) {\n output += '>';\n\n for (var i = 0; i < element.childNodes.length; ++i) {\n output += Util.createObject(element.childNodes[i]);\n }\n\n output += '';\n } else if (element.nodeName == 'DIV' || element.nodeName == 'SCRIPT') {\n output += '>';\n } else {\n output += '/>';\n }\n\n return output;\n }\n\n if (element.nodeType == 3) {\n // TEXT_NODE.\n return Util.htmlEntities(element.nodeValue);\n }\n\n return '';\n }\n /**\r\n * Concatenates two URL paths.\r\n * @param {string} path1 - first URL path\r\n * @param {string} path2 - second URL path\r\n * @returns {string} new URL.\r\n */\n\n }, {\n key: \"concatenateUrl\",\n value: function concatenateUrl(path1, path2) {\n var separator = \"\";\n\n if (path1.indexOf(\"/\") != path1.length && path2.indexOf(\"/\") != 0) {\n separator = \"/\";\n }\n\n return (path1 + separator + path2).replace(/([^:]\\/)\\/+/g, \"$1\");\n }\n /**\r\n * Parses a text and replaces all HTML special characters by their correspondent entities.\r\n * @param {string} input - text to be parsed.\r\n * @returns {string} the input text with all their special characters replaced by their entities.\r\n * @static\r\n */\n\n }, {\n key: \"htmlEntities\",\n value: function htmlEntities(input) {\n return input.split('&').join('&').split('<').join('<').split('>').join('>').split('\"').join('"');\n }\n /**\r\n * Parses a text and replaces all the HTML entities by their characters.\r\n * @param {string} input - text to be parsed\r\n * @returns {string} the input text with all their entities replaced by characters.\r\n * @static\r\n */\n\n }, {\n key: \"htmlEntitiesDecode\",\n value: function htmlEntitiesDecode(input) {\n return input.split('"').join('\"').split('>').join('>').split('<').join('<').split('&').join('&');\n }\n /**\r\n * Returns a cross-browser http request.\r\n * @return {object} httpRequest request object.\r\n * @returns {XMLHttpRequest|ActiveXObject} the proper request object.\r\n */\n\n }, {\n key: \"createHttpRequest\",\n value: function createHttpRequest() {\n var currentPath = window.location.toString().substr(0, window.location.toString().lastIndexOf('/') + 1);\n\n if (currentPath.substr(0, 7) == 'file://') {\n throw Core.getStringManager().getString('exception_cross_site');\n }\n\n if (typeof XMLHttpRequest != 'undefined') {\n return new XMLHttpRequest();\n }\n\n try {\n return new ActiveXObject('Msxml2.XMLHTTP');\n } catch (e) {\n try {\n return new ActiveXObject('Microsoft.XMLHTTP');\n } catch (oc) {}\n }\n\n return false;\n }\n /**\r\n * Converts a hash to a HTTP query.\r\n * @param {Object[]} properties - a key/value object.\r\n * @returns {string} a HTTP query containing all the key value pairs with all the special characters replaced by their entities.\r\n * @static\r\n */\n\n }, {\n key: \"httpBuildQuery\",\n value: function httpBuildQuery(properties) {\n var result = '';\n\n for (var i in properties) {\n if (properties[i] != null) {\n result += Util.urlEncode(i) + '=' + Util.urlEncode(properties[i]) + '&';\n }\n } // Deleting last '&' empty character.\n\n\n if (result.substring(result.length - 1) == '&') {\n result = result.substring(0, result.length - 1);\n }\n\n return result;\n }\n /**\r\n * Convert a hash to string sorting keys to get a deterministic output\r\n * @param {Object[]} hash - a key/value object.\r\n * @returns {string} a string with the form key1=value1...keyn=valuen\r\n * @static\r\n */\n\n }, {\n key: \"propertiesToString\",\n value: function propertiesToString(hash) {\n // 1. Sort keys. We sort the keys because we want a deterministic output.\n var keys = [];\n\n for (var key in hash) {\n if (hash.hasOwnProperty(key)) {\n keys.push(key);\n }\n }\n\n var n = keys.length;\n\n for (var i = 0; i < n; i++) {\n for (var j = i + 1; j < n; j++) {\n var s1 = keys[i];\n var s2 = keys[j];\n\n if (Util.compareStrings(s1, s2) > 0) {\n // Swap.\n keys[i] = s2;\n keys[j] = s1;\n }\n }\n } // 2. Generate output.\n\n\n var output = '';\n\n for (var i = 0; i < n; i++) {\n var key = keys[i];\n output += key;\n output += \"=\";\n var value = hash[key];\n value = value.replace(\"\\\\\", \"\\\\\\\\\");\n value = value.replace(\"\\n\", \"\\\\n\");\n value = value.replace(\"\\r\", \"\\\\r\");\n value = value.replace(\"\\t\", \"\\\\t\");\n output += value;\n output += \"\\n\";\n }\n\n return output;\n }\n /**\r\n * Compare two strings using charCodeAt method\r\n * @param {string} a - first string to compare.\r\n * @param {string} b - second string to compare.\r\n * @returns {number} the difference between a and b\r\n * @static\r\n */\n\n }, {\n key: \"compareStrings\",\n value: function compareStrings(a, b) {\n var i;\n var an = a.length;\n var bn = b.length;\n var n = an > bn ? bn : an;\n\n for (i = 0; i < n; i++) {\n var c = Util.fixedCharCodeAt(a, i) - Util.fixedCharCodeAt(b, i);\n\n if (c != 0) {\n return c;\n }\n }\n\n return a.length - b.length;\n }\n /**\r\n * Fix charCodeAt() JavaScript function to handle non-Basic-Multilingual-Plane characters.\r\n * @param {string} string - input string\r\n * @param {number} idx - an integer greater than or equal to 0 and less than the length of the string\r\n * @returns {number} an integer representing the UTF-16 code of the string at the given index.\r\n * @static\r\n */\n\n }, {\n key: \"fixedCharCodeAt\",\n value: function fixedCharCodeAt(string, idx) {\n idx = idx || 0;\n var code = string.charCodeAt(idx);\n var hi, low;\n /* High surrogate (could change last hex to 0xDB7F to treat high\r\n private surrogates as single characters) */\n\n if (0xD800 <= code && code <= 0xDBFF) {\n hi = code;\n low = string.charCodeAt(idx + 1);\n\n if (isNaN(low)) {\n throw Core.getStringManager().getString('exception_high_surrogate');\n }\n\n return (hi - 0xD800) * 0x400 + (low - 0xDC00) + 0x10000;\n }\n\n if (0xDC00 <= code && code <= 0xDFFF) {\n // Low surrogate.\n\n /* We return false to allow loops to skip this iteration since should have\r\n already handled high surrogate above in the previous iteration. */\n return false;\n }\n\n return code;\n }\n /**\r\n * Returns an URL with it's query params converted into array.\r\n * @param {string} url - input URL.\r\n * @returns {Object[]} an array containing all URL query params.\r\n * @static\r\n */\n\n }, {\n key: \"urlToAssArray\",\n value: function urlToAssArray(url) {\n var i;\n i = url.indexOf(\"?\");\n\n if (i > 0) {\n var query = url.substring(i + 1);\n var ss = query.split(\"&\");\n var h = new Object();\n\n for (i = 0; i < ss.length; i++) {\n var s = ss[i];\n var kv = s.split(\"=\");\n\n if (kv.length > 1) {\n h[kv[0]] = decodeURIComponent(kv[1].replace(/\\+/g, ' '));\n }\n }\n\n return h;\n } else {\n return new Object();\n }\n }\n /**\r\n * Returns an encoded URL by replacing each instance of certain characters by\r\n * one, two, three or four escape sequences using encodeURIComponent method.\r\n * !'()* . will not be encoded.\r\n *\r\n * @param {string} clearString - URL string to be encoded\r\n * @returns {string} URL with it's special characters replaced.\r\n * @static\r\n */\n\n }, {\n key: \"urlEncode\",\n value: function urlEncode(clearString) {\n var output = ''; // Method encodeURIComponent doesn't encode !'()*~ .\n\n output = encodeURIComponent(clearString);\n return output;\n } // TODO: To parser?\n\n /**\r\n * Converts the HTML of a image into the output code that WIRIS must return.\r\n * By default returns the MathML stored on data-mahml attribute (if imgCode is a formula)\r\n * or the Wiriscas attribute of a WIRIS applet.\r\n * @param {string} imgCode - the html code from a formula or a CAS image.\r\n * @param {boolean} convertToXml - true if the image should be converted to XML.\r\n * @param {boolean} convertToSafeXml - true if the image should be converted to safeXML.\r\n * @returns {string} the XML or safeXML of a WIRIS image.\r\n * @static\r\n */\n\n }, {\n key: \"getWIRISImageOutput\",\n value: function getWIRISImageOutput(imgCode, convertToXml, convertToSafeXml) {\n var imgObject = Util.createObject(imgCode);\n\n if (imgObject) {\n if (imgObject.className == _configuration__WEBPACK_IMPORTED_MODULE_1__[\"default\"].get('imageClassName') || imgObject.getAttribute(_configuration__WEBPACK_IMPORTED_MODULE_1__[\"default\"].get('imageMathmlAttribute'))) {\n if (!convertToXml) {\n return imgCode;\n }\n\n var xmlCode = imgObject.getAttribute(_configuration__WEBPACK_IMPORTED_MODULE_1__[\"default\"].get('imageMathmlAttribute'));\n\n if (!_configuration__WEBPACK_IMPORTED_MODULE_1__[\"default\"].get('saveHandTraces')) {\n xmlCode = _mathml__WEBPACK_IMPORTED_MODULE_0__[\"default\"].removeSemanticsOcurrences(xmlCode, _constants__WEBPACK_IMPORTED_MODULE_3__[\"default\"].safeXmlCharacters);\n }\n\n if (xmlCode == null) {\n xmlCode = imgObject.getAttribute('alt');\n }\n\n if (!convertToSafeXml) {\n xmlCode = _mathml__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlDecode(xmlCode);\n }\n\n return xmlCode;\n } else if (imgObject.className == _configuration__WEBPACK_IMPORTED_MODULE_1__[\"default\"].get('CASClassName')) {\n var appletCode = imgObject.getAttribute(_configuration__WEBPACK_IMPORTED_MODULE_1__[\"default\"].get('CASMathmlAttribute'));\n appletCode = _mathml__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlDecode(appletCode);\n var appletObject = Util.createObject(appletCode);\n appletObject.setAttribute('src', imgObject.src);\n var object = appletObject;\n var appletCodeToBeInserted = Util.createObjectCode(appletObject);\n\n if (convertToSafeXml) {\n appletCodeToBeInserted = _mathml__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlEncode(appletCodeToBeInserted);\n }\n\n return appletCodeToBeInserted;\n }\n }\n\n return imgCode;\n }\n /**\r\n * Gets the node length in characters.\r\n * @param {Node} node - HTML node.\r\n * @returns {number} node length.\r\n * @static\r\n */\n\n }, {\n key: \"getNodeLength\",\n value: function (_getNodeLength) {\n function getNodeLength(_x) {\n return _getNodeLength.apply(this, arguments);\n }\n\n getNodeLength.toString = function () {\n return _getNodeLength.toString();\n };\n\n return getNodeLength;\n }(function (node) {\n var staticNodeLengths = {\n 'IMG': 1,\n 'BR': 1\n };\n\n if (node.nodeType == 3) {\n // TEXT_NODE.\n return node.nodeValue.length;\n }\n\n if (node.nodeType == 1) {\n // ELEMENT_NODE.\n var length = staticNodeLengths[node.nodeName.toUpperCase()];\n\n if (length === undefined) {\n length = 0;\n }\n\n for (var i = 0; i < node.childNodes.length; ++i) {\n length += getNodeLength(node.childNodes[i]);\n }\n\n return length;\n }\n\n return 0;\n })\n /**\r\n * Gets a selected node or text from an editable HTMLElement.\r\n * If the caret is on a text node, concatenates it with all the previous and next text nodes.\r\n * @param {HTMLElement} target - the editable HTMLElement.\r\n * @param {boolean} isIframe - specifies if the target is an iframe or not\r\n * @param {boolean} forceGetSelection - if true, ignores IE system to get the current selection and uses window.getSelection()\r\n * @returns {object} an object with the 'node' key set if the item is an element or the keys 'node' and 'caretPosition' if the element is text.\r\n * @static\r\n */\n\n }, {\n key: \"getSelectedItem\",\n value: function getSelectedItem(target, isIframe, forceGetSelection) {\n var windowTarget;\n\n if (isIframe) {\n windowTarget = target.contentWindow;\n windowTarget.focus();\n } else {\n windowTarget = window;\n target.focus();\n }\n\n if (document.selection && !forceGetSelection) {\n var range = windowTarget.document.selection.createRange();\n\n if (range.parentElement) {\n if (range.htmlText.length > 0) {\n if (range.text.length == 0) {\n return Util.getSelectedItem(target, isIframe, true);\n }\n\n return null;\n }\n\n windowTarget.document.execCommand('InsertImage', false, '#');\n var temporalObject = range.parentElement();\n\n if (temporalObject.nodeName.toUpperCase() != 'IMG') {\n // IE9 fix: parentElement() does not return the IMG node, returns the parent DIV node. In IE < 9, pasteHTML does not work well.\n range.pasteHTML('');\n temporalObject = windowTarget.document.getElementById('wrs_openEditorWindow_temporalObject');\n }\n\n var node;\n var caretPosition;\n\n if (temporalObject.nextSibling && temporalObject.nextSibling.nodeType == 3) {\n // TEXT_NODE.\n node = temporalObject.nextSibling;\n caretPosition = 0;\n } else if (temporalObject.previousSibling && temporalObject.previousSibling.nodeType == 3) {\n // TEXT_NODE.\n node = temporalObject.previousSibling;\n caretPosition = node.nodeValue.length;\n } else {\n node = windowTarget.document.createTextNode('');\n temporalObject.parentNode.insertBefore(node, temporalObject);\n caretPosition = 0;\n }\n\n temporalObject.parentNode.removeChild(temporalObject);\n return {\n 'node': node,\n 'caretPosition': caretPosition\n };\n }\n\n if (range.length > 1) {\n return null;\n }\n\n return {\n 'node': range.item(0)\n };\n }\n\n if (windowTarget.getSelection) {\n var selection = windowTarget.getSelection();\n\n try {\n var range = selection.getRangeAt(0);\n } catch (e) {\n var range = windowTarget.document.createRange();\n }\n\n var node = range.startContainer;\n\n if (node.nodeType == 3) {\n // TEXT_NODE.\n return {\n 'node': node,\n 'caretPosition': range.startOffset\n };\n }\n\n if (node != range.endContainer) {\n return null;\n }\n\n if (node.nodeType == 1) {\n // ELEMENT_NODE.\n var position = range.startOffset;\n\n if (node.childNodes[position]) {\n return {\n 'node': node.childNodes[position]\n };\n }\n }\n }\n\n return null;\n }\n /**\r\n * Returns null if there isn't any item or if it is malformed.\r\n * Otherwise returns an object containing the node with the MathML image\r\n * and the cursor position inside the textarea.\r\n * @param {HTMLTextAreaElement} textarea - textarea element.\r\n * @returns {Object} An object containing the node, the index of the\r\n * beginning of the selected text, caret position and the start and end position of the\r\n * text node.\r\n * @static\r\n */\n\n }, {\n key: \"getSelectedItemOnTextarea\",\n value: function getSelectedItemOnTextarea(textarea) {\n var textNode = document.createTextNode(textarea.value);\n var textNodeValues = _latex__WEBPACK_IMPORTED_MODULE_2__[\"default\"].getLatexFromTextNode(textNode, textarea.selectionStart);\n\n if (textNodeValues === null) {\n return null;\n }\n\n ;\n return {\n 'node': textNode,\n 'caretPosition': textarea.selectionStart,\n 'startPosition': textNodeValues.startPosition,\n 'endPosition': textNodeValues.endPosition\n };\n }\n /**\r\n * Looks for elements that match the given name in a HTML code string.\r\n * Important: this function is very concrete for WIRIS code. It takes as preconditions lots of behaviors that are not the general case.\r\n * @param {string} code - HTML code.\r\n * @param {string} name - element name.\r\n * @param {boolean} autoClosed - true if the elements are autoClosed.\r\n * @return {Object[]} an object containing all HTML elements of code matching the name argument.\r\n * @static\r\n */\n\n }, {\n key: \"getElementsByNameFromString\",\n value: function getElementsByNameFromString(code, name, autoClosed) {\n var elements = [];\n var code = code.toLowerCase();\n name = name.toLowerCase();\n var start = code.indexOf('<' + name + ' ');\n\n while (start != -1) {\n // Look for nodes.\n var endString;\n\n if (autoClosed) {\n endString = '>';\n } else {\n endString = '';\n }\n\n var end = code.indexOf(endString, start);\n\n if (end != -1) {\n end += endString.length;\n elements.push({\n 'start': start,\n 'end': end\n });\n } else {\n end = start + 1;\n }\n\n start = code.indexOf('<' + name + ' ', end);\n }\n\n return elements;\n }\n /**\r\n * Returns the numeric value of a base64 character.\r\n * @param {string} character - base64 character.\r\n * @returns {number} base64 character numeric value.\r\n * @static\r\n */\n\n }, {\n key: \"decode64\",\n value: function decode64(character) {\n var PLUS = '+'.charCodeAt(0);\n var SLASH = '/'.charCodeAt(0);\n var NUMBER = '0'.charCodeAt(0);\n var LOWER = 'a'.charCodeAt(0);\n var UPPER = 'A'.charCodeAt(0);\n var PLUS_URL_SAFE = '-'.charCodeAt(0);\n var SLASH_URL_SAFE = '_'.charCodeAt(0);\n var code = character.charCodeAt(0);\n\n if (code === PLUS || code === PLUS_URL_SAFE) {\n return 62; // Char '+'.\n }\n\n if (code === SLASH || code === SLASH_URL_SAFE) {\n return 63; // Char '/'.\n }\n\n if (code < NUMBER) {\n return -1; // No match.\n }\n\n if (code < NUMBER + 10) {\n return code - NUMBER + 26 + 26;\n }\n\n if (code < UPPER + 26) {\n return code - UPPER;\n }\n\n if (code < LOWER + 26) {\n return code - LOWER + 26;\n }\n }\n /**\r\n * Converts a base64 string to a array of bytes.\r\n * @param {string} b64String - base64 string.\r\n * @param {number} length - dimension of byte array (by default whole string).\r\n * @return {Object[]} the resultant byte array.\r\n * @static\r\n */\n\n }, {\n key: \"b64ToByteArray\",\n value: function b64ToByteArray(b64String, length) {\n var tmp;\n\n if (b64String.length % 4 > 0) {\n throw new Error('Invalid string. Length must be a multiple of 4'); // Tipped base64. Length is fixed.\n }\n\n var arr = new Array();\n\n if (!length) {\n // All b64String string.\n var placeHolders = b64String.charAt(b64String.length - 2) === '=' ? 2 : b64String.charAt(b64String.length - 1) === '=' ? 1 : 0;\n var l = placeHolders > 0 ? b64String.length - 4 : b64String.length;\n } else {\n var l = length;\n }\n\n for (var i = 0; i < l; i += 4) {\n // Ignoring code checker standards (bitewise operators).\n // See https://tracker.moodle.org/browse/CONTRIB-5862 for further information.\n // @codingStandardsIgnoreStart\n tmp = Util.decode64(b64String.charAt(i)) << 18 | Util.decode64(b64String.charAt(i + 1)) << 12 | Util.decode64(b64String.charAt(i + 2)) << 6 | Util.decode64(b64String.charAt(i + 3));\n arr.push(tmp >> 16 & 0xFF);\n arr.push(tmp >> 8 & 0xFF);\n arr.push(tmp & 0xFF); // @codingStandardsIgnoreEnd\n }\n\n if (placeHolders) {\n if (placeHolders === 2) {\n // Ignoring code checker standards (bitewise operators).\n // @codingStandardsIgnoreStart\n tmp = Util.decode64(b64String.charAt(i)) << 2 | Util.decode64(b64String.charAt(i + 1)) >> 4;\n arr.push(tmp & 0xFF);\n } else if (placeHolders === 1) {\n tmp = Util.decode64(b64String.charAt(i)) << 10 | Util.decode64(b64String.charAt(i + 1)) << 4 | Util.decode64(b64String.charAt(i + 2)) >> 2;\n arr.push(tmp >> 8 & 0xFF);\n arr.push(tmp & 0xFF); // @codingStandardsIgnoreEnd\n }\n }\n\n return arr;\n }\n /**\r\n * Returns the first 32-bit signed integer from a byte array.\r\n * @param {Object[]} bytes - array of bytes.\r\n * @returns {number} the 32-bit signed integer.\r\n * @static\r\n */\n\n }, {\n key: \"readInt32\",\n value: function readInt32(bytes) {\n if (bytes.length < 4) {\n return false;\n }\n\n var int32 = bytes.splice(0, 4); // @codingStandardsIgnoreStart\n\n return int32[0] << 24 | int32[1] << 16 | int32[2] << 8 | int32[3] << 0; // @codingStandardsIgnoreEnd\n }\n /**\r\n * Read the first byte from a byte array.\r\n * @param {Object} bytes - input byte array.\r\n * @returns {number} first byte of the byte array.\r\n * @static\r\n */\n\n }, {\n key: \"readByte\",\n value: function readByte(bytes) {\n // @codingStandardsIgnoreStart\n return bytes.shift() << 0; // @codingStandardsIgnoreEnd\n }\n /**\r\n * Read an arbitrary number of bytes, from a fixed position on a byte array.\r\n * @param {Object[]} bytes - byte array.\r\n * @param {number} pos - start position.\r\n * @param {number} len - number of bytes to read.\r\n * @returns {Object[]} the byte array.\r\n * @static\r\n */\n\n }, {\n key: \"readBytes\",\n value: function readBytes(bytes, pos, len) {\n return bytes.splice(pos, len);\n }\n /**\r\n * Inserts or modifies formulas or CAS on a textarea.\r\n * @param {HTMLTextAreaElement} textarea - textarea target.\r\n * @param {string} text - text to add in the textarea. For example, to add the link to the image,\r\n * call this function as (textarea, Parser.createImageSrc(mathml));\r\n * @static\r\n */\n\n }, {\n key: \"updateTextArea\",\n value: function updateTextArea(textarea, text) {\n if (textarea && text) {\n textarea.focus();\n\n if (textarea.selectionStart != null) {\n var selectionEnd = textarea.selectionEnd;\n textarea.value = textarea.value.substring(0, textarea.selectionStart) + text + textarea.value.substring(textarea.selectionEnd, textarea.value.length);\n textarea.selectionEnd = selectionEnd + text.length;\n } else {\n var selection = document.selection.createRange();\n selection.text = text;\n }\n }\n }\n /**\r\n * Modifies existing formula on a textarea.\r\n * @param {HTMLTextAreaElement} textarea - text area target.\r\n * @param {string} text - text to add in the textarea. For example, if you want to add the link to the image, you can call this function as Util.updateTextarea(textarea, Parser.createImageSrc(mathml));\r\n * @param {number} start - beginning index from textarea where it needs to be replaced by text.\r\n * @param {number} end - ending index from textarea where it needs to be replaced by text\r\n * @static\r\n */\n\n }, {\n key: \"updateExistingTextOnTextarea\",\n value: function updateExistingTextOnTextarea(textarea, text, start, end) {\n textarea.focus();\n textarea.value = textarea.value.substring(0, start) + text + textarea.value.substring(end, textarea.value.length);\n textarea.selectionEnd = start + text.length;\n }\n /**\r\n * Add a parameter with it's correspondent value to an URL (GET).\r\n * @param {string} path - URL path\r\n * @param {string} parameter - parameter\r\n * @param {string} value - value\r\n * @static\r\n */\n\n }, {\n key: \"addArgument\",\n value: function addArgument(path, parameter, value) {\n var sep;\n\n if (path.indexOf(\"?\") > 0) {\n sep = \"&\";\n } else {\n sep = \"?\";\n }\n\n return path + sep + parameter + \"=\" + value;\n }\n }]);\n\n return Util;\n}();\n\n\n\n//# sourceURL=webpack:///./core/src/util.js?"); /***/ }), @@ -393,7 +393,7 @@ eval("\nvar content = __webpack_require__(/*! !../node_modules/mini-css-extract- /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"TinyMceIntegration\", function() { return TinyMceIntegration; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"instances\", function() { return instances; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"currentInstance\", function() { return currentInstance; });\n/* harmony import */ var _core_src_integrationmodel_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./core/src/integrationmodel.js */ \"./core/src/integrationmodel.js\");\n/* harmony import */ var _core_src_configuration_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./core/src/configuration.js */ \"./core/src/configuration.js\");\n/* harmony import */ var _core_src_parser_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./core/src/parser.js */ \"./core/src/parser.js\");\n/* harmony import */ var _core_src_util__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./core/src/util */ \"./core/src/util.js\");\n/* harmony import */ var _core_src_listeners__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./core/src/listeners */ \"./core/src/listeners.js\");\nfunction _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) { return call; } return _assertThisInitialized(self); }\n\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\n\nfunction _get(target, property, receiver) { if (typeof Reflect !== \"undefined\" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(receiver); } return desc.value; }; } return _get(target, property, receiver || target); }\n\nfunction _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }\n\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function\"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }\n\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\n\n\n\n\n\n\n/**\n * TinyMCE integration class. This class extends IntegrationModel class.\n */\n\nvar TinyMceIntegration =\n/*#__PURE__*/\nfunction (_IntegrationModel) {\n _inherits(TinyMceIntegration, _IntegrationModel);\n\n function TinyMceIntegration(integrationModelProperties) {\n var _this;\n\n _classCallCheck(this, TinyMceIntegration);\n\n _this = _possibleConstructorReturn(this, _getPrototypeOf(TinyMceIntegration).call(this, integrationModelProperties));\n /**\n * Indicates if the content of the TinyMCe editor has\n * been parsed.\n * @type {boolean}\n */\n\n _this.initParsed = integrationModelProperties.initParsed;\n /**\n * Indicates if the TinyMCE is integrated in Moodle.\n * @type {boolean}\n */\n\n _this.isMoodle = integrationModelProperties.isMoodle;\n /**\n * Indicates if the plugin is loaded as an external plugin by TinyMCE.\n * @type {boolean}\n */\n\n _this.isExternal = integrationModelProperties.isExternal;\n return _this;\n }\n /**\n * Returns the absolute path of the integration script. Depends on\n * TinyMCE integration (Moodle or standard).\n * @returns {boolean} - Absolute path for the integration script.\n */\n\n\n _createClass(TinyMceIntegration, [{\n key: \"getPath\",\n value: function getPath() {\n if (this.isMoodle) {\n var search = 'lib/editor/tinymce';\n var pos = tinymce.baseURL.indexOf(search);\n var baseURL = tinymce.baseURL.substr(0, pos + search.length);\n return baseURL + '/plugins/tiny_mce_wiris/tinymce/';\n } else if (this.isExternal) {\n var externalUrl = this.editorObject.getParam('external_plugins')['tiny_mce_wiris'];\n return externalUrl.substring(0, externalUrl.lastIndexOf('/') + 1);\n } else {\n return tinymce.baseURL + '/plugins/tiny_mce_wiris/';\n }\n }\n /**\n * Returns the absolute path of plugin icons. A set of different\n * icons is needed for TinyMCE and Moodle 2.5-\n * @returns {string} - Absolute path of the icons folder.\n */\n\n }, {\n key: \"getIconsPath\",\n value: function getIconsPath() {\n if (this.isMoodle && _core_src_configuration_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].get('versionPlatform') < 2013111800) {\n return this.getPath() + 'icons/tinymce3/';\n } else {\n return this.getPath() + 'icons/';\n }\n }\n /**\n * Returns the integration language. TinyMCE language is inherited.\n * @returns {string} - Integration language.\n */\n\n }, {\n key: \"getLanguage\",\n value: function getLanguage() {\n if (this.editorObject.settings['wirisformulaeditorlang']) {\n return editor.settings['wirisformulaeditorlang'];\n }\n\n return this.editorObject.getParam('language');\n }\n /**\n * Callback function called before 'onTargetLoad' is fired. All the logic here is to\n * avoid TinyMCE change MathType formulas.\n */\n\n }, {\n key: \"callbackFunction\",\n value: function callbackFunction() {\n var dataImgFiltered = [];\n\n _get(_getPrototypeOf(TinyMceIntegration.prototype), \"callbackFunction\", this).call(this); // Avoid to change class of image formulas.\n\n\n var imageClassName = _core_src_configuration_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].get('imageClassName');\n\n if (this.isIframe) {\n // Attaching observers to wiris images.\n if (typeof _core_src_parser_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].observer != 'undefined') {\n Array.prototype.forEach.call(this.target.contentDocument.getElementsByClassName(imageClassName), function (wirisImages) {\n _core_src_parser_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].observer.observe(wirisImages);\n });\n }\n } else {\n // Inline.\n // Attaching observers to wiris images.\n Array.prototype.forEach.call(document.getElementsByClassName(imageClassName), function (wirisImages) {\n _core_src_parser_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].observer.observe(wirisImages);\n });\n } // When a formula is updated TinyMCE 'Change' event must be fired.\n // See https://www.tiny.cloud/docs/advanced/events/#change for further information.\n\n\n var listener = _core_src_listeners__WEBPACK_IMPORTED_MODULE_4__[\"default\"].newListener('onAfterFormulaInsertion', function () {\n if (typeof this.editorObject.fire != 'undefined') {\n this.editorObject.fire('Change');\n }\n }.bind(this));\n this.getCore().addListener(listener); // Avoid filter formulas with performance enabled.\n\n dataImgFiltered[this.editorObject.id] = this.editorObject.settings.images_dataimg_filter;\n\n this.editorObject.settings.images_dataimg_filter = function (img) {\n if (img.hasAttribute('class') && img.getAttribute('class').indexOf(_core_src_configuration_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].get(imageClassName)) != -1) {\n return img.hasAttribute('internal-blob');\n } else {\n // If the client put an image data filter, run. Otherwise default behaviour (put blob).\n if (typeof dataImgFiltered[this.editorObject.id] != 'undefined') {\n return dataImgFiltered[this.editorObject.id](img);\n }\n\n return true;\n }\n };\n }\n }]);\n\n return TinyMceIntegration;\n}(_core_src_integrationmodel_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"]);\n/**\n * Object containing all TinyMCE integration instances. One for each TinyMCE editor.\n * @type {Object}\n */\n\nvar instances = {};\n/**\n * TinyMCE integration current instance. The current instance\n * is the instance related with the focused editor.\n * @type {TinyMceIntegration}\n */\n\nvar currentInstance = null;\n/* Plugin integration */\n\n(function () {\n tinymce.create('tinymce.plugins.tiny_mce_wiris', {\n init: function init(editor, url) {\n // Array with MathML valid alements.\n var validMathML = ['math[*]', 'maction[*]]', 'malignmark[*]', 'maligngroup[*]', 'menclose[*]', 'merror[*]', 'mfenced[*]', 'mfrac[*]', 'mglyph[*]', 'mi[*]', 'mlabeledtr[*]', 'mlongdiv[*]', 'mmultiscripts[*]', 'mn[*]', 'mo[*]', 'mover[*]', 'mpadded[*]', 'mphantom[*]', 'mprescripts[*]', 'mroot[*]', 'mrow[*]', 'ms[*]', 'mscarries[*]', 'mscarry[*]', 'msgroup[*]', 'msline[*]', 'mspace[*]', 'msqrt[*]', 'msrow[*]', 'mstack[*]', 'mstyle[*]', 'msub[*]', 'msubsup[*]', 'msup[*]', 'mtable[*]', 'mtd[*]', 'mtext[*]', 'mtr[*]', 'munder[*]', 'munderover[*]', 'semantics[*]', 'annotation[*]'];\n editor.settings.extended_valid_elements += ',' + validMathML.join();\n var callbackMethodArguments = {};\n /**\n * Integration model properties\n * @type {object}\n * @property {object} target - Integration DOM target.\n * @property {string} configurationService - Configuration integration service.\n * @property {string} version - Plugin version.\n * @property {string} scriptName - Integration script name.\n * @property {object} environment - Integration environment properties.\n * @property {string} editor - Editor name.\n */\n\n var integrationModelProperties = {};\n integrationModelProperties.configurationService = '' + M.cfg.wwwroot + '/filter/wiris/integration/configurationjs.php';\n integrationModelProperties.version = '7.6.1.1393';\n integrationModelProperties.isMoodle = true;\n\n if (typeof editor.getParam('wiriscontextpath') !== 'undefined') {\n integrationModelProperties.configurationService = _core_src_util__WEBPACK_IMPORTED_MODULE_3__[\"default\"].concatenateUrl(editor.getParam('wiriscontextpath'), integrationModelProperties.configurationService);\n editor.getParam('wiriscontextpath') + '/' + integrationModelProperties.configurationService;\n }\n\n integrationModelProperties.version = '7.5.0.1414';\n integrationModelProperties.scriptName = \"plugin.min.js\";\n integrationModelProperties.environment = {};\n integrationModelProperties.environment.editor = \"TinyMCE 4.x\";\n integrationModelProperties.callbackMethodArguments = callbackMethodArguments;\n integrationModelProperties.editorObject = editor;\n integrationModelProperties.initParsed = false; // We need to create the instance before TinyMce initialization in order to register commands.\n // However, as TinyMCE is not initialized at this point the HTML target is not created.\n // Here we create the target as null and onInit object the target is updated.\n\n integrationModelProperties.target = null;\n var isExternalPlugin = typeof editor.getParam('external_plugins') !== 'undefined' && 'tiny_mce_wiris' in editor.getParam('external_plugins');\n integrationModelProperties.isExternal = isExternalPlugin;\n integrationModelProperties.rtl = editor.getParam('directionality') === 'rtl'; // GenericIntegration instance.\n\n var tinyMceIntegrationInstance = new TinyMceIntegration(integrationModelProperties);\n tinyMceIntegrationInstance.init();\n WirisPlugin.instances[tinyMceIntegrationInstance.editorObject.id] = tinyMceIntegrationInstance;\n WirisPlugin.currentInstance = tinyMceIntegrationInstance;\n\n var onInit = function onInit(editor) {\n var integrationInstance = WirisPlugin.instances[tinyMceIntegrationInstance.editorObject.id];\n\n if (!editor.inline) {\n integrationInstance.setTarget(editor.getContentAreaContainer().firstChild);\n } else {\n integrationInstance.setTarget(editor.getElement());\n }\n\n integrationInstance.setEditorObject(editor);\n integrationInstance.listeners.fire('onTargetReady', {});\n\n if ('wiriseditorparameters' in editor.settings) {\n _core_src_configuration_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].update('_wrs_conf_editorParameters', editor.settings.wiriseditorparameters);\n }\n\n var content = editor.getContent(); // Bug fix: In Moodle2.x when TinyMCE is set to full screen\n // the content doesn't need to be filtered.\n\n if (!editor.getParam('fullscreen_is_enabled') && content !== \"\") {\n // We set content in html because other tiny plugins need data-mce\n // and this is not posibil with raw format.\n editor.setContent(_core_src_parser_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].initParse(content, editor.getParam('language')), {\n format: \"html\"\n }); // This clean undoQueue for prevent onChange and Dirty state.\n\n editor.undoManager.clear();\n } // Init parsing OK. If a setContent method is called\n // wrs_initParse is called again.\n // Now if source code is edited the returned code is parsed.\n // PLUGINS-1070: We set this variable out of condition to parse content after.\n\n\n WirisPlugin.instances[editor.id].initParsed = true;\n };\n\n if ('onInit' in editor) {\n editor.onInit.add(onInit);\n } else {\n editor.on('init', function () {\n onInit(editor);\n });\n }\n\n if ('onActivate' in editor) {\n editor.onActivate.add(function (editor) {\n WirisPlugin.currentInstance = WirisPlugin.instances[tinymce.activeEditor.id];\n });\n } else {\n editor.on('focus', function (event) {\n WirisPlugin.currentInstance = WirisPlugin.instances[tinymce.activeEditor.id];\n });\n }\n\n var onSave = function onSave(editor, params) {\n params.content = _core_src_parser_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].endParse(params.content, editor.getParam('language'));\n };\n\n if ('onSaveContent' in editor) {\n editor.onSaveContent.add(onSave);\n } else {\n editor.on('saveContent', function (params) {\n onSave(editor, params);\n });\n }\n\n if ('onGetContent' in editor) {\n editor.onGetContent.add(onSave);\n } else {\n editor.on('getContent', function (params) {\n onSave(editor, params);\n });\n }\n\n if ('onBeforeSetContent' in editor) {\n editor.onBeforeSetContent.add(function (e, params) {\n if (WirisPlugin.instances[editor.id].initParsed) {\n params.content = Parse.initParse(params.content, editor.getParam('language'));\n }\n });\n } else {\n editor.on('beforeSetContent', function (params) {\n if (WirisPlugin.instances[editor.id].initParsed) {\n params.content = _core_src_parser_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].initParse(params.content, editor.getParam('language'));\n }\n });\n } // We use a mutation to observe iframe of tiny and filter to remove data-mce.\n\n\n var observerConfig = {\n attributes: true,\n childList: true,\n characterData: true,\n subtree: true\n };\n\n function onMutations(mutations) {\n Array.prototype.forEach.call(mutations, function (mutation) {\n Array.prototype.forEach.call(mutation.addedNodes, function (node) {\n // We search only in element nodes.\n if (node.nodeType == 1) {\n Array.prototype.forEach.call(node.getElementsByClassName(WirisPlugin.Configuration.get('imageMathmlAttribute')), function (image) {\n image.removeAttribute('data-mce-src');\n image.removeAttribute('data-mce-style');\n });\n }\n });\n });\n }\n\n var mutationInstance = new MutationObserver(onMutations); // We wait for iframe definition for observe this.\n\n function waitForIframeBody() {\n if (typeof editor.contentDocument != 'undefined') {\n mutationInstance.observe(editor.getBody(), observerConfig);\n } else {\n setTimeout(waitForIframeBody, 50);\n }\n }\n\n waitForIframeBody(); // MathType button.\n\n editor.addCommand('tiny_mce_wiris_openFormulaEditor', function () {\n WirisPlugin.instances[editor.id].openNewFormulaEditor();\n });\n editor.addButton('tiny_mce_wiris_formulaEditor', {\n title: 'Insert a math equation - MathType',\n cmd: 'tiny_mce_wiris_openFormulaEditor',\n image: WirisPlugin.instances[editor.id].getIconsPath() + 'formula.png'\n }); // }\n // Dynamic customEditors buttons.\n\n var customEditors = WirisPlugin.instances[tinyMCE.activeEditor.id].getCore().getCustomEditors();\n\n for (var customEditor in customEditors.editors) {\n if (customEditors.editors[customEditor].confVariable) {\n var cmd = 'tiny_mce_wiris_openFormulaEditor' + customEditors.editors[customEditor].name;\n editor.addCommand(cmd, function () {\n customEditors.enable(customEditor);\n WirisPlugin.instances[editor.id].openNewFormulaEditor();\n });\n editor.addButton('tiny_mce_wiris_formulaEditor' + customEditors.editors[customEditor].name, {\n title: customEditors.editors[customEditor].tooltip,\n cmd: cmd,\n image: WirisPlugin.instances[editor.id].getIconsPath() + customEditors.editors[customEditor].icon\n });\n }\n }\n },\n // All versions.\n getInfo: function getInfo() {\n return {\n longname: 'tiny_mce_wiris',\n author: 'Maths for More',\n authorurl: 'http://www.wiris.com',\n infourl: 'http://www.wiris.com',\n version: '7.6.1.1393'\n };\n }\n });\n tinymce.PluginManager.add('tiny_mce_wiris', tinymce.plugins.tiny_mce_wiris);\n})();\n\n//# sourceURL=webpack:///./editor_plugin.src.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"TinyMceIntegration\", function() { return TinyMceIntegration; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"instances\", function() { return instances; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"currentInstance\", function() { return currentInstance; });\n/* harmony import */ var _core_src_integrationmodel_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./core/src/integrationmodel.js */ \"./core/src/integrationmodel.js\");\n/* harmony import */ var _core_src_configuration_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./core/src/configuration.js */ \"./core/src/configuration.js\");\n/* harmony import */ var _core_src_parser_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./core/src/parser.js */ \"./core/src/parser.js\");\n/* harmony import */ var _core_src_util__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./core/src/util */ \"./core/src/util.js\");\n/* harmony import */ var _core_src_listeners__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./core/src/listeners */ \"./core/src/listeners.js\");\nfunction _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) { return call; } return _assertThisInitialized(self); }\n\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\n\nfunction _get(target, property, receiver) { if (typeof Reflect !== \"undefined\" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(receiver); } return desc.value; }; } return _get(target, property, receiver || target); }\n\nfunction _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }\n\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function\"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }\n\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\n\n\n\n\n\n\n/**\n * TinyMCE integration class. This class extends IntegrationModel class.\n */\n\nvar TinyMceIntegration =\n/*#__PURE__*/\nfunction (_IntegrationModel) {\n _inherits(TinyMceIntegration, _IntegrationModel);\n\n function TinyMceIntegration(integrationModelProperties) {\n var _this;\n\n _classCallCheck(this, TinyMceIntegration);\n\n _this = _possibleConstructorReturn(this, _getPrototypeOf(TinyMceIntegration).call(this, integrationModelProperties));\n /**\n * Indicates if the content of the TinyMCe editor has\n * been parsed.\n * @type {boolean}\n */\n\n _this.initParsed = integrationModelProperties.initParsed;\n /**\n * Indicates if the TinyMCE is integrated in Moodle.\n * @type {boolean}\n */\n\n _this.isMoodle = integrationModelProperties.isMoodle;\n /**\n * Indicates if the plugin is loaded as an external plugin by TinyMCE.\n * @type {boolean}\n */\n\n _this.isExternal = integrationModelProperties.isExternal;\n return _this;\n }\n /**\n * Returns the absolute path of the integration script. Depends on\n * TinyMCE integration (Moodle or standard).\n * @returns {boolean} - Absolute path for the integration script.\n */\n\n\n _createClass(TinyMceIntegration, [{\n key: \"getPath\",\n value: function getPath() {\n if (this.isMoodle) {\n var search = 'lib/editor/tinymce';\n var pos = tinymce.baseURL.indexOf(search);\n var baseURL = tinymce.baseURL.substr(0, pos + search.length);\n return baseURL + '/plugins/tiny_mce_wiris/tinymce/';\n } else if (this.isExternal) {\n var externalUrl = this.editorObject.getParam('external_plugins')['tiny_mce_wiris'];\n return externalUrl.substring(0, externalUrl.lastIndexOf('/') + 1);\n } else {\n return tinymce.baseURL + '/plugins/tiny_mce_wiris/';\n }\n }\n /**\n * Returns the absolute path of plugin icons. A set of different\n * icons is needed for TinyMCE and Moodle 2.5-\n * @returns {string} - Absolute path of the icons folder.\n */\n\n }, {\n key: \"getIconsPath\",\n value: function getIconsPath() {\n if (this.isMoodle && _core_src_configuration_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].get('versionPlatform') < 2013111800) {\n return this.getPath() + 'icons/tinymce3/';\n } else {\n return this.getPath() + 'icons/';\n }\n }\n /**\n * Returns the integration language. TinyMCE language is inherited.\n * @returns {string} - Integration language.\n */\n\n }, {\n key: \"getLanguage\",\n value: function getLanguage() {\n if (this.editorObject.settings['wirisformulaeditorlang']) {\n return editor.settings['wirisformulaeditorlang'];\n }\n\n return this.editorObject.getParam('language');\n }\n /**\n * Callback function called before 'onTargetLoad' is fired. All the logic here is to\n * avoid TinyMCE change MathType formulas.\n */\n\n }, {\n key: \"callbackFunction\",\n value: function callbackFunction() {\n var dataImgFiltered = [];\n\n _get(_getPrototypeOf(TinyMceIntegration.prototype), \"callbackFunction\", this).call(this); // Avoid to change class of image formulas.\n\n\n var imageClassName = _core_src_configuration_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].get('imageClassName');\n\n if (this.isIframe) {\n // Attaching observers to wiris images.\n if (typeof _core_src_parser_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].observer != 'undefined') {\n Array.prototype.forEach.call(this.target.contentDocument.getElementsByClassName(imageClassName), function (wirisImages) {\n _core_src_parser_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].observer.observe(wirisImages);\n });\n }\n } else {\n // Inline.\n // Attaching observers to wiris images.\n Array.prototype.forEach.call(document.getElementsByClassName(imageClassName), function (wirisImages) {\n _core_src_parser_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].observer.observe(wirisImages);\n });\n } // When a formula is updated TinyMCE 'Change' event must be fired.\n // See https://www.tiny.cloud/docs/advanced/events/#change for further information.\n\n\n var listener = _core_src_listeners__WEBPACK_IMPORTED_MODULE_4__[\"default\"].newListener('onAfterFormulaInsertion', function () {\n if (typeof this.editorObject.fire != 'undefined') {\n this.editorObject.fire('Change');\n }\n }.bind(this));\n this.getCore().addListener(listener); // Avoid filter formulas with performance enabled.\n\n dataImgFiltered[this.editorObject.id] = this.editorObject.settings.images_dataimg_filter;\n\n this.editorObject.settings.images_dataimg_filter = function (img) {\n if (img.hasAttribute('class') && img.getAttribute('class').indexOf(_core_src_configuration_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].get(imageClassName)) != -1) {\n return img.hasAttribute('internal-blob');\n } else {\n // If the client put an image data filter, run. Otherwise default behaviour (put blob).\n if (typeof dataImgFiltered[this.editorObject.id] != 'undefined') {\n return dataImgFiltered[this.editorObject.id](img);\n }\n\n return true;\n }\n };\n }\n }]);\n\n return TinyMceIntegration;\n}(_core_src_integrationmodel_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"]);\n/**\n * Object containing all TinyMCE integration instances. One for each TinyMCE editor.\n * @type {Object}\n */\n\nvar instances = {};\n/**\n * TinyMCE integration current instance. The current instance\n * is the instance related with the focused editor.\n * @type {TinyMceIntegration}\n */\n\nvar currentInstance = null;\n/* Plugin integration */\n\n(function () {\n tinymce.create('tinymce.plugins.tiny_mce_wiris', {\n init: function init(editor, url) {\n // Array with MathML valid alements.\n var validMathML = ['math[*]', 'maction[*]]', 'malignmark[*]', 'maligngroup[*]', 'menclose[*]', 'merror[*]', 'mfenced[*]', 'mfrac[*]', 'mglyph[*]', 'mi[*]', 'mlabeledtr[*]', 'mlongdiv[*]', 'mmultiscripts[*]', 'mn[*]', 'mo[*]', 'mover[*]', 'mpadded[*]', 'mphantom[*]', 'mprescripts[*]', 'mroot[*]', 'mrow[*]', 'ms[*]', 'mscarries[*]', 'mscarry[*]', 'msgroup[*]', 'msline[*]', 'mspace[*]', 'msqrt[*]', 'msrow[*]', 'mstack[*]', 'mstyle[*]', 'msub[*]', 'msubsup[*]', 'msup[*]', 'mtable[*]', 'mtd[*]', 'mtext[*]', 'mtr[*]', 'munder[*]', 'munderover[*]', 'semantics[*]', 'annotation[*]'];\n editor.settings.extended_valid_elements += ',' + validMathML.join();\n var callbackMethodArguments = {};\n /**\n * Integration model properties\n * @type {object}\n * @property {object} target - Integration DOM target.\n * @property {string} configurationService - Configuration integration service.\n * @property {string} version - Plugin version.\n * @property {string} scriptName - Integration script name.\n * @property {object} environment - Integration environment properties.\n * @property {string} editor - Editor name.\n */\n\n var integrationModelProperties = {};\n integrationModelProperties.configurationService = '' + M.cfg.wwwroot + '/filter/wiris/integration/configurationjs.php';\n integrationModelProperties.version = '7.7.0.1394';\n integrationModelProperties.isMoodle = true;\n\n if (typeof editor.getParam('wiriscontextpath') !== 'undefined') {\n integrationModelProperties.configurationService = _core_src_util__WEBPACK_IMPORTED_MODULE_3__[\"default\"].concatenateUrl(editor.getParam('wiriscontextpath'), integrationModelProperties.configurationService);\n editor.getParam('wiriscontextpath') + '/' + integrationModelProperties.configurationService;\n }\n\n integrationModelProperties.version = '7.5.0.1414';\n integrationModelProperties.scriptName = \"plugin.min.js\";\n integrationModelProperties.environment = {};\n integrationModelProperties.environment.editor = \"TinyMCE 4.x\";\n integrationModelProperties.callbackMethodArguments = callbackMethodArguments;\n integrationModelProperties.editorObject = editor;\n integrationModelProperties.initParsed = false; // We need to create the instance before TinyMce initialization in order to register commands.\n // However, as TinyMCE is not initialized at this point the HTML target is not created.\n // Here we create the target as null and onInit object the target is updated.\n\n integrationModelProperties.target = null;\n var isExternalPlugin = typeof editor.getParam('external_plugins') !== 'undefined' && 'tiny_mce_wiris' in editor.getParam('external_plugins');\n integrationModelProperties.isExternal = isExternalPlugin;\n integrationModelProperties.rtl = editor.getParam('directionality') === 'rtl'; // GenericIntegration instance.\n\n var tinyMceIntegrationInstance = new TinyMceIntegration(integrationModelProperties);\n tinyMceIntegrationInstance.init();\n WirisPlugin.instances[tinyMceIntegrationInstance.editorObject.id] = tinyMceIntegrationInstance;\n WirisPlugin.currentInstance = tinyMceIntegrationInstance;\n\n var onInit = function onInit(editor) {\n var integrationInstance = WirisPlugin.instances[tinyMceIntegrationInstance.editorObject.id];\n\n if (!editor.inline) {\n integrationInstance.setTarget(editor.getContentAreaContainer().firstChild);\n } else {\n integrationInstance.setTarget(editor.getElement());\n }\n\n integrationInstance.setEditorObject(editor);\n integrationInstance.listeners.fire('onTargetReady', {});\n\n if ('wiriseditorparameters' in editor.settings) {\n _core_src_configuration_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].update('_wrs_conf_editorParameters', editor.settings.wiriseditorparameters);\n }\n\n var content = editor.getContent(); // Bug fix: In Moodle2.x when TinyMCE is set to full screen\n // the content doesn't need to be filtered.\n\n if (!editor.getParam('fullscreen_is_enabled') && content !== \"\") {\n // We set content in html because other tiny plugins need data-mce\n // and this is not posibil with raw format.\n editor.setContent(_core_src_parser_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].initParse(content, editor.getParam('language')), {\n format: \"html\"\n }); // This clean undoQueue for prevent onChange and Dirty state.\n\n editor.undoManager.clear();\n } // Init parsing OK. If a setContent method is called\n // wrs_initParse is called again.\n // Now if source code is edited the returned code is parsed.\n // PLUGINS-1070: We set this variable out of condition to parse content after.\n\n\n WirisPlugin.instances[editor.id].initParsed = true;\n };\n\n if ('onInit' in editor) {\n editor.onInit.add(onInit);\n } else {\n editor.on('init', function () {\n onInit(editor);\n });\n }\n\n if ('onActivate' in editor) {\n editor.onActivate.add(function (editor) {\n WirisPlugin.currentInstance = WirisPlugin.instances[tinymce.activeEditor.id];\n });\n } else {\n editor.on('focus', function (event) {\n WirisPlugin.currentInstance = WirisPlugin.instances[tinymce.activeEditor.id];\n });\n }\n\n var onSave = function onSave(editor, params) {\n params.content = _core_src_parser_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].endParse(params.content, editor.getParam('language'));\n };\n\n if ('onSaveContent' in editor) {\n editor.onSaveContent.add(onSave);\n } else {\n editor.on('saveContent', function (params) {\n onSave(editor, params);\n });\n }\n\n if ('onGetContent' in editor) {\n editor.onGetContent.add(onSave);\n } else {\n editor.on('getContent', function (params) {\n onSave(editor, params);\n });\n }\n\n if ('onBeforeSetContent' in editor) {\n editor.onBeforeSetContent.add(function (e, params) {\n if (WirisPlugin.instances[editor.id].initParsed) {\n params.content = Parse.initParse(params.content, editor.getParam('language'));\n }\n });\n } else {\n editor.on('beforeSetContent', function (params) {\n if (WirisPlugin.instances[editor.id].initParsed) {\n params.content = _core_src_parser_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].initParse(params.content, editor.getParam('language'));\n }\n });\n } // We use a mutation to observe iframe of tiny and filter to remove data-mce.\n\n\n var observerConfig = {\n attributes: true,\n childList: true,\n characterData: true,\n subtree: true\n };\n\n function onMutations(mutations) {\n Array.prototype.forEach.call(mutations, function (mutation) {\n Array.prototype.forEach.call(mutation.addedNodes, function (node) {\n // We search only in element nodes.\n if (node.nodeType == 1) {\n Array.prototype.forEach.call(node.getElementsByClassName(WirisPlugin.Configuration.get('imageMathmlAttribute')), function (image) {\n image.removeAttribute('data-mce-src');\n image.removeAttribute('data-mce-style');\n });\n }\n });\n });\n }\n\n var mutationInstance = new MutationObserver(onMutations); // We wait for iframe definition for observe this.\n\n function waitForIframeBody() {\n if (typeof editor.contentDocument != 'undefined') {\n mutationInstance.observe(editor.getBody(), observerConfig);\n } else {\n setTimeout(waitForIframeBody, 50);\n }\n }\n\n waitForIframeBody(); // MathType button.\n\n editor.addCommand('tiny_mce_wiris_openFormulaEditor', function () {\n WirisPlugin.instances[editor.id].openNewFormulaEditor();\n });\n editor.addButton('tiny_mce_wiris_formulaEditor', {\n title: 'Insert a math equation - MathType',\n cmd: 'tiny_mce_wiris_openFormulaEditor',\n image: WirisPlugin.instances[editor.id].getIconsPath() + 'formula.png'\n }); // }\n // Dynamic customEditors buttons.\n\n var customEditors = WirisPlugin.instances[tinyMCE.activeEditor.id].getCore().getCustomEditors();\n\n for (var customEditor in customEditors.editors) {\n if (customEditors.editors[customEditor].confVariable) {\n var cmd = 'tiny_mce_wiris_openFormulaEditor' + customEditors.editors[customEditor].name;\n editor.addCommand(cmd, function () {\n customEditors.enable(customEditor);\n WirisPlugin.instances[editor.id].openNewFormulaEditor();\n });\n editor.addButton('tiny_mce_wiris_formulaEditor' + customEditors.editors[customEditor].name, {\n title: customEditors.editors[customEditor].tooltip,\n cmd: cmd,\n image: WirisPlugin.instances[editor.id].getIconsPath() + customEditors.editors[customEditor].icon\n });\n }\n }\n },\n // All versions.\n getInfo: function getInfo() {\n return {\n longname: 'tiny_mce_wiris',\n author: 'Maths for More',\n authorurl: 'http://www.wiris.com',\n infourl: 'http://www.wiris.com',\n version: '7.7.0.1394'\n };\n }\n });\n tinymce.PluginManager.add('tiny_mce_wiris', tinymce.plugins.tiny_mce_wiris);\n})();\n\n//# sourceURL=webpack:///./editor_plugin.src.js?"); /***/ }), diff --git a/tinymce/editor_plugin.src.js b/tinymce/editor_plugin.src.js index 5a28c65..d5d3ec3 100644 --- a/tinymce/editor_plugin.src.js +++ b/tinymce/editor_plugin.src.js @@ -204,7 +204,7 @@ export var currentInstance = null; */ var integrationModelProperties = {}; integrationModelProperties.configurationService = '' + M.cfg.wwwroot + '/filter/wiris/integration/configurationjs.php'; - integrationModelProperties.version = '7.6.1.1393'; + integrationModelProperties.version = '7.7.0.1394'; integrationModelProperties.isMoodle = true; if (typeof(editor.getParam('wiriscontextpath')) !== 'undefined') { integrationModelProperties.configurationService = Util.concatenateUrl(editor.getParam('wiriscontextpath'), integrationModelProperties.configurationService); @@ -384,7 +384,7 @@ export var currentInstance = null; author : 'Maths for More', authorurl : 'http://www.wiris.com', infourl : 'http://www.wiris.com', - version : '7.6.1.1393' + version : '7.7.0.1394' }; } }); diff --git a/tinymce/editor_plugin_src.js b/tinymce/editor_plugin_src.js index d4235da..3c513d9 100644 --- a/tinymce/editor_plugin_src.js +++ b/tinymce/editor_plugin_src.js @@ -154,7 +154,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) * /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"default\", function() { return ContentManager; });\n/* harmony import */ var _configuration_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./configuration.js */ \"./core/src/configuration.js\");\n/* harmony import */ var _editorlistener_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./editorlistener.js */ \"./core/src/editorlistener.js\");\n/* harmony import */ var _listeners_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./listeners.js */ \"./core/src/listeners.js\");\n/* harmony import */ var _mathml_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./mathml.js */ \"./core/src/mathml.js\");\n/* harmony import */ var _util_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./util.js */ \"./core/src/util.js\");\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\n\n\n\n\n\n/**\r\n * This class represents the content of a ModalDialog class managing the following:\r\n * - Insertion in the ModalDialog.\r\n * - Actions to be done once the modal object has been submitted (submitAction() method).\r\n * - Updates itself when ModalDialog is updated, for example when ModalDialog\r\n * is re-opened (update(modalObject) method).\r\n * - Communicates ModalDialog if some changes have be done (hasChanges() method).\r\n */\n\nvar ContentManager =\n/*#__PURE__*/\nfunction () {\n /**\r\n * Class constructor\r\n * @param {Object} contentManagerAttributes - Object containing all attributes needed to\r\n * create a new instance of ContentManager class.\r\n * @param {Object} contentManagerAttributes.editorAttributes - Object containing MathType editor parameters.\r\n */\n function ContentManager(contentManagerAttributes) {\n _classCallCheck(this, ContentManager);\n\n /**\r\n * An object containing MathType editor parameters. See\r\n * http://docs.wiris.com/en/mathtype/mathtype_web/sdk-api/parameters for further information.\r\n * @type {Object}\r\n */\n this.contentManagerAttributes = {};\n\n if ('editorAttributes' in contentManagerAttributes) {\n this.editorAttributes = contentManagerAttributes.editorAttributes;\n } else {\n throw new Error('ContentManager constructor error: editorAttributes property missed.');\n }\n /**\r\n * CustomEditors instance. Contains the custom editors.\r\n * @type {CustomEditors}\r\n */\n\n\n this.customEditors = null;\n\n if ('customEditors' in contentManagerAttributes) {\n this.customEditors = contentManagerAttributes.customEditors;\n }\n /**\r\n * Environment properties. This object contains data about the integration platform.\r\n * @type {Object}\r\n * @property {string} editor - Editor name. Usually the HTML editor.\r\n * @property {string} mode - Save mode. Xml by default\r\n * @property {string} version - Plugin version.\r\n */\n\n\n this.environment = {};\n\n if ('environment' in contentManagerAttributes) {\n this.environment = contentManagerAttributes.environment;\n } else {\n throw new Error('ContentManager constructor error: environment property missed');\n }\n /**\r\n * ContentManager language.\r\n * @type {string}\r\n */\n\n\n this.language = '';\n\n if ('language' in contentManagerAttributes) {\n this.language = contentManagerAttributes.language;\n } else {\n throw new Error('ContentManager constructor error: language property missed');\n }\n /**\r\n * Editor listener. Needed to get control about editor changes.\r\n * @type {EditorListener}\r\n */\n\n\n this.editorListener = new _editorlistener_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"]();\n /**\r\n * MathType editor instance.\r\n * @type {JsEditor}\r\n */\n\n this.editor = null;\n /**\r\n * Navigator user agent.\r\n * @type {string}\r\n */\n\n this.ua = navigator.userAgent.toLowerCase();\n /**\r\n * Mobile device properties object\r\n * @type {Object}\r\n * @property {boolean} isAndroid - True if the device is android. False otherwise.\r\n * @property {boolean} isIOS - True if the device is iOS. False otherwise.\r\n */\n\n this.deviceProperties = {};\n this.deviceProperties.isAndroid = this.ua.indexOf(\"android\") > -1;\n this.deviceProperties.isIOS = this.ua.indexOf(\"ipad\") > -1 || this.ua.indexOf(\"iphone\") > -1;\n /**\r\n * Custom editor toolbar.\r\n * @type {string} toolbar\r\n */\n\n this.toolbar = null;\n /**\r\n * Instance of the ModalDialog class associated to the ContentManager instance.\r\n * @type {ModalDialog}\r\n */\n\n this.modalDialogInstance = null;\n /**\r\n * ContentManager listeners.\r\n * @type {Listeners}\r\n */\n\n this.listeners = new _listeners_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"]();\n /**\r\n * MathML associated to the ContentManager instance.\r\n * @type {string}\r\n */\n\n this.mathML = null;\n /**\r\n * Indicates if the edited element is a new element or not.\r\n * @type {boolean}\r\n */\n\n this.isNewElement = true;\n /**\r\n * IntegrationModel instance. Needed to call wrapper methods.\r\n * @type {IntegrationModel}\r\n */\n\n this.integrationModel = null;\n /**\r\n * Indicates if the editor is loaded.\r\n * @type {boolean}\r\n */\n\n this.isEditorLoaded = false;\n }\n /**\r\n * Add a new listener to ContentManager class.\r\n * @param {Object} listener - listener to be added.\r\n */\n\n\n _createClass(ContentManager, [{\n key: \"addListener\",\n value: function addListener(listener) {\n this.listeners.add(listener);\n }\n /**\r\n * Sets an instance of an IntegrationModel\r\n * @param {IntegrationModel} integrationModel\r\n */\n\n }, {\n key: \"setIntegrationModel\",\n value: function setIntegrationModel(integrationModel) {\n this.integrationModel = integrationModel;\n }\n /**\r\n * Sets a modal dialog instance.\r\n * @param {ModalDialog} - a ModalDialog instance\r\n */\n\n }, {\n key: \"setModalDialogInstance\",\n value: function setModalDialogInstance(modalDialogInstance) {\n this.modalDialogInstance = modalDialogInstance;\n }\n /**\r\n * Mandatory method. Inserts editor into modal object content container.\r\n */\n\n }, {\n key: \"insert\",\n value: function insert() {\n // Before insert the editor we update the modal object title to avoid weird render display.\n this.updateTitle(this.modalDialogInstance);\n this.insertEditor(this.modalDialogInstance);\n }\n /**\r\n * Method to insert MathType into modal object. This method\r\n * waits until editor JavaScript is loaded to insert the editor into\r\n * contentContainer modal object element.\r\n */\n\n }, {\n key: \"insertEditor\",\n value: function insertEditor() {\n // To know if editor JavaScript is loaded we need to wait until com.wiris.jsEditor namespace is ready.\n if ('com' in window && 'wiris' in window.com && 'jsEditor' in window.com.wiris) {\n this.editor = com.wiris.jsEditor.JsEditor.newInstance(this.editorAttributes);\n this.editor.insertInto(this.modalDialogInstance.contentContainer);\n this.editor.focus();\n\n if (this.modalDialogInstance.rtl) {\n this.editor.action('rtl');\n } // Setting div in rtl in case of it's activated.\n\n\n if (this.editor.getEditorModel().isRTL()) {\n this.editor.element.style.direction = 'rtl';\n } // Editor listener: this object manages the changes logic of editor.\n\n\n this.editor.getEditorModel().addEditorListener(this.editorListener); // iOS events.\n\n if (this.modalDialogInstance.deviceProperties['isIOS']) {\n setTimeout(function () {\n this.modalDialogInstance.hideKeyboard();\n }, 400);\n var formulaDisplayDiv = document.getElementsByClassName('wrs_formulaDisplay')[0];\n _util_js__WEBPACK_IMPORTED_MODULE_4__[\"default\"].addEvent(formulaDisplayDiv, 'focus', this.modalDialogInstance.openedIosSoftkeyboard.bind());\n _util_js__WEBPACK_IMPORTED_MODULE_4__[\"default\"].addEvent(formulaDisplayDiv, 'blur', this.modalDialogInstance.closedIosSoftkeyboard.bind());\n } // Fire onLoad event. Necessary to set the MathML into the editor\n // after is loaded.\n\n\n this.listeners.fire('onLoad', {});\n this.isEditorLoaded = true;\n } else {\n setTimeout(ContentManager.prototype.insertEditor.bind(this, this.modalDialogInstance), 100);\n }\n }\n /**\r\n * Loads MathType script.\r\n */\n\n }, {\n key: \"init\",\n value: function init() {\n var queryParams = window.location.search.substring(1).split(\"&\");\n\n for (var i = 0; i < queryParams.length; i++) {\n var pos = queryParams[i].indexOf(\"v=\");\n\n if (pos >= 0) {\n version = queryParams[i].substring(2);\n }\n }\n\n var script = document.createElement('script');\n script.type = 'text/javascript';\n var editorUrl = _configuration_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get('editorUrl'); // We create an object url for parse url string and work more efficiently.\n\n var urlObject = document.createElement('a');\n urlObject.href = editorUrl; // Change to https if necessary.\n\n if (window.location.href.indexOf(\"https://\") == 0) {\n // It check if browser is https and configuration is http. If this is so, we will replace protocol.\n if (urlObject.protocol == 'http:') {\n urlObject.protocol = 'https:';\n }\n } // Check protocol and remove port if it's standard.\n\n\n if (urlObject.port == '80' || urlObject.port == '443') {\n editorUrl = urlObject.protocol + '//' + urlObject.hostname + '/' + urlObject.pathname;\n } else {\n editorUrl = urlObject.protocol + '//' + urlObject.hostname + ':' + urlObject.port + '/' + urlObject.pathname;\n } // Editor stats. Use environment property to set it.\n\n\n var stats = {};\n\n if ('editor' in this.environment) {\n stats.editor = this.environment.editor;\n } else {\n stats.editor = 'unknown';\n }\n\n if ('mode' in this.environment) {\n stats.mode = this.environment.mode;\n } else {\n stats.mode = _configuration_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get('saveMode');\n }\n\n if ('version' in this.environment) {\n stats.version = this.environment.version;\n } else {\n stats.version = _configuration_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get('version');\n } // Load editor URL. We add stats as GET params.\n\n\n script.src = editorUrl + \"?lang=\" + this.language + '&stats-editor=' + stats.editor + '&stats-mode=' + stats.mode + '&stats-version=' + stats.version;\n document.getElementsByTagName('head')[0].appendChild(script);\n }\n /**\r\n * Set the editor initial content: an existing formula or a blank MathML\r\n */\n\n }, {\n key: \"setInitialContent\",\n value: function setInitialContent() {\n if (!this.isNewElement) {\n this.setMathML(this.mathML);\n }\n }\n /**\r\n * Set a MathML into editor.\r\n * @param {string} mathml - MathML string.\r\n * @param {bool} focusDisabled - if true editor don't get focus after the MathML is set. false by default.\r\n */\n\n }, {\n key: \"setMathML\",\n value: function setMathML(mathml, focusDisabled) {\n // By default focus is enabled\n if (typeof focusDisabled === 'undefined') {\n focusDisabled = false;\n } // Using setMathML method is not a change produced by the user but for the API\n // so we set to false the contentChange property of editorListener.\n\n\n this.editor.setMathMLWithCallback(mathml, function () {\n this.editorListener.setWaitingForChanges(true);\n }.bind(this)); // We need to wait a little until the callback finish.\n\n setTimeout(function () {\n this.editorListener.setIsContentChanged(false);\n }.bind(this), 500); // In some scenarios - like closing modal object - editor mustn't be focused.\n\n if (!focusDisabled) {\n this.onFocus();\n }\n }\n /**\r\n * Set focus on editor.\r\n */\n\n }, {\n key: \"onFocus\",\n value: function onFocus() {\n if (typeof this.editor !== 'undefined' && this.editor != null) {\n this.editor.focus();\n }\n }\n /**\r\n * Mandatory method: modal object calls this method to execute a callback action\r\n * on submit.\r\n * This method updates the edition area (inserting a new formula or update an older one),\r\n * and focus the edition area too.\r\n */\n\n }, {\n key: \"submitAction\",\n value: function submitAction() {\n var mathML = this.editor.getMathML(); // Add class for custom editors.\n\n if (this.customEditors.getActiveEditor() != null) {\n mathML = _mathml_js__WEBPACK_IMPORTED_MODULE_3__[\"default\"].addCustomEditorClassAttribute(mathML, this.customEditors.getActiveEditor().toolbar);\n } else {\n // We need - if exists - the editor name from MathML\n // class attribute.\n for (var key in this.customEditors.editors) {\n mathML = _mathml_js__WEBPACK_IMPORTED_MODULE_3__[\"default\"].removeCustomEditorClassAttribute(mathML, key);\n }\n }\n\n var mathmlEntitiesEncoded = _mathml_js__WEBPACK_IMPORTED_MODULE_3__[\"default\"].mathMLEntities(mathML);\n this.integrationModel.updateFormula(mathmlEntitiesEncoded);\n this.customEditors.disable();\n this.integrationModel.notifyWindowClosed(); // Set disabled focus to prevent lost focus.\n\n this.setEmptyMathML();\n this.customEditors.disable(); // Recovering editing area focus.\n\n setTimeout(function () {\n if (typeof _wrs_currentEditor !== 'undefined' && _wrs_currentEditor) {\n _wrs_currentEditor.focus();\n }\n }, 100);\n }\n /**\r\n * Set an empty MathML into the editor in order to clean the edit area.\r\n */\n\n }, {\n key: \"setEmptyMathML\",\n value: function setEmptyMathML() {\n // As second argument we pass\n if (this.deviceProperties.isAndroid || this.deviceProperties.isIOS) {\n // We need to set a empty annotation in order to maintain editor in Hand mode.\n // Adding dir rtl in case of it's activated.\n if (this.editor.getEditorModel().isRTL()) {\n this.setMathML('[]\"', true);\n } else {\n this.setMathML('[]\"', true);\n }\n } else {\n if (this.editor.getEditorModel().isRTL()) {\n this.setMathML('', true);\n } else {\n this.setMathML('', true);\n }\n }\n }\n /**\r\n * Mandatory method: modal object calls this method when is updated, for example re-editing a formula when the\r\n * editor is open with another formula. This method updates the editor content (with an empty MathML or an existing formula),\r\n * updates - if needed - the editor toolbar (math --> chem or chem --> math) and recover the focus.\r\n */\n\n }, {\n key: \"onOpen\",\n value: function onOpen() {\n if (this.isNewElement) {\n this.setEmptyMathML();\n } else {\n this.setMathML(this.mathML);\n }\n\n this.updateToolbar();\n this.onFocus();\n }\n /**\r\n * Sets the correct toolbar depending if exist other custom toolbars at the same time (e.g: Chemistry)\r\n */\n\n }, {\n key: \"updateToolbar\",\n value: function updateToolbar() {\n this.updateTitle(this.modalDialogInstance);\n var customEditor;\n\n if (customEditor = this.customEditors.getActiveEditor()) {\n var toolbar = customEditor.toolbar ? customEditor.toolbar : _wrs_int_wirisProperties['toolbar'];\n\n if (this.toolbar == null || this.toolbar != toolbar) {\n this.setToolbar(toolbar);\n }\n } else {\n var toolbar = this.getToolbar();\n\n if (this.toolbar == null || this.toolbar != toolbar) {\n this.setToolbar(toolbar);\n this.customEditors.disable();\n }\n }\n }\n /**\r\n * Updates the modalObject title: if a custom editor (with a custom toolbar) is enabled\r\n * picks the custom editor title. Otherwise default title.\r\n */\n\n }, {\n key: \"updateTitle\",\n value: function updateTitle() {\n var customEditor;\n\n if (customEditor = this.customEditors.getActiveEditor()) {\n this.modalDialogInstance.setTitle(customEditor.title);\n } else {\n this.modalDialogInstance.setTitle('MathType');\n }\n }\n /**\r\n * Returns toolbar depending on the configuration local or server side.\r\n */\n\n }, {\n key: \"getToolbar\",\n value: function getToolbar() {\n var toolbar;\n\n if ('toolbar' in this.editorAttributes) {\n toolbar = this.editorAttributes.toolbar;\n } else {\n toolbar = \"general\";\n } // TODO: Change global integration variable for integration custom toolbar\n\n\n if (toolbar == 'general') {\n toolbar = typeof _wrs_int_wirisProperties == 'undefined' || typeof _wrs_int_wirisProperties['toolbar'] == 'undefined' ? 'general' : _wrs_int_wirisProperties['toolbar'];\n }\n\n return toolbar;\n }\n /**\r\n * Set a toolbar into editor.\r\n * @param {string} toolbar - toolbar name.\r\n */\n\n }, {\n key: \"setToolbar\",\n value: function setToolbar(toolbar) {\n this.toolbar = toolbar;\n this.editor.setParams({\n 'toolbar': this.toolbar\n });\n }\n /**\r\n * Returns true if the content of the editor has been changed. The logic of the changes\r\n * is delegated to editorListener object.\r\n */\n\n }, {\n key: \"hasChanges\",\n value: function hasChanges() {\n return !this.editor.isFormulaEmpty() && this.editorListener.getIsContentChanged();\n }\n }]);\n\n return ContentManager;\n}();\n\n\n\n//# sourceURL=webpack:///./core/src/contentmanager.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"default\", function() { return ContentManager; });\n/* harmony import */ var _configuration_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./configuration.js */ \"./core/src/configuration.js\");\n/* harmony import */ var _editorlistener_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./editorlistener.js */ \"./core/src/editorlistener.js\");\n/* harmony import */ var _listeners_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./listeners.js */ \"./core/src/listeners.js\");\n/* harmony import */ var _mathml_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./mathml.js */ \"./core/src/mathml.js\");\n/* harmony import */ var _util_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./util.js */ \"./core/src/util.js\");\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\n\n\n\n\n\n/**\r\n * This class represents the content of a ModalDialog class managing the following:\r\n * - Insertion in the ModalDialog.\r\n * - Actions to be done once the modal object has been submitted (submitAction() method).\r\n * - Updates itself when ModalDialog is updated, for example when ModalDialog\r\n * is re-opened (update(modalObject) method).\r\n * - Communicates ModalDialog if some changes have be done (hasChanges() method).\r\n */\n\nvar ContentManager =\n/*#__PURE__*/\nfunction () {\n /**\r\n * Class constructor\r\n * @param {Object} contentManagerAttributes - Object containing all attributes needed to\r\n * create a new instance of ContentManager class.\r\n * @param {Object} contentManagerAttributes.editorAttributes - Object containing MathType editor parameters.\r\n */\n function ContentManager(contentManagerAttributes) {\n _classCallCheck(this, ContentManager);\n\n /**\r\n * An object containing MathType editor parameters. See\r\n * http://docs.wiris.com/en/mathtype/mathtype_web/sdk-api/parameters for further information.\r\n * @type {Object}\r\n */\n this.contentManagerAttributes = {};\n\n if ('editorAttributes' in contentManagerAttributes) {\n this.editorAttributes = contentManagerAttributes.editorAttributes;\n } else {\n throw new Error('ContentManager constructor error: editorAttributes property missed.');\n }\n /**\r\n * CustomEditors instance. Contains the custom editors.\r\n * @type {CustomEditors}\r\n */\n\n\n this.customEditors = null;\n\n if ('customEditors' in contentManagerAttributes) {\n this.customEditors = contentManagerAttributes.customEditors;\n }\n /**\r\n * Environment properties. This object contains data about the integration platform.\r\n * @type {Object}\r\n * @property {string} editor - Editor name. Usually the HTML editor.\r\n * @property {string} mode - Save mode. Xml by default\r\n * @property {string} version - Plugin version.\r\n */\n\n\n this.environment = {};\n\n if ('environment' in contentManagerAttributes) {\n this.environment = contentManagerAttributes.environment;\n } else {\n throw new Error('ContentManager constructor error: environment property missed');\n }\n /**\r\n * ContentManager language.\r\n * @type {string}\r\n */\n\n\n this.language = '';\n\n if ('language' in contentManagerAttributes) {\n this.language = contentManagerAttributes.language;\n } else {\n throw new Error('ContentManager constructor error: language property missed');\n }\n /**\r\n * Editor listener. Needed to get control about editor changes.\r\n * @type {EditorListener}\r\n */\n\n\n this.editorListener = new _editorlistener_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"]();\n /**\r\n * MathType editor instance.\r\n * @type {JsEditor}\r\n */\n\n this.editor = null;\n /**\r\n * Navigator user agent.\r\n * @type {string}\r\n */\n\n this.ua = navigator.userAgent.toLowerCase();\n /**\r\n * Mobile device properties object\r\n * @type {Object}\r\n * @property {boolean} isAndroid - True if the device is android. False otherwise.\r\n * @property {boolean} isIOS - True if the device is iOS. False otherwise.\r\n */\n\n this.deviceProperties = {};\n this.deviceProperties.isAndroid = this.ua.indexOf(\"android\") > -1;\n this.deviceProperties.isIOS = this.ua.indexOf(\"ipad\") > -1 || this.ua.indexOf(\"iphone\") > -1;\n /**\r\n * Custom editor toolbar.\r\n * @type {string} toolbar\r\n */\n\n this.toolbar = null;\n /**\r\n * Instance of the ModalDialog class associated to the ContentManager instance.\r\n * @type {ModalDialog}\r\n */\n\n this.modalDialogInstance = null;\n /**\r\n * ContentManager listeners.\r\n * @type {Listeners}\r\n */\n\n this.listeners = new _listeners_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"]();\n /**\r\n * MathML associated to the ContentManager instance.\r\n * @type {string}\r\n */\n\n this.mathML = null;\n /**\r\n * Indicates if the edited element is a new element or not.\r\n * @type {boolean}\r\n */\n\n this.isNewElement = true;\n /**\r\n * IntegrationModel instance. Needed to call wrapper methods.\r\n * @type {IntegrationModel}\r\n */\n\n this.integrationModel = null;\n /**\r\n * Indicates if the editor is loaded.\r\n * @type {boolean}\r\n */\n\n this.isEditorLoaded = false;\n }\n /**\r\n * Add a new listener to ContentManager class.\r\n * @param {Object} listener - listener to be added.\r\n */\n\n\n _createClass(ContentManager, [{\n key: \"addListener\",\n value: function addListener(listener) {\n this.listeners.add(listener);\n }\n /**\r\n * Sets an instance of an IntegrationModel\r\n * @param {IntegrationModel} integrationModel\r\n */\n\n }, {\n key: \"setIntegrationModel\",\n value: function setIntegrationModel(integrationModel) {\n this.integrationModel = integrationModel;\n }\n /**\r\n * Sets a modal dialog instance.\r\n * @param {ModalDialog} - a ModalDialog instance\r\n */\n\n }, {\n key: \"setModalDialogInstance\",\n value: function setModalDialogInstance(modalDialogInstance) {\n this.modalDialogInstance = modalDialogInstance;\n }\n /**\r\n * Mandatory method. Inserts editor into modal object content container.\r\n */\n\n }, {\n key: \"insert\",\n value: function insert() {\n // Before insert the editor we update the modal object title to avoid weird render display.\n this.updateTitle(this.modalDialogInstance);\n this.insertEditor(this.modalDialogInstance);\n }\n /**\r\n * Method to insert MathType into modal object. This method\r\n * waits until editor JavaScript is loaded to insert the editor into\r\n * contentContainer modal object element.\r\n */\n\n }, {\n key: \"insertEditor\",\n value: function insertEditor() {\n // To know if editor JavaScript is loaded we need to wait until com.wiris.jsEditor namespace is ready.\n if ('com' in window && 'wiris' in window.com && 'jsEditor' in window.com.wiris) {\n this.editor = com.wiris.jsEditor.JsEditor.newInstance(this.editorAttributes);\n this.editor.insertInto(this.modalDialogInstance.contentContainer);\n this.editor.focus();\n\n if (this.modalDialogInstance.rtl) {\n this.editor.action('rtl');\n } // Setting div in rtl in case of it's activated.\n\n\n if (this.editor.getEditorModel().isRTL()) {\n this.editor.element.style.direction = 'rtl';\n } // Editor listener: this object manages the changes logic of editor.\n\n\n this.editor.getEditorModel().addEditorListener(this.editorListener); // iOS events.\n\n if (this.modalDialogInstance.deviceProperties['isIOS']) {\n setTimeout(function () {\n this.modalDialogInstance.hideKeyboard();\n }, 400);\n var formulaDisplayDiv = document.getElementsByClassName('wrs_formulaDisplay')[0];\n _util_js__WEBPACK_IMPORTED_MODULE_4__[\"default\"].addEvent(formulaDisplayDiv, 'focus', this.modalDialogInstance.handleOpenedIosSoftkeyboard);\n _util_js__WEBPACK_IMPORTED_MODULE_4__[\"default\"].addEvent(formulaDisplayDiv, 'blur', this.modalDialogInstance.handleClosedIosSoftkeyboard);\n } // Fire onLoad event. Necessary to set the MathML into the editor\n // after is loaded.\n\n\n this.listeners.fire('onLoad', {});\n this.isEditorLoaded = true;\n } else {\n setTimeout(ContentManager.prototype.insertEditor.bind(this, this.modalDialogInstance), 100);\n }\n }\n /**\r\n * Loads MathType script.\r\n */\n\n }, {\n key: \"init\",\n value: function init() {\n var queryParams = window.location.search.substring(1).split(\"&\");\n\n for (var i = 0; i < queryParams.length; i++) {\n var pos = queryParams[i].indexOf(\"v=\");\n\n if (pos >= 0) {\n version = queryParams[i].substring(2);\n }\n }\n\n var script = document.createElement('script');\n script.type = 'text/javascript';\n var editorUrl = _configuration_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get('editorUrl'); // We create an object url for parse url string and work more efficiently.\n\n var urlObject = document.createElement('a');\n urlObject.href = editorUrl; // Change to https if necessary.\n\n if (window.location.href.indexOf(\"https://\") == 0) {\n // It check if browser is https and configuration is http. If this is so, we will replace protocol.\n if (urlObject.protocol == 'http:') {\n urlObject.protocol = 'https:';\n }\n } // Check protocol and remove port if it's standard.\n\n\n if (urlObject.port == '80' || urlObject.port == '443') {\n editorUrl = urlObject.protocol + '//' + urlObject.hostname + '/' + urlObject.pathname;\n } else {\n editorUrl = urlObject.protocol + '//' + urlObject.hostname + ':' + urlObject.port + '/' + urlObject.pathname;\n } // Editor stats. Use environment property to set it.\n\n\n var stats = {};\n\n if ('editor' in this.environment) {\n stats.editor = this.environment.editor;\n } else {\n stats.editor = 'unknown';\n }\n\n if ('mode' in this.environment) {\n stats.mode = this.environment.mode;\n } else {\n stats.mode = _configuration_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get('saveMode');\n }\n\n if ('version' in this.environment) {\n stats.version = this.environment.version;\n } else {\n stats.version = _configuration_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get('version');\n } // Load editor URL. We add stats as GET params.\n\n\n script.src = editorUrl + \"?lang=\" + this.language + '&stats-editor=' + stats.editor + '&stats-mode=' + stats.mode + '&stats-version=' + stats.version;\n document.getElementsByTagName('head')[0].appendChild(script);\n }\n /**\r\n * Set the editor initial content: an existing formula or a blank MathML\r\n */\n\n }, {\n key: \"setInitialContent\",\n value: function setInitialContent() {\n if (!this.isNewElement) {\n this.setMathML(this.mathML);\n }\n }\n /**\r\n * Set a MathML into editor.\r\n * @param {string} mathml - MathML string.\r\n * @param {bool} focusDisabled - if true editor don't get focus after the MathML is set. false by default.\r\n */\n\n }, {\n key: \"setMathML\",\n value: function setMathML(mathml, focusDisabled) {\n // By default focus is enabled\n if (typeof focusDisabled === 'undefined') {\n focusDisabled = false;\n } // Using setMathML method is not a change produced by the user but for the API\n // so we set to false the contentChange property of editorListener.\n\n\n this.editor.setMathMLWithCallback(mathml, function () {\n this.editorListener.setWaitingForChanges(true);\n }.bind(this)); // We need to wait a little until the callback finish.\n\n setTimeout(function () {\n this.editorListener.setIsContentChanged(false);\n }.bind(this), 500); // In some scenarios - like closing modal object - editor mustn't be focused.\n\n if (!focusDisabled) {\n this.onFocus();\n }\n }\n /**\r\n * Set focus on editor.\r\n */\n\n }, {\n key: \"onFocus\",\n value: function onFocus() {\n if (typeof this.editor !== 'undefined' && this.editor != null) {\n this.editor.focus();\n }\n }\n /**\r\n * Mandatory method: modal object calls this method to execute a callback action\r\n * on submit.\r\n * This method updates the edition area (inserting a new formula or update an older one),\r\n * and focus the edition area too.\r\n */\n\n }, {\n key: \"submitAction\",\n value: function submitAction() {\n if (!this.editor.isFormulaEmpty()) {\n var mathML = this.editor.getMathMLWithSemantics(); // Add class for custom editors.\n\n if (this.customEditors.getActiveEditor() != null) {\n mathML = _mathml_js__WEBPACK_IMPORTED_MODULE_3__[\"default\"].addCustomEditorClassAttribute(mathML, this.customEditors.getActiveEditor().toolbar);\n } else {\n // We need - if exists - the editor name from MathML\n // class attribute.\n for (var key in this.customEditors.editors) {\n mathML = _mathml_js__WEBPACK_IMPORTED_MODULE_3__[\"default\"].removeCustomEditorClassAttribute(mathML, key);\n }\n }\n\n var mathmlEntitiesEncoded = _mathml_js__WEBPACK_IMPORTED_MODULE_3__[\"default\"].mathMLEntities(mathML);\n this.integrationModel.updateFormula(mathmlEntitiesEncoded);\n } else {\n this.integrationModel.updateFormula(null);\n }\n\n this.customEditors.disable();\n this.integrationModel.notifyWindowClosed(); // Set disabled focus to prevent lost focus.\n\n this.setEmptyMathML();\n this.customEditors.disable();\n }\n /**\r\n * Set an empty MathML into the editor in order to clean the edit area.\r\n */\n\n }, {\n key: \"setEmptyMathML\",\n value: function setEmptyMathML() {\n // As second argument we pass\n if (this.deviceProperties.isAndroid || this.deviceProperties.isIOS) {\n // We need to set a empty annotation in order to maintain editor in Hand mode.\n // Adding dir rtl in case of it's activated.\n if (this.editor.getEditorModel().isRTL()) {\n this.setMathML('[]\"', true);\n } else {\n this.setMathML('[]\"', true);\n }\n } else {\n if (this.editor.getEditorModel().isRTL()) {\n this.setMathML('', true);\n } else {\n this.setMathML('', true);\n }\n }\n }\n /**\r\n * Mandatory method: modal object calls this method when is updated, for example re-editing a formula when the\r\n * editor is open with another formula. This method updates the editor content (with an empty MathML or an existing formula),\r\n * updates - if needed - the editor toolbar (math --> chem or chem --> math) and recover the focus.\r\n */\n\n }, {\n key: \"onOpen\",\n value: function onOpen() {\n if (this.isNewElement) {\n this.setEmptyMathML();\n } else {\n this.setMathML(this.mathML);\n }\n\n this.updateToolbar();\n this.onFocus();\n }\n /**\r\n * Sets the correct toolbar depending if exist other custom toolbars at the same time (e.g: Chemistry)\r\n */\n\n }, {\n key: \"updateToolbar\",\n value: function updateToolbar() {\n this.updateTitle(this.modalDialogInstance);\n var customEditor;\n\n if (customEditor = this.customEditors.getActiveEditor()) {\n var toolbar = customEditor.toolbar ? customEditor.toolbar : _wrs_int_wirisProperties['toolbar'];\n\n if (this.toolbar == null || this.toolbar != toolbar) {\n this.setToolbar(toolbar);\n }\n } else {\n var toolbar = this.getToolbar();\n\n if (this.toolbar == null || this.toolbar != toolbar) {\n this.setToolbar(toolbar);\n this.customEditors.disable();\n }\n }\n }\n /**\r\n * Updates the modalObject title: if a custom editor (with a custom toolbar) is enabled\r\n * picks the custom editor title. Otherwise default title.\r\n */\n\n }, {\n key: \"updateTitle\",\n value: function updateTitle() {\n var customEditor;\n\n if (customEditor = this.customEditors.getActiveEditor()) {\n this.modalDialogInstance.setTitle(customEditor.title);\n } else {\n this.modalDialogInstance.setTitle('MathType');\n }\n }\n /**\r\n * Returns toolbar depending on the configuration local or server side.\r\n */\n\n }, {\n key: \"getToolbar\",\n value: function getToolbar() {\n var toolbar;\n\n if ('toolbar' in this.editorAttributes) {\n toolbar = this.editorAttributes.toolbar;\n } else {\n toolbar = \"general\";\n } // TODO: Change global integration variable for integration custom toolbar\n\n\n if (toolbar == 'general') {\n toolbar = typeof _wrs_int_wirisProperties == 'undefined' || typeof _wrs_int_wirisProperties['toolbar'] == 'undefined' ? 'general' : _wrs_int_wirisProperties['toolbar'];\n }\n\n return toolbar;\n }\n /**\r\n * Set a toolbar into editor.\r\n * @param {string} toolbar - toolbar name.\r\n */\n\n }, {\n key: \"setToolbar\",\n value: function setToolbar(toolbar) {\n this.toolbar = toolbar;\n this.editor.setParams({\n 'toolbar': this.toolbar\n });\n }\n /**\r\n * Returns true if the content of the editor has been changed. The logic of the changes\r\n * is delegated to editorListener object.\r\n */\n\n }, {\n key: \"hasChanges\",\n value: function hasChanges() {\n return !this.editor.isFormulaEmpty() && this.editorListener.getIsContentChanged();\n }\n }]);\n\n return ContentManager;\n}();\n\n\n\n//# sourceURL=webpack:///./core/src/contentmanager.js?"); /***/ }), @@ -166,7 +166,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) * /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"default\", function() { return Core; });\n/* harmony import */ var _util_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./util.js */ \"./core/src/util.js\");\n/* harmony import */ var _stringmanager_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./stringmanager.js */ \"./core/src/stringmanager.js\");\n/* harmony import */ var _contentmanager_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./contentmanager.js */ \"./core/src/contentmanager.js\");\n/* harmony import */ var _modal_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./modal.js */ \"./core/src/modal.js\");\n/* harmony import */ var _serviceprovider_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./serviceprovider.js */ \"./core/src/serviceprovider.js\");\n/* harmony import */ var _parser_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./parser.js */ \"./core/src/parser.js\");\n/* harmony import */ var _latex_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./latex.js */ \"./core/src/latex.js\");\n/* harmony import */ var _mathml_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./mathml.js */ \"./core/src/mathml.js\");\n/* harmony import */ var _customeditors_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./customeditors.js */ \"./core/src/customeditors.js\");\n/* harmony import */ var _configuration_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./configuration.js */ \"./core/src/configuration.js\");\n/* harmony import */ var _jsvariables_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./jsvariables.js */ \"./core/src/jsvariables.js\");\n/* harmony import */ var _event_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./event.js */ \"./core/src/event.js\");\n/* harmony import */ var _listeners_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./listeners.js */ \"./core/src/listeners.js\");\n/* harmony import */ var _integrationmodel_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./integrationmodel.js */ \"./core/src/integrationmodel.js\");\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n/**\n * Class representing MathType integration Core. This class is the integration entry point. Manages integration\n * initialization (services, languages), events, and the insertion of the formulas in the edit area.\n */\n\nvar Core =\n/*#__PURE__*/\nfunction () {\n /**\n * Core class constructor. Admits a string containing the configurationjs service\n * which loads all JavaScript configuration generated in the backend. This file is needed\n * to instantiate the serviceProvider class (all services lives in the same path).\n */\n function Core() {\n _classCallCheck(this, Core);\n\n /**\n * Language. Needed for accessibility and locales. 'en' by default.\n * @type {string}\n */\n this.language = 'en';\n /**\n * Edit mode. Admit 'images' and 'latex' values.\n * @type {string}\n */\n\n this.editMode = 'images';\n /**\n * Modal dialog instance.\n * @type {ModalDialog}\n */\n\n this.modalDialog = null;\n /**\n * Core custom editors. By default only chemistry editor.\n * @type {CustomEditors}\n */\n\n this.customEditors = new _customeditors_js__WEBPACK_IMPORTED_MODULE_8__[\"default\"]();\n var chemEditorParams = {\n name: 'Chemistry',\n toolbar: 'chemistry',\n icon: 'chem.png',\n confVariable: 'chemEnabled',\n title: 'ChemType',\n tooltip: 'Insert a chemistry formula - ChemType' // TODO: Localize tooltip.\n\n };\n this.customEditors.addEditor('chemistry', chemEditorParams);\n /**\n * Environment properties. This object contains data about the integration platform.\n * @type {Object}\n * @property {string} editor - Editor name. Usually the HTML editor.\n * @property {string} mode - Save mode. Xml by default\n * @property {string} version - Plugin version.\n */\n\n this.environment = {};\n /**\n * Edit properties.\n * @type {Object}\n * @property {boolean} isNewElement - Indicates if the edit formula is a new one or not.\n * @property {Img} temporalImage - Image of the formula edited. Null if the formula is a new one.\n * @property {Range} latexRange - LaTeX formula range.\n * @property {Range} range - Image range.\n * @property {string} editMode - Edition mode. Images by default.\n */\n\n this.editionProperties = {\n isNewElement: true,\n temporalImage: null,\n latexRange: null,\n range: null\n /**\n * Integration model instance.\n * @type {IntegrationModel}\n */\n\n };\n this.integrationModel = null;\n /**\n * ContentManager instance.\n * @type {ContentManager}\n */\n\n this.contentManager = null;\n /**\n * Information about the current browser.\n * @type {string}\n */\n\n this.browser = function get_browser() {\n var ua = navigator.userAgent;\n\n if (ua.search(\"Edge/\") >= 0) {\n return \"EDGE\";\n } else if (ua.search(\"Chrome/\") >= 0) {\n return \"CHROME\";\n } else if (ua.search(\"Trident/\") >= 0) {\n return \"IE\";\n } else if (ua.search(\"Firefox/\") >= 0) {\n return \"FIREFOX\";\n } else if (ua.search(\"Safari/\") >= 0) {\n return \"SAFARI\";\n }\n }();\n /**\n * Plugin listeners.\n * @type {Object[]}\n */\n\n\n this.listeners = new _listeners_js__WEBPACK_IMPORTED_MODULE_12__[\"default\"]();\n }\n /**\n * Initializes the core.\n * @param {string} integrationPath - integration root folder path.\n */\n\n\n _createClass(Core, [{\n key: \"init\",\n value: function init(integrationPath) {\n this.load(integrationPath);\n }\n /**\n * Sets the instance of the integration model object.\n * @param {IntegrationModel} integrationModel - integrationModel instance.\n */\n\n }, {\n key: \"setIntegrationModel\",\n value: function setIntegrationModel(integrationModel) {\n this.integrationModel = integrationModel;\n }\n /**\n * This method set an object containing environment properties. The structure for the an\n * environment object is the following:\n * @param {Object} environmentObject - And object containing environment properties.\n * @param {string} environmentObject.editor - Integration editor (usually HTML editor).\n * @param {string} environmentObject.mode - Save mode.\n * @param {string} environmentObject.version - Integration version.\n */\n\n }, {\n key: \"setEnvironment\",\n value: function setEnvironment(environmentObject) {\n if ('editor' in environmentObject) {\n this.environment.editor = environmentObject.editor;\n }\n\n if ('mode' in environmentObject) {\n this.environment.mode = environmentObject.mode;\n }\n\n if ('version' in environmentObject) {\n this.environment.version = environmentObject.version;\n }\n }\n /**\n * Get modal dialog\n * @returns {ModalDialog} Modal Window core instance.\n */\n\n }, {\n key: \"getModalDialog\",\n value: function getModalDialog() {\n return this.modalDialog;\n }\n /**\n * This method inits the Core class doing the following:\n * - Calls (async) to configurationjs service, converting the response JSON into javascript variables.\n * - Updates Configuration class with the previous configuration properties.\n * - Updates the ServiceProvider class using configurationjs service path as reference.\n * - Load lang strings and CSS.\n * - Once the previous is ready fires 'onLoad' event.\n */\n\n }, {\n key: \"load\",\n value: function load(integrationPath) {\n var httpRequest = typeof XMLHttpRequest != 'undefined' ? new XMLHttpRequest() : new ActiveXObject('Microsoft.XMLHTTP');\n this.integrationPath = integrationPath.indexOf(\"/\") == 0 || integrationPath.indexOf(\"http\") == 0 ? integrationPath : _util_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].concatenateUrl(this.integrationModel.getPath(), integrationPath);\n httpRequest.open('GET', this.integrationPath, false); // Async request.\n\n httpRequest.onload = function (e) {\n var _this = this;\n\n if (httpRequest.readyState === 4) {\n // Loading configuration variables.\n var jsonConfiguration = JSON.parse(httpRequest.responseText);\n var variables = Object.keys(jsonConfiguration);\n _configuration_js__WEBPACK_IMPORTED_MODULE_9__[\"default\"].addConfiguration(jsonConfiguration); // Adding JavaScript (not backend) configuration variables.\n\n _configuration_js__WEBPACK_IMPORTED_MODULE_9__[\"default\"].addConfiguration(_jsvariables_js__WEBPACK_IMPORTED_MODULE_10__[\"default\"]); // Load service paths.\n\n this.loadServicePaths(); // Load lang file.\n\n this.loadLangFile();\n this.loadCSS(); // Fire 'onLoad' event. All integration must listen this event in order to know if the plugin has been properly loaded.\n // We need to wait until stringManager has been loaded.\n\n if (Core.stringManager === null) {\n var stringManagerListener = _listeners_js__WEBPACK_IMPORTED_MODULE_12__[\"default\"].newListener('onLoad', function () {\n _this.listeners.fire('onLoad', {});\n });\n Core.stringManager.addListener(stringManagerListener);\n } else {\n this.listeners.fire('onLoad', {});\n }\n }\n }.bind(this);\n\n httpRequest.send(null);\n }\n /**\n * Instantiate a new ServiceProvider path (static) and calculate all the backend services\n * paths using Core integrationPath as base path.\n */\n\n }, {\n key: \"loadServicePaths\",\n value: function loadServicePaths() {\n // Services path (tech dependant).\n var createImagePath = this.integrationPath.replace('configurationjs', 'createimage');\n var showImagePath = this.integrationPath.replace('configurationjs', 'showimage');\n var createImagePath = this.integrationPath.replace('configurationjs', 'createimage');\n var getMathMLPath = this.integrationPath.replace('configurationjs', 'getmathml');\n var servicePath = this.integrationPath.replace('configurationjs', 'service'); // Some backend integrations (like Java o Ruby) have an absolute backend path,\n // for example: /app/service. For them we calculate the absolute URL path, i.e\n // protocol://domain:port/app/service\n\n if (this.integrationPath.indexOf(\"/\") == 0) {\n var serverPath = this.getServerPath();\n showImagePath = serverPath + showImagePath;\n createImagePath = serverPath + createImagePath;\n getMathMLPath = serverPath + getMathMLPath;\n servicePath = serverPath + servicePath;\n }\n\n _serviceprovider_js__WEBPACK_IMPORTED_MODULE_4__[\"default\"].setServicePath('showimage', showImagePath);\n _serviceprovider_js__WEBPACK_IMPORTED_MODULE_4__[\"default\"].setServicePath('createimage', createImagePath);\n _serviceprovider_js__WEBPACK_IMPORTED_MODULE_4__[\"default\"].setServicePath('service', servicePath);\n _serviceprovider_js__WEBPACK_IMPORTED_MODULE_4__[\"default\"].setServicePath('getmathml', getMathMLPath);\n }\n /**\n * Returns the client side server path on integration script lives.\n * @return {string} client side server path.\n */\n\n }, {\n key: \"getServerPath\",\n value: function getServerPath() {\n var url = this.integrationModel.getPath();\n var hostNameIndex = url.indexOf(\"/\", url.indexOf(\"/\") + 2);\n return url.substr(0, hostNameIndex);\n }\n /**\n * Loads language file using integration script path as base path. Then\n * load the string into the core StringManager instance.\n */\n\n }, {\n key: \"loadLangFile\",\n value: function loadLangFile() {\n // Translated languages.\n var languages = 'ar,ca,cs,da,de,en,es,et,eu,fi,fr,gl,he,hr,hu,it,ja,ko,nl,no,pl,pt,pt_br,ru,sv,tr,zh,el';\n var langArray = languages.split(',');\n var lang = this.language;\n\n if (langArray.indexOf(lang) == -1) {\n lang = lang.substr(0, 2);\n }\n\n if (langArray.indexOf(lang) == -1) {\n lang = 'en';\n }\n\n var script = document.createElement('script');\n script.type = 'text/javascript';\n script.src = this.integrationModel.getPath() + '/' + this.integrationModel.langFolderName + '/' + lang + '/strings.js'; // When strings are loaded, it loads into stringManager\n\n script.onload = function () {\n Core.getStringManager().loadStrings(wrs_strings);\n };\n\n document.getElementsByTagName('head')[0].appendChild(script);\n }\n /**\n * Appends CSS file to header.\n */\n\n }, {\n key: \"loadCSS\",\n value: function loadCSS() {\n var fileRef = document.createElement(\"link\");\n fileRef.setAttribute(\"rel\", \"stylesheet\");\n fileRef.setAttribute(\"type\", \"text/css\");\n fileRef.setAttribute(\"href\", _util_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].concatenateUrl(this.integrationModel.getPath(), '/core/styles.css'));\n document.getElementsByTagName(\"head\")[0].appendChild(fileRef);\n }\n /**\n * Adds a listener to Listeners core property.\n * @param {Object} listener - listener to be added.\n */\n\n }, {\n key: \"addListener\",\n value: function addListener(listener) {\n this.listeners.add(listener);\n }\n /**\n * Adds a listener to global core listeners.\n * @param {Object} listener - listener to be added.\n * @static\n */\n\n }, {\n key: \"updateFormula\",\n\n /**\n * Transform a MathML into a image formula. Then the image formula is inserted in the specified target, creating\n * a new image (new formula) or updating an existing one.\n * @param {Object} focusElement - element to be focused\n * @param {Object} windowTarget - window where the editable content is\n * @param {string} mathml - Mathml code\n * @param {Object[]} wirisProperties - extra attributes for the formula (like background color or font size).\n */\n value: function updateFormula(focusElement, windowTarget, mathml, wirisProperties) {\n /**\n * This event is fired after update the formula.\n * @type {Object}\n * @property {string} mathml - MathML to be transformed.\n * @property {string} editMode - edit mode.\n * @property {Object} wirisProperties - extra attributes for the formula.\n * @property {string} language - formula language.\n */\n var beforeUpdateEvent = new _event_js__WEBPACK_IMPORTED_MODULE_11__[\"default\"]();\n beforeUpdateEvent.mathml = mathml; // Cloning wirisProperties object\n // We don't want wirisProperties object modified.\n\n beforeUpdateEvent.wirisProperties = {};\n\n for (var attr in wirisProperties) {\n beforeUpdateEvent.wirisProperties[attr] = wirisProperties[attr];\n } // Read only.\n\n\n beforeUpdateEvent.language = this.language;\n beforeUpdateEvent.editMode = this.editMode;\n\n if (this.listeners.fire('onBeforeFormulaInsertion', beforeUpdateEvent)) {\n return;\n }\n\n if (Core.globalListeners.fire('onBeforeFormulaInsertion', beforeUpdateEvent)) {\n return;\n }\n\n mathml = beforeUpdateEvent.mathml;\n wirisProperties = beforeUpdateEvent.wirisProperties;\n /**\n * This event is fired after update the formula.\n * @type {Object}\n * @param {string} editMode - edit mode.\n * @param {Object} windowTarget - target window.\n * @param {Object} focusElement - target element to be focused after update.\n * @param {string} latex - LaTeX generated by the formula (editMode=latex).\n * @param {Object} node - node generated after update the formula (text if LaTeX img otherwise).\n */\n\n var afterUpdateEvent = new _event_js__WEBPACK_IMPORTED_MODULE_11__[\"default\"]();\n afterUpdateEvent.editMode = this.editMode;\n afterUpdateEvent.windowTarget = windowTarget;\n afterUpdateEvent.focusElement = focusElement;\n\n if (mathml.length == 0) {\n this.insertElementOnSelection(null, focusElement, windowTarget);\n } else if (this.editMode == 'latex') {\n afterUpdateEvent.latex = _latex_js__WEBPACK_IMPORTED_MODULE_6__[\"default\"].getLatexFromMathML(mathml); // this.integrationModel.getNonLatexNode is an integration wrapper to have special behaviours for nonLatex.\n // Not all the integrations have special behaviours for nonLatex.\n\n if (!!this.integrationModel.fillNonLatexNode && typeof afterUpdateEvent.latex === 'undefined') {\n this.integrationModel.fillNonLatexNode(afterUpdateEvent, windowTarget, mathml);\n } else {\n afterUpdateEvent.node = windowTarget.document.createTextNode('$$' + afterUpdateEvent.latex + '$$');\n }\n\n this.insertElementOnSelection(afterUpdateEvent.node, focusElement, windowTarget);\n } else if (this.editMode == 'iframes') {\n var iframe = wrs_mathmlToIframeObject(windowTarget, mathml);\n this.insertElementOnSelection(iframe, focusElement, windowTarget);\n } else {\n afterUpdateEvent.node = _parser_js__WEBPACK_IMPORTED_MODULE_5__[\"default\"].mathmlToImgObject(windowTarget.document, mathml, wirisProperties, this.language);\n this.insertElementOnSelection(afterUpdateEvent.node, focusElement, windowTarget);\n }\n\n if (this.listeners.fire('onAfterFormulaInsertion', afterUpdateEvent)) {\n return;\n }\n\n if (Core.globalListeners.fire('onAfterFormulaInsertion', afterUpdateEvent)) {\n return;\n }\n }\n /**\n * Sets the caret after 'node' and focus node owner document.\n * @param {Object} node - node that it will be behind the caret after the execution.\n */\n\n }, {\n key: \"placeCaretAfterNode\",\n value: function placeCaretAfterNode(node) {\n this.integrationModel.getSelection();\n var nodeDocument = node.ownerDocument;\n\n if (typeof nodeDocument.getSelection !== 'undefined') {\n var range = nodeDocument.createRange();\n range.setStartAfter(node);\n range.collapse(true);\n var selection = nodeDocument.getSelection();\n selection.removeAllRanges();\n selection.addRange(range);\n nodeDocument.body.focus();\n }\n }\n /**\n * Replaces a selection with an element.\n * @param {Object} element - element to replace the selection.\n * @param {Object} focusElement - element to be focused after the replace.\n * @param {Object} windowTarget - target window.\n */\n\n }, {\n key: \"insertElementOnSelection\",\n value: function insertElementOnSelection(element, focusElement, windowTarget) {\n if (this.editionProperties.isNewElement) {\n if (focusElement.type == \"textarea\") {\n _util_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].updateTextArea(focusElement, element.textContent);\n } else if (document.selection && document.getSelection == 0) {\n var range = windowTarget.document.selection.createRange();\n windowTarget.document.execCommand('InsertImage', false, element.src);\n\n if (!('parentElement' in range)) {\n windowTarget.document.execCommand('delete', false);\n range = windowTarget.document.selection.createRange();\n windowTarget.document.execCommand('InsertImage', false, element.src);\n }\n\n if ('parentElement' in range) {\n var temporalObject = range.parentElement();\n\n if (temporalObject.nodeName.toUpperCase() == 'IMG') {\n temporalObject.parentNode.replaceChild(element, temporalObject);\n } else {\n // IE9 fix: parentNode() does not return the IMG node, returns the parent DIV node. In IE < 9, pasteHTML does not work well.\n range.pasteHTML(_util_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].createObjectCode(element));\n }\n }\n } else {\n var editorSelection = this.integrationModel.getSelection();\n\n var _range; // In IE is needed keep the range due to after focus the modal window it can't be retrieved the last selection.\n\n\n if (this.editionProperties.range) {\n _range = this.editionProperties.range;\n this.editionProperties.range = null;\n } else {\n _range = editorSelection.getRangeAt(0);\n } // Delete if something was surrounded.\n\n\n _range.deleteContents();\n\n var node = _range.startContainer;\n var position = _range.startOffset;\n\n if (node.nodeType == 3) {\n // TEXT_NODE.\n node = node.splitText(position);\n node.parentNode.insertBefore(element, node);\n } else if (node.nodeType == 1) {\n // ELEMENT_NODE.\n node.insertBefore(element, node.childNodes[position]);\n }\n\n this.placeCaretAfterNode(element);\n }\n } else if (this.editionProperties.latexRange) {\n if (document.selection && document.getSelection == 0) {\n this.editionProperties.isNewElement = true;\n this.editionProperties.latexRange.select();\n this.insertElementOnSelection(element, focusElement, windowTarget);\n } else {\n var parentNode = this.editionProperties.latexRange.startContainer;\n this.editionProperties.latexRange.deleteContents();\n this.editionProperties.latexRange.insertNode(element);\n this.placeCaretAfterNode(element);\n }\n } else if (focusElement.type == \"textarea\") {\n var item; // Wrapper for some integrations that can have special behaviours to show latex.\n\n if (typeof this.integrationModel.getSelectedItem !== 'undefined') {\n item = this.integrationModel.getSelectedItem(focusElement, false);\n } else {\n item = _util_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].getSelectedItemOnTextarea(focusElement);\n }\n\n _util_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].updateExistingTextOnTextarea(focusElement, element.textContent, item.startPosition, item.endPosition);\n } else {\n if (!element) {\n // Editor empty, formula has been erased on edit.\n this.editionProperties.temporalImage.parentNode.removeChild(this.editionProperties.temporalImage);\n }\n\n this.editionProperties.temporalImage.parentNode.replaceChild(element, this.editionProperties.temporalImage);\n this.placeCaretAfterNode(element);\n }\n }\n /**\n * Opens a new modal dialog.\n * @param {object} target - target element.\n * @param {boolean} isIframe - specifies if the target is an iframe.\n */\n\n }, {\n key: \"openModalDialog\",\n value: function openModalDialog(target, isIframe) {\n // Textarea elements don't have normal document ranges. It only accepts latex edit.\n this.editMode = 'images'; // In IE is needed keep the range due to after focus the modal window it can't be retrieved the last selection.\n\n try {\n if (isIframe) {\n // Is needed focus the target first.\n target.contentWindow.focus();\n var selection = target.contentWindow.getSelection();\n this.editionProperties.range = selection.getRangeAt(0);\n } else {\n // Is needed focus the target first.\n target.focus();\n\n var _selection = getSelection();\n\n this.editionProperties.range = _selection.getRangeAt(0);\n }\n } catch (e) {\n this.editionProperties.range = null;\n }\n\n if (isIframe === undefined) {\n isIframe = true;\n }\n\n this.editionProperties.latexRange = null;\n\n if (target) {\n var selectedItem;\n\n if (typeof this.integrationModel.getSelectedItem !== 'undefined') {\n selectedItem = this.integrationModel.getSelectedItem(target, isIframe);\n } else {\n selectedItem = _util_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].getSelectedItem(target, isIframe);\n } // Check LaTeX if and only if the node is a text node (nodeType==3).\n\n\n if (selectedItem) {\n // Case when image was selected and button pressed.\n if (!selectedItem.caretPosition && _util_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].containsClass(selectedItem.node, _configuration_js__WEBPACK_IMPORTED_MODULE_9__[\"default\"].get('imageClassName'))) {\n this.editionProperties.temporalImage = selectedItem.node;\n this.editionProperties.isNewElement = false;\n } else if (selectedItem.node.nodeType === 3) {\n // If it's a text node means that editor is working with LaTeX.\n if (!!this.integrationModel.getMathmlFromTextNode) {\n // If integration has this function it isn't set range due to we don't\n // know if it will be put into a textarea as a text or image.\n var mathml = this.integrationModel.getMathmlFromTextNode(selectedItem.node, selectedItem.caretPosition);\n\n if (mathml) {\n this.editMode = 'latex';\n this.editionProperties.isNewElement = false;\n this.editionProperties.temporalImage = document.createElement('img');\n this.editionProperties.temporalImage.setAttribute(_configuration_js__WEBPACK_IMPORTED_MODULE_9__[\"default\"].get('imageMathmlAttribute'), _mathml_js__WEBPACK_IMPORTED_MODULE_7__[\"default\"].safeXmlEncode(mathml));\n }\n } else {\n var latexResult = _latex_js__WEBPACK_IMPORTED_MODULE_6__[\"default\"].getLatexFromTextNode(selectedItem.node, selectedItem.caretPosition);\n\n if (latexResult) {\n var _mathml = _latex_js__WEBPACK_IMPORTED_MODULE_6__[\"default\"].getMathMLFromLatex(latexResult.latex);\n\n this.editMode = 'latex';\n this.editionProperties.isNewElement = false;\n this.editionProperties.temporalImage = document.createElement('img');\n this.editionProperties.temporalImage.setAttribute(_configuration_js__WEBPACK_IMPORTED_MODULE_9__[\"default\"].get('imageMathmlAttribute'), _mathml_js__WEBPACK_IMPORTED_MODULE_7__[\"default\"].safeXmlEncode(_mathml));\n var windowTarget = isIframe ? target.contentWindow : window;\n\n if (target.tagName.toLowerCase() !== 'textarea') {\n if (document.selection) {\n var leftOffset = 0;\n var previousNode = latexResult.startNode.previousSibling;\n\n while (previousNode) {\n leftOffset += _util_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].getNodeLength(previousNode);\n previousNode = previousNode.previousSibling;\n }\n\n this.editionProperties.latexRange = windowTarget.document.selection.createRange();\n this.editionProperties.latexRange.moveToElementText(latexResult.startNode.parentNode);\n this.editionProperties.latexRange.move('character', leftOffset + latexResult.startPosition);\n this.editionProperties.latexRange.moveEnd('character', latexResult.latex.length + 4); // Plus 4 for the '$$' characters.\n } else {\n this.editionProperties.latexRange = windowTarget.document.createRange();\n this.editionProperties.latexRange.setStart(latexResult.startNode, latexResult.startPosition);\n this.editionProperties.latexRange.setEnd(latexResult.endNode, latexResult.endPosition);\n }\n }\n }\n }\n }\n } else if (target.tagName.toLowerCase() === 'textarea') {\n // By default editMode is 'images', but when target is a textarea it needs to be 'latex'.\n this.editMode = 'latex';\n }\n } // Setting an object with the editor parameters.\n // Editor parameters can be customized in several ways:\n // 1 - editorAttributes: Contains the default editor attributes, usually the metrics in a comma separated string. Always exists.\n // 2 - editorParameters: Object containing custom editor parameters. These parameters are defined in the backend. So they affects\n // all integration instances.\n // The backend send the default editor attributes in a coma separated with the following structure:\n // key1=value1,key2=value2...\n\n\n var defaultEditorAttributesArray = _configuration_js__WEBPACK_IMPORTED_MODULE_9__[\"default\"].get('editorAttributes').split(\", \");\n var defaultEditorAttributes = {};\n\n for (var i = 0, len = defaultEditorAttributesArray.length; i < len; i++) {\n var tempAttribute = defaultEditorAttributesArray[i].split('=');\n var key = tempAttribute[0];\n var value = tempAttribute[1];\n defaultEditorAttributes[key] = value;\n } // Custom editor parameters.\n\n\n var editorAttributes = {};\n Object.assign(editorAttributes, defaultEditorAttributes, _configuration_js__WEBPACK_IMPORTED_MODULE_9__[\"default\"].get('editorParameters'));\n editorAttributes.language = this.language;\n editorAttributes.rtl = this.integrationModel.rtl;\n var contentManagerAttributes = {};\n contentManagerAttributes.editorAttributes = editorAttributes;\n contentManagerAttributes.language = this.language;\n contentManagerAttributes.customEditors = this.customEditors;\n contentManagerAttributes.environment = this.environment;\n\n if (this.modalDialog == null) {\n this.modalDialog = new _modal_js__WEBPACK_IMPORTED_MODULE_3__[\"default\"](editorAttributes);\n this.contentManager = new _contentmanager_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"](contentManagerAttributes); // When an instance of ContentManager is created we need to wait until the ContentManager is ready\n // by listening 'onLoad' event.\n\n var listener = _listeners_js__WEBPACK_IMPORTED_MODULE_12__[\"default\"].newListener('onLoad', function () {\n this.contentManager.isNewElement = this.editionProperties.isNewElement;\n\n if (this.editionProperties.temporalImage != null) {\n var mathML = _mathml_js__WEBPACK_IMPORTED_MODULE_7__[\"default\"].safeXmlDecode(this.editionProperties.temporalImage.getAttribute(_configuration_js__WEBPACK_IMPORTED_MODULE_9__[\"default\"].get('imageMathmlAttribute')));\n this.contentManager.mathML = mathML;\n }\n }.bind(this));\n this.contentManager.addListener(listener);\n this.contentManager.init();\n this.modalDialog.setContentManager(this.contentManager);\n this.contentManager.setModalDialogInstance(this.modalDialog);\n } else {\n this.contentManager.isNewElement = this.editionProperties.isNewElement;\n\n if (this.editionProperties.temporalImage != null) {\n var mathML = _mathml_js__WEBPACK_IMPORTED_MODULE_7__[\"default\"].safeXmlDecode(this.editionProperties.temporalImage.getAttribute(_configuration_js__WEBPACK_IMPORTED_MODULE_9__[\"default\"].get('imageMathmlAttribute')));\n this.contentManager.mathML = mathML;\n }\n }\n\n this.contentManager.setIntegrationModel(this.integrationModel);\n this.modalDialog.open();\n }\n /**\n * Returns the instance of the ServiceProvider class.\n * @returns {ServiceProvider} ServiceProvider instance.\n * @static\n */\n\n }, {\n key: \"getCustomEditors\",\n\n /**\n * Return an object with all instance custom editors.\n * @return {CustomEditors}\n */\n value: function getCustomEditors() {\n return this.customEditors;\n }\n }], [{\n key: \"addGlobalListener\",\n value: function addGlobalListener(listener) {\n Core.globalListeners.add(listener);\n }\n }, {\n key: \"getServiceProvider\",\n value: function getServiceProvider() {\n return Core.serviceProvider;\n }\n /**\n * Returns the instance of the StringManager class.\n * @returns {StringManager} StringManager instance\n */\n\n }, {\n key: \"getStringManager\",\n value: function getStringManager() {\n return Core.stringManager;\n }\n }]);\n\n return Core;\n}();\n/**\n * Plugin static listeners.\n * @type {Object[]}\n * @static\n */\n\n\n\nCore.globalListeners = new _listeners_js__WEBPACK_IMPORTED_MODULE_12__[\"default\"]();\n/**\n * Class to manage plugin locales.\n * @type {StringManager}\n * @static\n */\n\nCore.stringManager = new _stringmanager_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"]();\n\n//# sourceURL=webpack:///./core/src/core.src.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"default\", function() { return Core; });\n/* harmony import */ var _util_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./util.js */ \"./core/src/util.js\");\n/* harmony import */ var _stringmanager_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./stringmanager.js */ \"./core/src/stringmanager.js\");\n/* harmony import */ var _contentmanager_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./contentmanager.js */ \"./core/src/contentmanager.js\");\n/* harmony import */ var _modal_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./modal.js */ \"./core/src/modal.js\");\n/* harmony import */ var _serviceprovider_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./serviceprovider.js */ \"./core/src/serviceprovider.js\");\n/* harmony import */ var _parser_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./parser.js */ \"./core/src/parser.js\");\n/* harmony import */ var _latex_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./latex.js */ \"./core/src/latex.js\");\n/* harmony import */ var _mathml_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./mathml.js */ \"./core/src/mathml.js\");\n/* harmony import */ var _customeditors_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./customeditors.js */ \"./core/src/customeditors.js\");\n/* harmony import */ var _configuration_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./configuration.js */ \"./core/src/configuration.js\");\n/* harmony import */ var _jsvariables_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./jsvariables.js */ \"./core/src/jsvariables.js\");\n/* harmony import */ var _event_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./event.js */ \"./core/src/event.js\");\n/* harmony import */ var _listeners_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./listeners.js */ \"./core/src/listeners.js\");\n/* harmony import */ var _integrationmodel_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./integrationmodel.js */ \"./core/src/integrationmodel.js\");\n/* harmony import */ var _image_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./image.js */ \"./core/src/image.js\");\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n/**\n * Class representing MathType integration Core. This class is the integration entry point. Manages integration\n * initialization (services, languages), events, and the insertion of the formulas in the edit area.\n */\n\nvar Core =\n/*#__PURE__*/\nfunction () {\n /**\n * Core class constructor. Admits a string containing the configurationjs service\n * which loads all JavaScript configuration generated in the backend. This file is needed\n * to instantiate the serviceProvider class (all services lives in the same path).\n */\n function Core() {\n _classCallCheck(this, Core);\n\n /**\n * Language. Needed for accessibility and locales. 'en' by default.\n * @type {string}\n */\n this.language = 'en';\n /**\n * Edit mode. Admit 'images' and 'latex' values.\n * @type {string}\n */\n\n this.editMode = 'images';\n /**\n * Modal dialog instance.\n * @type {ModalDialog}\n */\n\n this.modalDialog = null;\n /**\n * Core custom editors. By default only chemistry editor.\n * @type {CustomEditors}\n */\n\n this.customEditors = new _customeditors_js__WEBPACK_IMPORTED_MODULE_8__[\"default\"]();\n var chemEditorParams = {\n name: 'Chemistry',\n toolbar: 'chemistry',\n icon: 'chem.png',\n confVariable: 'chemEnabled',\n title: 'ChemType',\n tooltip: 'Insert a chemistry formula - ChemType' // TODO: Localize tooltip.\n\n };\n this.customEditors.addEditor('chemistry', chemEditorParams);\n /**\n * Environment properties. This object contains data about the integration platform.\n * @type {Object}\n * @property {string} editor - Editor name. Usually the HTML editor.\n * @property {string} mode - Save mode. Xml by default\n * @property {string} version - Plugin version.\n */\n\n this.environment = {};\n /**\n * Edit properties.\n * @type {Object}\n * @property {boolean} isNewElement - Indicates if the edit formula is a new one or not.\n * @property {Img} temporalImage - Image of the formula edited. Null if the formula is a new one.\n * @property {Range} latexRange - LaTeX formula range.\n * @property {Range} range - Image range.\n * @property {string} editMode - Edition mode. Images by default.\n */\n\n this.editionProperties = {\n isNewElement: true,\n temporalImage: null,\n latexRange: null,\n range: null\n /**\n * Integration model instance.\n * @type {IntegrationModel}\n */\n\n };\n this.integrationModel = null;\n /**\n * ContentManager instance.\n * @type {ContentManager}\n */\n\n this.contentManager = null;\n /**\n * Information about the current browser.\n * @type {string}\n */\n\n this.browser = function get_browser() {\n var ua = navigator.userAgent;\n\n if (ua.search(\"Edge/\") >= 0) {\n return \"EDGE\";\n } else if (ua.search(\"Chrome/\") >= 0) {\n return \"CHROME\";\n } else if (ua.search(\"Trident/\") >= 0) {\n return \"IE\";\n } else if (ua.search(\"Firefox/\") >= 0) {\n return \"FIREFOX\";\n } else if (ua.search(\"Safari/\") >= 0) {\n return \"SAFARI\";\n }\n }();\n /**\n * Plugin listeners.\n * @type {Object[]}\n */\n\n\n this.listeners = new _listeners_js__WEBPACK_IMPORTED_MODULE_12__[\"default\"]();\n }\n /**\n * Initializes the core.\n * @param {string} integrationPath - integration root folder path.\n */\n\n\n _createClass(Core, [{\n key: \"init\",\n value: function init(integrationPath) {\n this.load(integrationPath);\n }\n /**\n * Sets the instance of the integration model object.\n * @param {IntegrationModel} integrationModel - integrationModel instance.\n */\n\n }, {\n key: \"setIntegrationModel\",\n value: function setIntegrationModel(integrationModel) {\n this.integrationModel = integrationModel;\n }\n /**\n * This method set an object containing environment properties. The structure for the an\n * environment object is the following:\n * @param {Object} environmentObject - And object containing environment properties.\n * @param {string} environmentObject.editor - Integration editor (usually HTML editor).\n * @param {string} environmentObject.mode - Save mode.\n * @param {string} environmentObject.version - Integration version.\n */\n\n }, {\n key: \"setEnvironment\",\n value: function setEnvironment(environmentObject) {\n if ('editor' in environmentObject) {\n this.environment.editor = environmentObject.editor;\n }\n\n if ('mode' in environmentObject) {\n this.environment.mode = environmentObject.mode;\n }\n\n if ('version' in environmentObject) {\n this.environment.version = environmentObject.version;\n }\n }\n /**\n * Get modal dialog\n * @returns {ModalDialog} Modal Window core instance.\n */\n\n }, {\n key: \"getModalDialog\",\n value: function getModalDialog() {\n return this.modalDialog;\n }\n /**\n * This method inits the Core class doing the following:\n * - Calls (async) to configurationjs service, converting the response JSON into javascript variables.\n * - Updates Configuration class with the previous configuration properties.\n * - Updates the ServiceProvider class using configurationjs service path as reference.\n * - Load lang strings and CSS.\n * - Once the previous is ready fires 'onLoad' event.\n */\n\n }, {\n key: \"load\",\n value: function load(integrationPath) {\n var httpRequest = typeof XMLHttpRequest != 'undefined' ? new XMLHttpRequest() : new ActiveXObject('Microsoft.XMLHTTP');\n this.integrationPath = integrationPath.indexOf(\"/\") == 0 || integrationPath.indexOf(\"http\") == 0 ? integrationPath : _util_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].concatenateUrl(this.integrationModel.getPath(), integrationPath);\n httpRequest.open('GET', this.integrationPath, false); // Async request.\n\n httpRequest.onload = function (e) {\n var _this = this;\n\n if (httpRequest.readyState === 4) {\n // Loading configuration variables.\n var jsonConfiguration = JSON.parse(httpRequest.responseText);\n var variables = Object.keys(jsonConfiguration);\n _configuration_js__WEBPACK_IMPORTED_MODULE_9__[\"default\"].addConfiguration(jsonConfiguration); // Adding JavaScript (not backend) configuration variables.\n\n _configuration_js__WEBPACK_IMPORTED_MODULE_9__[\"default\"].addConfiguration(_jsvariables_js__WEBPACK_IMPORTED_MODULE_10__[\"default\"]); // Load service paths.\n\n this.loadServicePaths(); // Load lang file.\n\n this.loadLangFile();\n this.loadCSS(); // Fire 'onLoad' event. All integration must listen this event in order to know if the plugin has been properly loaded.\n // We need to wait until stringManager has been loaded.\n\n if (Core.stringManager === null) {\n var stringManagerListener = _listeners_js__WEBPACK_IMPORTED_MODULE_12__[\"default\"].newListener('onLoad', function () {\n _this.listeners.fire('onLoad', {});\n });\n Core.stringManager.addListener(stringManagerListener);\n } else {\n this.listeners.fire('onLoad', {});\n }\n }\n }.bind(this);\n\n httpRequest.send(null);\n }\n /**\n * Instantiate a new ServiceProvider path (static) and calculate all the backend services\n * paths using Core integrationPath as base path.\n */\n\n }, {\n key: \"loadServicePaths\",\n value: function loadServicePaths() {\n // Services path (tech dependant).\n var createImagePath = this.integrationPath.replace('configurationjs', 'createimage');\n var showImagePath = this.integrationPath.replace('configurationjs', 'showimage');\n var createImagePath = this.integrationPath.replace('configurationjs', 'createimage');\n var getMathMLPath = this.integrationPath.replace('configurationjs', 'getmathml');\n var servicePath = this.integrationPath.replace('configurationjs', 'service'); // Some backend integrations (like Java o Ruby) have an absolute backend path,\n // for example: /app/service. For them we calculate the absolute URL path, i.e\n // protocol://domain:port/app/service\n\n if (this.integrationPath.indexOf(\"/\") == 0) {\n var serverPath = this.getServerPath();\n showImagePath = serverPath + showImagePath;\n createImagePath = serverPath + createImagePath;\n getMathMLPath = serverPath + getMathMLPath;\n servicePath = serverPath + servicePath;\n }\n\n _serviceprovider_js__WEBPACK_IMPORTED_MODULE_4__[\"default\"].setServicePath('showimage', showImagePath);\n _serviceprovider_js__WEBPACK_IMPORTED_MODULE_4__[\"default\"].setServicePath('createimage', createImagePath);\n _serviceprovider_js__WEBPACK_IMPORTED_MODULE_4__[\"default\"].setServicePath('service', servicePath);\n _serviceprovider_js__WEBPACK_IMPORTED_MODULE_4__[\"default\"].setServicePath('getmathml', getMathMLPath);\n }\n /**\n * Returns the client side server path on integration script lives.\n * @return {string} client side server path.\n */\n\n }, {\n key: \"getServerPath\",\n value: function getServerPath() {\n var url = this.integrationModel.getPath();\n var hostNameIndex = url.indexOf(\"/\", url.indexOf(\"/\") + 2);\n return url.substr(0, hostNameIndex);\n }\n /**\n * Loads language file using integration script path as base path. Then\n * load the string into the core StringManager instance.\n */\n\n }, {\n key: \"loadLangFile\",\n value: function loadLangFile() {\n // Translated languages.\n var languages = 'ar,ca,cs,da,de,en,es,et,eu,fi,fr,gl,he,hr,hu,it,ja,ko,nl,no,pl,pt,pt_br,ru,sv,tr,zh,el';\n var langArray = languages.split(',');\n var lang = this.language;\n\n if (langArray.indexOf(lang) == -1) {\n lang = lang.substr(0, 2);\n }\n\n if (langArray.indexOf(lang) == -1) {\n lang = 'en';\n }\n\n var script = document.createElement('script');\n script.type = 'text/javascript';\n script.src = this.integrationModel.getPath() + '/' + this.integrationModel.langFolderName + '/' + lang + '/strings.js'; // When strings are loaded, it loads into stringManager\n\n script.onload = function () {\n Core.getStringManager().loadStrings(wrs_strings);\n };\n\n document.getElementsByTagName('head')[0].appendChild(script);\n }\n /**\n * Appends CSS file to header.\n */\n\n }, {\n key: \"loadCSS\",\n value: function loadCSS() {\n var fileRef = document.createElement(\"link\");\n fileRef.setAttribute(\"rel\", \"stylesheet\");\n fileRef.setAttribute(\"type\", \"text/css\");\n fileRef.setAttribute(\"href\", _util_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].concatenateUrl(this.integrationModel.getPath(), '/core/styles.css'));\n document.getElementsByTagName(\"head\")[0].appendChild(fileRef);\n }\n /**\n * Adds a listener to Listeners core property.\n * @param {Object} listener - listener to be added.\n */\n\n }, {\n key: \"addListener\",\n value: function addListener(listener) {\n this.listeners.add(listener);\n }\n /**\n * Adds a listener to global core listeners.\n * @param {Object} listener - listener to be added.\n * @static\n */\n\n }, {\n key: \"updateFormula\",\n\n /**\n * Transform a MathML into a image formula. Then the image formula is inserted in the specified target, creating\n * a new image (new formula) or updating an existing one.\n * @param {Object} focusElement - element to be focused\n * @param {Object} windowTarget - window where the editable content is\n * @param {string} mathml - Mathml code\n * @param {Object[]} wirisProperties - extra attributes for the formula (like background color or font size).\n */\n value: function updateFormula(focusElement, windowTarget, mathml, wirisProperties) {\n /**\n * This event is fired after update the formula.\n * @type {Object}\n * @property {string} mathml - MathML to be transformed.\n * @property {string} editMode - edit mode.\n * @property {Object} wirisProperties - extra attributes for the formula.\n * @property {string} language - formula language.\n */\n var beforeUpdateEvent = new _event_js__WEBPACK_IMPORTED_MODULE_11__[\"default\"]();\n beforeUpdateEvent.mathml = mathml; // Cloning wirisProperties object\n // We don't want wirisProperties object modified.\n\n beforeUpdateEvent.wirisProperties = {};\n\n for (var attr in wirisProperties) {\n beforeUpdateEvent.wirisProperties[attr] = wirisProperties[attr];\n } // Read only.\n\n\n beforeUpdateEvent.language = this.language;\n beforeUpdateEvent.editMode = this.editMode;\n\n if (this.listeners.fire('onBeforeFormulaInsertion', beforeUpdateEvent)) {\n return;\n }\n\n if (Core.globalListeners.fire('onBeforeFormulaInsertion', beforeUpdateEvent)) {\n return;\n }\n\n mathml = beforeUpdateEvent.mathml;\n wirisProperties = beforeUpdateEvent.wirisProperties;\n /**\n * This event is fired after update the formula.\n * @type {Object}\n * @param {string} editMode - edit mode.\n * @param {Object} windowTarget - target window.\n * @param {Object} focusElement - target element to be focused after update.\n * @param {string} latex - LaTeX generated by the formula (editMode=latex).\n * @param {Object} node - node generated after update the formula (text if LaTeX img otherwise).\n */\n\n var afterUpdateEvent = new _event_js__WEBPACK_IMPORTED_MODULE_11__[\"default\"]();\n afterUpdateEvent.editMode = this.editMode;\n afterUpdateEvent.windowTarget = windowTarget;\n afterUpdateEvent.focusElement = focusElement;\n\n if (!mathml) {\n this.insertElementOnSelection(null, focusElement, windowTarget);\n } else if (this.editMode == 'latex') {\n afterUpdateEvent.latex = _latex_js__WEBPACK_IMPORTED_MODULE_6__[\"default\"].getLatexFromMathML(mathml); // this.integrationModel.getNonLatexNode is an integration wrapper to have special behaviours for nonLatex.\n // Not all the integrations have special behaviours for nonLatex.\n\n if (!!this.integrationModel.fillNonLatexNode && !afterUpdateEvent.latex) {\n this.integrationModel.fillNonLatexNode(afterUpdateEvent, windowTarget, mathml);\n } else {\n afterUpdateEvent.node = windowTarget.document.createTextNode('$$' + afterUpdateEvent.latex + '$$');\n }\n\n this.insertElementOnSelection(afterUpdateEvent.node, focusElement, windowTarget);\n } else if (this.editMode == 'iframes') {\n var iframe = wrs_mathmlToIframeObject(windowTarget, mathml);\n this.insertElementOnSelection(iframe, focusElement, windowTarget);\n } else {\n afterUpdateEvent.node = _parser_js__WEBPACK_IMPORTED_MODULE_5__[\"default\"].mathmlToImgObject(windowTarget.document, mathml, wirisProperties, this.language);\n this.insertElementOnSelection(afterUpdateEvent.node, focusElement, windowTarget);\n }\n\n if (this.listeners.fire('onAfterFormulaInsertion', afterUpdateEvent)) {\n return;\n }\n\n if (Core.globalListeners.fire('onAfterFormulaInsertion', afterUpdateEvent)) {\n return;\n }\n }\n /**\n * Sets the caret after 'node' and focus node owner document.\n * @param {Object} node - node that it will be behind the caret after the execution.\n */\n\n }, {\n key: \"placeCaretAfterNode\",\n value: function placeCaretAfterNode(node) {\n this.integrationModel.getSelection();\n var nodeDocument = node.ownerDocument;\n\n if (typeof nodeDocument.getSelection !== 'undefined' && !!node.parentElement) {\n var range = nodeDocument.createRange();\n range.setStartAfter(node);\n range.collapse(true);\n var selection = nodeDocument.getSelection();\n selection.removeAllRanges();\n selection.addRange(range);\n nodeDocument.body.focus();\n }\n }\n /**\n * Replaces a selection with an element.\n * @param {Object} element - element to replace the selection.\n * @param {Object} focusElement - element to be focused after the replace.\n * @param {Object} windowTarget - target window.\n */\n\n }, {\n key: \"insertElementOnSelection\",\n value: function insertElementOnSelection(element, focusElement, windowTarget) {\n if (this.editionProperties.isNewElement) {\n if (element) {\n if (focusElement.type == 'textarea') {\n _util_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].updateTextArea(focusElement, element.textContent);\n } else if (document.selection && document.getSelection == 0) {\n var range = windowTarget.document.selection.createRange();\n windowTarget.document.execCommand('InsertImage', false, element.src);\n\n if (!('parentElement' in range)) {\n windowTarget.document.execCommand('delete', false);\n range = windowTarget.document.selection.createRange();\n windowTarget.document.execCommand('InsertImage', false, element.src);\n }\n\n if ('parentElement' in range) {\n var temporalObject = range.parentElement();\n\n if (temporalObject.nodeName.toUpperCase() == 'IMG') {\n temporalObject.parentNode.replaceChild(element, temporalObject);\n } else {\n // IE9 fix: parentNode() does not return the IMG node, returns the parent DIV node. In IE < 9, pasteHTML does not work well.\n range.pasteHTML(_util_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].createObjectCode(element));\n }\n }\n } else {\n var editorSelection = this.integrationModel.getSelection();\n\n var _range; // In IE is needed keep the range due to after focus the modal window it can't be retrieved the last selection.\n\n\n if (this.editionProperties.range) {\n _range = this.editionProperties.range;\n this.editionProperties.range = null;\n } else {\n _range = editorSelection.getRangeAt(0);\n } // Delete if something was surrounded.\n\n\n _range.deleteContents();\n\n var node = _range.startContainer;\n var position = _range.startOffset;\n\n if (node.nodeType == 3) {\n // TEXT_NODE.\n node = node.splitText(position);\n node.parentNode.insertBefore(element, node);\n } else if (node.nodeType == 1) {\n // ELEMENT_NODE.\n node.insertBefore(element, node.childNodes[position]);\n }\n\n this.placeCaretAfterNode(element);\n }\n } else if (focusElement.type == 'textarea') {\n focusElement.focus();\n } else {\n var _editorSelection = this.integrationModel.getSelection();\n\n _editorSelection.removeAllRanges();\n\n if (this.editionProperties.range) {\n var _range2 = this.editionProperties.range;\n this.editionProperties.range = null;\n\n _editorSelection.addRange(_range2);\n }\n }\n } else if (this.editionProperties.latexRange) {\n if (document.selection && document.getSelection == 0) {\n this.editionProperties.isNewElement = true;\n this.editionProperties.latexRange.select();\n this.insertElementOnSelection(element, focusElement, windowTarget);\n } else {\n this.editionProperties.latexRange.deleteContents();\n this.editionProperties.latexRange.insertNode(element);\n this.placeCaretAfterNode(element);\n }\n } else if (focusElement.type == \"textarea\") {\n var item; // Wrapper for some integrations that can have special behaviours to show latex.\n\n if (typeof this.integrationModel.getSelectedItem !== 'undefined') {\n item = this.integrationModel.getSelectedItem(focusElement, false);\n } else {\n item = _util_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].getSelectedItemOnTextarea(focusElement);\n }\n\n _util_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].updateExistingTextOnTextarea(focusElement, element.textContent, item.startPosition, item.endPosition);\n } else {\n if (element && element.nodeName.toLowerCase() === 'img') {\n // Editor empty, formula has been erased on edit.\n // Clone is needed to maintain event references to temporalImage.\n _image_js__WEBPACK_IMPORTED_MODULE_14__[\"default\"].clone(element, this.editionProperties.temporalImage);\n } else {\n this.editionProperties.temporalImage.remove();\n }\n\n this.placeCaretAfterNode(this.editionProperties.temporalImage);\n }\n }\n /**\n * Opens a new modal dialog.\n * @param {object} target - target element.\n * @param {boolean} isIframe - specifies if the target is an iframe.\n */\n\n }, {\n key: \"openModalDialog\",\n value: function openModalDialog(target, isIframe) {\n // Textarea elements don't have normal document ranges. It only accepts latex edit.\n this.editMode = 'images'; // In IE is needed keep the range due to after focus the modal window it can't be retrieved the last selection.\n\n try {\n if (isIframe) {\n // Is needed focus the target first.\n target.contentWindow.focus();\n var selection = target.contentWindow.getSelection();\n this.editionProperties.range = selection.getRangeAt(0);\n } else {\n // Is needed focus the target first.\n target.focus();\n\n var _selection = getSelection();\n\n this.editionProperties.range = _selection.getRangeAt(0);\n }\n } catch (e) {\n this.editionProperties.range = null;\n }\n\n if (isIframe === undefined) {\n isIframe = true;\n }\n\n this.editionProperties.latexRange = null;\n\n if (target) {\n var selectedItem;\n\n if (typeof this.integrationModel.getSelectedItem !== 'undefined') {\n selectedItem = this.integrationModel.getSelectedItem(target, isIframe);\n } else {\n selectedItem = _util_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].getSelectedItem(target, isIframe);\n } // Check LaTeX if and only if the node is a text node (nodeType==3).\n\n\n if (selectedItem) {\n // Case when image was selected and button pressed.\n if (!selectedItem.caretPosition && _util_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].containsClass(selectedItem.node, _configuration_js__WEBPACK_IMPORTED_MODULE_9__[\"default\"].get('imageClassName'))) {\n this.editionProperties.temporalImage = selectedItem.node;\n this.editionProperties.isNewElement = false;\n } else if (selectedItem.node.nodeType === 3) {\n // If it's a text node means that editor is working with LaTeX.\n if (!!this.integrationModel.getMathmlFromTextNode) {\n // If integration has this function it isn't set range due to we don't\n // know if it will be put into a textarea as a text or image.\n var mathml = this.integrationModel.getMathmlFromTextNode(selectedItem.node, selectedItem.caretPosition);\n\n if (mathml) {\n this.editMode = 'latex';\n this.editionProperties.isNewElement = false;\n this.editionProperties.temporalImage = document.createElement('img');\n this.editionProperties.temporalImage.setAttribute(_configuration_js__WEBPACK_IMPORTED_MODULE_9__[\"default\"].get('imageMathmlAttribute'), _mathml_js__WEBPACK_IMPORTED_MODULE_7__[\"default\"].safeXmlEncode(mathml));\n }\n } else {\n var latexResult = _latex_js__WEBPACK_IMPORTED_MODULE_6__[\"default\"].getLatexFromTextNode(selectedItem.node, selectedItem.caretPosition);\n\n if (latexResult) {\n var _mathml = _latex_js__WEBPACK_IMPORTED_MODULE_6__[\"default\"].getMathMLFromLatex(latexResult.latex);\n\n this.editMode = 'latex';\n this.editionProperties.isNewElement = false;\n this.editionProperties.temporalImage = document.createElement('img');\n this.editionProperties.temporalImage.setAttribute(_configuration_js__WEBPACK_IMPORTED_MODULE_9__[\"default\"].get('imageMathmlAttribute'), _mathml_js__WEBPACK_IMPORTED_MODULE_7__[\"default\"].safeXmlEncode(_mathml));\n var windowTarget = isIframe ? target.contentWindow : window;\n\n if (target.tagName.toLowerCase() !== 'textarea') {\n if (document.selection) {\n var leftOffset = 0;\n var previousNode = latexResult.startNode.previousSibling;\n\n while (previousNode) {\n leftOffset += _util_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].getNodeLength(previousNode);\n previousNode = previousNode.previousSibling;\n }\n\n this.editionProperties.latexRange = windowTarget.document.selection.createRange();\n this.editionProperties.latexRange.moveToElementText(latexResult.startNode.parentNode);\n this.editionProperties.latexRange.move('character', leftOffset + latexResult.startPosition);\n this.editionProperties.latexRange.moveEnd('character', latexResult.latex.length + 4); // Plus 4 for the '$$' characters.\n } else {\n this.editionProperties.latexRange = windowTarget.document.createRange();\n this.editionProperties.latexRange.setStart(latexResult.startNode, latexResult.startPosition);\n this.editionProperties.latexRange.setEnd(latexResult.endNode, latexResult.endPosition);\n }\n }\n }\n }\n }\n } else if (target.tagName.toLowerCase() === 'textarea') {\n // By default editMode is 'images', but when target is a textarea it needs to be 'latex'.\n this.editMode = 'latex';\n }\n } // Setting an object with the editor parameters.\n // Editor parameters can be customized in several ways:\n // 1 - editorAttributes: Contains the default editor attributes, usually the metrics in a comma separated string. Always exists.\n // 2 - editorParameters: Object containing custom editor parameters. These parameters are defined in the backend. So they affects\n // all integration instances.\n // The backend send the default editor attributes in a coma separated with the following structure:\n // key1=value1,key2=value2...\n\n\n var defaultEditorAttributesArray = _configuration_js__WEBPACK_IMPORTED_MODULE_9__[\"default\"].get('editorAttributes').split(\", \");\n var defaultEditorAttributes = {};\n\n for (var i = 0, len = defaultEditorAttributesArray.length; i < len; i++) {\n var tempAttribute = defaultEditorAttributesArray[i].split('=');\n var key = tempAttribute[0];\n var value = tempAttribute[1];\n defaultEditorAttributes[key] = value;\n } // Custom editor parameters.\n\n\n var editorAttributes = {};\n Object.assign(editorAttributes, defaultEditorAttributes, _configuration_js__WEBPACK_IMPORTED_MODULE_9__[\"default\"].get('editorParameters'));\n editorAttributes.language = this.language;\n editorAttributes.rtl = this.integrationModel.rtl;\n var contentManagerAttributes = {};\n contentManagerAttributes.editorAttributes = editorAttributes;\n contentManagerAttributes.language = this.language;\n contentManagerAttributes.customEditors = this.customEditors;\n contentManagerAttributes.environment = this.environment;\n\n if (this.modalDialog == null) {\n this.modalDialog = new _modal_js__WEBPACK_IMPORTED_MODULE_3__[\"default\"](editorAttributes);\n this.contentManager = new _contentmanager_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"](contentManagerAttributes); // When an instance of ContentManager is created we need to wait until the ContentManager is ready\n // by listening 'onLoad' event.\n\n var listener = _listeners_js__WEBPACK_IMPORTED_MODULE_12__[\"default\"].newListener('onLoad', function () {\n this.contentManager.isNewElement = this.editionProperties.isNewElement;\n\n if (this.editionProperties.temporalImage != null) {\n var mathML = _mathml_js__WEBPACK_IMPORTED_MODULE_7__[\"default\"].safeXmlDecode(this.editionProperties.temporalImage.getAttribute(_configuration_js__WEBPACK_IMPORTED_MODULE_9__[\"default\"].get('imageMathmlAttribute')));\n this.contentManager.mathML = mathML;\n }\n }.bind(this));\n this.contentManager.addListener(listener);\n this.contentManager.init();\n this.modalDialog.setContentManager(this.contentManager);\n this.contentManager.setModalDialogInstance(this.modalDialog);\n } else {\n this.contentManager.isNewElement = this.editionProperties.isNewElement;\n\n if (this.editionProperties.temporalImage != null) {\n var mathML = _mathml_js__WEBPACK_IMPORTED_MODULE_7__[\"default\"].safeXmlDecode(this.editionProperties.temporalImage.getAttribute(_configuration_js__WEBPACK_IMPORTED_MODULE_9__[\"default\"].get('imageMathmlAttribute')));\n this.contentManager.mathML = mathML;\n }\n }\n\n this.contentManager.setIntegrationModel(this.integrationModel);\n this.modalDialog.open();\n }\n /**\n * Returns the instance of the ServiceProvider class.\n * @returns {ServiceProvider} ServiceProvider instance.\n * @static\n */\n\n }, {\n key: \"getCustomEditors\",\n\n /**\n * Return an object with all instance custom editors.\n * @return {CustomEditors}\n */\n value: function getCustomEditors() {\n return this.customEditors;\n }\n }], [{\n key: \"addGlobalListener\",\n value: function addGlobalListener(listener) {\n Core.globalListeners.add(listener);\n }\n }, {\n key: \"getServiceProvider\",\n value: function getServiceProvider() {\n return Core.serviceProvider;\n }\n /**\n * Returns the instance of the StringManager class.\n * @returns {StringManager} StringManager instance\n */\n\n }, {\n key: \"getStringManager\",\n value: function getStringManager() {\n return Core.stringManager;\n }\n }]);\n\n return Core;\n}();\n/**\n * Plugin static listeners.\n * @type {Object[]}\n * @static\n */\n\n\n\nCore.globalListeners = new _listeners_js__WEBPACK_IMPORTED_MODULE_12__[\"default\"]();\n/**\n * Class to manage plugin locales.\n * @type {StringManager}\n * @static\n */\n\nCore.stringManager = new _stringmanager_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"]();\n\n//# sourceURL=webpack:///./core/src/core.src.js?"); /***/ }), @@ -214,7 +214,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) * /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"default\", function() { return Image; });\n/* harmony import */ var _configuration_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./configuration.js */ \"./core/src/configuration.js\");\n/* harmony import */ var _util_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./util.js */ \"./core/src/util.js\");\nfunction _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\n\n\n/**\r\n * This class contains all the logic related to image manipulation.\r\n */\n\nvar Image =\n/*#__PURE__*/\nfunction () {\n function Image() {\n _classCallCheck(this, Image);\n }\n\n _createClass(Image, null, [{\n key: \"setImgSize\",\n\n /**\r\n * Calculates the metrics of an img dom object given the response URI.\r\n * @param {Object} img - DOM image object.\r\n * @param {string} uri - URI generated by the image service: can be a data URI scheme or a URL.\r\n * @param {boolean} jsonResponse - indicates if the response of the image service is a JSON object.\r\n */\n value: function setImgSize(img, uri, jsonResponse) {\n if (jsonResponse) {\n // Cleaning data:image/png;base64.\n if (_configuration_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get('imageFormat') == 'svg') {\n // SVG format.\n // If SVG is encoded in base64 we need to convert the base64 bytes into a SVG string.\n if (_configuration_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get('saveMode') != 'base64') {\n var ar = Image.getMetricsFromSvgString(uri);\n } else {\n var base64String = img.src.substr(img.src.indexOf('base64,') + 7, img.src.length);\n var svgString = '';\n var bytes = _util_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].b64ToByteArray(base64String, base64String.length);\n\n for (var i = 0; i < bytes.length; i++) {\n svgString += String.fromCharCode(bytes[i]);\n }\n\n var ar = Image.getMetricsFromSvgString(svgString);\n } // PNG format: we store all metrics information in the first 88 bytes.\n\n } else {\n var base64String = img.src.substr(img.src.indexOf('base64,') + 7, img.src.length);\n var bytes = _util_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].b64ToByteArray(base64String, 88);\n var ar = Image.getMetricsFromBytes(bytes);\n } // Backwards compatibility: we store the metrics into createimage response.\n\n } else {\n var ar = _util_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].urlToAssArray(uri);\n }\n\n var width = ar['cw'];\n\n if (!width) {\n return;\n }\n\n var height = ar['ch'];\n var baseline = ar['cb'];\n var dpi = ar['dpi'];\n\n if (dpi) {\n width = width * 96 / dpi;\n height = height * 96 / dpi;\n baseline = baseline * 96 / dpi;\n }\n\n img.width = width;\n img.height = height;\n img.style.verticalAlign = \"-\" + (height - baseline) + \"px\";\n }\n /**\r\n * Re-calculates the metrics of a image which has been resized.\r\n * @param {Object} img - DOM image object.\r\n */\n\n }, {\n key: \"fixAfterResize\",\n value: function fixAfterResize(img) {\n img.removeAttribute('style');\n img.removeAttribute('width');\n img.removeAttribute('height'); // In order to avoid resize with max-width css property.\n\n img.style.maxWidth = 'none';\n\n if (img.src.indexOf(\"data:image\") != -1) {\n if (_configuration_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get('imageFormat') == 'svg') {\n // ...data:image/svg+xml;charset=utf8, = 32.\n var svg = decodeURIComponent(img.src.substring(32, img.src.length));\n Image.setImgSize(img, svg, true);\n } else {\n // ...data:image/png;base64, == 22.\n var base64 = img.src.substring(22, img.src.length);\n Image.setImgSize(img, base64, true);\n }\n } else {\n Image.setImgSize(img, img.src);\n }\n }\n /**\r\n * Returns the metrics (height, width and baseline) contained in SVG image generated\r\n * by the MathType image service. This image contains as an extra attribute the image baseline (wrs:baseline).\r\n * @param {string} svgString - a string containing an svg image.\r\n * @return {Object[]} - Array object containing the image metrics.\r\n */\n\n }, {\n key: \"getMetricsFromSvgString\",\n value: function getMetricsFromSvgString(svgString) {\n var first = svgString.indexOf('height=\"');\n var last = svgString.indexOf('\"', first + 8, svgString.length);\n var height = svgString.substring(first + 8, last);\n first = svgString.indexOf('width=\"');\n last = svgString.indexOf('\"', first + 7, svgString.length);\n var width = svgString.substring(first + 7, last);\n first = svgString.indexOf('wrs:baseline=\"');\n last = svgString.indexOf('\"', first + 14, svgString.length);\n var baseline = svgString.substring(first + 14, last);\n\n if (_typeof(width != 'undefined')) {\n var arr = new Array();\n arr['cw'] = width;\n arr['ch'] = height;\n\n if (typeof baseline != 'undefined') {\n arr['cb'] = baseline;\n }\n\n return arr;\n }\n }\n /**\r\n * Get metrics (width, height, baseline and dpi) from a png byte array.\r\n * @param {Object[]} bytes - png byte array.\r\n * @return {Object[]} a array containing the png metrics.\r\n * @static\r\n */\n\n }, {\n key: \"getMetricsFromBytes\",\n value: function getMetricsFromBytes(bytes) {\n _util_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].readBytes(bytes, 0, 8);\n var alloc = 10;\n var i = 0;\n\n while (bytes.length >= 4) {\n var len = _util_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].readInt32(bytes);\n var typ = _util_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].readInt32(bytes);\n\n if (typ == 0x49484452) {\n var width = _util_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].readInt32(bytes);\n var height = _util_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].readInt32(bytes); // Read 5 bytes.\n\n _util_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].readInt32(bytes);\n _util_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].readByte(bytes);\n } else if (typ == 0x62615345) {\n // Baseline: 'baSE'.\n var baseline = _util_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].readInt32(bytes);\n } else if (typ == 0x70485973) {\n // Dpis: 'pHYs'.\n var dpi = _util_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].readInt32(bytes);\n dpi = Math.round(dpi / 39.37);\n _util_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].readInt32(bytes);\n _util_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].readByte(bytes);\n }\n\n _util_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].readInt32(bytes);\n }\n\n if (typeof width != 'undefined') {\n var arr = new Array();\n arr['cw'] = width;\n arr['ch'] = height;\n arr['dpi'] = dpi;\n\n if (baseline) {\n arr['cb'] = baseline;\n }\n\n return arr;\n }\n }\n }]);\n\n return Image;\n}();\n\n\n\n//# sourceURL=webpack:///./core/src/image.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"default\", function() { return Image; });\n/* harmony import */ var _configuration_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./configuration.js */ \"./core/src/configuration.js\");\n/* harmony import */ var _util_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./util.js */ \"./core/src/util.js\");\nfunction _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\n\n\n/**\r\n * This class contains all the logic related to image manipulation.\r\n */\n\nvar Image =\n/*#__PURE__*/\nfunction () {\n function Image() {\n _classCallCheck(this, Image);\n }\n\n _createClass(Image, null, [{\n key: \"clone\",\n\n /**\r\n * Clone Wirisformula attributes from 'originImg' to 'destImg'.\r\n * @param {HTMLImageElement} originImg - formula to copy to 'destImg'. Is a Wirisformula.\r\n * @param {HTMLImageElement} destImg - formula where 'destImg' copies. Is a Wirisformula.\r\n */\n value: function clone(originImg, destImg) {\n var customEditorAttributeName = 'data-custom-editor';\n\n if (!originImg.hasAttribute(customEditorAttributeName)) {\n destImg.removeAttribute(customEditorAttributeName);\n }\n\n var mathmlAttributeName = _configuration_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get('imageMathmlAttribute');\n var imgAttributes = [mathmlAttributeName, customEditorAttributeName, 'alt', 'height', 'width', 'style', 'src', 'role'];\n\n for (var _i = 0; _i < imgAttributes.length; _i++) {\n var iterator = imgAttributes[_i];\n var originAttribute = originImg.getAttribute(iterator);\n\n if (originAttribute) {\n destImg.setAttribute(iterator, originAttribute);\n }\n }\n }\n /**\r\n * Calculates the metrics of an img dom object given the response URI.\r\n * @param {Object} img - DOM image object.\r\n * @param {string} uri - URI generated by the image service: can be a data URI scheme or a URL.\r\n * @param {boolean} jsonResponse - indicates if the response of the image service is a JSON object.\r\n */\n\n }, {\n key: \"setImgSize\",\n value: function setImgSize(img, uri, jsonResponse) {\n if (jsonResponse) {\n // Cleaning data:image/png;base64.\n if (_configuration_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get('imageFormat') == 'svg') {\n // SVG format.\n // If SVG is encoded in base64 we need to convert the base64 bytes into a SVG string.\n if (_configuration_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get('saveMode') != 'base64') {\n var ar = Image.getMetricsFromSvgString(uri);\n } else {\n var base64String = img.src.substr(img.src.indexOf('base64,') + 7, img.src.length);\n var svgString = '';\n var bytes = _util_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].b64ToByteArray(base64String, base64String.length);\n\n for (var i = 0; i < bytes.length; i++) {\n svgString += String.fromCharCode(bytes[i]);\n }\n\n var ar = Image.getMetricsFromSvgString(svgString);\n } // PNG format: we store all metrics information in the first 88 bytes.\n\n } else {\n var base64String = img.src.substr(img.src.indexOf('base64,') + 7, img.src.length);\n var bytes = _util_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].b64ToByteArray(base64String, 88);\n var ar = Image.getMetricsFromBytes(bytes);\n } // Backwards compatibility: we store the metrics into createimage response.\n\n } else {\n var ar = _util_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].urlToAssArray(uri);\n }\n\n var width = ar['cw'];\n\n if (!width) {\n return;\n }\n\n var height = ar['ch'];\n var baseline = ar['cb'];\n var dpi = ar['dpi'];\n\n if (dpi) {\n width = width * 96 / dpi;\n height = height * 96 / dpi;\n baseline = baseline * 96 / dpi;\n }\n\n img.width = width;\n img.height = height;\n img.style.verticalAlign = \"-\" + (height - baseline) + \"px\";\n }\n /**\r\n * Re-calculates the metrics of a image which has been resized.\r\n * @param {Object} img - DOM image object.\r\n */\n\n }, {\n key: \"fixAfterResize\",\n value: function fixAfterResize(img) {\n img.removeAttribute('style');\n img.removeAttribute('width');\n img.removeAttribute('height'); // In order to avoid resize with max-width css property.\n\n img.style.maxWidth = 'none';\n\n if (img.src.indexOf(\"data:image\") != -1) {\n if (_configuration_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get('imageFormat') == 'svg') {\n // ...data:image/svg+xml;charset=utf8, = 32.\n var svg = decodeURIComponent(img.src.substring(32, img.src.length));\n Image.setImgSize(img, svg, true);\n } else {\n // ...data:image/png;base64, == 22.\n var base64 = img.src.substring(22, img.src.length);\n Image.setImgSize(img, base64, true);\n }\n } else {\n Image.setImgSize(img, img.src);\n }\n }\n /**\r\n * Returns the metrics (height, width and baseline) contained in SVG image generated\r\n * by the MathType image service. This image contains as an extra attribute the image baseline (wrs:baseline).\r\n * @param {string} svgString - a string containing an svg image.\r\n * @return {Object[]} - Array object containing the image metrics.\r\n */\n\n }, {\n key: \"getMetricsFromSvgString\",\n value: function getMetricsFromSvgString(svgString) {\n var first = svgString.indexOf('height=\"');\n var last = svgString.indexOf('\"', first + 8, svgString.length);\n var height = svgString.substring(first + 8, last);\n first = svgString.indexOf('width=\"');\n last = svgString.indexOf('\"', first + 7, svgString.length);\n var width = svgString.substring(first + 7, last);\n first = svgString.indexOf('wrs:baseline=\"');\n last = svgString.indexOf('\"', first + 14, svgString.length);\n var baseline = svgString.substring(first + 14, last);\n\n if (_typeof(width != 'undefined')) {\n var arr = new Array();\n arr['cw'] = width;\n arr['ch'] = height;\n\n if (typeof baseline != 'undefined') {\n arr['cb'] = baseline;\n }\n\n return arr;\n }\n }\n /**\r\n * Get metrics (width, height, baseline and dpi) from a png byte array.\r\n * @param {Object[]} bytes - png byte array.\r\n * @return {Object[]} a array containing the png metrics.\r\n * @static\r\n */\n\n }, {\n key: \"getMetricsFromBytes\",\n value: function getMetricsFromBytes(bytes) {\n _util_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].readBytes(bytes, 0, 8);\n var alloc = 10;\n var i = 0;\n\n while (bytes.length >= 4) {\n var len = _util_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].readInt32(bytes);\n var typ = _util_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].readInt32(bytes);\n\n if (typ == 0x49484452) {\n var width = _util_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].readInt32(bytes);\n var height = _util_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].readInt32(bytes); // Read 5 bytes.\n\n _util_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].readInt32(bytes);\n _util_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].readByte(bytes);\n } else if (typ == 0x62615345) {\n // Baseline: 'baSE'.\n var baseline = _util_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].readInt32(bytes);\n } else if (typ == 0x70485973) {\n // Dpis: 'pHYs'.\n var dpi = _util_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].readInt32(bytes);\n dpi = Math.round(dpi / 39.37);\n _util_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].readInt32(bytes);\n _util_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].readByte(bytes);\n }\n\n _util_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].readInt32(bytes);\n }\n\n if (typeof width != 'undefined') {\n var arr = new Array();\n arr['cw'] = width;\n arr['ch'] = height;\n arr['dpi'] = dpi;\n\n if (baseline) {\n arr['cb'] = baseline;\n }\n\n return arr;\n }\n }\n }]);\n\n return Image;\n}();\n\n\n\n//# sourceURL=webpack:///./core/src/image.js?"); /***/ }), @@ -250,7 +250,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/**\r\n * Represents the conf /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"default\", function() { return Latex; });\n/* harmony import */ var _cache_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./cache.js */ \"./core/src/cache.js\");\n/* harmony import */ var _mathml_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./mathml.js */ \"./core/src/mathml.js\");\n/* harmony import */ var _serviceprovider_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./serviceprovider.js */ \"./core/src/serviceprovider.js\");\n/* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./constants.js */ \"./core/src/constants.js\");\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\n\n\n\n\n/**\r\n * This class represents a LaTeX parser. Manages the services which allows to convert\r\n * LaTeX into MathML and MathML into LaTeX.\r\n */\n\nvar Latex =\n/*#__PURE__*/\nfunction () {\n function Latex() {\n _classCallCheck(this, Latex);\n }\n\n _createClass(Latex, null, [{\n key: \"getLatexFromMathML\",\n\n /**\r\n * Converts MathML to LaTeX by calling mathml2latex service. For text services\r\n * we call a text service with the param mathml2latex.\r\n * @param {string} mathml - MathML String\r\n * @return {string} LaTeX string generated by the MathML argument.\r\n */\n value: function getLatexFromMathML(mathml) {\n /**\r\n * @type {TextCache}\r\n */\n var cache = Latex.cache;\n var data = {\n 'service': 'mathml2latex',\n 'mml': mathml\n };\n var jsonResponse = JSON.parse(_serviceprovider_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].getService('service', data)); //TODO: Error handling.\n\n var latex = '';\n\n if (jsonResponse.status == \"ok\") {\n latex = jsonResponse.result.text; // Inserting LaTeX semantics.\n\n mathml = _mathml_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].insertSemanticsMathml(mathml, latex, 'LaTeX');\n cache.populate(latex, mathml);\n }\n\n return latex;\n }\n /**\r\n * Converts LaTeX to MathML by calling latex2mathml service. For text services\r\n * we call a text service with the param latex2mathml.\r\n * @param {string} latex - string containing a LaTeX formula.\r\n * @param {boolean} includeLatexOnSemantics - if true LaTeX would me included into MathML semantics.\r\n * @return {string} MathML string generated by the LaTeX argument.\r\n */\n\n }, {\n key: \"getMathMLFromLatex\",\n value: function getMathMLFromLatex(latex, includeLatexOnSemantics) {\n /**\r\n * @type {TextCache}\r\n */\n var latexCache = Latex.cache;\n\n if (Latex.cache.get(latex)) {\n return Latex.cache.get(latex);\n }\n\n var data = {\n 'service': 'latex2mathml',\n 'latex': latex\n };\n\n if (includeLatexOnSemantics) {\n data['saveLatex'] = '';\n }\n\n var jsonResponse = JSON.parse(_serviceprovider_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].getService('service', data));\n var output;\n\n if (jsonResponse.status == \"ok\") {\n var mathml = jsonResponse.result.text;\n mathml = mathml.split(\"\\r\").join('').split(\"\\n\").join(' '); // Populate LatexCache.\n\n if (mathml.indexOf('semantics') == -1 && mathml.indexOf('annotation') == -1) {\n mathml = _mathml_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].insertSemanticsMathml(mathml, latex, 'LaTeX');\n output = mathml;\n }\n\n if (!latexCache.get(latex)) {\n latexCache.populate(latex, mathml);\n }\n } else {\n output = \"$$\" + latex + \"$$\";\n }\n\n return output;\n }\n /**\r\n * Converts all occurrences of MathML code to LaTeX. The MathML code should containing to be converted.\r\n * @param {string} content - a string containing MathML valid code.\r\n * @param {Object} characters - an object containing special characters.\r\n * @return {string} a string containing all MathML annotated occurrences replaced by the corresponding LaTeX code.\r\n */\n\n }, {\n key: \"parseMathmlToLatex\",\n value: function parseMathmlToLatex(content, characters) {\n var output = '';\n var mathTagBegin = characters.tagOpener + 'math';\n var mathTagEnd = characters.tagOpener + '/math' + characters.tagCloser;\n var openTarget = characters.tagOpener + 'annotation encoding=' + characters.doubleQuote + 'LaTeX' + characters.doubleQuote + characters.tagCloser;\n var closeTarget = characters.tagOpener + '/annotation' + characters.tagCloser;\n var start = content.indexOf(mathTagBegin);\n var end = 0;\n var mathml, startAnnotation, closeAnnotation;\n\n while (start != -1) {\n output += content.substring(end, start);\n end = content.indexOf(mathTagEnd, start);\n\n if (end == -1) {\n end = content.length - 1;\n } else {\n end += mathTagEnd.length;\n }\n\n mathml = content.substring(start, end);\n startAnnotation = mathml.indexOf(openTarget);\n\n if (startAnnotation != -1) {\n startAnnotation += openTarget.length;\n closeAnnotation = mathml.indexOf(closeTarget);\n var latex = mathml.substring(startAnnotation, closeAnnotation);\n\n if (characters == _constants_js__WEBPACK_IMPORTED_MODULE_3__[\"default\"].safeXmlCharacters) {\n latex = _mathml_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].safeXmlDecode(latex);\n }\n\n output += '$$' + latex + '$$'; // Populate latex into cache.\n\n Latex.cache.populate(latex, mathml);\n } else {\n output += mathml;\n }\n\n start = content.indexOf(mathTagBegin, end);\n }\n\n output += content.substring(end, content.length);\n return output;\n }\n /**\r\n * Extracts the latex of a determined position in a text.\r\n * @param {Node} textNode - textNode to extract the LaTeX\r\n * @param {number} caretPosition - starting position to find LaTeX.\r\n * @param {Object} latexTags - optional parameter representing tags between latex is inserted. It has the 'open' attribute for the open tag and the 'close' attribute for the close tag.\r\n * \"$$\" by default.\r\n * @return {Object} An object with 3 keys: 'latex', 'start' and 'end'. Null if latex is not found.\r\n * @static\r\n */\n\n }, {\n key: \"getLatexFromTextNode\",\n value: function getLatexFromTextNode(textNode, caretPosition, latexTags) {\n // TODO: Set LaTeX Tags as Core variable. Fix the call to this function (third argument).\n // Tags used for LaTeX formulas.\n var defaultLatexTags = {\n 'open': '$$',\n 'close': '$$'\n }; // latexTags is an optional parameter. If is not set, use default latexTags.\n\n if (typeof latexTags == 'undefined' || latexTags == null) {\n latexTags = defaultLatexTags;\n } // Looking for the first textNode.\n\n\n var startNode = textNode;\n\n while (startNode.previousSibling && startNode.previousSibling.nodeType == 3) {\n // TEXT_NODE.\n startNode = startNode.previousSibling;\n } // Finding latex.\n\n /**\r\n * Returns the next latex position and node from a specific node and position.\r\n * @param {Node} currentNode - node where searching latex.\r\n * @param {number} currentPosition - current position inside the currentNode.\r\n * @param {Object} latexTagsToUse - tags used at latex beginning and latex final. \"$$\" by default.\r\n * @param {boolean} tag - tag containing the current search.\r\n * @returns {object} object containing the current node and the position.\r\n */\n\n\n function getNextLatexPosition(currentNode, currentPosition, tag) {\n var position = currentNode.nodeValue.indexOf(tag, currentPosition);\n\n while (position == -1) {\n currentNode = currentNode.nextSibling;\n\n if (!currentNode) {\n // TEXT_NODE.\n return null; // Not found.\n }\n\n position = currentNode.nodeValue ? currentNode.nodeValue.indexOf(latexTags.close) : -1;\n }\n\n return {\n 'node': currentNode,\n 'position': position\n };\n }\n /**\r\n * Determines if a node is previous, or not, to a second one.\r\n * @param {Node} node - start node.\r\n * @param {number} position - start node position.\r\n * @param {Node} endNode - end node.\r\n * @param {number} endPosition - end node position.\r\n * @returns {boolean} true if the starting node is previous thant the en node. false otherwise.\r\n */\n\n\n function isPrevious(node, position, endNode, endPosition) {\n if (node == endNode) {\n return position <= endPosition;\n }\n\n while (node && node != endNode) {\n node = node.nextSibling;\n }\n\n return node == endNode;\n }\n\n var start;\n var end = {\n 'node': startNode,\n 'position': 0\n }; // Is supposed that open and close tags has the same length.\n\n var tagLength = latexTags.open.length;\n\n do {\n var start = getNextLatexPosition(end.node, end.position, latexTags.open);\n\n if (start == null || isPrevious(textNode, caretPosition, start.node, start.position)) {\n return null;\n }\n\n var end = getNextLatexPosition(start.node, start.position + tagLength, latexTags.close);\n\n if (end == null) {\n return null;\n }\n\n end.position += tagLength;\n } while (isPrevious(end.node, end.position, textNode, caretPosition)); // Isolating latex.\n\n\n var latex;\n\n if (start.node == end.node) {\n latex = start.node.nodeValue.substring(start.position + tagLength, end.position - tagLength);\n } else {\n latex = start.node.nodeValue.substring(start.position + tagLength, start.node.nodeValue.length);\n var currentNode = start.node;\n\n do {\n currentNode = currentNode.nextSibling;\n\n if (currentNode == end.node) {\n latex += end.node.nodeValue.substring(0, end.position - tagLength);\n } else {\n latex += currentNode.nodeValue ? currentNode.nodeValue : '';\n }\n } while (currentNode != end.node);\n }\n\n return {\n 'latex': latex,\n 'startNode': start.node,\n 'startPosition': start.position,\n 'endNode': end.node,\n 'endPosition': end.position\n };\n }\n }]);\n\n return Latex;\n}();\n/**\r\n * Text cache. Stores all processed LaTeX strings and it's correspondent MathML string.\r\n * @type {Cache}\r\n * @static\r\n */\n\n\n\nLatex.cache = new _cache_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"]();\n\n//# sourceURL=webpack:///./core/src/latex.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"default\", function() { return Latex; });\n/* harmony import */ var _cache_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./cache.js */ \"./core/src/cache.js\");\n/* harmony import */ var _mathml_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./mathml.js */ \"./core/src/mathml.js\");\n/* harmony import */ var _serviceprovider_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./serviceprovider.js */ \"./core/src/serviceprovider.js\");\n/* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./constants.js */ \"./core/src/constants.js\");\n/* harmony import */ var _util_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./util.js */ \"./core/src/util.js\");\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\n\n\n\n\n\n/**\r\n * This class represents a LaTeX parser. Manages the services which allows to convert\r\n * LaTeX into MathML and MathML into LaTeX.\r\n */\n\nvar Latex =\n/*#__PURE__*/\nfunction () {\n function Latex() {\n _classCallCheck(this, Latex);\n }\n\n _createClass(Latex, null, [{\n key: \"getLatexFromMathML\",\n\n /**\r\n * Converts MathML to LaTeX by calling mathml2latex service. For text services\r\n * we call a text service with the param mathml2latex.\r\n * @param {string} mathml - MathML String\r\n * @return {string} LaTeX string generated by the MathML argument.\r\n */\n value: function getLatexFromMathML(mathml) {\n /**\r\n * @type {TextCache}\r\n */\n var cache = Latex.cache;\n var data = {\n 'service': 'mathml2latex',\n 'mml': mathml\n };\n var jsonResponse = JSON.parse(_serviceprovider_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].getService('service', data)); //TODO: Error handling.\n\n var latex = '';\n\n if (jsonResponse.status == \"ok\") {\n latex = jsonResponse.result.text;\n var latexHtmlEntitiesEncoded = _util_js__WEBPACK_IMPORTED_MODULE_4__[\"default\"].htmlEntities(latex); // Inserting LaTeX semantics.\n\n mathml = _mathml_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].insertSemanticsMathml(mathml, latexHtmlEntitiesEncoded, 'LaTeX');\n cache.populate(latex, mathml);\n }\n\n return latex;\n }\n /**\r\n * Converts LaTeX to MathML by calling latex2mathml service. For text services\r\n * we call a text service with the param latex2mathml.\r\n * @param {string} latex - string containing a LaTeX formula.\r\n * @param {boolean} includeLatexOnSemantics - if true LaTeX would me included into MathML semantics.\r\n * @return {string} MathML string generated by the LaTeX argument.\r\n */\n\n }, {\n key: \"getMathMLFromLatex\",\n value: function getMathMLFromLatex(latex, includeLatexOnSemantics) {\n /**\r\n * @type {TextCache}\r\n */\n var latexCache = Latex.cache;\n\n if (Latex.cache.get(latex)) {\n return Latex.cache.get(latex);\n }\n\n var data = {\n 'service': 'latex2mathml',\n 'latex': latex\n };\n\n if (includeLatexOnSemantics) {\n data['saveLatex'] = '';\n }\n\n var jsonResponse = JSON.parse(_serviceprovider_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].getService('service', data));\n var output;\n\n if (jsonResponse.status == \"ok\") {\n var mathml = jsonResponse.result.text;\n mathml = mathml.split(\"\\r\").join('').split(\"\\n\").join(' '); // Populate LatexCache.\n\n if (mathml.indexOf('semantics') == -1 && mathml.indexOf('annotation') == -1) {\n mathml = _mathml_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].insertSemanticsMathml(mathml, latex, 'LaTeX');\n output = mathml;\n }\n\n if (!latexCache.get(latex)) {\n latexCache.populate(latex, mathml);\n }\n } else {\n output = \"$$\" + latex + \"$$\";\n }\n\n return output;\n }\n /**\r\n * Converts all occurrences of MathML code to LaTeX. The MathML code should containing to be converted.\r\n * @param {string} content - a string containing MathML valid code.\r\n * @param {Object} characters - an object containing special characters.\r\n * @return {string} a string containing all MathML annotated occurrences replaced by the corresponding LaTeX code.\r\n */\n\n }, {\n key: \"parseMathmlToLatex\",\n value: function parseMathmlToLatex(content, characters) {\n var output = '';\n var mathTagBegin = characters.tagOpener + 'math';\n var mathTagEnd = characters.tagOpener + '/math' + characters.tagCloser;\n var openTarget = characters.tagOpener + 'annotation encoding=' + characters.doubleQuote + 'LaTeX' + characters.doubleQuote + characters.tagCloser;\n var closeTarget = characters.tagOpener + '/annotation' + characters.tagCloser;\n var start = content.indexOf(mathTagBegin);\n var end = 0;\n var mathml, startAnnotation, closeAnnotation;\n\n while (start != -1) {\n output += content.substring(end, start);\n end = content.indexOf(mathTagEnd, start);\n\n if (end == -1) {\n end = content.length - 1;\n } else {\n end += mathTagEnd.length;\n }\n\n mathml = content.substring(start, end);\n startAnnotation = mathml.indexOf(openTarget);\n\n if (startAnnotation != -1) {\n startAnnotation += openTarget.length;\n closeAnnotation = mathml.indexOf(closeTarget);\n var latex = mathml.substring(startAnnotation, closeAnnotation);\n\n if (characters == _constants_js__WEBPACK_IMPORTED_MODULE_3__[\"default\"].safeXmlCharacters) {\n latex = _mathml_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].safeXmlDecode(latex);\n }\n\n output += '$$' + latex + '$$'; // Populate latex into cache.\n\n Latex.cache.populate(latex, mathml);\n } else {\n output += mathml;\n }\n\n start = content.indexOf(mathTagBegin, end);\n }\n\n output += content.substring(end, content.length);\n return output;\n }\n /**\r\n * Extracts the latex of a determined position in a text.\r\n * @param {Node} textNode - textNode to extract the LaTeX\r\n * @param {number} caretPosition - starting position to find LaTeX.\r\n * @param {Object} latexTags - optional parameter representing tags between latex is inserted. It has the 'open' attribute for the open tag and the 'close' attribute for the close tag.\r\n * \"$$\" by default.\r\n * @return {Object} An object with 3 keys: 'latex', 'start' and 'end'. Null if latex is not found.\r\n * @static\r\n */\n\n }, {\n key: \"getLatexFromTextNode\",\n value: function getLatexFromTextNode(textNode, caretPosition, latexTags) {\n // TODO: Set LaTeX Tags as Core variable. Fix the call to this function (third argument).\n // Tags used for LaTeX formulas.\n var defaultLatexTags = {\n 'open': '$$',\n 'close': '$$'\n }; // latexTags is an optional parameter. If is not set, use default latexTags.\n\n if (typeof latexTags == 'undefined' || latexTags == null) {\n latexTags = defaultLatexTags;\n } // Looking for the first textNode.\n\n\n var startNode = textNode;\n\n while (startNode.previousSibling && startNode.previousSibling.nodeType == 3) {\n // TEXT_NODE.\n startNode = startNode.previousSibling;\n } // Finding latex.\n\n /**\r\n * Returns the next latex position and node from a specific node and position.\r\n * @param {Node} currentNode - node where searching latex.\r\n * @param {number} currentPosition - current position inside the currentNode.\r\n * @param {Object} latexTagsToUse - tags used at latex beginning and latex final. \"$$\" by default.\r\n * @param {boolean} tag - tag containing the current search.\r\n * @returns {object} object containing the current node and the position.\r\n */\n\n\n function getNextLatexPosition(currentNode, currentPosition, tag) {\n var position = currentNode.nodeValue.indexOf(tag, currentPosition);\n\n while (position == -1) {\n currentNode = currentNode.nextSibling;\n\n if (!currentNode) {\n // TEXT_NODE.\n return null; // Not found.\n }\n\n position = currentNode.nodeValue ? currentNode.nodeValue.indexOf(latexTags.close) : -1;\n }\n\n return {\n 'node': currentNode,\n 'position': position\n };\n }\n /**\r\n * Determines if a node is previous, or not, to a second one.\r\n * @param {Node} node - start node.\r\n * @param {number} position - start node position.\r\n * @param {Node} endNode - end node.\r\n * @param {number} endPosition - end node position.\r\n * @returns {boolean} true if the starting node is previous thant the en node. false otherwise.\r\n */\n\n\n function isPrevious(node, position, endNode, endPosition) {\n if (node == endNode) {\n return position <= endPosition;\n }\n\n while (node && node != endNode) {\n node = node.nextSibling;\n }\n\n return node == endNode;\n }\n\n var start;\n var end = {\n 'node': startNode,\n 'position': 0\n }; // Is supposed that open and close tags has the same length.\n\n var tagLength = latexTags.open.length;\n\n do {\n var start = getNextLatexPosition(end.node, end.position, latexTags.open);\n\n if (start == null || isPrevious(textNode, caretPosition, start.node, start.position)) {\n return null;\n }\n\n var end = getNextLatexPosition(start.node, start.position + tagLength, latexTags.close);\n\n if (end == null) {\n return null;\n }\n\n end.position += tagLength;\n } while (isPrevious(end.node, end.position, textNode, caretPosition)); // Isolating latex.\n\n\n var latex;\n\n if (start.node == end.node) {\n latex = start.node.nodeValue.substring(start.position + tagLength, end.position - tagLength);\n } else {\n latex = start.node.nodeValue.substring(start.position + tagLength, start.node.nodeValue.length);\n var currentNode = start.node;\n\n do {\n currentNode = currentNode.nextSibling;\n\n if (currentNode == end.node) {\n latex += end.node.nodeValue.substring(0, end.position - tagLength);\n } else {\n latex += currentNode.nodeValue ? currentNode.nodeValue : '';\n }\n } while (currentNode != end.node);\n }\n\n return {\n 'latex': latex,\n 'startNode': start.node,\n 'startPosition': start.position,\n 'endNode': end.node,\n 'endPosition': end.position\n };\n }\n }]);\n\n return Latex;\n}();\n/**\r\n * Text cache. Stores all processed LaTeX strings and it's correspondent MathML string.\r\n * @type {Cache}\r\n * @static\r\n */\n\n\n\nLatex.cache = new _cache_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"]();\n\n//# sourceURL=webpack:///./core/src/latex.js?"); /***/ }), @@ -274,7 +274,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) * /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"default\", function() { return MathML; });\n/* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./constants.js */ \"./core/src/constants.js\");\n/* harmony import */ var _util_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./util.js */ \"./core/src/util.js\");\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\n\n\n/**\r\n * This class represents a class to manage MathML objects.\r\n */\n\nvar MathML =\n/*#__PURE__*/\nfunction () {\n function MathML() {\n _classCallCheck(this, MathML);\n }\n\n _createClass(MathML, null, [{\n key: \"isMathmlInAttribute\",\n\n /**\r\n * Checks if the mathml at position i is inside an HTML attribute or not.\r\n * @param {string} content - a string containing MathML code.\r\n * @param {number} i - search index.\r\n * @return {boolean} true if is inside an HTML attribute. false otherwise.\r\n */\n value: function isMathmlInAttribute(content, i) {\n // Regex = '^[\\'\"][\\\\s]*=[\\\\s]*[\\\\w-]+([\\\\s]*(\"[^\"]*\"|\\'[^\\']*\\')[\\\\s]*=[\\\\s]*[\\\\w-]+[\\\\s]*)*[\\\\s]+gmi<';\n var math_att = '[\\'\"][\\\\s]*=[\\\\s]*[\\\\w-]+'; // \"=att OR '=att\n\n var att_content = '\"[^\"]*\"|\\'[^\\']*\\''; // \"blabla\" OR 'blabla'\n\n var att = '[\\\\s]*(' + att_content + ')[\\\\s]*=[\\\\s]*[\\\\w-]+[\\\\s]*'; // \"blabla\"=att OR 'blabla'=att\n\n var atts = '(' + att + ')*'; // \"blabla\"=att1 \"blabla\"=att2\n\n var regex = '^' + math_att + atts + '[\\\\s]+gmi<'; // \"=att \"blabla\"=att1 \"blabla\"=att2 gmi< .\n\n var expression = new RegExp(regex);\n var actual_content = content.substring(0, i);\n var reversed = actual_content.split('').reverse().join('');\n var exists = expression.test(reversed);\n return exists;\n }\n /**\r\n * Decodes an encoded MathML with standard XML tags.\r\n * We use these entities because IE doesn't support html entities on its attributes sometimes. Yes, sometimes.\r\n * @param {string} input - string to be decoded.\r\n * @return {string} decoded string.\r\n */\n\n }, {\n key: \"safeXmlDecode\",\n value: function safeXmlDecode(input) {\n // Decoding entities.\n input = input.split(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlCharactersEntities.tagOpener).join(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlCharacters.tagOpener);\n input = input.split(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlCharactersEntities.tagCloser).join(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlCharacters.tagCloser);\n input = input.split(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlCharactersEntities.doubleQuote).join(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlCharacters.doubleQuote); // Added to fix problem due to import from 1.9.x.\n\n input = input.split(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlCharactersEntities.realDoubleQuote).join(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlCharacters.realDoubleQuote); // Blackboard.\n\n if ('_wrs_blackboard' in window && window._wrs_blackboard) {\n input = input.split(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeBadBlackboardCharacters.ltElement).join(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeGoodBlackboardCharacters.ltElement);\n input = input.split(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeBadBlackboardCharacters.gtElement).join(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeGoodBlackboardCharacters.gtElement);\n input = input.split(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeBadBlackboardCharacters.ampElement).join(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeGoodBlackboardCharacters.ampElement);\n } // Decoding characters.\n\n\n input = input.split(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlCharacters.tagOpener).join(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].xmlCharacters.tagOpener);\n input = input.split(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlCharacters.tagCloser).join(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].xmlCharacters.tagCloser);\n input = input.split(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlCharacters.doubleQuote).join(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].xmlCharacters.doubleQuote);\n input = input.split(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlCharacters.ampersand).join(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].xmlCharacters.ampersand);\n input = input.split(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlCharacters.quote).join(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].xmlCharacters.quote); // We are replacing $ by & when its part of an entity for retrocompatibility. Now, the standard is replace § by &.\n\n var returnValue = '';\n var currentEntity = null;\n\n for (var i = 0; i < input.length; ++i) {\n var character = input.charAt(i);\n\n if (currentEntity == null) {\n if (character == '$') {\n currentEntity = '';\n } else {\n returnValue += character;\n }\n } else {\n if (character == ';') {\n returnValue += '&' + currentEntity + ';';\n currentEntity = null;\n } else if (character.match(/([a-zA-Z0-9#._-] | '-')/)) {\n // Character is part of an entity.\n currentEntity += character;\n } else {\n returnValue += '$' + currentEntity; // Is not an entity.\n\n currentEntity = null;\n --i; // Parse again the current character.\n }\n }\n }\n\n return returnValue;\n }\n /**\r\n * Encodes a MathML with standard XML tags to a MMathML encoded with safe XML tags.\r\n * We use these entities because IE doesn't support html entities on its attributes sometimes. Yes, sometimes.\r\n * @param {string} input - input string to be encoded\r\n * @returns {string} encoded string.\r\n */\n\n }, {\n key: \"safeXmlEncode\",\n value: function safeXmlEncode(input) {\n input = input.split(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].xmlCharacters.tagOpener).join(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlCharacters.tagOpener);\n input = input.split(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].xmlCharacters.tagCloser).join(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlCharacters.tagCloser);\n input = input.split(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].xmlCharacters.doubleQuote).join(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlCharacters.doubleQuote);\n input = input.split(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].xmlCharacters.ampersand).join(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlCharacters.ampersand);\n input = input.split(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].xmlCharacters.quote).join(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlCharacters.quote);\n return input;\n }\n /**\r\n * Converts special symbols (> 128) to entities and replaces all textual entities by its number entities.\r\n * @param {string} mathml - MathML string containing - or not - special symbols\r\n * @returns {string} MathML with all textual entities replaced.\r\n */\n\n }, {\n key: \"mathMLEntities\",\n value: function mathMLEntities(mathml) {\n var toReturn = '';\n\n for (var i = 0; i < mathml.length; ++i) {\n var character = mathml.charAt(i); // Parsing > 128 characters.\n\n if (mathml.codePointAt(i) > 128) {\n toReturn += '&#' + mathml.codePointAt(i) + ';'; // For UTF-32 characters we need to move the index one position.\n\n if (mathml.codePointAt(i) > 0xffff) {\n i++;\n }\n } else if (character == '&') {\n var end = mathml.indexOf(';', i + 1);\n\n if (end >= 0) {\n var container = document.createElement('span');\n container.innerHTML = mathml.substring(i, end + 1);\n toReturn += '&#' + _util_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].fixedCharCodeAt(container.innerText || container.textContent, 0) + ';';\n i = end;\n } else {\n toReturn += character;\n }\n } else {\n toReturn += character;\n }\n }\n\n return toReturn;\n }\n /**\r\n * Add a custom editor name with the prefix wrs_ to a MathML class attribute.\r\n * @param {string} mathml - a MathML string created with a custom editor, like chemistry.\r\n * @param {string} customEditor - custom editor name.\r\n * @returns {string} MathML string with his class containing the editor toolbar string.\r\n */\n\n }, {\n key: \"addCustomEditorClassAttribute\",\n value: function addCustomEditorClassAttribute(mathml, customEditor) {\n var toReturn = '';\n var start = mathml.indexOf('');\n\n if (mathml.indexOf(\"class\") == -1) {\n // Adding custom editor type.\n toReturn = mathml.substr(start, end) + ' class=\"wrs_' + customEditor + '\">';\n toReturn += mathml.substr(end + 1, mathml.length);\n return toReturn;\n }\n }\n\n return mathml;\n }\n /**\r\n * Remove a custom editor name from the MathML class attribute.\r\n * @param {string} mathml - a MathML string.\r\n * @param {string} customEditor - custom editor name.\r\n * @returns {string} The input MathML without customEditor name in his class.\r\n */\n\n }, {\n key: \"removeCustomEditorClassAttribute\",\n value: function removeCustomEditorClassAttribute(mathml, customEditor) {\n // Discard MathML without the specified class.\n if (mathml.indexOf('class') == -1 || mathml.indexOf('wrs_' + customEditor)) {\n return mathml;\n } // Trivial case: class attribute value equal to editor name. Then\n // class attribute is removed.\n\n\n if (mathml.indexOf('class=\"wrs_' + customEditor + '\"') !== -1) {\n return mathml.replace('class=\"wrs_' + customEditor + '\"', '');\n } // Non Trivial case: class attribute contains editor name.\n\n\n return mathml.replace('wrs_' + customEditor, '');\n }\n /**\r\n * Add annotation tag to mathml without it (mathml comes from LaTeX string)\r\n * @param {string} mathml - MathML code generated by a LaTeX string.\r\n * @param {string} latex - original LaTeX string\r\n * @param {string} withoutLatexTranslate - true if not exists latex translation from mathml. false otherwise.\r\n * @param {string} encoding - encoding attribute.\r\n * @returns {string} MathML containing LaTeX code on annotation tag.\r\n */\n\n }, {\n key: \"insertSemanticsMathml\",\n value: function insertSemanticsMathml(mathml, latex, encoding) {\n // If latex is empty, insert semantics doesn't provide information. We can avoid semantics insertion and return the mathml.\n if (latex == \"\") {\n return mathml;\n }\n\n var firstEndTag = '>';\n var mathTagEnd = '<' + '/math' + '>';\n var openSemantics = '<' + 'semantics' + '>';\n var closeSemantics = '<' + '/semantics' + '>';\n var openTarget = '';\n var closeTarget = '<' + '/annotation' + '>';\n var mrowOpen = '';\n var mrowClose = '';\n var indexMathBegin = mathml.indexOf(firstEndTag);\n var indexMathEnd = mathml.indexOf(mathTagEnd);\n var mathBeginExists = mathml.substring(mathml.indexOf('<'), mathml.indexOf('>')).indexOf('math');\n\n if (indexMathBegin != -1 && indexMathEnd != -1 && mathBeginExists) {\n var mathmlContent = mathml.substring(indexMathBegin + 1, indexMathEnd);\n\n if (mathmlContent.indexOf(mrowOpen) != 0) {\n var mathmlContentSemantics = openSemantics + mrowOpen + mathmlContent + mrowClose + openTarget + latex + closeTarget + closeSemantics;\n } else {\n var mathmlContentSemantics = openSemantics + mathmlContent + openTarget + latex + closeTarget + closeSemantics;\n }\n\n return mathml.replace(mathmlContent, mathmlContentSemantics);\n } else {\n return mathml;\n }\n }\n /**\r\n * Removes annotation tag to mathml.\r\n * @param {string} mathml - MathML string\r\n * @param {string} encoding - string containing annotation encoding.\r\n * @returns {string} MathML with an annotation tag.\r\n */\n\n }, {\n key: \"removeSemanticsMathml\",\n value: function removeSemanticsMathml(mathml, encoding) {\n var mathTagEnd = '<' + '/math' + '>';\n var openSemantics = '<' + 'semantics' + '>';\n var openAnnotation = '';\n var mathmlWithoutSemantics = mathml;\n var startSemantics = mathml.indexOf(openSemantics);\n\n if (startSemantics != -1) {\n var startAnnotation = mathml.indexOf(openAnnotation, startSemantics + openSemantics.length);\n\n if (startAnnotation != -1) {\n mathmlWithoutSemantics = mathml.substring(0, startSemantics) + mathml.substring(startSemantics + openSemantics.length, startAnnotation) + mathTagEnd;\n }\n }\n\n return mathmlWithoutSemantics;\n }\n /**\r\n * Returns true if a MathML contains a certain class.\r\n * @param {string} mathML - input MathML.\r\n * @param {string} className - className.\r\n * @returns {boolean} true if the input MathML contains the input class.\r\n * false otherwise.\r\n * @static\r\n */\n\n }, {\n key: \"containClass\",\n value: function containClass(mathML, className) {\n var classIndex = mathML.indexOf('class');\n\n if (classIndex == -1) {\n return false;\n } else {\n var classTagEndIndex = mathML.indexOf('>', classIndex);\n var classTag = mathML.substring(classIndex, classTagEndIndex);\n\n if (classTag.indexOf(className) != -1) {\n return true;\n } else {\n return false;\n }\n }\n }\n }]);\n\n return MathML;\n}();\n\n\n\n//# sourceURL=webpack:///./core/src/mathml.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"default\", function() { return MathML; });\n/* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./constants.js */ \"./core/src/constants.js\");\n/* harmony import */ var _util_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./util.js */ \"./core/src/util.js\");\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\n\n\n/**\r\n * This class represents a class to manage MathML objects.\r\n */\n\nvar MathML =\n/*#__PURE__*/\nfunction () {\n function MathML() {\n _classCallCheck(this, MathML);\n }\n\n _createClass(MathML, null, [{\n key: \"isMathmlInAttribute\",\n\n /**\r\n * Checks if the mathml at position i is inside an HTML attribute or not.\r\n * @param {string} content - a string containing MathML code.\r\n * @param {number} i - search index.\r\n * @return {boolean} true if is inside an HTML attribute. false otherwise.\r\n */\n value: function isMathmlInAttribute(content, i) {\n // Regex = '^[\\'\"][\\\\s]*=[\\\\s]*[\\\\w-]+([\\\\s]*(\"[^\"]*\"|\\'[^\\']*\\')[\\\\s]*=[\\\\s]*[\\\\w-]+[\\\\s]*)*[\\\\s]+gmi<';\n var math_att = '[\\'\"][\\\\s]*=[\\\\s]*[\\\\w-]+'; // \"=att OR '=att\n\n var att_content = '\"[^\"]*\"|\\'[^\\']*\\''; // \"blabla\" OR 'blabla'\n\n var att = '[\\\\s]*(' + att_content + ')[\\\\s]*=[\\\\s]*[\\\\w-]+[\\\\s]*'; // \"blabla\"=att OR 'blabla'=att\n\n var atts = '(' + att + ')*'; // \"blabla\"=att1 \"blabla\"=att2\n\n var regex = '^' + math_att + atts + '[\\\\s]+gmi<'; // \"=att \"blabla\"=att1 \"blabla\"=att2 gmi< .\n\n var expression = new RegExp(regex);\n var actual_content = content.substring(0, i);\n var reversed = actual_content.split('').reverse().join('');\n var exists = expression.test(reversed);\n return exists;\n }\n /**\r\n * Decodes an encoded MathML with standard XML tags.\r\n * We use these entities because IE doesn't support html entities on its attributes sometimes. Yes, sometimes.\r\n * @param {string} input - string to be decoded.\r\n * @return {string} decoded string.\r\n */\n\n }, {\n key: \"safeXmlDecode\",\n value: function safeXmlDecode(input) {\n // Decoding entities.\n input = input.split(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlCharactersEntities.tagOpener).join(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlCharacters.tagOpener);\n input = input.split(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlCharactersEntities.tagCloser).join(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlCharacters.tagCloser);\n input = input.split(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlCharactersEntities.doubleQuote).join(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlCharacters.doubleQuote); // Added to fix problem due to import from 1.9.x.\n\n input = input.split(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlCharactersEntities.realDoubleQuote).join(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlCharacters.realDoubleQuote); // Blackboard.\n\n if ('_wrs_blackboard' in window && window._wrs_blackboard) {\n input = input.split(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeBadBlackboardCharacters.ltElement).join(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeGoodBlackboardCharacters.ltElement);\n input = input.split(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeBadBlackboardCharacters.gtElement).join(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeGoodBlackboardCharacters.gtElement);\n input = input.split(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeBadBlackboardCharacters.ampElement).join(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeGoodBlackboardCharacters.ampElement);\n } // Decoding characters.\n\n\n input = input.split(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlCharacters.tagOpener).join(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].xmlCharacters.tagOpener);\n input = input.split(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlCharacters.tagCloser).join(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].xmlCharacters.tagCloser);\n input = input.split(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlCharacters.doubleQuote).join(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].xmlCharacters.doubleQuote);\n input = input.split(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlCharacters.ampersand).join(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].xmlCharacters.ampersand);\n input = input.split(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlCharacters.quote).join(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].xmlCharacters.quote); // We are replacing $ by & when its part of an entity for retrocompatibility. Now, the standard is replace § by &.\n\n var returnValue = '';\n var currentEntity = null;\n\n for (var i = 0; i < input.length; ++i) {\n var character = input.charAt(i);\n\n if (currentEntity == null) {\n if (character == '$') {\n currentEntity = '';\n } else {\n returnValue += character;\n }\n } else {\n if (character == ';') {\n returnValue += '&' + currentEntity + ';';\n currentEntity = null;\n } else if (character.match(/([a-zA-Z0-9#._-] | '-')/)) {\n // Character is part of an entity.\n currentEntity += character;\n } else {\n returnValue += '$' + currentEntity; // Is not an entity.\n\n currentEntity = null;\n --i; // Parse again the current character.\n }\n }\n }\n\n return returnValue;\n }\n /**\r\n * Encodes a MathML with standard XML tags to a MMathML encoded with safe XML tags.\r\n * We use these entities because IE doesn't support html entities on its attributes sometimes. Yes, sometimes.\r\n * @param {string} input - input string to be encoded\r\n * @returns {string} encoded string.\r\n */\n\n }, {\n key: \"safeXmlEncode\",\n value: function safeXmlEncode(input) {\n input = input.split(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].xmlCharacters.tagOpener).join(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlCharacters.tagOpener);\n input = input.split(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].xmlCharacters.tagCloser).join(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlCharacters.tagCloser);\n input = input.split(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].xmlCharacters.doubleQuote).join(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlCharacters.doubleQuote);\n input = input.split(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].xmlCharacters.ampersand).join(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlCharacters.ampersand);\n input = input.split(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].xmlCharacters.quote).join(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlCharacters.quote);\n return input;\n }\n /**\r\n * Converts special symbols (> 128) to entities and replaces all textual entities by its number entities.\r\n * @param {string} mathml - MathML string containing - or not - special symbols\r\n * @returns {string} MathML with all textual entities replaced.\r\n */\n\n }, {\n key: \"mathMLEntities\",\n value: function mathMLEntities(mathml) {\n var toReturn = '';\n\n for (var i = 0; i < mathml.length; ++i) {\n var character = mathml.charAt(i); // Parsing > 128 characters.\n\n if (mathml.codePointAt(i) > 128) {\n toReturn += '&#' + mathml.codePointAt(i) + ';'; // For UTF-32 characters we need to move the index one position.\n\n if (mathml.codePointAt(i) > 0xffff) {\n i++;\n }\n } else if (character == '&') {\n var end = mathml.indexOf(';', i + 1);\n\n if (end >= 0) {\n var container = document.createElement('span');\n container.innerHTML = mathml.substring(i, end + 1);\n toReturn += '&#' + _util_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].fixedCharCodeAt(container.innerText || container.textContent, 0) + ';';\n i = end;\n } else {\n toReturn += character;\n }\n } else {\n toReturn += character;\n }\n }\n\n return toReturn;\n }\n /**\r\n * Add a custom editor name with the prefix wrs_ to a MathML class attribute.\r\n * @param {string} mathml - a MathML string created with a custom editor, like chemistry.\r\n * @param {string} customEditor - custom editor name.\r\n * @returns {string} MathML string with his class containing the editor toolbar string.\r\n */\n\n }, {\n key: \"addCustomEditorClassAttribute\",\n value: function addCustomEditorClassAttribute(mathml, customEditor) {\n var toReturn = '';\n var start = mathml.indexOf('');\n\n if (mathml.indexOf(\"class\") == -1) {\n // Adding custom editor type.\n toReturn = mathml.substr(start, end) + ' class=\"wrs_' + customEditor + '\">';\n toReturn += mathml.substr(end + 1, mathml.length);\n return toReturn;\n }\n }\n\n return mathml;\n }\n /**\r\n * Remove a custom editor name from the MathML class attribute.\r\n * @param {string} mathml - a MathML string.\r\n * @param {string} customEditor - custom editor name.\r\n * @returns {string} The input MathML without customEditor name in his class.\r\n */\n\n }, {\n key: \"removeCustomEditorClassAttribute\",\n value: function removeCustomEditorClassAttribute(mathml, customEditor) {\n // Discard MathML without the specified class.\n if (mathml.indexOf('class') === -1 || mathml.indexOf('wrs_' + customEditor) === -1) {\n return mathml;\n } // Trivial case: class attribute value equal to editor name. Then\n // class attribute is removed.\n\n\n if (mathml.indexOf('class=\"wrs_' + customEditor + '\"') !== -1) {\n return mathml.replace('class=\"wrs_' + customEditor + '\"', '');\n } // Non Trivial case: class attribute contains editor name.\n\n\n return mathml.replace('wrs_' + customEditor, '');\n }\n /**\r\n * Add annotation tag to mathml without it (mathml comes from LaTeX string)\r\n * @param {string} mathml - MathML code generated by a LaTeX string.\r\n * @param {string} latex - original LaTeX string\r\n * @param {string} withoutLatexTranslate - true if not exists latex translation from mathml. false otherwise.\r\n * @param {string} encoding - encoding attribute.\r\n * @returns {string} MathML containing LaTeX code on annotation tag.\r\n */\n\n }, {\n key: \"insertSemanticsMathml\",\n value: function insertSemanticsMathml(mathml, latex, encoding) {\n // If latex is empty, insert semantics doesn't provide information. We can avoid semantics insertion and return the mathml.\n if (latex == \"\") {\n return mathml;\n }\n\n var firstEndTag = '>';\n var mathTagEnd = '<' + '/math' + '>';\n var openSemantics = '<' + 'semantics' + '>';\n var closeSemantics = '<' + '/semantics' + '>';\n var openTarget = '';\n var closeTarget = '<' + '/annotation' + '>';\n var mrowOpen = '';\n var mrowClose = '';\n var indexMathBegin = mathml.indexOf(firstEndTag);\n var indexMathEnd = mathml.indexOf(mathTagEnd);\n var mathBeginExists = mathml.substring(mathml.indexOf('<'), mathml.indexOf('>')).indexOf('math');\n\n if (indexMathBegin != -1 && indexMathEnd != -1 && mathBeginExists) {\n var mathmlContent = mathml.substring(indexMathBegin + 1, indexMathEnd);\n\n if (mathmlContent.indexOf(mrowOpen) != 0) {\n var mathmlContentSemantics = openSemantics + mrowOpen + mathmlContent + mrowClose + openTarget + latex + closeTarget + closeSemantics;\n } else {\n var mathmlContentSemantics = openSemantics + mathmlContent + openTarget + latex + closeTarget + closeSemantics;\n }\n\n return mathml.replace(mathmlContent, mathmlContentSemantics);\n } else {\n return mathml;\n }\n }\n /**\r\n * Removes annotation tag to mathml.\r\n * @param {string} mathml - MathML string\r\n * @param {string} encoding - string containing annotation encoding.\r\n * @returns {string} MathML with an annotation tag.\r\n */\n\n }, {\n key: \"removeSemantics\",\n value: function removeSemantics(mathml, encoding) {\n var mathTagEnd = '<' + '/math' + '>';\n var openSemantics = '<' + 'semantics' + '>';\n var openAnnotation = '';\n var mathmlWithoutSemantics = mathml;\n var startSemantics = mathml.indexOf(openSemantics);\n\n if (startSemantics != -1) {\n var startAnnotation = mathml.indexOf(openAnnotation, startSemantics + openSemantics.length);\n\n if (startAnnotation != -1) {\n mathmlWithoutSemantics = mathml.substring(0, startSemantics) + mathml.substring(startSemantics + openSemantics.length, startAnnotation) + mathTagEnd;\n }\n }\n\n return mathmlWithoutSemantics;\n }\n /**\r\n * Transforms all xml mathml ocurrences that contain semantics to the same\r\n * xml mathml ocurrences without semantics.\r\n * @param {string} text - string that can contain xml mathml ocurrences.\r\n * @param {string} [encoding] - encoding name that semantics need to have to be removed.\r\n * 'application/json' by default. 'application/json' removes hand traces.\r\n * @param {Constants} [characters] - Constant object containing xmlCharacters or safeXmlCharacters relation.\r\n * xmlCharacters by default.\r\n * @returns {string} - 'text' with all xml mathml ocurrences without annotation tag.\r\n */\n\n }, {\n key: \"removeSemanticsOcurrences\",\n value: function removeSemanticsOcurrences(text) {\n var characters = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].xmlCharacters;\n var encoding = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'application/json';\n var mathTagStart = characters.tagOpener + 'math';\n var mathTagEnd = characters.tagOpener + '/math' + characters.tagCloser;\n var mathTagEndline = '/' + characters.tagCloser;\n var tagCloser = characters.tagCloser;\n var semanticsTagStart = characters.tagOpener + 'semantics' + characters.tagCloser;\n var annotationTagStart = characters.tagOpener + 'annotation encoding=' + characters.doubleQuote + encoding + characters.doubleQuote + characters.tagCloser;\n var output = '';\n var start = text.indexOf(mathTagStart);\n var end = 0;\n\n while (start !== -1) {\n output += text.substring(end, start); // MathML can be written as '' or ''.\n\n var mathTagEndIndex = text.indexOf(mathTagEnd, start);\n var mathTagEndlineIndex = text.indexOf(mathTagEndline, start);\n var firstTagCloser = text.indexOf(tagCloser, start);\n\n if (mathTagEndIndex !== -1) {\n end = mathTagEndIndex;\n } else if (mathTagEndlineIndex === firstTagCloser - 1) {\n end = mathTagEndlineIndex;\n }\n\n var semanticsIndex = text.indexOf(semanticsTagStart, start);\n\n if (semanticsIndex !== -1) {\n var mmlTagStart = text.substring(start, semanticsIndex);\n var annotationIndex = text.indexOf(annotationTagStart, start);\n\n if (annotationIndex !== -1) {\n var mmlContent = text.substring(semanticsIndex + semanticsTagStart.length, annotationIndex);\n output += mmlTagStart + mmlContent + mathTagEnd;\n start = text.indexOf(mathTagStart, start + mathTagStart.length);\n end += mathTagEnd.length;\n } else {\n end = start;\n start = text.indexOf(mathTagStart, start + mathTagStart.length);\n }\n } else {\n end = start;\n start = text.indexOf(mathTagStart, start + mathTagStart.length);\n }\n }\n\n output += text.substring(end, text.length);\n return output;\n }\n /**\r\n * Returns true if a MathML contains a certain class.\r\n * @param {string} mathML - input MathML.\r\n * @param {string} className - className.\r\n * @returns {boolean} true if the input MathML contains the input class.\r\n * false otherwise.\r\n * @static\r\n */\n\n }, {\n key: \"containClass\",\n value: function containClass(mathML, className) {\n var classIndex = mathML.indexOf('class');\n\n if (classIndex == -1) {\n return false;\n } else {\n var classTagEndIndex = mathML.indexOf('>', classIndex);\n var classTag = mathML.substring(classIndex, classTagEndIndex);\n\n if (classTag.indexOf(className) != -1) {\n return true;\n } else {\n return false;\n }\n }\n }\n }]);\n\n return MathML;\n}();\n\n\n\n//# sourceURL=webpack:///./core/src/mathml.js?"); /***/ }), @@ -298,7 +298,7 @@ eval("__webpack_require__.r(__webpack_exports__);\nfunction _typeof(obj) { if (t /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"default\", function() { return ModalDialog; });\n/* harmony import */ var _popupmessage_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./popupmessage.js */ \"./core/src/popupmessage.js\");\n/* harmony import */ var _core_src_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./core.src.js */ \"./core/src/core.src.js\");\n/* harmony import */ var _util_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./util.js */ \"./core/src/util.js\");\n/* harmony import */ var _configuration_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./configuration.js */ \"./core/src/configuration.js\");\n/* harmony import */ var _listeners__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./listeners */ \"./core/src/listeners.js\");\n/* harmony import */ var _contentmanager_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./contentmanager.js */ \"./core/src/contentmanager.js\");\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\n\n\n\n\n\n\n/**\r\n * This class represents a modal dialog. The modal dialog admits a ContentManager instance in order\r\n * to manage the content of the dialog.\r\n */\n\nvar ModalDialog =\n/*#__PURE__*/\nfunction () {\n /**\r\n * Modal dialog constructor\r\n * @param {Object} modalDialogAttributes - An object containing all modal dialog attributes.\r\n */\n function ModalDialog(modalDialogAttributes) {\n _classCallCheck(this, ModalDialog);\n\n this.attributes = modalDialogAttributes; // Metrics\n\n var ua = navigator.userAgent.toLowerCase();\n var isAndroid = ua.indexOf(\"android\") > -1;\n var isIOS = ua.indexOf(\"ipad\") > -1 || ua.indexOf(\"iphone\") > -1;\n this.iosSoftkeyboardOpened = false;\n this.iosMeasureUnit = ua.indexOf(\"crios\") == -1 ? \"%\" : \"vh\";\n this.iosDivHeight = \"100\" + this.iosMeasureUnit;\n var deviceWidth = window.outerWidth;\n var deviceHeight = window.outerHeight;\n var landscape = deviceWidth > deviceHeight;\n var portrait = deviceWidth < deviceHeight; // TODO: Detect isMobile without using editor metrics.\n\n var isMobile = landscape && this.attributes.height > deviceHeight || portrait && this.attributes.width > deviceWidth ? true : false; // Obtain number of current instance\n\n this.instanceId = document.getElementsByClassName(\"wrs_modal_dialogContainer\").length; // Device object properties.\n\n this.deviceProperties = {\n orientation: landscape ? 'landscape' : 'portait',\n isAndroid: isAndroid ? true : false,\n isIOS: isIOS ? true : false,\n isMobile: isMobile,\n isDesktop: !isMobile && !isIOS && !isAndroid\n };\n this.properties = {\n created: false,\n state: '',\n previousState: '',\n position: {\n bottom: 0,\n right: 10\n },\n size: {\n height: 338,\n width: 580\n }\n };\n var attributes = {};\n attributes.class = 'wrs_modal_overlay';\n attributes.id = this.getElementId(attributes.class);\n this.overlay = _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].createElement('div', attributes);\n attributes = {};\n attributes.class = 'wrs_modal_title_bar';\n attributes.id = this.getElementId(attributes.class);\n this.titleBar = _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].createElement('div', attributes);\n attributes = {};\n attributes.class = 'wrs_modal_title';\n attributes.id = this.getElementId(attributes.class);\n this.title = _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].createElement('div', attributes);\n this.title.innerHTML = '';\n attributes = {};\n attributes.class = 'wrs_modal_close_button';\n attributes.id = this.getElementId(attributes.class);\n attributes.title = _core_src_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].getStringManager().getString('close');\n this.closeDiv = _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].createElement('a', attributes);\n ;\n this.closeDiv.setAttribute('role', 'button');\n attributes = {};\n attributes.class = 'wrs_modal_stack_button';\n attributes.id = this.getElementId(attributes.class);\n attributes.title = \"Exit full-screen\";\n this.stackDiv = _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].createElement('a', attributes);\n this.stackDiv.setAttribute('role', 'button');\n attributes = {};\n attributes.class = 'wrs_modal_maximize_button';\n attributes.id = this.getElementId(attributes.class);\n attributes.title = _core_src_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].getStringManager().getString('fullscreen');\n this.maximizeDiv = _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].createElement('a', attributes);\n this.maximizeDiv.setAttribute('role', 'button');\n attributes = {};\n attributes.class = 'wrs_modal_minimize_button';\n attributes.id = this.getElementId(attributes.class);\n attributes.title = _core_src_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].getStringManager().getString('minimise');\n this.minimizeDiv = _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].createElement('a', attributes);\n this.minimizeDiv.setAttribute('role', 'button');\n attributes = {};\n attributes.class = 'wrs_modal_dialogContainer';\n attributes.id = this.getElementId(attributes.class);\n this.container = _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].createElement('div', attributes);\n attributes = {};\n attributes.class = 'wrs_modal_wrapper';\n attributes.id = this.getElementId(attributes.class);\n this.wrapper = _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].createElement('div', attributes);\n attributes = {};\n attributes.class = 'wrs_content_container';\n attributes.id = this.getElementId(attributes.class);\n this.contentContainer = _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].createElement('div', attributes);\n attributes = {};\n attributes.class = 'wrs_modal_controls';\n attributes.id = this.getElementId(attributes.class);\n this.controls = _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].createElement('div', attributes);\n attributes = {};\n attributes.class = 'wrs_modal_buttons_container';\n attributes.id = this.getElementId(attributes.class);\n this.buttonContainer = _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].createElement('div', attributes); // Buttons: all button must be created using createSubmitButton method.\n\n this.submitButton = this.createSubmitButton({\n id: this.getElementId('wrs_modal_button_accept'),\n class: 'wrs_modal_button_accept',\n innerHTML: _core_src_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].getStringManager().getString('accept')\n }, this.submitAction.bind(this));\n this.cancelButton = this.createSubmitButton({\n id: this.getElementId('wrs_modal_button_cancel'),\n class: 'wrs_modal_button_cancel',\n innerHTML: _core_src_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].getStringManager().getString('cancel')\n }, this.cancelAction.bind(this));\n this.contentManager = null; // Overlay popup.\n\n var popupStrings = {\n 'cancelString': _core_src_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].getStringManager().getString('cancel'),\n 'submitString': _core_src_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].getStringManager().getString('close'),\n 'message': _core_src_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].getStringManager().getString('close_modal_warning')\n };\n var callbacks = {\n 'closeCallback': function () {\n this.close();\n }.bind(this),\n 'cancelCallback': function () {\n this.focus();\n }.bind(this)\n };\n var popupupProperties = {\n 'overlayElement': this.container,\n 'callbacks': callbacks,\n 'strings': popupStrings\n };\n this.popup = new _popupmessage_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"](popupupProperties);\n /**\r\n * Indicates if directionality of the modal dialog is RTL. false by default.\r\n * @type {boolean}\r\n */\n\n this.rtl = false;\n\n if ('rtl' in this.attributes) {\n this.rtl = this.attributes.rtl;\n }\n }\n /**\r\n * This method sets an ContentManager instance to ModalDialog. ContentManager\r\n * manages the logic of ModalDialog content: submit, update, close and changes.\r\n * @param {ContentManager} contentManager - ContentManager instance.\r\n */\n\n\n _createClass(ModalDialog, [{\n key: \"setContentManager\",\n value: function setContentManager(contentManager) {\n this.contentManager = contentManager;\n }\n /**\r\n * Returns the modal contentElement object.\r\n * @returns {ContentManager} the instance of the ContentManager class.\r\n */\n\n }, {\n key: \"getContentManager\",\n value: function getContentManager() {\n return this.contentManager;\n }\n /**\r\n * This method is called when the modal object has been submitted. Calls\r\n * contentElement submitAction method - if exists - and closes the modal\r\n * object. No logic about the content should be placed here,\r\n * contentElement.submitAction is the responsible of the content logic.\r\n */\n\n }, {\n key: \"submitAction\",\n value: function submitAction() {\n if (typeof this.contentManager.submitAction !== 'undefined') {\n this.contentManager.submitAction();\n }\n\n this.close();\n }\n /**\r\n * This method is called when the modal object has been cancelled. If\r\n * contentElement has implemented hasChanges method, a confirm popup\r\n * will be shown if hasChanges returns true.\r\n */\n\n }, {\n key: \"cancelAction\",\n value: function cancelAction() {\n if (typeof this.contentManager.hasChanges === 'undefined') {\n this.close();\n } else if (!this.contentManager.hasChanges()) {\n this.close();\n } else {\n this.showPopUpMessage();\n }\n }\n /**\r\n * Returns a button element.\r\n * @param {Object} properties - input button properties.\r\n * @param {string} properties.class - input button class.\r\n * @param {string} properties.innerHTML - input button innerHTML.\r\n * @param {Object} callback - callback function associated to click event.\r\n * @returns {HTMLButtonElement} the button element.\r\n *\r\n */\n\n }, {\n key: \"createSubmitButton\",\n value: function createSubmitButton(properties, callback) {\n function SubmitButton(properties, callback) {\n this.element = document.createElement('button');\n this.element.id = properties.id;\n this.element.className = properties.class;\n this.element.innerHTML = properties.innerHTML;\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addEvent(this.element, 'click', callback);\n }\n\n SubmitButton.prototype.getElement = function () {\n return this.element;\n };\n\n return new SubmitButton(properties, callback).getElement();\n }\n /**\r\n * Creates the modal window object inserting a contentElement object.\r\n */\n\n }, {\n key: \"create\",\n value: function create() {\n /*Modal Window Structure\r\n _____________________________________________________________________________________\r\n |wrs_modal_dialog_Container |\r\n | _________________________________________________________________________________ |\r\n | |title_bar minimize_button stack_button close_button | |\r\n | |_______________________________________________________________________________| |\r\n | |wrapper | |\r\n | | _____________________________________________________________________________ | |\r\n | | |content | | |\r\n | | | | | |\r\n | | | | | |\r\n | | |___________________________________________________________________________| | |\r\n | | _____________________________________________________________________________ | |\r\n | | |controls | | |\r\n | | | ___________________________________ | | |\r\n | | | |buttonContainer | | | |\r\n | | | | _______________________________ | | | |\r\n | | | | |button_accept | button_cancel| | | | |\r\n | | | |_|_____________ |______________|_| | | |\r\n | | |___________________________________________________________________________| | |\r\n | |_______________________________________________________________________________| |\r\n |___________________________________________________________________________________|*/\n this.titleBar.appendChild(this.closeDiv);\n this.titleBar.appendChild(this.stackDiv);\n this.titleBar.appendChild(this.maximizeDiv);\n this.titleBar.appendChild(this.minimizeDiv);\n this.titleBar.appendChild(this.title);\n\n if (this.deviceProperties['isDesktop']) {\n this.container.appendChild(this.titleBar);\n }\n\n this.wrapper.appendChild(this.contentContainer);\n this.wrapper.appendChild(this.controls);\n this.controls.appendChild(this.buttonContainer);\n this.buttonContainer.appendChild(this.submitButton);\n this.buttonContainer.appendChild(this.cancelButton);\n this.container.appendChild(this.wrapper); // Check if browser has scrollBar before modal has modified.\n\n this.recalculateScrollBar();\n document.body.appendChild(this.container);\n document.body.appendChild(this.overlay);\n\n if (this.deviceProperties['isDesktop']) {\n // Desktop.\n this.createModalWindowDesktop();\n this.createResizeButtons();\n this.addListeners(); // Maximize window only when the configuration is set and the device is not iOS or Android.\n\n if (_configuration_js__WEBPACK_IMPORTED_MODULE_3__[\"default\"].get('modalWindowFullScreen')) {\n this.maximize();\n }\n } else if (this.deviceProperties['isAndroid']) {\n this.createModalWindowAndroid();\n } else if (this.deviceProperties['isIOS'] && !this.deviceProperties['isMobile']) {\n this.createModalWindowIos();\n }\n\n if (this.contentManager != null) {\n this.contentManager.insert(this);\n }\n\n this.properties.open = true;\n this.properties.created = true; // Checks language directionality.\n\n if (this.isRTL()) {\n this.container.style.right = window.innerWidth - this.scrollbarWidth - this.container.offsetWidth + 'px';\n this.container.className += ' wrs_modal_rtl';\n }\n }\n /**\r\n * Creates a button in the modal object to resize it.\r\n */\n\n }, {\n key: \"createResizeButtons\",\n value: function createResizeButtons() {\n // This is a definition of Resize Button Bottom-Right\n this.resizerBR = document.createElement('div');\n this.resizerBR.className = 'wrs_bottom_right_resizer';\n this.resizerBR.innerHTML = '◢'; // This is a definition of Resize Button Top-Left\n\n this.resizerTL = document.createElement('div');\n this.resizerTL.className = 'wrs_bottom_left_resizer'; // Append resize buttons to modal\n\n this.container.appendChild(this.resizerBR);\n this.titleBar.appendChild(this.resizerTL); // Add events to resize on click and drag\n\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addEvent(this.resizerBR, 'mousedown', this.activateResizeStateBR.bind(this));\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addEvent(this.resizerTL, 'mousedown', this.activateResizeStateTL.bind(this));\n }\n /**\r\n * Initialize variables for Bottom-Right resize button\r\n * @param {MouseEvent} mouseEvent - mouse event.\r\n */\n\n }, {\n key: \"activateResizeStateBR\",\n value: function activateResizeStateBR(mouseEvent) {\n this.initializeResizeProperties(mouseEvent, false);\n }\n /**\r\n * Initialize variables for Top-Left resize button\r\n * @param {MouseEvent} mouseEvent - mouse event.\r\n */\n\n }, {\n key: \"activateResizeStateTL\",\n value: function activateResizeStateTL(mouseEvent) {\n this.initializeResizeProperties(mouseEvent, true);\n }\n /**\r\n * Common method to initialize variables at resize\r\n * @param {MouseEvent} mouseEvent - mouse event.\r\n */\n\n }, {\n key: \"initializeResizeProperties\",\n value: function initializeResizeProperties(mouseEvent, leftOption) {\n // Apply class for disable involuntary select text when drag.\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addClass(document.body, 'wrs_noselect');\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addClass(this.overlay, 'wrs_overlay_active');\n this.resizeDataObject = {\n x: this.eventClient(mouseEvent).X,\n y: this.eventClient(mouseEvent).Y\n }; // Save Initial state of modal to compare on drag and obtain the difference.\n\n this.initialWidth = parseInt(this.container.style.width);\n this.initialHeight = parseInt(this.container.style.height);\n\n if (!leftOption) {\n this.initialRight = parseInt(this.container.style.right);\n this.initialBottom = parseInt(this.container.style.bottom);\n } else {\n this.leftScale = true;\n }\n\n if (!this.initialRight) {\n this.initialRight = 0;\n }\n\n if (!this.initialBottom) {\n this.initialBottom = 0;\n } // Disable mouse events on editor when we start to drag modal.\n\n\n document.body.style['user-select'] = 'none';\n }\n /**\r\n * This method opens the modal window, restoring the previous state, position and metrics,\r\n * if exists. By default the modal object opens in stack mode.\r\n */\n\n }, {\n key: \"open\",\n value: function open() {\n //Removing close class.\n this.removeClass('wrs_closed'); // Hiding keyboard for mobile devices.\n\n if (this.deviceProperties['isIOS'] || this.deviceProperties['isAndroid'] || this.deviceProperties['isMobile']) {\n // Restore scale to 1\n this.restoreWebsiteScale();\n this.blockWebsiteScroll(); // Due to editor wait we need to wait until editor focus.\n\n setTimeout(function () {\n this.hideKeyboard();\n }.bind(this), 400);\n } // New modal window. He need to create the whole object.\n\n\n if (!this.properties.created) {\n this.create();\n } else {\n // Previous state closed. Open method can be called even the previous state is open,\n // for example updating the content of the modal object.\n if (!this.properties.open) {\n this.properties.open = true; // Restoring the previous open state: if the modal object has been closed\n // re-open it should preserve the state and the metrics.\n\n if (!this.deviceProperties.isAndroid && !this.deviceProperties.isIOS) {\n this.restoreState();\n }\n } // Maximize window only when the configuration is set and the device is not iOs or Android.\n\n\n if (this.deviceProperties['isDesktop'] && _configuration_js__WEBPACK_IMPORTED_MODULE_3__[\"default\"].get('modalWindowFullScreen')) {\n this.maximize();\n } // In iOS we need to recalculate the size of the modal object because\n // iOS keyboard is a float div which can overlay the modal object.\n\n\n if (this.deviceProperties['isIOS']) {\n this.iosSoftkeyboardOpened = false;\n this.setContainerHeight(\"100\" + this.iosMeasureUnit);\n }\n }\n\n if (this.contentManager.isEditorLoaded === false) {\n var listener = _listeners__WEBPACK_IMPORTED_MODULE_4__[\"default\"].newListener('onLoad', function () {\n this.contentManager.onOpen(this);\n }.bind(this));\n this.contentManager.addListener(listener);\n } else {\n this.contentManager.onOpen(this);\n }\n }\n /**\r\n * Closes modal window and restores viewport header.\r\n */\n\n }, {\n key: \"close\",\n value: function close() {\n this.removeClass('wrs_maximized');\n this.removeClass('wrs_minimized');\n this.removeClass('wrs_stack');\n this.addClass('wrs_closed');\n this.saveModalProperties();\n this.unblockWebsiteScroll();\n this.properties.open = false;\n }\n /**\r\n * Sets the website scale to one.\r\n */\n\n }, {\n key: \"restoreWebsiteScale\",\n value: function restoreWebsiteScale() {\n var viewportmeta = document.querySelector('meta[name=viewport]'); // Let the equal symbols in order to search and make meta's final content.\n\n var contentAttrsToUpdate = ['initial-scale=', 'minimum-scale=', 'maximum-scale='];\n var contentAttrsValuesToUpdate = ['1.0', '1.0', '1.0'];\n\n var setMetaAttrFunc = function setMetaAttrFunc(viewportelement, contentAttrsToUpdate) {\n var contentAttr = viewportelement.getAttribute('content'); // If it exists, we need to maintain old values and put our values.\n\n if (contentAttr) {\n var attrArray = contentAttr.split(',');\n var finalContentMeta = \"\";\n var oldAttrs = [];\n\n for (var i = 0; i < attrArray.length; i++) {\n var isAttrToUpdate = false;\n var j = 0;\n\n while (!isAttrToUpdate && j < contentAttrsToUpdate.length) {\n if (attrArray[i].indexOf(contentAttrsToUpdate[j])) {\n isAttrToUpdate = true;\n }\n\n j++;\n }\n\n if (!isAttrToUpdate) {\n oldAttrs.push(attrArray[i]);\n }\n }\n\n for (var _i = 0; _i < contentAttrsToUpdate.length; _i++) {\n var attr = contentAttrsToUpdate[_i] + contentAttrsValuesToUpdate[_i];\n finalContentMeta += _i == 0 ? attr : ',' + attr;\n }\n\n for (var _i2 = 0; _i2 < oldAttrs.length; _i2++) {\n finalContentMeta += ',' + oldAttrs[_i2];\n }\n\n viewportelement.setAttribute('content', finalContentMeta);\n viewportelement.setAttribute('content', contentAttr);\n } else {\n viewportelement.setAttribute('content', 'initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0');\n viewportelement.removeAttribute('content');\n }\n };\n\n if (!viewportmeta) {\n viewportmeta = document.createElement('meta');\n document.getElementsByTagName('head')[0].appendChild(viewportmeta);\n setMetaAttrFunc(viewportmeta, contentAttrsToUpdate, contentAttrsValuesToUpdate);\n viewportmeta.remove();\n } else {\n setMetaAttrFunc(viewportmeta, contentAttrsToUpdate, contentAttrsValuesToUpdate);\n }\n }\n /**\r\n * Adds an event to avoid touch scrolling.\r\n */\n\n }, {\n key: \"blockWebsiteScroll\",\n value: function blockWebsiteScroll() {\n document.body.addEventListener('touchmove', this.disableTouchMove, {\n passive: false\n });\n }\n /**\r\n * Removes the event to avoid touch scrolling.\r\n */\n\n }, {\n key: \"unblockWebsiteScroll\",\n value: function unblockWebsiteScroll() {\n document.body.removeEventListener('touchmove', this.disableTouchMove, {\n passive: false\n });\n }\n /**\r\n * Prevents the default event behavior to a MouseEvent.\r\n * @param {MouseEvent} mouseEvent - mouse event.\r\n */\n\n }, {\n key: \"disableTouchMove\",\n value: function disableTouchMove(mouseEvent) {\n mouseEvent.preventDefault();\n }\n /**\r\n * Util function to known if browser is IE11.\r\n * @returns {boolean} true if the browser is IE11. false otherwise.\r\n */\n\n }, {\n key: \"isIE11\",\n value: function isIE11() {\n if (navigator.userAgent.search(\"Msie/\") >= 0 || navigator.userAgent.search(\"Trident/\") >= 0 || navigator.userAgent.search(\"Edge/\") >= 0) {\n return true;\n }\n\n return false;\n }\n /**\r\n * Returns if the current language type is RTL.\r\n * @return {boolean} true if current language is RTL. false otherwise.\r\n */\n\n }, {\n key: \"isRTL\",\n value: function isRTL() {\n if (this.attributes.language == 'ar' || this.attributes.language == 'he') {\n return true;\n } else {\n return this.rtl;\n }\n\n ;\n }\n /**\r\n * Adds a class to all modal ModalDialog DOM elements.\r\n * @param {string} className - class name.\r\n */\n\n }, {\n key: \"addClass\",\n value: function addClass(className) {\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addClass(this.overlay, className);\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addClass(this.titleBar, className);\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addClass(this.overlay, className);\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addClass(this.container, className);\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addClass(this.contentContainer, className);\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addClass(this.stackDiv, className);\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addClass(this.minimizeDiv, className);\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addClass(this.maximizeDiv, className);\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addClass(this.wrapper, className);\n }\n /**\r\n * Remove a class from all modal DOM elements.\r\n * @param {string} className - class name.\r\n */\n\n }, {\n key: \"removeClass\",\n value: function removeClass(className) {\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].removeClass(this.overlay, className);\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].removeClass(this.titleBar, className);\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].removeClass(this.overlay, className);\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].removeClass(this.container, className);\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].removeClass(this.contentContainer, className);\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].removeClass(this.stackDiv, className);\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].removeClass(this.minimizeDiv, className);\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].removeClass(this.maximizeDiv, className);\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].removeClass(this.wrapper, className);\n }\n /**\r\n * Create modal dialog for desktop.\r\n */\n\n }, {\n key: \"createModalWindowDesktop\",\n value: function createModalWindowDesktop() {\n this.addClass('wrs_modal_desktop');\n this.stack();\n }\n /**\r\n * Create modal dialog for non android devices.\r\n */\n\n }, {\n key: \"createModalWindowAndroid\",\n value: function createModalWindowAndroid() {\n this.addClass('wrs_modal_android');\n window.addEventListener('resize', this.orientationChangeAndroidSoftkeyboard.bind(this));\n }\n /**\r\n * Create modal dialog for iOS devices.\r\n */\n\n }, {\n key: \"createModalWindowIos\",\n value: function createModalWindowIos() {\n this.addClass('wrs_modal_ios'); // Refresh the size when the orientation is changed\n\n window.addEventListener('resize', this.orientationChangeIosSoftkeyboard.bind(this));\n }\n /**\r\n * Restore previous state, position and size of previous stacked modal dialog.\r\n */\n\n }, {\n key: \"restoreState\",\n value: function restoreState() {\n if (this.properties.state == 'maximized') {\n // Reset states for prevent return to stack state.\n this.maximize();\n } else if (this.properties.state == 'minimized') {\n // Reset states for prevent return to stack state.\n this.properties.state = this.properties.previousState;\n this.properties.previousState = '';\n this.minimize();\n } else {\n this.stack();\n }\n }\n /**\r\n * Stacks the modal object.\r\n */\n\n }, {\n key: \"stack\",\n value: function stack() {\n this.properties.previousState = this.properties.state;\n this.properties.state = 'stack';\n this.removeClass('wrs_maximized');\n this.minimizeDiv.title = \"Minimise\";\n this.removeClass('wrs_minimized');\n this.addClass('wrs_stack');\n this.restoreModalProperties();\n\n if (typeof this.resizerBR !== 'undefined' && typeof this.resizerTL !== 'undefined') {\n this.setResizeButtonsVisibility();\n } // Need recalculate position of actual modal because window can was changed in fullscreenmode\n\n\n this.recalculateScrollBar();\n this.recalculatePosition();\n this.recalculateScale();\n this.focus();\n }\n /**\r\n * Minimizes the modal object\r\n */\n\n }, {\n key: \"minimize\",\n value: function minimize() {\n // Saving width, height, top and bottom parameters to restore when open\n this.saveModalProperties();\n\n if (this.properties.state == 'minimized' && this.properties.previousState == 'stack') {\n this.stack();\n } else if (this.properties.state == 'minimized' && this.properties.previousState == 'maximized') {\n this.maximize();\n } else {\n // Setting css to prevent important tag into css style\n this.container.style.height = \"30px\";\n this.container.style.width = \"250px\";\n this.container.style.bottom = \"0px\";\n this.container.style.right = \"10px\";\n this.removeListeners();\n this.properties.previousState = this.properties.state;\n this.properties.state = \"minimized\";\n this.setResizeButtonsVisibility();\n this.minimizeDiv.title = \"Maximise\";\n\n if (_util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].containsClass(this.overlay, 'wrs_stack')) {\n this.removeClass('wrs_stack');\n } else {\n this.removeClass('wrs_maximized');\n }\n\n this.addClass('wrs_minimized');\n }\n }\n /**\r\n * Maximizes the modal object.\r\n */\n\n }, {\n key: \"maximize\",\n value: function maximize() {\n // Saving width, height, top and bottom parameters to restore when open\n this.saveModalProperties();\n\n if (this.properties.state != 'maximized') {\n this.properties.previousState = this.properties.state;\n this.properties.state = 'maximized';\n } // Don't permit resize on maximize mode.\n\n\n this.setResizeButtonsVisibility();\n\n if (_util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].containsClass(this.overlay, 'wrs_minimized')) {\n this.minimizeDiv.title = \"Minimise\";\n this.removeClass('wrs_minimized');\n } else if (_util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].containsClass(this.overlay, 'wrs_stack')) {\n this.container.style.left = null;\n this.container.style.top = null;\n this.removeClass('wrs_stack');\n }\n\n this.addClass('wrs_maximized'); // Set size to 80% screen with a max size.\n\n this.setSize(parseInt(window.innerHeight * 0.8), parseInt(window.innerWidth * 0.8));\n var sizeModificated = false;\n\n if (this.container.clientHeight > 700) {\n this.container.style.height = '700px';\n sizeModificated = true;\n }\n\n if (this.container.clientWidth > 1200) {\n this.container.style.width = '1200px';\n sizeModificated = true;\n } // Setting modal position in center on screen.\n\n\n this.setPosition(window.innerHeight / 2 - this.container.offsetHeight / 2, window.innerWidth / 2 - this.container.offsetWidth / 2);\n this.recalculateScale();\n this.recalculatePosition();\n this.recalculateSize();\n this.focus();\n }\n /**\r\n * Sets modal size.\r\n * @param {number} height - height of the ModalDialog\r\n * @param {number} width - width of the ModalDialog.\r\n */\n\n }, {\n key: \"setSize\",\n value: function setSize(height, width) {\n this.container.style.height = height + 'px';\n this.container.style.width = width + 'px';\n this.recalculateSize();\n }\n /**\r\n * Sets modal position using bottom and right style attributes.\r\n * @param {number} bottom - bottom attribute.\r\n * @param {number} right - right attribute.\r\n */\n\n }, {\n key: \"setPosition\",\n value: function setPosition(bottom, right) {\n this.container.style.bottom = bottom + 'px';\n this.container.style.right = right + 'px';\n }\n /**\r\n * Saves position and size parameters of and open ModalDialog. This attributes\r\n * are needed to restore it on re-open.\r\n */\n\n }, {\n key: \"saveModalProperties\",\n value: function saveModalProperties() {\n // Saving values of modal only when modal is in stack state.\n if (this.properties.state == 'stack') {\n this.properties.position.bottom = parseInt(this.container.style.bottom);\n this.properties.position.right = parseInt(this.container.style.right);\n this.properties.size.width = parseInt(this.container.style.width);\n this.properties.size.height = parseInt(this.container.style.height);\n }\n }\n /**\r\n * Restore ModalDialog position and size parameters.\r\n */\n\n }, {\n key: \"restoreModalProperties\",\n value: function restoreModalProperties() {\n if (this.properties.state == 'stack') {\n // Restoring Bottom and Right values from last modal\n this.setPosition(this.properties.position.bottom, this.properties.position.right); // Restoring Height and Left values from last modal\n\n this.setSize(this.properties.size.height, this.properties.size.width);\n }\n }\n /**\r\n * Sets the modal dialog initial size.\r\n */\n\n }, {\n key: \"recalculateSize\",\n value: function recalculateSize() {\n this.wrapper.style.width = this.container.clientWidth - 12 + 'px';\n this.wrapper.style.height = this.container.clientHeight - 38 + 'px';\n this.contentContainer.style.height = parseInt(this.wrapper.offsetHeight - 50) + 'px';\n }\n /**\r\n * Enable or disable visibility of resize buttons in modal window depend on state.\r\n */\n\n }, {\n key: \"setResizeButtonsVisibility\",\n value: function setResizeButtonsVisibility() {\n if (this.properties.state == 'stack') {\n this.resizerTL.style.visibility = 'visible';\n this.resizerBR.style.visibility = 'visible';\n } else {\n this.resizerTL.style.visibility = 'hidden';\n this.resizerBR.style.visibility = 'hidden';\n }\n }\n /**\r\n * Makes an object draggable adding mouse and touch events.\r\n */\n\n }, {\n key: \"addListeners\",\n value: function addListeners() {\n // Button events (maximize, minimize, stack and close).\n this.maximizeDiv.addEventListener('click', this.maximize.bind(this), true);\n this.stackDiv.addEventListener('click', this.stack.bind(this), true);\n this.minimizeDiv.addEventListener('click', this.minimize.bind(this), true);\n this.closeDiv.addEventListener('click', this.cancelAction.bind(this)); // Mouse events.\n\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addEvent(window, 'mousedown', this.startDrag.bind(this));\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addEvent(window, 'mouseup', this.stopDrag.bind(this));\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addEvent(window, 'mousemove', this.drag.bind(this));\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addEvent(window, 'resize', this.onWindowResize.bind(this)); // Key events.\n\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addEvent(window, 'keydown', this.onKeyDown.bind(this));\n }\n /**\r\n * Removes draggable events from an object.\r\n */\n\n }, {\n key: \"removeListeners\",\n value: function removeListeners() {\n // Mouse events.\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].removeEvent(window, 'mousedown', this.startDrag);\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].removeEvent(window, 'mouseup', this.stopDrag);\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].removeEvent(window, 'mousemove', this.drag);\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].removeEvent(window, 'resize', this.onWindowResize); // Key events\n\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].removeEvent(window, 'keydown', this.onKeyDown);\n }\n /**\r\n * Returns mouse or touch coordinates (on touch events ev.ClientX doesn't exists)\r\n * @param {MouseEvent} mouseEvent - mouse event.\r\n * @return {Object} with the X and Y coordinates.\r\n */\n\n }, {\n key: \"eventClient\",\n value: function eventClient(mouseEvent) {\n if (typeof mouseEvent.clientX == 'undefined' && mouseEvent.changedTouches) {\n var client = {\n X: mouseEvent.changedTouches[0].clientX,\n Y: mouseEvent.changedTouches[0].clientY\n };\n return client;\n } else {\n client = {\n X: mouseEvent.clientX,\n Y: mouseEvent.clientY\n };\n return client;\n }\n }\n /**\r\n * Start drag function: set the object dragDataObject with the draggable object offsets coordinates.\r\n * when drag starts (on touchstart or mousedown events).\r\n * @param {MouseEvent} mouseEvent - touchstart or mousedown event.\r\n */\n\n }, {\n key: \"startDrag\",\n value: function startDrag(mouseEvent) {\n if (this.properties.state == 'minimized') {\n return;\n }\n\n if (mouseEvent.target === this.title) {\n if (typeof this.dragDataObject === 'undefined' || this.dragDataObject === null) {\n mouseEvent = mouseEvent || event; // Save first click mouse point on screen\n\n this.dragDataObject = {\n x: this.eventClient(mouseEvent).X,\n y: this.eventClient(mouseEvent).Y\n }; // Reset last drag position when start drag\n\n this.lastDrag = {\n x: \"0px\",\n y: \"0px\"\n }; // Init right and bottom values for window modal if it isn't exist.\n\n if (this.container.style.right == '') {\n this.container.style.right = \"0px\";\n }\n\n if (this.container.style.bottom == '') {\n this.container.style.bottom = \"0px\";\n } // Needed for IE11 for apply disabled mouse events on editor because iexplorer need a dinamic object to apply this property.\n\n\n if (this.isIE11()) {} // this.iframe.style['position'] = 'relative';\n // Apply class for disable involuntary select text when drag.\n\n\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addClass(document.body, 'wrs_noselect');\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addClass(this.overlay, 'wrs_overlay_active'); // Obtain screen limits for prevent overflow.\n\n this.limitWindow = this.getLimitWindow();\n }\n }\n }\n /**\r\n * Updates dragDataObject with the draggable object coordinates when the draggable object is being moved.\r\n * @param {MouseEvent} mouseEvent - the mouse event.\r\n */\n\n }, {\n key: \"drag\",\n value: function drag(mouseEvent) {\n if (this.dragDataObject) {\n mouseEvent.preventDefault();\n mouseEvent = mouseEvent || event; // Calculate max and min between actual mouse position and limit of screeen. It restric the movement of modal into window.\n\n var limitY = Math.min(this.eventClient(mouseEvent).Y, this.limitWindow.minPointer.y);\n limitY = Math.max(this.limitWindow.maxPointer.y, limitY);\n var limitX = Math.min(this.eventClient(mouseEvent).X, this.limitWindow.minPointer.x);\n limitX = Math.max(this.limitWindow.maxPointer.x, limitX); // Substract limit with first position to obtain relative pixels increment to the anchor point.\n\n var dragX = limitX - this.dragDataObject.x + \"px\";\n var dragY = limitY - this.dragDataObject.y + \"px\"; // Save last valid position of modal before window overflow.\n\n this.lastDrag = {\n x: dragX,\n y: dragY\n }; // This move modal with hadware acceleration.\n\n this.container.style.transform = \"translate3d(\" + dragX + \",\" + dragY + \",0)\";\n }\n\n if (this.resizeDataObject) {\n var limitX = Math.min(this.eventClient(mouseEvent).X, window.innerWidth - this.scrollbarWidth - 7);\n var limitY = Math.min(this.eventClient(mouseEvent).Y, window.innerHeight - 7);\n\n if (limitX < 0) {\n limitX = 0;\n }\n\n if (limitY < 0) {\n limitY = 0;\n }\n\n var scaleMultiplier;\n\n if (this.leftScale) {\n scaleMultiplier = -1;\n } else {\n scaleMultiplier = 1;\n }\n\n this.container.style.width = this.initialWidth + scaleMultiplier * (limitX - this.resizeDataObject.x) + 'px';\n this.container.style.height = this.initialHeight + scaleMultiplier * (limitY - this.resizeDataObject.y) + 'px';\n\n if (!this.leftScale) {\n if (this.resizeDataObject.x - limitX - this.initialWidth < -580) {\n this.container.style.right = this.initialRight - (limitX - this.resizeDataObject.x) + 'px';\n } else {\n this.container.style.right = this.initialRight + this.initialWidth - 580 + \"px\";\n this.container.style.width = \"580px\";\n }\n\n if (this.resizeDataObject.y - limitY < this.initialHeight - 338) {\n this.container.style.bottom = this.initialBottom - (limitY - this.resizeDataObject.y) + 'px';\n } else {\n this.container.style.bottom = this.initialBottom + this.initialHeight - 338 + \"px\";\n this.container.style.height = \"338px\";\n }\n }\n\n this.recalculateScale();\n this.recalculatePosition();\n }\n }\n /**\r\n * Returns the boundaries of actual window to limit modal movement.\r\n * @return {Object} Object containing mouseX and mouseY coordinates of actual mouse on screen.\r\n */\n\n }, {\n key: \"getLimitWindow\",\n value: function getLimitWindow() {\n // Obtain dimensions of window page.\n var maxWidth = window.innerWidth;\n var maxHeight = window.innerHeight; // Calculate relative position of mouse point into window.\n\n var offSetToolbarY = this.container.offsetHeight + parseInt(this.container.style.bottom) - (maxHeight - (this.dragDataObject.y - window.pageXOffset));\n var offSetToolbarX = maxWidth - this.scrollbarWidth - (this.dragDataObject.x - window.pageXOffset) - parseInt(this.container.style.right); // Calculate limits with sizes of window, modal and mouse position.\n\n var minPointerY = maxHeight - this.container.offsetHeight + offSetToolbarY;\n var maxPointerY = this.title.offsetHeight - (this.title.offsetHeight - offSetToolbarY);\n var minPointerX = maxWidth - offSetToolbarX - this.scrollbarWidth;\n var maxPointerX = this.container.offsetWidth - offSetToolbarX;\n var minPointer = {\n x: minPointerX,\n y: minPointerY\n };\n var maxPointer = {\n x: maxPointerX,\n y: maxPointerY\n };\n return {\n minPointer: minPointer,\n maxPointer: maxPointer\n };\n }\n /**\r\n * Returns the scrollbar width size of browser\r\n * @returns {number} the scrollbar width.\r\n */\n\n }, {\n key: \"getScrollBarWidth\",\n value: function getScrollBarWidth() {\n // Create a paragraph with full width of page.\n var inner = document.createElement('p');\n inner.style.width = \"100%\";\n inner.style.height = \"200px\"; // Create a hidden div to compare sizes.\n\n var outer = document.createElement('div');\n outer.style.position = \"absolute\";\n outer.style.top = \"0px\";\n outer.style.left = \"0px\";\n outer.style.visibility = \"hidden\";\n outer.style.width = \"200px\";\n outer.style.height = \"150px\";\n outer.style.overflow = \"hidden\";\n outer.appendChild(inner);\n document.body.appendChild(outer);\n var widthOuter = inner.offsetWidth; // Change type overflow of paragraph for measure scrollbar.\n\n outer.style.overflow = 'scroll';\n var widthInner = inner.offsetWidth; // If measure is the same, we compare with internal div.\n\n if (widthOuter == widthInner) {\n widthInner = outer.clientWidth;\n }\n\n document.body.removeChild(outer);\n return widthOuter - widthInner;\n }\n /**\r\n * Set the dragDataObject to null.\r\n */\n\n }, {\n key: \"stopDrag\",\n value: function stopDrag() {\n // Due to we have multiple events that call this function, we need only to execute the next modifiers one time,\n // when the user stops to drag and dragDataObject is not null (the object to drag is attached).\n if (this.dragDataObject || this.resizeDataObject) {\n // If modal doesn't change, it's not necessary to set position with interpolation\n this.container.style.transform = '';\n\n if (this.dragDataObject) {\n this.container.style.right = parseInt(this.container.style.right) - parseInt(this.lastDrag.x) + \"px\";\n this.container.style.bottom = parseInt(this.container.style.bottom) - parseInt(this.lastDrag.y) + \"px\";\n } // We make focus on editor after drag modal windows to prevent lose focus.\n\n\n this.focus(); // Restore mouse events on iframe\n // this.iframe.style['pointer-events'] = 'auto';\n\n document.body.style['user-select'] = ''; // Restore static state of iframe if we use Internet Explorer.\n\n if (this.isIE11()) {} // this.iframe.style['position'] = null;\n // Active text select event\n\n\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].removeClass(document.body, 'wrs_noselect');\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].removeClass(this.overlay, 'wrs_overlay_active');\n }\n\n this.dragDataObject = null;\n this.resizeDataObject = null;\n this.initialWidth = null;\n this.leftScale = null;\n }\n /**\r\n * Recalculates scale for modal when resize browser window.\r\n */\n\n }, {\n key: \"onWindowResize\",\n value: function onWindowResize() {\n this.recalculateScrollBar();\n this.recalculatePosition();\n this.recalculateScale();\n }\n /**\r\n * Triggers keyboard events:\r\n * - Tab key tab to go to submit button.\r\n * - Esc key to close the modal dialog.\r\n * @param {KeyboardEvent} keyboardEvent - the keyboard event.\r\n */\n\n }, {\n key: \"onKeyDown\",\n value: function onKeyDown(keyboardEvent) {\n if (keyboardEvent.key !== undefined && keyboardEvent.repeat === false) {\n // Code for detect Esc event\n if (keyboardEvent.key === \"Escape\" || keyboardEvent.key === 'Esc') {\n if (this.properties.open) {\n this.cancelAction();\n }\n } // Code for detect Tab event\n\n\n if (keyboardEvent.key === \"Tab\") {\n this.submitButton.focus();\n keyboardEvent.preventDefault();\n }\n }\n }\n /**\r\n * Recalculating position for modal dialog when the browser is resized.\r\n */\n\n }, {\n key: \"recalculatePosition\",\n value: function recalculatePosition() {\n this.container.style.right = Math.min(parseInt(this.container.style.right), window.innerWidth - this.scrollbarWidth - this.container.offsetWidth) + \"px\";\n\n if (parseInt(this.container.style.right) < 0) {\n this.container.style.right = \"0px\";\n }\n\n this.container.style.bottom = Math.min(parseInt(this.container.style.bottom), window.innerHeight - this.container.offsetHeight) + \"px\";\n\n if (parseInt(this.container.style.bottom) < 0) {\n this.container.style.bottom = \"0px\";\n }\n }\n /**\r\n * Recalculating scale for modal when the browser is resized.\r\n */\n\n }, {\n key: \"recalculateScale\",\n value: function recalculateScale() {\n var sizeModificated = false;\n\n if (parseInt(this.container.style.width) > 580) {\n this.container.style.width = Math.min(parseInt(this.container.style.width), window.innerWidth - this.scrollbarWidth) + \"px\";\n sizeModificated = true;\n } else {\n this.container.style.width = \"580px\";\n sizeModificated = true;\n }\n\n if (parseInt(this.container.style.height) > 338) {\n this.container.style.height = Math.min(parseInt(this.container.style.height), window.innerHeight) + \"px\";\n sizeModificated = true;\n } else {\n this.container.style.height = \"338px\";\n sizeModificated = true;\n }\n\n if (sizeModificated) {\n this.recalculateSize();\n }\n }\n /**\r\n * Recalculating width of browser scroll bar.\r\n */\n\n }, {\n key: \"recalculateScrollBar\",\n value: function recalculateScrollBar() {\n this.hasScrollBar = window.innerWidth > document.documentElement.clientWidth;\n\n if (this.hasScrollBar) {\n this.scrollbarWidth = this.getScrollBarWidth();\n } else {\n this.scrollbarWidth = 0;\n }\n }\n /**\r\n * Hide soft keyboards on iOS devices.\r\n */\n\n }, {\n key: \"hideKeyboard\",\n value: function hideKeyboard() {\n document.activeElement.blur();\n }\n /**\r\n * Focus to contentManager object.\r\n */\n\n }, {\n key: \"focus\",\n value: function focus() {\n if (this.contentManager != null && typeof this.contentManager.onFocus !== 'undefined') {\n this.contentManager.onFocus();\n }\n }\n /**\r\n * Returns true when the device is on portrait mode.\r\n */\n\n }, {\n key: \"portraitMode\",\n value: function portraitMode() {\n return window.innerHeight > window.innerWidth;\n }\n /**\r\n * Change container sizes when the keyboard is opened on iOS.\r\n */\n\n }, {\n key: \"openedIosSoftkeyboard\",\n value: function openedIosSoftkeyboard() {\n if (!this.iosSoftkeyboardOpened && this.iosDivHeight != null && this.iosDivHeight == \"100\" + this.iosMeasureUnit) {\n if (this.portraitMode()) {\n this.setContainerHeight(\"63\" + this.iosMeasureUnit);\n } else {\n this.setContainerHeight(\"40\" + this.iosMeasureUnit);\n }\n }\n\n this.iosSoftkeyboardOpened = true;\n }\n /**\r\n * Change container sizes when the keyboard is closed on iOS.\r\n */\n\n }, {\n key: \"closedIosSoftkeyboard\",\n value: function closedIosSoftkeyboard() {\n this.iosSoftkeyboardOpened = false;\n this.setContainerHeight(\"100\" + this.iosMeasureUnit);\n }\n /**\r\n * Change container sizes when orientation is changed on iOS.\r\n */\n\n }, {\n key: \"orientationChangeIosSoftkeyboard\",\n value: function orientationChangeIosSoftkeyboard() {\n if (this.iosSoftkeyboardOpened) {\n if (this.portraitMode()) {\n this.setContainerHeight(\"63\" + this.iosMeasureUnit);\n } else {\n this.setContainerHeight(\"40\" + this.iosMeasureUnit);\n }\n } else {\n this.setContainerHeight(\"100\" + this.iosMeasureUnit);\n }\n }\n /**\r\n * Change container sizes when orientation is changed on Android.\r\n */\n\n }, {\n key: \"orientationChangeAndroidSoftkeyboard\",\n value: function orientationChangeAndroidSoftkeyboard() {\n this.setContainerHeight(\"100%\");\n }\n /**\r\n * Set iframe container height.\r\n * @param {number} height - new height.\r\n */\n\n }, {\n key: \"setContainerHeight\",\n value: function setContainerHeight(height) {\n this.iosDivHeight = height;\n this.wrapper.style.height = height;\n }\n /**\r\n * Check content of editor before close action.\r\n */\n\n }, {\n key: \"showPopUpMessage\",\n value: function showPopUpMessage() {\n if (this.properties.state == 'minimized') {\n this.stack();\n }\n\n this.popup.show();\n }\n /**\r\n * Sets the tithle of the modal dialog.\r\n * @param {string} title - modal dialog title.\r\n */\n\n }, {\n key: \"setTitle\",\n value: function setTitle(title) {\n this.title.innerHTML = title;\n }\n /**\r\n * Returns the id of an element, adding the instance number to\r\n * the element class name:\r\n * className --> className[idNumber]\r\n * @param {string} className - the element class name.\r\n * @returns {string} a string appending the instance id to the className.\r\n */\n\n }, {\n key: \"getElementId\",\n value: function getElementId(className) {\n return className + \"[\" + this.instanceId + \"]\";\n }\n }]);\n\n return ModalDialog;\n}();\n\n\n\n//# sourceURL=webpack:///./core/src/modal.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"default\", function() { return ModalDialog; });\n/* harmony import */ var _popupmessage_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./popupmessage.js */ \"./core/src/popupmessage.js\");\n/* harmony import */ var _core_src_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./core.src.js */ \"./core/src/core.src.js\");\n/* harmony import */ var _util_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./util.js */ \"./core/src/util.js\");\n/* harmony import */ var _configuration_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./configuration.js */ \"./core/src/configuration.js\");\n/* harmony import */ var _listeners__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./listeners */ \"./core/src/listeners.js\");\n/* harmony import */ var _contentmanager_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./contentmanager.js */ \"./core/src/contentmanager.js\");\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\n\n\n\n\n\n\n/**\r\n * This class represents a modal dialog. The modal dialog admits a ContentManager instance in order\r\n * to manage the content of the dialog.\r\n */\n\nvar ModalDialog =\n/*#__PURE__*/\nfunction () {\n /**\r\n * Modal dialog constructor\r\n * @param {Object} modalDialogAttributes - An object containing all modal dialog attributes.\r\n */\n function ModalDialog(modalDialogAttributes) {\n _classCallCheck(this, ModalDialog);\n\n this.attributes = modalDialogAttributes; // Metrics\n\n var ua = navigator.userAgent.toLowerCase();\n var isAndroid = ua.indexOf(\"android\") > -1;\n var isIOS = ua.indexOf(\"ipad\") > -1 || ua.indexOf(\"iphone\") > -1;\n this.iosSoftkeyboardOpened = false;\n this.iosMeasureUnit = ua.indexOf(\"crios\") == -1 ? \"%\" : \"vh\";\n this.iosDivHeight = \"100\" + this.iosMeasureUnit;\n var deviceWidth = window.outerWidth;\n var deviceHeight = window.outerHeight;\n var landscape = deviceWidth > deviceHeight;\n var portrait = deviceWidth < deviceHeight; // TODO: Detect isMobile without using editor metrics.\n\n var isMobile = landscape && this.attributes.height > deviceHeight || portrait && this.attributes.width > deviceWidth ? true : false; // Obtain number of current instance\n\n this.instanceId = document.getElementsByClassName(\"wrs_modal_dialogContainer\").length; // Device object properties.\n\n this.deviceProperties = {\n orientation: landscape ? 'landscape' : 'portait',\n isAndroid: isAndroid ? true : false,\n isIOS: isIOS ? true : false,\n isMobile: isMobile,\n isDesktop: !isMobile && !isIOS && !isAndroid\n };\n this.properties = {\n created: false,\n state: '',\n previousState: '',\n position: {\n bottom: 0,\n right: 10\n },\n size: {\n height: 338,\n width: 580\n }\n };\n var attributes = {};\n attributes.class = 'wrs_modal_overlay';\n attributes.id = this.getElementId(attributes.class);\n this.overlay = _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].createElement('div', attributes);\n attributes = {};\n attributes.class = 'wrs_modal_title_bar';\n attributes.id = this.getElementId(attributes.class);\n this.titleBar = _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].createElement('div', attributes);\n attributes = {};\n attributes.class = 'wrs_modal_title';\n attributes.id = this.getElementId(attributes.class);\n this.title = _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].createElement('div', attributes);\n this.title.innerHTML = '';\n attributes = {};\n attributes.class = 'wrs_modal_close_button';\n attributes.id = this.getElementId(attributes.class);\n attributes.title = _core_src_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].getStringManager().getString('close');\n this.closeDiv = _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].createElement('a', attributes);\n ;\n this.closeDiv.setAttribute('role', 'button');\n attributes = {};\n attributes.class = 'wrs_modal_stack_button';\n attributes.id = this.getElementId(attributes.class);\n attributes.title = \"Exit full-screen\";\n this.stackDiv = _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].createElement('a', attributes);\n this.stackDiv.setAttribute('role', 'button');\n attributes = {};\n attributes.class = 'wrs_modal_maximize_button';\n attributes.id = this.getElementId(attributes.class);\n attributes.title = _core_src_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].getStringManager().getString('fullscreen');\n this.maximizeDiv = _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].createElement('a', attributes);\n this.maximizeDiv.setAttribute('role', 'button');\n attributes = {};\n attributes.class = 'wrs_modal_minimize_button';\n attributes.id = this.getElementId(attributes.class);\n attributes.title = _core_src_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].getStringManager().getString('minimise');\n this.minimizeDiv = _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].createElement('a', attributes);\n this.minimizeDiv.setAttribute('role', 'button');\n attributes = {};\n attributes.class = 'wrs_modal_dialogContainer';\n attributes.id = this.getElementId(attributes.class);\n this.container = _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].createElement('div', attributes);\n attributes = {};\n attributes.class = 'wrs_modal_wrapper';\n attributes.id = this.getElementId(attributes.class);\n this.wrapper = _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].createElement('div', attributes);\n attributes = {};\n attributes.class = 'wrs_content_container';\n attributes.id = this.getElementId(attributes.class);\n this.contentContainer = _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].createElement('div', attributes);\n attributes = {};\n attributes.class = 'wrs_modal_controls';\n attributes.id = this.getElementId(attributes.class);\n this.controls = _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].createElement('div', attributes);\n attributes = {};\n attributes.class = 'wrs_modal_buttons_container';\n attributes.id = this.getElementId(attributes.class);\n this.buttonContainer = _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].createElement('div', attributes); // Buttons: all button must be created using createSubmitButton method.\n\n this.submitButton = this.createSubmitButton({\n id: this.getElementId('wrs_modal_button_accept'),\n class: 'wrs_modal_button_accept',\n innerHTML: _core_src_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].getStringManager().getString('accept')\n }, this.submitAction.bind(this));\n this.cancelButton = this.createSubmitButton({\n id: this.getElementId('wrs_modal_button_cancel'),\n class: 'wrs_modal_button_cancel',\n innerHTML: _core_src_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].getStringManager().getString('cancel')\n }, this.cancelAction.bind(this));\n this.contentManager = null; // Overlay popup.\n\n var popupStrings = {\n 'cancelString': _core_src_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].getStringManager().getString('cancel'),\n 'submitString': _core_src_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].getStringManager().getString('close'),\n 'message': _core_src_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].getStringManager().getString('close_modal_warning')\n };\n var callbacks = {\n 'closeCallback': function () {\n this.close();\n }.bind(this),\n 'cancelCallback': function () {\n this.focus();\n }.bind(this)\n };\n var popupupProperties = {\n 'overlayElement': this.container,\n 'callbacks': callbacks,\n 'strings': popupStrings\n };\n this.popup = new _popupmessage_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"](popupupProperties);\n /**\r\n * Indicates if directionality of the modal dialog is RTL. false by default.\r\n * @type {boolean}\r\n */\n\n this.rtl = false;\n\n if ('rtl' in this.attributes) {\n this.rtl = this.attributes.rtl;\n } // Event handlers need modal instance context.\n\n\n this.handleOpenedIosSoftkeyboard = this.handleOpenedIosSoftkeyboard.bind(this);\n this.handleClosedIosSoftkeyboard = this.handleClosedIosSoftkeyboard.bind(this);\n }\n /**\r\n * This method sets an ContentManager instance to ModalDialog. ContentManager\r\n * manages the logic of ModalDialog content: submit, update, close and changes.\r\n * @param {ContentManager} contentManager - ContentManager instance.\r\n */\n\n\n _createClass(ModalDialog, [{\n key: \"setContentManager\",\n value: function setContentManager(contentManager) {\n this.contentManager = contentManager;\n }\n /**\r\n * Returns the modal contentElement object.\r\n * @returns {ContentManager} the instance of the ContentManager class.\r\n */\n\n }, {\n key: \"getContentManager\",\n value: function getContentManager() {\n return this.contentManager;\n }\n /**\r\n * This method is called when the modal object has been submitted. Calls\r\n * contentElement submitAction method - if exists - and closes the modal\r\n * object. No logic about the content should be placed here,\r\n * contentElement.submitAction is the responsible of the content logic.\r\n */\n\n }, {\n key: \"submitAction\",\n value: function submitAction() {\n if (typeof this.contentManager.submitAction !== 'undefined') {\n this.contentManager.submitAction();\n }\n\n this.close();\n }\n /**\r\n * This method is called when the modal object has been cancelled. If\r\n * contentElement has implemented hasChanges method, a confirm popup\r\n * will be shown if hasChanges returns true.\r\n */\n\n }, {\n key: \"cancelAction\",\n value: function cancelAction() {\n if (typeof this.contentManager.hasChanges === 'undefined') {\n this.close();\n } else if (!this.contentManager.hasChanges()) {\n this.close();\n } else {\n this.showPopUpMessage();\n }\n }\n /**\r\n * Returns a button element.\r\n * @param {Object} properties - input button properties.\r\n * @param {string} properties.class - input button class.\r\n * @param {string} properties.innerHTML - input button innerHTML.\r\n * @param {Object} callback - callback function associated to click event.\r\n * @returns {HTMLButtonElement} the button element.\r\n *\r\n */\n\n }, {\n key: \"createSubmitButton\",\n value: function createSubmitButton(properties, callback) {\n function SubmitButton(properties, callback) {\n this.element = document.createElement('button');\n this.element.id = properties.id;\n this.element.className = properties.class;\n this.element.innerHTML = properties.innerHTML;\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addEvent(this.element, 'click', callback);\n }\n\n SubmitButton.prototype.getElement = function () {\n return this.element;\n };\n\n return new SubmitButton(properties, callback).getElement();\n }\n /**\r\n * Creates the modal window object inserting a contentElement object.\r\n */\n\n }, {\n key: \"create\",\n value: function create() {\n /*Modal Window Structure\r\n _____________________________________________________________________________________\r\n |wrs_modal_dialog_Container |\r\n | _________________________________________________________________________________ |\r\n | |title_bar minimize_button stack_button close_button | |\r\n | |_______________________________________________________________________________| |\r\n | |wrapper | |\r\n | | _____________________________________________________________________________ | |\r\n | | |content | | |\r\n | | | | | |\r\n | | | | | |\r\n | | |___________________________________________________________________________| | |\r\n | | _____________________________________________________________________________ | |\r\n | | |controls | | |\r\n | | | ___________________________________ | | |\r\n | | | |buttonContainer | | | |\r\n | | | | _______________________________ | | | |\r\n | | | | |button_accept | button_cancel| | | | |\r\n | | | |_|_____________ |______________|_| | | |\r\n | | |___________________________________________________________________________| | |\r\n | |_______________________________________________________________________________| |\r\n |___________________________________________________________________________________|*/\n this.titleBar.appendChild(this.closeDiv);\n this.titleBar.appendChild(this.stackDiv);\n this.titleBar.appendChild(this.maximizeDiv);\n this.titleBar.appendChild(this.minimizeDiv);\n this.titleBar.appendChild(this.title);\n\n if (this.deviceProperties['isDesktop']) {\n this.container.appendChild(this.titleBar);\n }\n\n this.wrapper.appendChild(this.contentContainer);\n this.wrapper.appendChild(this.controls);\n this.controls.appendChild(this.buttonContainer);\n this.buttonContainer.appendChild(this.submitButton);\n this.buttonContainer.appendChild(this.cancelButton);\n this.container.appendChild(this.wrapper); // Check if browser has scrollBar before modal has modified.\n\n this.recalculateScrollBar();\n document.body.appendChild(this.container);\n document.body.appendChild(this.overlay);\n\n if (this.deviceProperties['isDesktop']) {\n // Desktop.\n this.createModalWindowDesktop();\n this.createResizeButtons();\n this.addListeners(); // Maximize window only when the configuration is set and the device is not iOS or Android.\n\n if (_configuration_js__WEBPACK_IMPORTED_MODULE_3__[\"default\"].get('modalWindowFullScreen')) {\n this.maximize();\n }\n } else if (this.deviceProperties['isAndroid']) {\n this.createModalWindowAndroid();\n } else if (this.deviceProperties['isIOS'] && !this.deviceProperties['isMobile']) {\n this.createModalWindowIos();\n }\n\n if (this.contentManager != null) {\n this.contentManager.insert(this);\n }\n\n this.properties.open = true;\n this.properties.created = true; // Checks language directionality.\n\n if (this.isRTL()) {\n this.container.style.right = window.innerWidth - this.scrollbarWidth - this.container.offsetWidth + 'px';\n this.container.className += ' wrs_modal_rtl';\n }\n }\n /**\r\n * Creates a button in the modal object to resize it.\r\n */\n\n }, {\n key: \"createResizeButtons\",\n value: function createResizeButtons() {\n // This is a definition of Resize Button Bottom-Right\n this.resizerBR = document.createElement('div');\n this.resizerBR.className = 'wrs_bottom_right_resizer';\n this.resizerBR.innerHTML = '◢'; // This is a definition of Resize Button Top-Left\n\n this.resizerTL = document.createElement('div');\n this.resizerTL.className = 'wrs_bottom_left_resizer'; // Append resize buttons to modal\n\n this.container.appendChild(this.resizerBR);\n this.titleBar.appendChild(this.resizerTL); // Add events to resize on click and drag\n\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addEvent(this.resizerBR, 'mousedown', this.activateResizeStateBR.bind(this));\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addEvent(this.resizerTL, 'mousedown', this.activateResizeStateTL.bind(this));\n }\n /**\r\n * Initialize variables for Bottom-Right resize button\r\n * @param {MouseEvent} mouseEvent - mouse event.\r\n */\n\n }, {\n key: \"activateResizeStateBR\",\n value: function activateResizeStateBR(mouseEvent) {\n this.initializeResizeProperties(mouseEvent, false);\n }\n /**\r\n * Initialize variables for Top-Left resize button\r\n * @param {MouseEvent} mouseEvent - mouse event.\r\n */\n\n }, {\n key: \"activateResizeStateTL\",\n value: function activateResizeStateTL(mouseEvent) {\n this.initializeResizeProperties(mouseEvent, true);\n }\n /**\r\n * Common method to initialize variables at resize\r\n * @param {MouseEvent} mouseEvent - mouse event.\r\n */\n\n }, {\n key: \"initializeResizeProperties\",\n value: function initializeResizeProperties(mouseEvent, leftOption) {\n // Apply class for disable involuntary select text when drag.\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addClass(document.body, 'wrs_noselect');\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addClass(this.overlay, 'wrs_overlay_active');\n this.resizeDataObject = {\n x: this.eventClient(mouseEvent).X,\n y: this.eventClient(mouseEvent).Y\n }; // Save Initial state of modal to compare on drag and obtain the difference.\n\n this.initialWidth = parseInt(this.container.style.width);\n this.initialHeight = parseInt(this.container.style.height);\n\n if (!leftOption) {\n this.initialRight = parseInt(this.container.style.right);\n this.initialBottom = parseInt(this.container.style.bottom);\n } else {\n this.leftScale = true;\n }\n\n if (!this.initialRight) {\n this.initialRight = 0;\n }\n\n if (!this.initialBottom) {\n this.initialBottom = 0;\n } // Disable mouse events on editor when we start to drag modal.\n\n\n document.body.style['user-select'] = 'none';\n }\n /**\r\n * This method opens the modal window, restoring the previous state, position and metrics,\r\n * if exists. By default the modal object opens in stack mode.\r\n */\n\n }, {\n key: \"open\",\n value: function open() {\n //Removing close class.\n this.removeClass('wrs_closed'); // Hiding keyboard for mobile devices.\n\n if (this.deviceProperties['isIOS'] || this.deviceProperties['isAndroid'] || this.deviceProperties['isMobile']) {\n // Restore scale to 1\n this.restoreWebsiteScale();\n this.blockWebsiteScroll(); // Due to editor wait we need to wait until editor focus.\n\n setTimeout(function () {\n this.hideKeyboard();\n }.bind(this), 400);\n } // New modal window. He need to create the whole object.\n\n\n if (!this.properties.created) {\n this.create();\n } else {\n // Previous state closed. Open method can be called even the previous state is open,\n // for example updating the content of the modal object.\n if (!this.properties.open) {\n this.properties.open = true; // Restoring the previous open state: if the modal object has been closed\n // re-open it should preserve the state and the metrics.\n\n if (!this.deviceProperties.isAndroid && !this.deviceProperties.isIOS) {\n this.restoreState();\n }\n } // Maximize window only when the configuration is set and the device is not iOs or Android.\n\n\n if (this.deviceProperties['isDesktop'] && _configuration_js__WEBPACK_IMPORTED_MODULE_3__[\"default\"].get('modalWindowFullScreen')) {\n this.maximize();\n } // In iOS we need to recalculate the size of the modal object because\n // iOS keyboard is a float div which can overlay the modal object.\n\n\n if (this.deviceProperties['isIOS']) {\n this.iosSoftkeyboardOpened = false;\n this.setContainerHeight(\"100\" + this.iosMeasureUnit);\n }\n }\n\n if (this.contentManager.isEditorLoaded === false) {\n var listener = _listeners__WEBPACK_IMPORTED_MODULE_4__[\"default\"].newListener('onLoad', function () {\n this.contentManager.onOpen(this);\n }.bind(this));\n this.contentManager.addListener(listener);\n } else {\n this.contentManager.onOpen(this);\n }\n }\n /**\r\n * Closes modal window and restores viewport header.\r\n */\n\n }, {\n key: \"close\",\n value: function close() {\n this.removeClass('wrs_maximized');\n this.removeClass('wrs_minimized');\n this.removeClass('wrs_stack');\n this.addClass('wrs_closed');\n this.saveModalProperties();\n this.unblockWebsiteScroll();\n this.properties.open = false;\n }\n /**\r\n * Sets the website scale to one.\r\n */\n\n }, {\n key: \"restoreWebsiteScale\",\n value: function restoreWebsiteScale() {\n var viewportmeta = document.querySelector('meta[name=viewport]'); // Let the equal symbols in order to search and make meta's final content.\n\n var contentAttrsToUpdate = ['initial-scale=', 'minimum-scale=', 'maximum-scale='];\n var contentAttrsValuesToUpdate = ['1.0', '1.0', '1.0'];\n\n var setMetaAttrFunc = function setMetaAttrFunc(viewportelement, contentAttrsToUpdate) {\n var contentAttr = viewportelement.getAttribute('content'); // If it exists, we need to maintain old values and put our values.\n\n if (contentAttr) {\n var attrArray = contentAttr.split(',');\n var finalContentMeta = \"\";\n var oldAttrs = [];\n\n for (var i = 0; i < attrArray.length; i++) {\n var isAttrToUpdate = false;\n var j = 0;\n\n while (!isAttrToUpdate && j < contentAttrsToUpdate.length) {\n if (attrArray[i].indexOf(contentAttrsToUpdate[j])) {\n isAttrToUpdate = true;\n }\n\n j++;\n }\n\n if (!isAttrToUpdate) {\n oldAttrs.push(attrArray[i]);\n }\n }\n\n for (var _i = 0; _i < contentAttrsToUpdate.length; _i++) {\n var attr = contentAttrsToUpdate[_i] + contentAttrsValuesToUpdate[_i];\n finalContentMeta += _i == 0 ? attr : ',' + attr;\n }\n\n for (var _i2 = 0; _i2 < oldAttrs.length; _i2++) {\n finalContentMeta += ',' + oldAttrs[_i2];\n }\n\n viewportelement.setAttribute('content', finalContentMeta);\n viewportelement.setAttribute('content', contentAttr);\n } else {\n viewportelement.setAttribute('content', 'initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0');\n viewportelement.removeAttribute('content');\n }\n };\n\n if (!viewportmeta) {\n viewportmeta = document.createElement('meta');\n document.getElementsByTagName('head')[0].appendChild(viewportmeta);\n setMetaAttrFunc(viewportmeta, contentAttrsToUpdate, contentAttrsValuesToUpdate);\n viewportmeta.remove();\n } else {\n setMetaAttrFunc(viewportmeta, contentAttrsToUpdate, contentAttrsValuesToUpdate);\n }\n }\n /**\r\n * Adds an event to avoid touch scrolling.\r\n */\n\n }, {\n key: \"blockWebsiteScroll\",\n value: function blockWebsiteScroll() {\n document.body.addEventListener('touchmove', this.disableTouchMove, {\n passive: false\n });\n }\n /**\r\n * Removes the event to avoid touch scrolling.\r\n */\n\n }, {\n key: \"unblockWebsiteScroll\",\n value: function unblockWebsiteScroll() {\n document.body.removeEventListener('touchmove', this.disableTouchMove, {\n passive: false\n });\n }\n /**\r\n * Prevents the default event behavior to a MouseEvent.\r\n * @param {MouseEvent} mouseEvent - mouse event.\r\n */\n\n }, {\n key: \"disableTouchMove\",\n value: function disableTouchMove(mouseEvent) {\n mouseEvent.preventDefault();\n }\n /**\r\n * Util function to known if browser is IE11.\r\n * @returns {boolean} true if the browser is IE11. false otherwise.\r\n */\n\n }, {\n key: \"isIE11\",\n value: function isIE11() {\n if (navigator.userAgent.search(\"Msie/\") >= 0 || navigator.userAgent.search(\"Trident/\") >= 0 || navigator.userAgent.search(\"Edge/\") >= 0) {\n return true;\n }\n\n return false;\n }\n /**\r\n * Returns if the current language type is RTL.\r\n * @return {boolean} true if current language is RTL. false otherwise.\r\n */\n\n }, {\n key: \"isRTL\",\n value: function isRTL() {\n if (this.attributes.language == 'ar' || this.attributes.language == 'he') {\n return true;\n } else {\n return this.rtl;\n }\n\n ;\n }\n /**\r\n * Adds a class to all modal ModalDialog DOM elements.\r\n * @param {string} className - class name.\r\n */\n\n }, {\n key: \"addClass\",\n value: function addClass(className) {\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addClass(this.overlay, className);\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addClass(this.titleBar, className);\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addClass(this.overlay, className);\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addClass(this.container, className);\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addClass(this.contentContainer, className);\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addClass(this.stackDiv, className);\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addClass(this.minimizeDiv, className);\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addClass(this.maximizeDiv, className);\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addClass(this.wrapper, className);\n }\n /**\r\n * Remove a class from all modal DOM elements.\r\n * @param {string} className - class name.\r\n */\n\n }, {\n key: \"removeClass\",\n value: function removeClass(className) {\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].removeClass(this.overlay, className);\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].removeClass(this.titleBar, className);\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].removeClass(this.overlay, className);\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].removeClass(this.container, className);\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].removeClass(this.contentContainer, className);\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].removeClass(this.stackDiv, className);\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].removeClass(this.minimizeDiv, className);\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].removeClass(this.maximizeDiv, className);\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].removeClass(this.wrapper, className);\n }\n /**\r\n * Create modal dialog for desktop.\r\n */\n\n }, {\n key: \"createModalWindowDesktop\",\n value: function createModalWindowDesktop() {\n this.addClass('wrs_modal_desktop');\n this.stack();\n }\n /**\r\n * Create modal dialog for non android devices.\r\n */\n\n }, {\n key: \"createModalWindowAndroid\",\n value: function createModalWindowAndroid() {\n this.addClass('wrs_modal_android');\n window.addEventListener('resize', this.orientationChangeAndroidSoftkeyboard.bind(this));\n }\n /**\r\n * Create modal dialog for iOS devices.\r\n */\n\n }, {\n key: \"createModalWindowIos\",\n value: function createModalWindowIos() {\n this.addClass('wrs_modal_ios'); // Refresh the size when the orientation is changed\n\n window.addEventListener('resize', this.orientationChangeIosSoftkeyboard.bind(this));\n }\n /**\r\n * Restore previous state, position and size of previous stacked modal dialog.\r\n */\n\n }, {\n key: \"restoreState\",\n value: function restoreState() {\n if (this.properties.state == 'maximized') {\n // Reset states for prevent return to stack state.\n this.maximize();\n } else if (this.properties.state == 'minimized') {\n // Reset states for prevent return to stack state.\n this.properties.state = this.properties.previousState;\n this.properties.previousState = '';\n this.minimize();\n } else {\n this.stack();\n }\n }\n /**\r\n * Stacks the modal object.\r\n */\n\n }, {\n key: \"stack\",\n value: function stack() {\n this.properties.previousState = this.properties.state;\n this.properties.state = 'stack';\n this.removeClass('wrs_maximized');\n this.minimizeDiv.title = \"Minimise\";\n this.removeClass('wrs_minimized');\n this.addClass('wrs_stack');\n this.restoreModalProperties();\n\n if (typeof this.resizerBR !== 'undefined' && typeof this.resizerTL !== 'undefined') {\n this.setResizeButtonsVisibility();\n } // Need recalculate position of actual modal because window can was changed in fullscreenmode\n\n\n this.recalculateScrollBar();\n this.recalculatePosition();\n this.recalculateScale();\n this.focus();\n }\n /**\r\n * Minimizes the modal object\r\n */\n\n }, {\n key: \"minimize\",\n value: function minimize() {\n // Saving width, height, top and bottom parameters to restore when open\n this.saveModalProperties();\n\n if (this.properties.state == 'minimized' && this.properties.previousState == 'stack') {\n this.stack();\n } else if (this.properties.state == 'minimized' && this.properties.previousState == 'maximized') {\n this.maximize();\n } else {\n // Setting css to prevent important tag into css style\n this.container.style.height = \"30px\";\n this.container.style.width = \"250px\";\n this.container.style.bottom = \"0px\";\n this.container.style.right = \"10px\";\n this.removeListeners();\n this.properties.previousState = this.properties.state;\n this.properties.state = \"minimized\";\n this.setResizeButtonsVisibility();\n this.minimizeDiv.title = \"Maximise\";\n\n if (_util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].containsClass(this.overlay, 'wrs_stack')) {\n this.removeClass('wrs_stack');\n } else {\n this.removeClass('wrs_maximized');\n }\n\n this.addClass('wrs_minimized');\n }\n }\n /**\r\n * Maximizes the modal object.\r\n */\n\n }, {\n key: \"maximize\",\n value: function maximize() {\n // Saving width, height, top and bottom parameters to restore when open\n this.saveModalProperties();\n\n if (this.properties.state != 'maximized') {\n this.properties.previousState = this.properties.state;\n this.properties.state = 'maximized';\n } // Don't permit resize on maximize mode.\n\n\n this.setResizeButtonsVisibility();\n\n if (_util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].containsClass(this.overlay, 'wrs_minimized')) {\n this.minimizeDiv.title = \"Minimise\";\n this.removeClass('wrs_minimized');\n } else if (_util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].containsClass(this.overlay, 'wrs_stack')) {\n this.container.style.left = null;\n this.container.style.top = null;\n this.removeClass('wrs_stack');\n }\n\n this.addClass('wrs_maximized'); // Set size to 80% screen with a max size.\n\n this.setSize(parseInt(window.innerHeight * 0.8), parseInt(window.innerWidth * 0.8));\n var sizeModificated = false;\n\n if (this.container.clientHeight > 700) {\n this.container.style.height = '700px';\n sizeModificated = true;\n }\n\n if (this.container.clientWidth > 1200) {\n this.container.style.width = '1200px';\n sizeModificated = true;\n } // Setting modal position in center on screen.\n\n\n this.setPosition(window.innerHeight / 2 - this.container.offsetHeight / 2, window.innerWidth / 2 - this.container.offsetWidth / 2);\n this.recalculateScale();\n this.recalculatePosition();\n this.recalculateSize();\n this.focus();\n }\n /**\r\n * Sets modal size.\r\n * @param {number} height - height of the ModalDialog\r\n * @param {number} width - width of the ModalDialog.\r\n */\n\n }, {\n key: \"setSize\",\n value: function setSize(height, width) {\n this.container.style.height = height + 'px';\n this.container.style.width = width + 'px';\n this.recalculateSize();\n }\n /**\r\n * Sets modal position using bottom and right style attributes.\r\n * @param {number} bottom - bottom attribute.\r\n * @param {number} right - right attribute.\r\n */\n\n }, {\n key: \"setPosition\",\n value: function setPosition(bottom, right) {\n this.container.style.bottom = bottom + 'px';\n this.container.style.right = right + 'px';\n }\n /**\r\n * Saves position and size parameters of and open ModalDialog. This attributes\r\n * are needed to restore it on re-open.\r\n */\n\n }, {\n key: \"saveModalProperties\",\n value: function saveModalProperties() {\n // Saving values of modal only when modal is in stack state.\n if (this.properties.state == 'stack') {\n this.properties.position.bottom = parseInt(this.container.style.bottom);\n this.properties.position.right = parseInt(this.container.style.right);\n this.properties.size.width = parseInt(this.container.style.width);\n this.properties.size.height = parseInt(this.container.style.height);\n }\n }\n /**\r\n * Restore ModalDialog position and size parameters.\r\n */\n\n }, {\n key: \"restoreModalProperties\",\n value: function restoreModalProperties() {\n if (this.properties.state == 'stack') {\n // Restoring Bottom and Right values from last modal\n this.setPosition(this.properties.position.bottom, this.properties.position.right); // Restoring Height and Left values from last modal\n\n this.setSize(this.properties.size.height, this.properties.size.width);\n }\n }\n /**\r\n * Sets the modal dialog initial size.\r\n */\n\n }, {\n key: \"recalculateSize\",\n value: function recalculateSize() {\n this.wrapper.style.width = this.container.clientWidth - 12 + 'px';\n this.wrapper.style.height = this.container.clientHeight - 38 + 'px';\n this.contentContainer.style.height = parseInt(this.wrapper.offsetHeight - 50) + 'px';\n }\n /**\r\n * Enable or disable visibility of resize buttons in modal window depend on state.\r\n */\n\n }, {\n key: \"setResizeButtonsVisibility\",\n value: function setResizeButtonsVisibility() {\n if (this.properties.state == 'stack') {\n this.resizerTL.style.visibility = 'visible';\n this.resizerBR.style.visibility = 'visible';\n } else {\n this.resizerTL.style.visibility = 'hidden';\n this.resizerBR.style.visibility = 'hidden';\n }\n }\n /**\r\n * Makes an object draggable adding mouse and touch events.\r\n */\n\n }, {\n key: \"addListeners\",\n value: function addListeners() {\n // Button events (maximize, minimize, stack and close).\n this.maximizeDiv.addEventListener('click', this.maximize.bind(this), true);\n this.stackDiv.addEventListener('click', this.stack.bind(this), true);\n this.minimizeDiv.addEventListener('click', this.minimize.bind(this), true);\n this.closeDiv.addEventListener('click', this.cancelAction.bind(this)); // Mouse events.\n\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addEvent(window, 'mousedown', this.startDrag.bind(this));\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addEvent(window, 'mouseup', this.stopDrag.bind(this));\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addEvent(window, 'mousemove', this.drag.bind(this));\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addEvent(window, 'resize', this.onWindowResize.bind(this)); // Key events.\n\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addEvent(window, 'keydown', this.onKeyDown.bind(this));\n }\n /**\r\n * Removes draggable events from an object.\r\n */\n\n }, {\n key: \"removeListeners\",\n value: function removeListeners() {\n // Mouse events.\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].removeEvent(window, 'mousedown', this.startDrag);\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].removeEvent(window, 'mouseup', this.stopDrag);\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].removeEvent(window, 'mousemove', this.drag);\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].removeEvent(window, 'resize', this.onWindowResize); // Key events\n\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].removeEvent(window, 'keydown', this.onKeyDown);\n }\n /**\r\n * Returns mouse or touch coordinates (on touch events ev.ClientX doesn't exists)\r\n * @param {MouseEvent} mouseEvent - mouse event.\r\n * @return {Object} with the X and Y coordinates.\r\n */\n\n }, {\n key: \"eventClient\",\n value: function eventClient(mouseEvent) {\n if (typeof mouseEvent.clientX == 'undefined' && mouseEvent.changedTouches) {\n var client = {\n X: mouseEvent.changedTouches[0].clientX,\n Y: mouseEvent.changedTouches[0].clientY\n };\n return client;\n } else {\n client = {\n X: mouseEvent.clientX,\n Y: mouseEvent.clientY\n };\n return client;\n }\n }\n /**\r\n * Start drag function: set the object dragDataObject with the draggable object offsets coordinates.\r\n * when drag starts (on touchstart or mousedown events).\r\n * @param {MouseEvent} mouseEvent - touchstart or mousedown event.\r\n */\n\n }, {\n key: \"startDrag\",\n value: function startDrag(mouseEvent) {\n if (this.properties.state == 'minimized') {\n return;\n }\n\n if (mouseEvent.target === this.title) {\n if (typeof this.dragDataObject === 'undefined' || this.dragDataObject === null) {\n mouseEvent = mouseEvent || event; // Save first click mouse point on screen\n\n this.dragDataObject = {\n x: this.eventClient(mouseEvent).X,\n y: this.eventClient(mouseEvent).Y\n }; // Reset last drag position when start drag\n\n this.lastDrag = {\n x: \"0px\",\n y: \"0px\"\n }; // Init right and bottom values for window modal if it isn't exist.\n\n if (this.container.style.right == '') {\n this.container.style.right = \"0px\";\n }\n\n if (this.container.style.bottom == '') {\n this.container.style.bottom = \"0px\";\n } // Needed for IE11 for apply disabled mouse events on editor because iexplorer need a dinamic object to apply this property.\n\n\n if (this.isIE11()) {} // this.iframe.style['position'] = 'relative';\n // Apply class for disable involuntary select text when drag.\n\n\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addClass(document.body, 'wrs_noselect');\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addClass(this.overlay, 'wrs_overlay_active'); // Obtain screen limits for prevent overflow.\n\n this.limitWindow = this.getLimitWindow();\n }\n }\n }\n /**\r\n * Updates dragDataObject with the draggable object coordinates when the draggable object is being moved.\r\n * @param {MouseEvent} mouseEvent - the mouse event.\r\n */\n\n }, {\n key: \"drag\",\n value: function drag(mouseEvent) {\n if (this.dragDataObject) {\n mouseEvent.preventDefault();\n mouseEvent = mouseEvent || event; // Calculate max and min between actual mouse position and limit of screeen. It restric the movement of modal into window.\n\n var limitY = Math.min(this.eventClient(mouseEvent).Y, this.limitWindow.minPointer.y);\n limitY = Math.max(this.limitWindow.maxPointer.y, limitY);\n var limitX = Math.min(this.eventClient(mouseEvent).X, this.limitWindow.minPointer.x);\n limitX = Math.max(this.limitWindow.maxPointer.x, limitX); // Substract limit with first position to obtain relative pixels increment to the anchor point.\n\n var dragX = limitX - this.dragDataObject.x + \"px\";\n var dragY = limitY - this.dragDataObject.y + \"px\"; // Save last valid position of modal before window overflow.\n\n this.lastDrag = {\n x: dragX,\n y: dragY\n }; // This move modal with hadware acceleration.\n\n this.container.style.transform = \"translate3d(\" + dragX + \",\" + dragY + \",0)\";\n }\n\n if (this.resizeDataObject) {\n var limitX = Math.min(this.eventClient(mouseEvent).X, window.innerWidth - this.scrollbarWidth - 7);\n var limitY = Math.min(this.eventClient(mouseEvent).Y, window.innerHeight - 7);\n\n if (limitX < 0) {\n limitX = 0;\n }\n\n if (limitY < 0) {\n limitY = 0;\n }\n\n var scaleMultiplier;\n\n if (this.leftScale) {\n scaleMultiplier = -1;\n } else {\n scaleMultiplier = 1;\n }\n\n this.container.style.width = this.initialWidth + scaleMultiplier * (limitX - this.resizeDataObject.x) + 'px';\n this.container.style.height = this.initialHeight + scaleMultiplier * (limitY - this.resizeDataObject.y) + 'px';\n\n if (!this.leftScale) {\n if (this.resizeDataObject.x - limitX - this.initialWidth < -580) {\n this.container.style.right = this.initialRight - (limitX - this.resizeDataObject.x) + 'px';\n } else {\n this.container.style.right = this.initialRight + this.initialWidth - 580 + \"px\";\n this.container.style.width = \"580px\";\n }\n\n if (this.resizeDataObject.y - limitY < this.initialHeight - 338) {\n this.container.style.bottom = this.initialBottom - (limitY - this.resizeDataObject.y) + 'px';\n } else {\n this.container.style.bottom = this.initialBottom + this.initialHeight - 338 + \"px\";\n this.container.style.height = \"338px\";\n }\n }\n\n this.recalculateScale();\n this.recalculatePosition();\n }\n }\n /**\r\n * Returns the boundaries of actual window to limit modal movement.\r\n * @return {Object} Object containing mouseX and mouseY coordinates of actual mouse on screen.\r\n */\n\n }, {\n key: \"getLimitWindow\",\n value: function getLimitWindow() {\n // Obtain dimensions of window page.\n var maxWidth = window.innerWidth;\n var maxHeight = window.innerHeight; // Calculate relative position of mouse point into window.\n\n var offSetToolbarY = this.container.offsetHeight + parseInt(this.container.style.bottom) - (maxHeight - (this.dragDataObject.y - window.pageXOffset));\n var offSetToolbarX = maxWidth - this.scrollbarWidth - (this.dragDataObject.x - window.pageXOffset) - parseInt(this.container.style.right); // Calculate limits with sizes of window, modal and mouse position.\n\n var minPointerY = maxHeight - this.container.offsetHeight + offSetToolbarY;\n var maxPointerY = this.title.offsetHeight - (this.title.offsetHeight - offSetToolbarY);\n var minPointerX = maxWidth - offSetToolbarX - this.scrollbarWidth;\n var maxPointerX = this.container.offsetWidth - offSetToolbarX;\n var minPointer = {\n x: minPointerX,\n y: minPointerY\n };\n var maxPointer = {\n x: maxPointerX,\n y: maxPointerY\n };\n return {\n minPointer: minPointer,\n maxPointer: maxPointer\n };\n }\n /**\r\n * Returns the scrollbar width size of browser\r\n * @returns {number} the scrollbar width.\r\n */\n\n }, {\n key: \"getScrollBarWidth\",\n value: function getScrollBarWidth() {\n // Create a paragraph with full width of page.\n var inner = document.createElement('p');\n inner.style.width = \"100%\";\n inner.style.height = \"200px\"; // Create a hidden div to compare sizes.\n\n var outer = document.createElement('div');\n outer.style.position = \"absolute\";\n outer.style.top = \"0px\";\n outer.style.left = \"0px\";\n outer.style.visibility = \"hidden\";\n outer.style.width = \"200px\";\n outer.style.height = \"150px\";\n outer.style.overflow = \"hidden\";\n outer.appendChild(inner);\n document.body.appendChild(outer);\n var widthOuter = inner.offsetWidth; // Change type overflow of paragraph for measure scrollbar.\n\n outer.style.overflow = 'scroll';\n var widthInner = inner.offsetWidth; // If measure is the same, we compare with internal div.\n\n if (widthOuter == widthInner) {\n widthInner = outer.clientWidth;\n }\n\n document.body.removeChild(outer);\n return widthOuter - widthInner;\n }\n /**\r\n * Set the dragDataObject to null.\r\n */\n\n }, {\n key: \"stopDrag\",\n value: function stopDrag() {\n // Due to we have multiple events that call this function, we need only to execute the next modifiers one time,\n // when the user stops to drag and dragDataObject is not null (the object to drag is attached).\n if (this.dragDataObject || this.resizeDataObject) {\n // If modal doesn't change, it's not necessary to set position with interpolation\n this.container.style.transform = '';\n\n if (this.dragDataObject) {\n this.container.style.right = parseInt(this.container.style.right) - parseInt(this.lastDrag.x) + \"px\";\n this.container.style.bottom = parseInt(this.container.style.bottom) - parseInt(this.lastDrag.y) + \"px\";\n } // We make focus on editor after drag modal windows to prevent lose focus.\n\n\n this.focus(); // Restore mouse events on iframe\n // this.iframe.style['pointer-events'] = 'auto';\n\n document.body.style['user-select'] = ''; // Restore static state of iframe if we use Internet Explorer.\n\n if (this.isIE11()) {} // this.iframe.style['position'] = null;\n // Active text select event\n\n\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].removeClass(document.body, 'wrs_noselect');\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].removeClass(this.overlay, 'wrs_overlay_active');\n }\n\n this.dragDataObject = null;\n this.resizeDataObject = null;\n this.initialWidth = null;\n this.leftScale = null;\n }\n /**\r\n * Recalculates scale for modal when resize browser window.\r\n */\n\n }, {\n key: \"onWindowResize\",\n value: function onWindowResize() {\n this.recalculateScrollBar();\n this.recalculatePosition();\n this.recalculateScale();\n }\n /**\r\n * Triggers keyboard events:\r\n * - Tab key tab to go to submit button.\r\n * - Esc key to close the modal dialog.\r\n * @param {KeyboardEvent} keyboardEvent - the keyboard event.\r\n */\n\n }, {\n key: \"onKeyDown\",\n value: function onKeyDown(keyboardEvent) {\n if (keyboardEvent.key !== undefined && keyboardEvent.repeat === false) {\n // Code for detect Esc event\n if (keyboardEvent.key === \"Escape\" || keyboardEvent.key === 'Esc') {\n if (this.properties.open) {\n this.cancelAction();\n }\n } // Code for detect Tab event\n\n\n if (keyboardEvent.key === \"Tab\") {\n this.submitButton.focus();\n keyboardEvent.preventDefault();\n }\n }\n }\n /**\r\n * Recalculating position for modal dialog when the browser is resized.\r\n */\n\n }, {\n key: \"recalculatePosition\",\n value: function recalculatePosition() {\n this.container.style.right = Math.min(parseInt(this.container.style.right), window.innerWidth - this.scrollbarWidth - this.container.offsetWidth) + \"px\";\n\n if (parseInt(this.container.style.right) < 0) {\n this.container.style.right = \"0px\";\n }\n\n this.container.style.bottom = Math.min(parseInt(this.container.style.bottom), window.innerHeight - this.container.offsetHeight) + \"px\";\n\n if (parseInt(this.container.style.bottom) < 0) {\n this.container.style.bottom = \"0px\";\n }\n }\n /**\r\n * Recalculating scale for modal when the browser is resized.\r\n */\n\n }, {\n key: \"recalculateScale\",\n value: function recalculateScale() {\n var sizeModificated = false;\n\n if (parseInt(this.container.style.width) > 580) {\n this.container.style.width = Math.min(parseInt(this.container.style.width), window.innerWidth - this.scrollbarWidth) + \"px\";\n sizeModificated = true;\n } else {\n this.container.style.width = \"580px\";\n sizeModificated = true;\n }\n\n if (parseInt(this.container.style.height) > 338) {\n this.container.style.height = Math.min(parseInt(this.container.style.height), window.innerHeight) + \"px\";\n sizeModificated = true;\n } else {\n this.container.style.height = \"338px\";\n sizeModificated = true;\n }\n\n if (sizeModificated) {\n this.recalculateSize();\n }\n }\n /**\r\n * Recalculating width of browser scroll bar.\r\n */\n\n }, {\n key: \"recalculateScrollBar\",\n value: function recalculateScrollBar() {\n this.hasScrollBar = window.innerWidth > document.documentElement.clientWidth;\n\n if (this.hasScrollBar) {\n this.scrollbarWidth = this.getScrollBarWidth();\n } else {\n this.scrollbarWidth = 0;\n }\n }\n /**\r\n * Hide soft keyboards on iOS devices.\r\n */\n\n }, {\n key: \"hideKeyboard\",\n value: function hideKeyboard() {\n document.activeElement.blur();\n }\n /**\r\n * Focus to contentManager object.\r\n */\n\n }, {\n key: \"focus\",\n value: function focus() {\n if (this.contentManager != null && typeof this.contentManager.onFocus !== 'undefined') {\n this.contentManager.onFocus();\n }\n }\n /**\r\n * Returns true when the device is on portrait mode.\r\n */\n\n }, {\n key: \"portraitMode\",\n value: function portraitMode() {\n return window.innerHeight > window.innerWidth;\n }\n /**\r\n * Event handler that change container size when IOS softkeyboard is opened.\r\n */\n\n }, {\n key: \"handleOpenedIosSoftkeyboard\",\n value: function handleOpenedIosSoftkeyboard() {\n if (!this.iosSoftkeyboardOpened && this.iosDivHeight != null && this.iosDivHeight == \"100\" + this.iosMeasureUnit) {\n if (this.portraitMode()) {\n this.setContainerHeight(\"63\" + this.iosMeasureUnit);\n } else {\n this.setContainerHeight(\"40\" + this.iosMeasureUnit);\n }\n }\n\n this.iosSoftkeyboardOpened = true;\n }\n /**\r\n * Event handler that change container size when IOS softkeyboard is closed.\r\n */\n\n }, {\n key: \"handleClosedIosSoftkeyboard\",\n value: function handleClosedIosSoftkeyboard() {\n this.iosSoftkeyboardOpened = false;\n this.setContainerHeight(\"100\" + this.iosMeasureUnit);\n }\n /**\r\n * Change container sizes when orientation is changed on iOS.\r\n */\n\n }, {\n key: \"orientationChangeIosSoftkeyboard\",\n value: function orientationChangeIosSoftkeyboard() {\n if (this.iosSoftkeyboardOpened) {\n if (this.portraitMode()) {\n this.setContainerHeight(\"63\" + this.iosMeasureUnit);\n } else {\n this.setContainerHeight(\"40\" + this.iosMeasureUnit);\n }\n } else {\n this.setContainerHeight(\"100\" + this.iosMeasureUnit);\n }\n }\n /**\r\n * Change container sizes when orientation is changed on Android.\r\n */\n\n }, {\n key: \"orientationChangeAndroidSoftkeyboard\",\n value: function orientationChangeAndroidSoftkeyboard() {\n this.setContainerHeight(\"100%\");\n }\n /**\r\n * Set iframe container height.\r\n * @param {number} height - new height.\r\n */\n\n }, {\n key: \"setContainerHeight\",\n value: function setContainerHeight(height) {\n this.iosDivHeight = height;\n this.wrapper.style.height = height;\n }\n /**\r\n * Check content of editor before close action.\r\n */\n\n }, {\n key: \"showPopUpMessage\",\n value: function showPopUpMessage() {\n if (this.properties.state == 'minimized') {\n this.stack();\n }\n\n this.popup.show();\n }\n /**\r\n * Sets the tithle of the modal dialog.\r\n * @param {string} title - modal dialog title.\r\n */\n\n }, {\n key: \"setTitle\",\n value: function setTitle(title) {\n this.title.innerHTML = title;\n }\n /**\r\n * Returns the id of an element, adding the instance number to\r\n * the element class name:\r\n * className --> className[idNumber]\r\n * @param {string} className - the element class name.\r\n * @returns {string} a string appending the instance id to the className.\r\n */\n\n }, {\n key: \"getElementId\",\n value: function getElementId(className) {\n return className + \"[\" + this.instanceId + \"]\";\n }\n }]);\n\n return ModalDialog;\n}();\n\n\n\n//# sourceURL=webpack:///./core/src/modal.js?"); /***/ }), @@ -310,7 +310,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) * /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"default\", function() { return Parser; });\n/* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./util */ \"./core/src/util.js\");\n/* harmony import */ var _core_src__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./core.src */ \"./core/src/core.src.js\");\n/* harmony import */ var _latex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./latex */ \"./core/src/latex.js\");\n/* harmony import */ var _mathml__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./mathml */ \"./core/src/mathml.js\");\n/* harmony import */ var _image__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./image */ \"./core/src/image.js\");\n/* harmony import */ var _accessibility__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./accessibility */ \"./core/src/accessibility.js\");\n/* harmony import */ var _serviceprovider__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./serviceprovider */ \"./core/src/serviceprovider.js\");\n/* harmony import */ var _configuration__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./configuration */ \"./core/src/configuration.js\");\n/* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./constants */ \"./core/src/constants.js\");\n/* harmony import */ var _md5__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./md5 */ \"./core/src/md5.js\");\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\n\n\n\n\n\n\n\n\n\n\n/**\r\n * This class represent a MahML parser. Converts MathML into formulas depending on the\r\n * image format (SVG, PNG, base64) and the save mode (XML, safeXML, Image) configured in the backend.\r\n */\n\nvar Parser =\n/*#__PURE__*/\nfunction () {\n function Parser() {\n _classCallCheck(this, Parser);\n }\n\n _createClass(Parser, null, [{\n key: \"mathmlToImgObject\",\n\n /**\r\n * Converts a MathML string to an img element.\r\n * @param {Document} creator - Document object to call createElement method.\r\n * @param {string} mathml - MathML code\r\n * @param {Object[]} wirisProperties - object containing WIRIS custom properties\r\n * @param {language} language - custom language for accessibility.\r\n * @returns {HTMLImageElement} the formula image corresponding to initial MathML string.\r\n * @static\r\n */\n value: function mathmlToImgObject(creator, mathml, wirisProperties, language) {\n var width;\n var height;\n var baseline;\n var imgObject = creator.createElement('img');\n imgObject.align = 'middle';\n imgObject.style.maxWidth = 'none';\n var data = wirisProperties ? wirisProperties : {};\n data['mml'] = mathml;\n data['lang'] = language; // Request metrics of the generated image.\n\n data['metrics'] = 'true';\n data['centerbaseline'] = 'false'; // Full base64 method (edit & save).\n\n if (_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('saveMode') == 'base64' && _configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('editMode') == 'default') {\n data['base64'] = true;\n } // Render js params: _wrs_int_wirisProperties contains some js render params. Since mathml can support render params, js params should be send only to editor, not to render.\n\n\n imgObject.className = _configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('imageClassName');\n\n if (mathml.indexOf('class=\"') != -1) {\n // We check here if the MathML has been created from a customEditor (such chemistry)\n // to add data-custom-editor attribute to img object (if necessary).\n var mathmlSubstring = mathml.substring(mathml.indexOf('class=\"') + 'class=\"'.length, mathml.length);\n mathmlSubstring = mathmlSubstring.substring(0, mathmlSubstring.indexOf('\"'));\n mathmlSubstring = mathmlSubstring.substring(4, mathmlSubstring.length);\n imgObject.setAttribute('data-custom-editor', mathmlSubstring);\n } // Performance enabled.\n\n\n if (_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('wirisPluginPerformance') && (_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('saveMode') == 'xml' || _configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('saveMode') == 'safeXml')) {\n var result = JSON.parse(Parser.createShowImageSrc(data, language));\n\n if (result[\"status\"] == 'warning') {\n // POST call.\n // if the mathml is malformed, this function will throw an exception.\n try {\n result = JSON.parse(_serviceprovider__WEBPACK_IMPORTED_MODULE_6__[\"default\"].getService('showimage', data));\n } catch (e) {\n return;\n }\n }\n\n result = result.result;\n\n if (result['format'] == 'png') {\n imgObject.src = 'data:image/png;base64,' + result['content'];\n } else {\n imgObject.src = 'data:image/svg+xml;charset=utf8,' + _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].urlEncode(result['content']);\n }\n\n imgObject.setAttribute(_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('imageMathmlAttribute'), _mathml__WEBPACK_IMPORTED_MODULE_3__[\"default\"].safeXmlEncode(mathml));\n _image__WEBPACK_IMPORTED_MODULE_4__[\"default\"].setImgSize(imgObject, result['content'], true);\n\n if (_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('enableAccessibility')) {\n if (typeof result.alt == 'undefined') {\n imgObject.alt = _accessibility__WEBPACK_IMPORTED_MODULE_5__[\"default\"].mathMLToAccessible(mathml, language, data);\n } else {\n imgObject.alt = result.alt;\n }\n }\n } else {\n var result = Parser.createImageSrc(mathml, data);\n imgObject.setAttribute(_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('imageMathmlAttribute'), _mathml__WEBPACK_IMPORTED_MODULE_3__[\"default\"].safeXmlEncode(mathml));\n imgObject.src = result;\n _image__WEBPACK_IMPORTED_MODULE_4__[\"default\"].setImgSize(imgObject, result, _configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('saveMode') == 'base64' && _configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('editMode') == 'default' ? true : false);\n\n if (_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('enableAccessibility')) {\n imgObject.alt = _accessibility__WEBPACK_IMPORTED_MODULE_5__[\"default\"].mathMLToAccessible(mathml, language, data);\n }\n }\n\n if (typeof Parser.observer != 'undefined') {\n Parser.observer.observe(imgObject);\n } // Role math https://www.w3.org/TR/wai-aria/roles#math.\n\n\n imgObject.setAttribute('role', 'math');\n return imgObject;\n }\n /**\r\n * Returns the source to showimage service by calling createimage service. The\r\n * output of the createimage service is a URL path pointing to showimage service.\r\n * This method is called when performance is disabled.\r\n * @param {string} mathml - MathML code.\r\n * @param {Object[]} data - data object containing service parameters.\r\n * @returns {string} the showimage path.\r\n */\n\n }, {\n key: \"createImageSrc\",\n value: function createImageSrc(mathml, data) {\n // Full base64 method (edit & save).\n if (_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('saveMode') == 'base64' && _configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('editMode') == 'default') {\n data['base64'] = true;\n }\n\n var result = _serviceprovider__WEBPACK_IMPORTED_MODULE_6__[\"default\"].getService('createimage', data);\n\n if (result.indexOf('@BASE@') != -1) {\n // Replacing '@BASE@' with the base URL of createimage.\n var baseParts = _core_src__WEBPACK_IMPORTED_MODULE_1__[\"default\"].getServiceProvider().getServicePath('createimage').split('/');\n baseParts.pop();\n result = result.split('@BASE@').join(baseParts.join('/'));\n }\n\n return result;\n }\n /**\r\n * Parses initial HTML code. If the HTML contains data generated by WIRIS, this data would be converted as following:\r\n *
\r\n     * MathML code: Image containing the corresponding MathML formulas.\r\n     * MathML code with LaTeX annotation : LaTeX string.\r\n     * 
\r\n * @param {string} code - HTML code containing MathML data.\r\n * @param {string} language - language to create image alt text.\r\n * @returns {string} HTML code with the original MathML converted into LaTeX and images.\r\n */\n\n }, {\n key: \"initParse\",\n value: function initParse(code, language) {\n /* Note: The code inside this function has been inverted.\r\n If you invert again the code then you cannot use correctly LaTeX\r\n in Moodle.\r\n */\n code = Parser.initParseSaveMode(code, language);\n return Parser.initParseEditMode(code);\n }\n /**\r\n * Parses initial HTML code depending on the save mode. Transforms all MathML\r\n * occurrences for it's correspondent image or LaTeX.\r\n * @param {string} code - HTML code to be parsed\r\n * @param {string} language - language to create image alt text.\r\n * @returns {string} HTML code parsed.\r\n */\n\n }, {\n key: \"initParseSaveMode\",\n value: function initParseSaveMode(code, language) {\n if (_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('saveMode')) {\n // Converting XML to tags.\n code = _latex__WEBPACK_IMPORTED_MODULE_2__[\"default\"].parseMathmlToLatex(code, _constants__WEBPACK_IMPORTED_MODULE_8__[\"default\"].safeXmlCharacters);\n code = _latex__WEBPACK_IMPORTED_MODULE_2__[\"default\"].parseMathmlToLatex(code, _constants__WEBPACK_IMPORTED_MODULE_8__[\"default\"].xmlCharacters); // Safe XML and XML must be parsed regardeless of save mode.\n // Order is important here, safeXml must be parsed first in order to avoid conflicts with data-mathml img attribute.\n\n code = Parser.parseSafeAppletsToObjects(code);\n code = Parser.parseMathmlToImg(code, _constants__WEBPACK_IMPORTED_MODULE_8__[\"default\"].safeXmlCharacters, language);\n code = Parser.parseMathmlToImg(code, _constants__WEBPACK_IMPORTED_MODULE_8__[\"default\"].xmlCharacters, language);\n\n if (_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('saveMode') == 'base64' && _configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('editMode') == 'image') {\n code = Parser.codeImgTransform(code, 'base642showimage');\n }\n }\n\n var appletList = _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].getElementsByNameFromString(code, 'applet', false);\n var carry = 0; // While replacing applets with images, the indexes of the found applets changes respecting the original code, so this carry is needed.\n\n for (var i = 0; i < appletList.length; ++i) {\n var appletCode = code.substring(appletList[i].start + carry, appletList[i].end + carry); // The second control in the if is used to find WIRIS applet which don't have Wiriscas class (as it was in old CAS applets).\n\n if (appletCode.indexOf(' class=\"' + _configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('CASClassName') + '\"') != -1 || appletCode.toUpperCase().indexOf('WIRIS') != -1) {\n if (appletCode.indexOf(' src=\"') != -1) {\n var srcStart = appletCode.indexOf(' src=\"') + ' src=\"'.length;\n var srcEnd = appletCode.indexOf('\"', srcStart);\n var src = appletCode.substring(srcStart, srcEnd);\n } else {\n // This should happen only with old CAS imported from Moodle 1 to Moodle 2.\n if (typeof _wrs_conf_pluginBasePath != 'undefined') {\n var src = _wrs_conf_pluginBasePath + '/integration/showcasimage.php?formula=noimage';\n } else {\n var src = '';\n }\n\n if (appletCode.indexOf(' class=\"' + _configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('CASClassName') + '\"') == -1) {\n var closeSymbol = appletCode.indexOf('>');\n var appletTag = appletCode.substring(0, closeSymbol);\n var newAppletTag = appletTag.split(' width=').join(' class=\"Wiriscas\" width=');\n appletCode = appletCode.split(appletTag).join(newAppletTag);\n appletCode = appletCode.split('\\'').join('\"');\n }\n } // Double click to edit has been removed here.\n\n\n var imgCode = '';\n code = code.substring(0, appletList[i].start + carry) + imgCode + code.substring(appletList[i].end + carry);\n carry += imgCode.length - (appletList[i].end - appletList[i].start);\n }\n }\n\n return code;\n }\n /**\r\n * Parses initial HTML code depending on the edit mode.\r\n * If 'latex' parseMode is enabled all MathML containing an annotation with encoding='LaTeX' will\r\n * be converted into a LaTeX string instead of an image.\r\n * @param {string} code - HTML code containing MathML.\r\n * @returns {string} parsed HTML code.\r\n */\n\n }, {\n key: \"initParseEditMode\",\n value: function initParseEditMode(code) {\n if (_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('parseModes').indexOf('latex') != -1) {\n var imgList = _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].getElementsByNameFromString(code, 'img', true);\n var token = 'encoding=\"LaTeX\">';\n var carry = 0;\n 4; // While replacing images with latex, the indexes of the found images changes respecting the original code, so this carry is needed.\n\n for (var i = 0; i < imgList.length; ++i) {\n var imgCode = code.substring(imgList[i].start + carry, imgList[i].end + carry);\n\n if (imgCode.indexOf(' class=\"' + _configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('imageClassName') + '\"') != -1) {\n var mathmlStartToken = ' ' + _configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('imageMathmlAttribute') + '=\"';\n var mathmlStart = imgCode.indexOf(mathmlStartToken);\n\n if (mathmlStart == -1) {\n mathmlStartToken = ' alt=\"';\n mathmlStart = imgCode.indexOf(mathmlStartToken);\n }\n\n if (mathmlStart != -1) {\n mathmlStart += mathmlStartToken.length;\n var mathmlEnd = imgCode.indexOf('\"', mathmlStart);\n var mathml = _mathml__WEBPACK_IMPORTED_MODULE_3__[\"default\"].safeXmlDecode(imgCode.substring(mathmlStart, mathmlEnd));\n var latexStartPosition = mathml.indexOf(token);\n\n if (latexStartPosition != -1) {\n latexStartPosition += token.length;\n var latexEndPosition = mathml.indexOf('', latexStartPosition);\n var latex = mathml.substring(latexStartPosition, latexEndPosition);\n var replaceText = '$$' + _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].htmlEntitiesDecode(latex) + '$$';\n code = code.substring(0, imgList[i].start + carry) + replaceText + code.substring(imgList[i].end + carry);\n carry += replaceText.length - (imgList[i].end - imgList[i].start);\n }\n }\n }\n }\n }\n\n return code;\n }\n /**\r\n * Parses end HTML code. The end HTML code is HTML code with embedded images or LaTeX formulas created with MathType.
\r\n * By default this method converts the formula images and LaTeX strings in MathML.
\r\n * If image mode is enabled the images will not be converted into MathML. For further information see {@link http://www.wiris.com/plugins/docs/full-mathml-mode}.\r\n * @param {string} code - HTML to be parsed\r\n * @returns {string} the HTML code parsed.\r\n */\n\n }, {\n key: \"endParse\",\n value: function endParse(code) {\n code = Parser.endParseEditMode(code);\n return Parser.endParseSaveMode(code);\n }\n /**\r\n * Parses end HTML code depending on the edit mode.\r\n * - LaTeX is an enabled parse mode, all LaTeX occurrences will be converted into MathML.\r\n * @param {string} code - HTML code to be parsed.\r\n * @returns {string} HTML code parsed.\r\n */\n\n }, {\n key: \"endParseEditMode\",\n value: function endParseEditMode(code) {\n // Converting LaTeX to images.\n if (_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('parseModes').indexOf('latex') != -1) {\n var output = '';\n var endPosition = 0;\n var startPosition = code.indexOf('$$');\n\n while (startPosition != -1) {\n output += code.substring(endPosition, startPosition);\n endPosition = code.indexOf('$$', startPosition + 2);\n\n if (endPosition != -1) {\n // Before, it was a condition here to execute the next codelines 'latex.indexOf('<') == -1'.\n // We don't know why it was used, but seems to have a conflict with latex formulas that contains '<'.\n var latex = code.substring(startPosition + 2, endPosition);\n latex = _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].htmlEntitiesDecode(latex);\n var mathml = _latex__WEBPACK_IMPORTED_MODULE_2__[\"default\"].getMathMLFromLatex(latex, true);\n output += mathml;\n endPosition += 2;\n } else {\n output += '$$';\n endPosition = startPosition + 2;\n }\n\n startPosition = code.indexOf('$$', endPosition);\n }\n\n output += code.substring(endPosition, code.length);\n code = output;\n }\n\n return code;\n }\n /**\r\n * Parses end HTML code depending on the save mode. Converts all\r\n * images into the element determined by the save mode:\r\n * - xml: Parses images formulas into MathML.\r\n * - safeXml: Parses images formulas into safeMAthML\r\n * - base64: Parses images into base64 images.\r\n * - image: Parse images into images (no parsing)\r\n * @param {string} code - HTML code to be parsed\r\n * @returns {string} HTML code parsed.\r\n */\n\n }, {\n key: \"endParseSaveMode\",\n value: function endParseSaveMode(code) {\n if (_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('saveMode')) {\n if (_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('saveMode') == 'safeXml') {\n code = Parser.codeImgTransform(code, 'img2mathml');\n } else if (_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('saveMode') == 'xml') {\n code = Parser.codeImgTransform(code, 'img2mathml');\n } else if (_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('saveMode') == 'base64' && _configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('editMode') == 'image') {\n code = Parser.codeImgTransform(code, 'img264');\n }\n }\n\n return code;\n }\n /**\r\n * Returns the result to call showimage service with the formula md5 as parameter.\r\n * The result could be:\r\n * - {'status' : warning'} : The image associated to the MathML md5 is not in cache.\r\n * - {'status' : 'ok' ...} : The image associated to the MathML md5 is in cache.\r\n * @param {Object[]} data - object containing showimage service parameters.\r\n * @param {string} language - string containing the language of the formula.\r\n * @returns {Object} JSON object containing showimage response.\r\n */\n\n }, {\n key: \"createShowImageSrc\",\n value: function createShowImageSrc(data, language) {\n var dataMd5 = [];\n var renderParams = 'mml,color,centerbaseline,zoom,dpi,fontSize,fontFamily,defaultStretchy,backgroundColor,format';\n var renderParamsArray = renderParams.split(',');\n\n for (var key in renderParamsArray) {\n var param = renderParamsArray[key];\n\n if (typeof data[param] != 'undefined') {\n dataMd5[param] = data[param];\n }\n } // Data variables to get.\n\n\n var dataObject = {};\n\n for (var key in data) {\n // We don't need mathml in this request we try to get cached so we only need the formula md5 calculated before.\n if (key != 'mml') {\n dataObject[key] = data[key];\n }\n }\n\n dataObject.formula = com.wiris.js.JsPluginTools.md5encode(_util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].propertiesToString(dataMd5));\n dataObject.lang = typeof language == 'undefined' ? 'en' : language;\n dataObject.version = _configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('version');\n var result = _serviceprovider__WEBPACK_IMPORTED_MODULE_6__[\"default\"].getService('showimage', _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].httpBuildQuery(dataObject), true);\n return result;\n }\n /**\r\n * Transform html img tags inside a html code to mathml, base64 img tags (i.e with base64 on src) or showimage img tags (i.e with showimage.php on src)\r\n * @param {string} code - HTML code\r\n * @param {string} mode - base642showimage or img2mathml or img264 transform.\r\n * @returns {string} html - code transformed.\r\n */\n\n }, {\n key: \"codeImgTransform\",\n value: function codeImgTransform(code, mode) {\n var output = '';\n var endPosition = 0;\n var pattern = /') {\n endPosition = i + 1;\n }\n\n ++i;\n }\n\n if (endPosition < startPosition) {\n // The img tag is stripped.\n output += code.substring(startPosition, code.length);\n return output;\n }\n\n var imgCode = code.substring(startPosition, endPosition);\n var imgObject = _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].createObject(imgCode);\n var xmlCode = imgObject.getAttribute(_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('imageMathmlAttribute'));\n var convertToXml;\n var convertToSafeXml;\n\n if (mode == 'base642showimage') {\n if (xmlCode == null) {\n xmlCode = imgObject.getAttribute('alt');\n }\n\n xmlCode = _mathml__WEBPACK_IMPORTED_MODULE_3__[\"default\"].safeXmlDecode(xmlCode);\n imgCode = Parser.mathmlToImgObject(document, xmlCode, null, null);\n output += _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].createObjectCode(imgCode);\n } else if (mode == 'img2mathml') {\n if (_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('saveMode')) {\n if (_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('saveMode') == 'safeXml') {\n convertToXml = true;\n convertToSafeXml = true;\n } else if (_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('saveMode') == 'xml') {\n convertToXml = true;\n convertToSafeXml = false;\n }\n }\n\n output += _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].getWIRISImageOutput(imgCode, convertToXml, convertToSafeXml);\n } else if (mode == 'img264') {\n if (xmlCode == null) {\n xmlCode = imgObject.getAttribute('alt');\n }\n\n xmlCode = _mathml__WEBPACK_IMPORTED_MODULE_3__[\"default\"].safeXmlDecode(xmlCode);\n var properties = {};\n properties['base64'] = 'true';\n imgCode = Parser.mathmlToImgObject(document, xmlCode, properties, null); // Metrics.\n\n _image__WEBPACK_IMPORTED_MODULE_4__[\"default\"].setImgSize(imgCode, imgCode.src, true);\n output += _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].createObjectCode(imgCode);\n }\n }\n\n output += code.substring(endPosition, code.length);\n return output;\n }\n /**\r\n * Converts all occurrences of safe applet code to the corresponding code.\r\n * @param {string} content - String containing valid applet code ...\r\n * @returns {string} content with all the applet code converted to safe tags.\r\n */\n\n }, {\n key: \"parseSafeAppletsToObjects\",\n value: function parseSafeAppletsToObjects(content) {\n var output = '';\n var appletTagBegin = _constants__WEBPACK_IMPORTED_MODULE_8__[\"default\"].safeXmlCharacters.tagOpener + 'APPLET';\n var appletTagEnd = _constants__WEBPACK_IMPORTED_MODULE_8__[\"default\"].safeXmlCharacters.tagOpener + '/APPLET' + _constants__WEBPACK_IMPORTED_MODULE_8__[\"default\"].safeXmlCharacters.tagCloser;\n var upperCaseContent = content.toUpperCase();\n var start = upperCaseContent.indexOf(appletTagBegin);\n var end = 0;\n var applet;\n\n while (start != -1) {\n output += content.substring(end, start);\n end = upperCaseContent.indexOf(appletTagEnd, start);\n\n if (end == -1) {\n end = content.length - 1;\n } else {\n end += appletTagEnd.length;\n }\n\n applet = _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].convertOldXmlinitialtextAttribute(content.substring(start, end));\n output += _mathml__WEBPACK_IMPORTED_MODULE_3__[\"default\"].safeXmlDecode(applet);\n start = upperCaseContent.indexOf(appletTagBegin, end);\n }\n\n output += content.substring(end, content.length);\n return output;\n }\n /**\r\n * Converts all occurrences of MathML to the corresponding image.\r\n * @param {string} content - string with valid MathML code. The MathML code doesn't contain semantics.\r\n * @param {Constants} characters - Constant object containing xmlCharacters or safeXmlCharacters relation.\r\n * @param {string} language - a valid language code in order to generate formula accessibility.\r\n * @returns {string} The input string with all the MathML occurrences replaced by the corresponding image.\r\n */\n\n }, {\n key: \"parseMathmlToImg\",\n value: function parseMathmlToImg(content, characters, language) {\n var output = '';\n var mathTagBegin = characters.tagOpener + 'math';\n var mathTagEnd = characters.tagOpener + '/math' + characters.tagCloser;\n var start = content.indexOf(mathTagBegin);\n var end = 0;\n\n while (start != -1) {\n output += content.substring(end, start); // Avoid WIRIS images to be parsed.\n\n var imageMathmlAtrribute = content.indexOf(_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('imageMathmlAttribute'));\n end = content.indexOf(mathTagEnd, start);\n\n if (end == -1) {\n end = content.length - 1;\n } else if (imageMathmlAtrribute != -1) {\n // First close tag of img attribute\n // If a mathmlAttribute exists should be inside a img tag.\n end += content.indexOf(\"/>\", start);\n } else {\n end += mathTagEnd.length;\n }\n\n if (!_mathml__WEBPACK_IMPORTED_MODULE_3__[\"default\"].isMathmlInAttribute(content, start) && imageMathmlAtrribute == -1) {\n var mathml = content.substring(start, end);\n mathml = characters == _constants__WEBPACK_IMPORTED_MODULE_8__[\"default\"].safeXmlCharacters ? _mathml__WEBPACK_IMPORTED_MODULE_3__[\"default\"].safeXmlDecode(mathml) : _mathml__WEBPACK_IMPORTED_MODULE_3__[\"default\"].mathMLEntities(mathml);\n output += _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].createObjectCode(Parser.mathmlToImgObject(document, mathml, null, language));\n } else {\n output += content.substring(start, end);\n }\n\n start = content.indexOf(mathTagBegin, end);\n }\n\n output += content.substring(end, content.length);\n return output;\n }\n }]);\n\n return Parser;\n}(); // Mutation observers to avoid wiris image formulas class be removed.\n\n\n\n\nif (typeof MutationObserver !== 'undefined') {\n var mutationObserver = new MutationObserver(function (mutations) {\n mutations.forEach(function (mutation) {\n if (mutation.oldValue === _configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('imageClassName') && mutation.attributeName === 'class' && mutation.target.className.indexOf(_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('imageClassName')) == -1) {\n mutation.target.className = _configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('imageClassName');\n }\n });\n });\n Parser.observer = Object.create(mutationObserver);\n Parser.observer.Config = {\n attributes: true,\n attributeOldValue: true\n }; // We use own default config.\n\n Parser.observer.observe = function name(target) {\n this.__proto__.observe(target, this.Config);\n };\n}\n\n//# sourceURL=webpack:///./core/src/parser.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"default\", function() { return Parser; });\n/* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./util */ \"./core/src/util.js\");\n/* harmony import */ var _core_src__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./core.src */ \"./core/src/core.src.js\");\n/* harmony import */ var _latex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./latex */ \"./core/src/latex.js\");\n/* harmony import */ var _mathml__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./mathml */ \"./core/src/mathml.js\");\n/* harmony import */ var _image__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./image */ \"./core/src/image.js\");\n/* harmony import */ var _accessibility__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./accessibility */ \"./core/src/accessibility.js\");\n/* harmony import */ var _serviceprovider__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./serviceprovider */ \"./core/src/serviceprovider.js\");\n/* harmony import */ var _configuration__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./configuration */ \"./core/src/configuration.js\");\n/* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./constants */ \"./core/src/constants.js\");\n/* harmony import */ var _md5__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./md5 */ \"./core/src/md5.js\");\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\n\n\n\n\n\n\n\n\n\n\n/**\r\n * This class represent a MahML parser. Converts MathML into formulas depending on the\r\n * image format (SVG, PNG, base64) and the save mode (XML, safeXML, Image) configured in the backend.\r\n */\n\nvar Parser =\n/*#__PURE__*/\nfunction () {\n function Parser() {\n _classCallCheck(this, Parser);\n }\n\n _createClass(Parser, null, [{\n key: \"mathmlToImgObject\",\n\n /**\r\n * Converts a MathML string to an img element.\r\n * @param {Document} creator - Document object to call createElement method.\r\n * @param {string} mathml - MathML code\r\n * @param {Object[]} wirisProperties - object containing WIRIS custom properties\r\n * @param {language} language - custom language for accessibility.\r\n * @returns {HTMLImageElement} the formula image corresponding to initial MathML string.\r\n * @static\r\n */\n value: function mathmlToImgObject(creator, mathml, wirisProperties, language) {\n var width;\n var height;\n var baseline;\n var imgObject = creator.createElement('img');\n imgObject.align = 'middle';\n imgObject.style.maxWidth = 'none';\n var data = wirisProperties ? wirisProperties : {};\n data['mml'] = mathml;\n data['lang'] = language; // Request metrics of the generated image.\n\n data['metrics'] = 'true';\n data['centerbaseline'] = 'false'; // Full base64 method (edit & save).\n\n if (_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('saveMode') == 'base64' && _configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('editMode') == 'default') {\n data['base64'] = true;\n } // Render js params: _wrs_int_wirisProperties contains some js render params. Since mathml can support render params, js params should be send only to editor, not to render.\n\n\n imgObject.className = _configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('imageClassName');\n\n if (mathml.indexOf('class=\"') != -1) {\n // We check here if the MathML has been created from a customEditor (such chemistry)\n // to add data-custom-editor attribute to img object (if necessary).\n var mathmlSubstring = mathml.substring(mathml.indexOf('class=\"') + 'class=\"'.length, mathml.length);\n mathmlSubstring = mathmlSubstring.substring(0, mathmlSubstring.indexOf('\"'));\n mathmlSubstring = mathmlSubstring.substring(4, mathmlSubstring.length);\n imgObject.setAttribute('data-custom-editor', mathmlSubstring);\n } // Performance enabled.\n\n\n if (_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('wirisPluginPerformance') && (_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('saveMode') == 'xml' || _configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('saveMode') == 'safeXml')) {\n var result = JSON.parse(Parser.createShowImageSrc(data, language));\n\n if (result[\"status\"] == 'warning') {\n // POST call.\n // if the mathml is malformed, this function will throw an exception.\n try {\n result = JSON.parse(_serviceprovider__WEBPACK_IMPORTED_MODULE_6__[\"default\"].getService('showimage', data));\n } catch (e) {\n return;\n }\n }\n\n result = result.result;\n\n if (result['format'] == 'png') {\n imgObject.src = 'data:image/png;base64,' + result['content'];\n } else {\n imgObject.src = 'data:image/svg+xml;charset=utf8,' + _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].urlEncode(result['content']);\n }\n\n imgObject.setAttribute(_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('imageMathmlAttribute'), _mathml__WEBPACK_IMPORTED_MODULE_3__[\"default\"].safeXmlEncode(mathml));\n _image__WEBPACK_IMPORTED_MODULE_4__[\"default\"].setImgSize(imgObject, result['content'], true);\n\n if (_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('enableAccessibility')) {\n if (typeof result.alt == 'undefined') {\n imgObject.alt = _accessibility__WEBPACK_IMPORTED_MODULE_5__[\"default\"].mathMLToAccessible(mathml, language, data);\n } else {\n imgObject.alt = result.alt;\n }\n }\n } else {\n var result = Parser.createImageSrc(mathml, data);\n imgObject.setAttribute(_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('imageMathmlAttribute'), _mathml__WEBPACK_IMPORTED_MODULE_3__[\"default\"].safeXmlEncode(mathml));\n imgObject.src = result;\n _image__WEBPACK_IMPORTED_MODULE_4__[\"default\"].setImgSize(imgObject, result, _configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('saveMode') == 'base64' && _configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('editMode') == 'default' ? true : false);\n\n if (_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('enableAccessibility')) {\n imgObject.alt = _accessibility__WEBPACK_IMPORTED_MODULE_5__[\"default\"].mathMLToAccessible(mathml, language, data);\n }\n }\n\n if (typeof Parser.observer != 'undefined') {\n Parser.observer.observe(imgObject);\n } // Role math https://www.w3.org/TR/wai-aria/roles#math.\n\n\n imgObject.setAttribute('role', 'math');\n return imgObject;\n }\n /**\r\n * Returns the source to showimage service by calling createimage service. The\r\n * output of the createimage service is a URL path pointing to showimage service.\r\n * This method is called when performance is disabled.\r\n * @param {string} mathml - MathML code.\r\n * @param {Object[]} data - data object containing service parameters.\r\n * @returns {string} the showimage path.\r\n */\n\n }, {\n key: \"createImageSrc\",\n value: function createImageSrc(mathml, data) {\n // Full base64 method (edit & save).\n if (_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('saveMode') == 'base64' && _configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('editMode') == 'default') {\n data['base64'] = true;\n }\n\n var result = _serviceprovider__WEBPACK_IMPORTED_MODULE_6__[\"default\"].getService('createimage', data);\n\n if (result.indexOf('@BASE@') != -1) {\n // Replacing '@BASE@' with the base URL of createimage.\n var baseParts = _core_src__WEBPACK_IMPORTED_MODULE_1__[\"default\"].getServiceProvider().getServicePath('createimage').split('/');\n baseParts.pop();\n result = result.split('@BASE@').join(baseParts.join('/'));\n }\n\n return result;\n }\n /**\r\n * Parses initial HTML code. If the HTML contains data generated by WIRIS, this data would be converted as following:\r\n *
\r\n     * MathML code: Image containing the corresponding MathML formulas.\r\n     * MathML code with LaTeX annotation : LaTeX string.\r\n     * 
\r\n * @param {string} code - HTML code containing MathML data.\r\n * @param {string} language - language to create image alt text.\r\n * @returns {string} HTML code with the original MathML converted into LaTeX and images.\r\n */\n\n }, {\n key: \"initParse\",\n value: function initParse(code, language) {\n /* Note: The code inside this function has been inverted.\r\n If you invert again the code then you cannot use correctly LaTeX\r\n in Moodle.\r\n */\n code = Parser.initParseSaveMode(code, language);\n return Parser.initParseEditMode(code);\n }\n /**\r\n * Parses initial HTML code depending on the save mode. Transforms all MathML\r\n * occurrences for it's correspondent image or LaTeX.\r\n * @param {string} code - HTML code to be parsed\r\n * @param {string} language - language to create image alt text.\r\n * @returns {string} HTML code parsed.\r\n */\n\n }, {\n key: \"initParseSaveMode\",\n value: function initParseSaveMode(code, language) {\n if (_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('saveMode')) {\n // Converting XML to tags.\n code = _latex__WEBPACK_IMPORTED_MODULE_2__[\"default\"].parseMathmlToLatex(code, _constants__WEBPACK_IMPORTED_MODULE_8__[\"default\"].safeXmlCharacters);\n code = _latex__WEBPACK_IMPORTED_MODULE_2__[\"default\"].parseMathmlToLatex(code, _constants__WEBPACK_IMPORTED_MODULE_8__[\"default\"].xmlCharacters); // Safe XML and XML must be parsed regardeless of save mode.\n // Order is important here, safeXml must be parsed first in order to avoid conflicts with data-mathml img attribute.\n\n code = Parser.parseSafeAppletsToObjects(code);\n code = Parser.parseMathmlToImg(code, _constants__WEBPACK_IMPORTED_MODULE_8__[\"default\"].safeXmlCharacters, language);\n code = Parser.parseMathmlToImg(code, _constants__WEBPACK_IMPORTED_MODULE_8__[\"default\"].xmlCharacters, language);\n\n if (_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('saveMode') == 'base64' && _configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('editMode') == 'image') {\n code = Parser.codeImgTransform(code, 'base642showimage');\n }\n }\n\n var appletList = _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].getElementsByNameFromString(code, 'applet', false);\n var carry = 0; // While replacing applets with images, the indexes of the found applets changes respecting the original code, so this carry is needed.\n\n for (var i = 0; i < appletList.length; ++i) {\n var appletCode = code.substring(appletList[i].start + carry, appletList[i].end + carry); // The second control in the if is used to find WIRIS applet which don't have Wiriscas class (as it was in old CAS applets).\n\n if (appletCode.indexOf(' class=\"' + _configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('CASClassName') + '\"') != -1 || appletCode.toUpperCase().indexOf('WIRIS') != -1) {\n if (appletCode.indexOf(' src=\"') != -1) {\n var srcStart = appletCode.indexOf(' src=\"') + ' src=\"'.length;\n var srcEnd = appletCode.indexOf('\"', srcStart);\n var src = appletCode.substring(srcStart, srcEnd);\n } else {\n // This should happen only with old CAS imported from Moodle 1 to Moodle 2.\n if (typeof _wrs_conf_pluginBasePath != 'undefined') {\n var src = _wrs_conf_pluginBasePath + '/integration/showcasimage.php?formula=noimage';\n } else {\n var src = '';\n }\n\n if (appletCode.indexOf(' class=\"' + _configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('CASClassName') + '\"') == -1) {\n var closeSymbol = appletCode.indexOf('>');\n var appletTag = appletCode.substring(0, closeSymbol);\n var newAppletTag = appletTag.split(' width=').join(' class=\"Wiriscas\" width=');\n appletCode = appletCode.split(appletTag).join(newAppletTag);\n appletCode = appletCode.split('\\'').join('\"');\n }\n } // Double click to edit has been removed here.\n\n\n var imgCode = '';\n code = code.substring(0, appletList[i].start + carry) + imgCode + code.substring(appletList[i].end + carry);\n carry += imgCode.length - (appletList[i].end - appletList[i].start);\n }\n }\n\n return code;\n }\n /**\r\n * Parses initial HTML code depending on the edit mode.\r\n * If 'latex' parseMode is enabled all MathML containing an annotation with encoding='LaTeX' will\r\n * be converted into a LaTeX string instead of an image.\r\n * @param {string} code - HTML code containing MathML.\r\n * @returns {string} parsed HTML code.\r\n */\n\n }, {\n key: \"initParseEditMode\",\n value: function initParseEditMode(code) {\n if (_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('parseModes').indexOf('latex') != -1) {\n var imgList = _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].getElementsByNameFromString(code, 'img', true);\n var token = 'encoding=\"LaTeX\">';\n var carry = 0;\n 4; // While replacing images with latex, the indexes of the found images changes respecting the original code, so this carry is needed.\n\n for (var i = 0; i < imgList.length; ++i) {\n var imgCode = code.substring(imgList[i].start + carry, imgList[i].end + carry);\n\n if (imgCode.indexOf(' class=\"' + _configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('imageClassName') + '\"') != -1) {\n var mathmlStartToken = ' ' + _configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('imageMathmlAttribute') + '=\"';\n var mathmlStart = imgCode.indexOf(mathmlStartToken);\n\n if (mathmlStart == -1) {\n mathmlStartToken = ' alt=\"';\n mathmlStart = imgCode.indexOf(mathmlStartToken);\n }\n\n if (mathmlStart != -1) {\n mathmlStart += mathmlStartToken.length;\n var mathmlEnd = imgCode.indexOf('\"', mathmlStart);\n var mathml = _mathml__WEBPACK_IMPORTED_MODULE_3__[\"default\"].safeXmlDecode(imgCode.substring(mathmlStart, mathmlEnd));\n var latexStartPosition = mathml.indexOf(token);\n\n if (latexStartPosition != -1) {\n latexStartPosition += token.length;\n var latexEndPosition = mathml.indexOf('', latexStartPosition);\n var latex = mathml.substring(latexStartPosition, latexEndPosition);\n var replaceText = '$$' + _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].htmlEntitiesDecode(latex) + '$$';\n code = code.substring(0, imgList[i].start + carry) + replaceText + code.substring(imgList[i].end + carry);\n carry += replaceText.length - (imgList[i].end - imgList[i].start);\n }\n }\n }\n }\n }\n\n return code;\n }\n /**\r\n * Parses end HTML code. The end HTML code is HTML code with embedded images or LaTeX formulas created with MathType.
\r\n * By default this method converts the formula images and LaTeX strings in MathML.
\r\n * If image mode is enabled the images will not be converted into MathML. For further information see {@link http://www.wiris.com/plugins/docs/full-mathml-mode}.\r\n * @param {string} code - HTML to be parsed\r\n * @returns {string} the HTML code parsed.\r\n */\n\n }, {\n key: \"endParse\",\n value: function endParse(code) {\n // Transform LaTeX ocurrences to MathML elements.\n var codeEndParsedEditMode = Parser.endParseEditMode(code); // Transform img elements to MathML elements.\n\n var codeEndParseSaveMode = Parser.endParseSaveMode(codeEndParsedEditMode);\n return codeEndParseSaveMode;\n }\n /**\r\n * Parses end HTML code depending on the edit mode.\r\n * - LaTeX is an enabled parse mode, all LaTeX occurrences will be converted into MathML.\r\n * @param {string} code - HTML code to be parsed.\r\n * @returns {string} HTML code parsed.\r\n */\n\n }, {\n key: \"endParseEditMode\",\n value: function endParseEditMode(code) {\n // Converting LaTeX to images.\n if (_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('parseModes').indexOf('latex') != -1) {\n var output = '';\n var endPosition = 0;\n var startPosition = code.indexOf('$$');\n\n while (startPosition != -1) {\n output += code.substring(endPosition, startPosition);\n endPosition = code.indexOf('$$', startPosition + 2);\n\n if (endPosition != -1) {\n // Before, it was a condition here to execute the next codelines 'latex.indexOf('<') == -1'.\n // We don't know why it was used, but seems to have a conflict with latex formulas that contains '<'.\n var latex = code.substring(startPosition + 2, endPosition);\n latex = _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].htmlEntitiesDecode(latex);\n var mathml = _latex__WEBPACK_IMPORTED_MODULE_2__[\"default\"].getMathMLFromLatex(latex, true);\n output += mathml;\n endPosition += 2;\n } else {\n output += '$$';\n endPosition = startPosition + 2;\n }\n\n startPosition = code.indexOf('$$', endPosition);\n }\n\n output += code.substring(endPosition, code.length);\n code = output;\n }\n\n return code;\n }\n /**\r\n * Parses end HTML code depending on the save mode. Converts all\r\n * images into the element determined by the save mode:\r\n * - xml: Parses images formulas into MathML.\r\n * - safeXml: Parses images formulas into safeMAthML\r\n * - base64: Parses images into base64 images.\r\n * - image: Parse images into images (no parsing)\r\n * @param {string} code - HTML code to be parsed\r\n * @returns {string} HTML code parsed.\r\n */\n\n }, {\n key: \"endParseSaveMode\",\n value: function endParseSaveMode(code) {\n if (_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('saveMode')) {\n if (_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('saveMode') == 'safeXml') {\n code = Parser.codeImgTransform(code, 'img2mathml');\n } else if (_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('saveMode') == 'xml') {\n code = Parser.codeImgTransform(code, 'img2mathml');\n } else if (_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('saveMode') == 'base64' && _configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('editMode') == 'image') {\n code = Parser.codeImgTransform(code, 'img264');\n }\n }\n\n return code;\n }\n /**\r\n * Returns the result to call showimage service with the formula md5 as parameter.\r\n * The result could be:\r\n * - {'status' : warning'} : The image associated to the MathML md5 is not in cache.\r\n * - {'status' : 'ok' ...} : The image associated to the MathML md5 is in cache.\r\n * @param {Object[]} data - object containing showimage service parameters.\r\n * @param {string} language - string containing the language of the formula.\r\n * @returns {Object} JSON object containing showimage response.\r\n */\n\n }, {\n key: \"createShowImageSrc\",\n value: function createShowImageSrc(data, language) {\n var dataMd5 = [];\n var renderParams = 'mml,color,centerbaseline,zoom,dpi,fontSize,fontFamily,defaultStretchy,backgroundColor,format';\n var renderParamsArray = renderParams.split(',');\n\n for (var key in renderParamsArray) {\n var param = renderParamsArray[key];\n\n if (typeof data[param] != 'undefined') {\n dataMd5[param] = data[param];\n }\n } // Data variables to get.\n\n\n var dataObject = {};\n\n for (var key in data) {\n // We don't need mathml in this request we try to get cached so we only need the formula md5 calculated before.\n if (key != 'mml') {\n dataObject[key] = data[key];\n }\n }\n\n dataObject.formula = com.wiris.js.JsPluginTools.md5encode(_util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].propertiesToString(dataMd5));\n dataObject.lang = typeof language == 'undefined' ? 'en' : language;\n dataObject.version = _configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('version');\n var result = _serviceprovider__WEBPACK_IMPORTED_MODULE_6__[\"default\"].getService('showimage', _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].httpBuildQuery(dataObject), true);\n return result;\n }\n /**\r\n * Transform html img tags inside a html code to mathml, base64 img tags (i.e with base64 on src) or showimage img tags (i.e with showimage.php on src)\r\n * @param {string} code - HTML code\r\n * @param {string} mode - base642showimage or img2mathml or img264 transform.\r\n * @returns {string} html - code transformed.\r\n */\n\n }, {\n key: \"codeImgTransform\",\n value: function codeImgTransform(code, mode) {\n var output = '';\n var endPosition = 0;\n var pattern = /') {\n endPosition = i + 1;\n }\n\n ++i;\n }\n\n if (endPosition < startPosition) {\n // The img tag is stripped.\n output += code.substring(startPosition, code.length);\n return output;\n }\n\n var imgCode = code.substring(startPosition, endPosition);\n var imgObject = _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].createObject(imgCode);\n var xmlCode = imgObject.getAttribute(_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('imageMathmlAttribute'));\n var convertToXml;\n var convertToSafeXml;\n\n if (mode == 'base642showimage') {\n if (xmlCode == null) {\n xmlCode = imgObject.getAttribute('alt');\n }\n\n xmlCode = _mathml__WEBPACK_IMPORTED_MODULE_3__[\"default\"].safeXmlDecode(xmlCode);\n imgCode = Parser.mathmlToImgObject(document, xmlCode, null, null);\n output += _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].createObjectCode(imgCode);\n } else if (mode == 'img2mathml') {\n if (_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('saveMode')) {\n if (_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('saveMode') == 'safeXml') {\n convertToXml = true;\n convertToSafeXml = true;\n } else if (_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('saveMode') == 'xml') {\n convertToXml = true;\n convertToSafeXml = false;\n }\n }\n\n output += _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].getWIRISImageOutput(imgCode, convertToXml, convertToSafeXml);\n } else if (mode == 'img264') {\n if (xmlCode == null) {\n xmlCode = imgObject.getAttribute('alt');\n }\n\n xmlCode = _mathml__WEBPACK_IMPORTED_MODULE_3__[\"default\"].safeXmlDecode(xmlCode);\n var properties = {};\n properties['base64'] = 'true';\n imgCode = Parser.mathmlToImgObject(document, xmlCode, properties, null); // Metrics.\n\n _image__WEBPACK_IMPORTED_MODULE_4__[\"default\"].setImgSize(imgCode, imgCode.src, true);\n output += _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].createObjectCode(imgCode);\n }\n }\n\n output += code.substring(endPosition, code.length);\n return output;\n }\n /**\r\n * Converts all occurrences of safe applet code to the corresponding code.\r\n * @param {string} content - String containing valid applet code ...\r\n * @returns {string} content with all the applet code converted to safe tags.\r\n */\n\n }, {\n key: \"parseSafeAppletsToObjects\",\n value: function parseSafeAppletsToObjects(content) {\n var output = '';\n var appletTagBegin = _constants__WEBPACK_IMPORTED_MODULE_8__[\"default\"].safeXmlCharacters.tagOpener + 'APPLET';\n var appletTagEnd = _constants__WEBPACK_IMPORTED_MODULE_8__[\"default\"].safeXmlCharacters.tagOpener + '/APPLET' + _constants__WEBPACK_IMPORTED_MODULE_8__[\"default\"].safeXmlCharacters.tagCloser;\n var upperCaseContent = content.toUpperCase();\n var start = upperCaseContent.indexOf(appletTagBegin);\n var end = 0;\n var applet;\n\n while (start != -1) {\n output += content.substring(end, start);\n end = upperCaseContent.indexOf(appletTagEnd, start);\n\n if (end == -1) {\n end = content.length - 1;\n } else {\n end += appletTagEnd.length;\n }\n\n applet = _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].convertOldXmlinitialtextAttribute(content.substring(start, end));\n output += _mathml__WEBPACK_IMPORTED_MODULE_3__[\"default\"].safeXmlDecode(applet);\n start = upperCaseContent.indexOf(appletTagBegin, end);\n }\n\n output += content.substring(end, content.length);\n return output;\n }\n /**\r\n * Converts all occurrences of MathML to the corresponding image.\r\n * @param {string} content - string with valid MathML code. The MathML code doesn't contain semantics.\r\n * @param {Constants} characters - Constant object containing xmlCharacters or safeXmlCharacters relation.\r\n * @param {string} language - a valid language code in order to generate formula accessibility.\r\n * @returns {string} The input string with all the MathML occurrences replaced by the corresponding image.\r\n */\n\n }, {\n key: \"parseMathmlToImg\",\n value: function parseMathmlToImg(content, characters, language) {\n var output = '';\n var mathTagBegin = characters.tagOpener + 'math';\n var mathTagEnd = characters.tagOpener + '/math' + characters.tagCloser;\n var start = content.indexOf(mathTagBegin);\n var end = 0;\n\n while (start != -1) {\n output += content.substring(end, start); // Avoid WIRIS images to be parsed.\n\n var imageMathmlAtrribute = content.indexOf(_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('imageMathmlAttribute'));\n end = content.indexOf(mathTagEnd, start);\n\n if (end == -1) {\n end = content.length - 1;\n } else if (imageMathmlAtrribute != -1) {\n // First close tag of img attribute\n // If a mathmlAttribute exists should be inside a img tag.\n end += content.indexOf(\"/>\", start);\n } else {\n end += mathTagEnd.length;\n }\n\n if (!_mathml__WEBPACK_IMPORTED_MODULE_3__[\"default\"].isMathmlInAttribute(content, start) && imageMathmlAtrribute == -1) {\n var mathml = content.substring(start, end);\n mathml = characters == _constants__WEBPACK_IMPORTED_MODULE_8__[\"default\"].safeXmlCharacters ? _mathml__WEBPACK_IMPORTED_MODULE_3__[\"default\"].safeXmlDecode(mathml) : _mathml__WEBPACK_IMPORTED_MODULE_3__[\"default\"].mathMLEntities(mathml);\n output += _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].createObjectCode(Parser.mathmlToImgObject(document, mathml, null, language));\n } else {\n output += content.substring(start, end);\n }\n\n start = content.indexOf(mathTagBegin, end);\n }\n\n output += content.substring(end, content.length);\n return output;\n }\n }]);\n\n return Parser;\n}(); // Mutation observers to avoid wiris image formulas class be removed.\n\n\n\n\nif (typeof MutationObserver !== 'undefined') {\n var mutationObserver = new MutationObserver(function (mutations) {\n mutations.forEach(function (mutation) {\n if (mutation.oldValue === _configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('imageClassName') && mutation.attributeName === 'class' && mutation.target.className.indexOf(_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('imageClassName')) == -1) {\n mutation.target.className = _configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('imageClassName');\n }\n });\n });\n Parser.observer = Object.create(mutationObserver);\n Parser.observer.Config = {\n attributes: true,\n attributeOldValue: true\n }; // We use own default config.\n\n Parser.observer.observe = function name(target) {\n this.__proto__.observe(target, this.Config);\n };\n}\n\n//# sourceURL=webpack:///./core/src/parser.js?"); /***/ }), @@ -370,7 +370,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) * /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"default\", function() { return Util; });\n/* harmony import */ var _mathml__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./mathml */ \"./core/src/mathml.js\");\n/* harmony import */ var _configuration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./configuration */ \"./core/src/configuration.js\");\n/* harmony import */ var _latex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./latex */ \"./core/src/latex.js\");\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\n\n\n\n/**\r\n * This class represents an utility class.\r\n */\n\nvar Util =\n/*#__PURE__*/\nfunction () {\n function Util() {\n _classCallCheck(this, Util);\n }\n\n _createClass(Util, null, [{\n key: \"fireEvent\",\n\n /**\r\n * Fires an event in a target.\r\n * @param {EventTarget} eventTarget - target where event should be fired.\r\n * @param {string} eventName event to fire.\r\n * @static\r\n */\n value: function fireEvent(eventTarget, eventName) {\n if (document.createEvent) {\n var eventObject = document.createEvent('HTMLEvents');\n eventObject.initEvent(eventName, true, true);\n return !eventTarget.dispatchEvent(eventObject);\n }\n\n var eventObject = document.createEventObject();\n return eventTarget.fireEvent('on' + eventName, eventObject);\n }\n /**\r\n * Cross-browser addEventListener/attachEvent function.\r\n * @param {EventTarget} eventTarget - target to add the event.\r\n * @param {string} eventName - specifies the type of event.\r\n * @param {Function} callBackFunction - callback function.\r\n * @static\r\n */\n\n }, {\n key: \"addEvent\",\n value: function addEvent(eventTarget, eventName, callBackFunction) {\n if (eventTarget.addEventListener) {\n eventTarget.addEventListener(eventName, callBackFunction, true);\n } else if (eventTarget.attachEvent) {\n // Backwards compatibility.\n eventTarget.attachEvent('on' + eventName, callBackFunction);\n }\n }\n /**\r\n * Cross-browser removeEventListener/detachEvent function.\r\n * @param {EventTarget} eventTarget - target to add the event.\r\n * @param {string} eventName - specifies the type of event.\r\n * @param {Function} callBackFunction - function to remove from the event target.\r\n * @static\r\n */\n\n }, {\n key: \"removeEvent\",\n value: function removeEvent(eventTarget, eventName, callBackFunction) {\n if (eventTarget.removeEventListener) {\n eventTarget.removeEventListener(eventName, callBackFunction, true);\n } else if (eventTarget.detachEvent) {\n eventTarget.detachEvent('on' + eventName, callBackFunction);\n }\n }\n /**\r\n * Adds the a callback function, for a certain event target, to the following event types:\r\n * - dblclick\r\n * - mousedown\r\n * - mouseup\r\n * @param {EventTarget} eventTarget - event target.\r\n * @param {Function} doubleClickHandler - function to run when on dblclick event.\r\n * @param {Function} mousedownHandler - function to run when on mousedown event.\r\n * @param {Function} mouseupHandler - function to run when on mouseup event.\r\n * @static\r\n */\n\n }, {\n key: \"addElementEvents\",\n value: function addElementEvents(eventTarget, doubleClickHandler, mousedownHandler, mouseupHandler) {\n if (doubleClickHandler) {\n Util.addEvent(eventTarget, 'dblclick', function (event) {\n var realEvent = event ? event : window.event;\n var element = realEvent.srcElement ? realEvent.srcElement : realEvent.target;\n doubleClickHandler(element, realEvent);\n });\n }\n\n if (mousedownHandler) {\n Util.addEvent(eventTarget, 'mousedown', function (event) {\n var realEvent = event ? event : window.event;\n var element = realEvent.srcElement ? realEvent.srcElement : realEvent.target;\n mousedownHandler(element, realEvent);\n });\n }\n\n if (mouseupHandler) {\n Util.addEvent(eventTarget, 'mouseup', function (event) {\n var realEvent = event ? event : window.event;\n var element = realEvent.srcElement ? realEvent.srcElement : realEvent.target;\n mouseupHandler(element, realEvent);\n });\n }\n }\n /**\r\n * Adds a class name to a HTMLElement.\r\n * @param {HTMLElement} element - the HTML element.\r\n * @param {string} className - the class name.\r\n * @static\r\n */\n\n }, {\n key: \"addClass\",\n value: function addClass(element, className) {\n if (!Util.containsClass(element, className)) {\n element.className += \" \" + className;\n }\n }\n /**\r\n * Checks if a HTMLElement contains a certain class.\r\n * @param {HTMLElement} element - the HTML element.\r\n * @param {string} className - the className.\r\n * @returns {boolean} true if the HTMLElement contains the class name. false otherwise.\r\n * @static\r\n */\n\n }, {\n key: \"containsClass\",\n value: function containsClass(element, className) {\n if (element == null || !('className' in element)) {\n return false;\n }\n\n var currentClasses = element.className.split(' ');\n\n for (var i = currentClasses.length - 1; i >= 0; --i) {\n if (currentClasses[i] == className) {\n return true;\n }\n }\n\n return false;\n }\n /**\r\n * Remove a certain class for a HTMLElement.\r\n * @param {HTMLElement} element - the HTML element.\r\n * @param {string} className - the class name.\r\n * @static\r\n */\n\n }, {\n key: \"removeClass\",\n value: function removeClass(element, className) {\n var newClassName = '';\n var classes = element.className.split(\" \");\n\n for (var i = 0; i < classes.length; i++) {\n if (classes[i] != className) {\n newClassName += classes[i] + \" \";\n }\n }\n\n element.className = newClassName.trim();\n }\n /**\r\n * Converts old xml initial text attribute (with «») to the correct one(with §lt;§gt;). It's\r\n * used to parse old applets.\r\n * @param {string} text - string containing safeXml characters\r\n * @returns {string} a string with safeXml characters parsed.\r\n * @static\r\n */\n\n }, {\n key: \"convertOldXmlinitialtextAttribute\",\n value: function convertOldXmlinitialtextAttribute(text) {\n // Used to fix a bug with Cas imported from Moodle 1.9 to Moodle 2.x.\n // This could be removed in future.\n var val = 'value=';\n var xitpos = text.indexOf('xmlinitialtext');\n var valpos = text.indexOf(val, xitpos);\n var quote = text.charAt(valpos + val.length);\n var startquote = valpos + val.length + 1;\n var endquote = text.indexOf(quote, startquote);\n var value = text.substring(startquote, endquote);\n var newvalue = value.split('«').join('§lt;');\n newvalue = newvalue.split('»').join('§gt;');\n newvalue = newvalue.split('&').join('§');\n newvalue = newvalue.split('¨').join('§quot;');\n text = text.split(value).join(newvalue);\n return text;\n }\n /**\r\n * Cross-browser solution for creating new elements.\r\n * @param {string} tagName - tag name of the wished element.\r\n * @param {Object} attributes - an object where each key is a wished attribute name and each value is its value.\r\n * @param {Object} [creator] - if supplied, this function will use the \"createElement\" method from this param. Otherwise\r\n * document will be used as creator.\r\n * @returns {Element} The DOM element with the specified attributes assigned.\r\n * @static\r\n */\n\n }, {\n key: \"createElement\",\n value: function createElement(tagName, attributes, creator) {\n if (attributes === undefined) {\n attributes = {};\n }\n\n if (creator === undefined) {\n creator = document;\n }\n\n var element;\n /*\r\n * Internet Explorer fix:\r\n * If you create a new object dynamically, you can't set a non-standard attribute.\r\n * For example, you can't set the \"src\" attribute on an \"applet\" object.\r\n * Other browsers will throw an exception and will run the standard code.\r\n */\n\n try {\n var html = '<' + tagName;\n\n for (var attributeName in attributes) {\n html += ' ' + attributeName + '=\"' + Util.htmlEntities(attributes[attributeName]) + '\"';\n }\n\n html += '>';\n element = creator.createElement(html);\n } catch (e) {\n element = creator.createElement(tagName);\n\n for (var attributeName in attributes) {\n element.setAttribute(attributeName, attributes[attributeName]);\n }\n }\n\n return element;\n }\n /**\r\n * Creates new HTML from it's HTML code as string.\r\n * @param {string} objectCode - html code\r\n * @returns {Element} the HTML element.\r\n * @static\r\n */\n\n }, {\n key: \"createObject\",\n value: function createObject(objectCode, creator) {\n if (creator === undefined) {\n creator = document;\n } // Internet Explorer can't include \"param\" tag when is setting an innerHTML property.\n\n\n objectCode = objectCode.split('').join('').split('').join('');\n objectCode = objectCode.split('').join('
').split('').join('
');\n var container = Util.createElement('div', {}, creator);\n container.innerHTML = objectCode;\n\n function recursiveParamsFix(object) {\n if (object.getAttribute && object.getAttribute('wirisObject') == 'WirisParam') {\n var attributesParsed = {};\n\n for (var i = 0; i < object.attributes.length; ++i) {\n if (object.attributes[i].nodeValue !== null) {\n attributesParsed[object.attributes[i].nodeName] = object.attributes[i].nodeValue;\n }\n }\n\n var param = Util.createElement('param', attributesParsed, creator); // IE fix.\n\n if (param.NAME) {\n param.name = param.NAME;\n param.value = param.VALUE;\n }\n\n param.removeAttribute('wirisObject');\n object.parentNode.replaceChild(param, object);\n } else if (object.getAttribute && object.getAttribute('wirisObject') == 'WirisApplet') {\n var attributesParsed = {};\n\n for (var i = 0; i < object.attributes.length; ++i) {\n if (object.attributes[i].nodeValue !== null) {\n attributesParsed[object.attributes[i].nodeName] = object.attributes[i].nodeValue;\n }\n }\n\n var applet = Util.createElement('applet', attributesParsed, creator);\n applet.removeAttribute('wirisObject');\n\n for (var i = 0; i < object.childNodes.length; ++i) {\n recursiveParamsFix(object.childNodes[i]);\n\n if (object.childNodes[i].nodeName.toLowerCase() == 'param') {\n applet.appendChild(object.childNodes[i]);\n --i; // When we insert the object child into the applet, object loses one child.\n }\n }\n\n object.parentNode.replaceChild(applet, object);\n } else {\n for (var i = 0; i < object.childNodes.length; ++i) {\n recursiveParamsFix(object.childNodes[i]);\n }\n }\n }\n\n recursiveParamsFix(container);\n return container.firstChild;\n }\n /**\r\n * Converts an Element to its HTML code.\r\n * @param {Element} element - entry element.\r\n * @return {string} the HTML code of the input element.\r\n * @static\r\n */\n\n }, {\n key: \"createObjectCode\",\n value: function createObjectCode(element) {\n // In case that the image was not created, the object can be null or undefined.\n if (typeof element == 'undefined' || element == null) {\n return;\n }\n\n if (element.nodeType == 1) {\n // ELEMENT_NODE.\n var output = '<' + element.tagName;\n\n for (var i = 0; i < element.attributes.length; ++i) {\n if (element.attributes[i].specified) {\n output += ' ' + element.attributes[i].name + '=\"' + Util.htmlEntities(element.attributes[i].value) + '\"';\n }\n }\n\n if (element.childNodes.length > 0) {\n output += '>';\n\n for (var i = 0; i < element.childNodes.length; ++i) {\n output += Util.createObject(element.childNodes[i]);\n }\n\n output += '';\n } else if (element.nodeName == 'DIV' || element.nodeName == 'SCRIPT') {\n output += '>';\n } else {\n output += '/>';\n }\n\n return output;\n }\n\n if (element.nodeType == 3) {\n // TEXT_NODE.\n return Util.htmlEntities(element.nodeValue);\n }\n\n return '';\n }\n /**\r\n * Concatenates two URL paths.\r\n * @param {string} path1 - first URL path\r\n * @param {string} path2 - second URL path\r\n * @returns {string} new URL.\r\n */\n\n }, {\n key: \"concatenateUrl\",\n value: function concatenateUrl(path1, path2) {\n var separator = \"\";\n\n if (path1.indexOf(\"/\") != path1.length && path2.indexOf(\"/\") != 0) {\n separator = \"/\";\n }\n\n return (path1 + separator + path2).replace(/([^:]\\/)\\/+/g, \"$1\");\n }\n /**\r\n * Parses a text and replaces all HTML special characters by their correspondent entities.\r\n * @param {string} input - text to be parsed.\r\n * @returns {string} the input text with all their special characters replaced by their entities.\r\n * @static\r\n */\n\n }, {\n key: \"htmlEntities\",\n value: function htmlEntities(input) {\n return input.split('&').join('&').split('<').join('<').split('>').join('>').split('\"').join('"');\n }\n /**\r\n * Parses a text and replaces all the HTML entities by their characters.\r\n * @param {string} input - text to be parsed\r\n * @returns {string} the input text with all their entities replaced by characters.\r\n * @static\r\n */\n\n }, {\n key: \"htmlEntitiesDecode\",\n value: function htmlEntitiesDecode(input) {\n return input.split('"').join('\"').split('>').join('>').split('<').join('<').split('&').join('&');\n }\n /**\r\n * Returns a cross-browser http request.\r\n * @return {object} httpRequest request object.\r\n * @returns {XMLHttpRequest|ActiveXObject} the proper request object.\r\n */\n\n }, {\n key: \"createHttpRequest\",\n value: function createHttpRequest() {\n var currentPath = window.location.toString().substr(0, window.location.toString().lastIndexOf('/') + 1);\n\n if (currentPath.substr(0, 7) == 'file://') {\n throw Core.getStringManager().getString('exception_cross_site');\n }\n\n if (typeof XMLHttpRequest != 'undefined') {\n return new XMLHttpRequest();\n }\n\n try {\n return new ActiveXObject('Msxml2.XMLHTTP');\n } catch (e) {\n try {\n return new ActiveXObject('Microsoft.XMLHTTP');\n } catch (oc) {}\n }\n\n return false;\n }\n /**\r\n * Converts a hash to a HTTP query.\r\n * @param {Object[]} properties - a key/value object.\r\n * @returns {string} a HTTP query containing all the key value pairs with all the special characters replaced by their entities.\r\n * @static\r\n */\n\n }, {\n key: \"httpBuildQuery\",\n value: function httpBuildQuery(properties) {\n var result = '';\n\n for (var i in properties) {\n if (properties[i] != null) {\n result += Util.urlEncode(i) + '=' + Util.urlEncode(properties[i]) + '&';\n }\n } // Deleting last '&' empty character.\n\n\n if (result.substring(result.length - 1) == '&') {\n result = result.substring(0, result.length - 1);\n }\n\n return result;\n }\n /**\r\n * Convert a hash to string sorting keys to get a deterministic output\r\n * @param {Object[]} hash - a key/value object.\r\n * @returns {string} a string with the form key1=value1...keyn=valuen\r\n * @static\r\n */\n\n }, {\n key: \"propertiesToString\",\n value: function propertiesToString(hash) {\n // 1. Sort keys. We sort the keys because we want a deterministic output.\n var keys = [];\n\n for (var key in hash) {\n if (hash.hasOwnProperty(key)) {\n keys.push(key);\n }\n }\n\n var n = keys.length;\n\n for (var i = 0; i < n; i++) {\n for (var j = i + 1; j < n; j++) {\n var s1 = keys[i];\n var s2 = keys[j];\n\n if (Util.compareStrings(s1, s2) > 0) {\n // Swap.\n keys[i] = s2;\n keys[j] = s1;\n }\n }\n } // 2. Generate output.\n\n\n var output = '';\n\n for (var i = 0; i < n; i++) {\n var key = keys[i];\n output += key;\n output += \"=\";\n var value = hash[key];\n value = value.replace(\"\\\\\", \"\\\\\\\\\");\n value = value.replace(\"\\n\", \"\\\\n\");\n value = value.replace(\"\\r\", \"\\\\r\");\n value = value.replace(\"\\t\", \"\\\\t\");\n output += value;\n output += \"\\n\";\n }\n\n return output;\n }\n /**\r\n * Compare two strings using charCodeAt method\r\n * @param {string} a - first string to compare.\r\n * @param {string} b - second string to compare.\r\n * @returns {number} the difference between a and b\r\n * @static\r\n */\n\n }, {\n key: \"compareStrings\",\n value: function compareStrings(a, b) {\n var i;\n var an = a.length;\n var bn = b.length;\n var n = an > bn ? bn : an;\n\n for (i = 0; i < n; i++) {\n var c = Util.fixedCharCodeAt(a, i) - Util.fixedCharCodeAt(b, i);\n\n if (c != 0) {\n return c;\n }\n }\n\n return a.length - b.length;\n }\n /**\r\n * Fix charCodeAt() JavaScript function to handle non-Basic-Multilingual-Plane characters.\r\n * @param {string} string - input string\r\n * @param {number} idx - an integer greater than or equal to 0 and less than the length of the string\r\n * @returns {number} an integer representing the UTF-16 code of the string at the given index.\r\n * @static\r\n */\n\n }, {\n key: \"fixedCharCodeAt\",\n value: function fixedCharCodeAt(string, idx) {\n idx = idx || 0;\n var code = string.charCodeAt(idx);\n var hi, low;\n /* High surrogate (could change last hex to 0xDB7F to treat high\r\n private surrogates as single characters) */\n\n if (0xD800 <= code && code <= 0xDBFF) {\n hi = code;\n low = string.charCodeAt(idx + 1);\n\n if (isNaN(low)) {\n throw Core.getStringManager().getString('exception_high_surrogate');\n }\n\n return (hi - 0xD800) * 0x400 + (low - 0xDC00) + 0x10000;\n }\n\n if (0xDC00 <= code && code <= 0xDFFF) {\n // Low surrogate.\n\n /* We return false to allow loops to skip this iteration since should have\r\n already handled high surrogate above in the previous iteration. */\n return false;\n }\n\n return code;\n }\n /**\r\n * Returns an URL with it's query params converted into array.\r\n * @param {string} url - input URL.\r\n * @returns {Object[]} an array containing all URL query params.\r\n * @static\r\n */\n\n }, {\n key: \"urlToAssArray\",\n value: function urlToAssArray(url) {\n var i;\n i = url.indexOf(\"?\");\n\n if (i > 0) {\n var query = url.substring(i + 1);\n var ss = query.split(\"&\");\n var h = new Object();\n\n for (i = 0; i < ss.length; i++) {\n var s = ss[i];\n var kv = s.split(\"=\");\n\n if (kv.length > 1) {\n h[kv[0]] = decodeURIComponent(kv[1].replace(/\\+/g, ' '));\n }\n }\n\n return h;\n } else {\n return new Object();\n }\n }\n /**\r\n * Returns an encoded URL by replacing each instance of certain characters by\r\n * one, two, three or four escape sequences using encodeURIComponent method.\r\n * !'()* . will not be encoded.\r\n *\r\n * @param {string} clearString - URL string to be encoded\r\n * @returns {string} URL with it's special characters replaced.\r\n * @static\r\n */\n\n }, {\n key: \"urlEncode\",\n value: function urlEncode(clearString) {\n var output = ''; // Method encodeURIComponent doesn't encode !'()*~ .\n\n output = encodeURIComponent(clearString);\n return output;\n } // TODO: To parser?\n\n /**\r\n * Converts the HTML of a image into the output code that WIRIS must return.\r\n * By default returns the MathML stored on data-mahml attribute (if imgCode is a formula)\r\n * or the Wiriscas attribute of a WIRIS applet.\r\n * @param {string} imgCode - the html code from a formula or a CAS image.\r\n * @param {boolean} convertToXml - true if the image should be converted to XML.\r\n * @param {boolean} convertToSafeXml - true if the image should be converted to safeXML.\r\n * @returns {string} the XML or safeXML of a WIRIS image.\r\n * @static\r\n */\n\n }, {\n key: \"getWIRISImageOutput\",\n value: function getWIRISImageOutput(imgCode, convertToXml, convertToSafeXml) {\n var imgObject = Util.createObject(imgCode);\n\n if (imgObject) {\n if (imgObject.className == _configuration__WEBPACK_IMPORTED_MODULE_1__[\"default\"].get('imageClassName') || imgObject.getAttribute(_configuration__WEBPACK_IMPORTED_MODULE_1__[\"default\"].get('imageMathmlAttribute'))) {\n if (!convertToXml) {\n return imgCode;\n }\n\n var xmlCode = imgObject.getAttribute(_configuration__WEBPACK_IMPORTED_MODULE_1__[\"default\"].get('imageMathmlAttribute'));\n\n if (xmlCode == null) {\n xmlCode = imgObject.getAttribute('alt');\n }\n\n if (!convertToSafeXml) {\n xmlCode = _mathml__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlDecode(xmlCode);\n }\n\n return xmlCode;\n } else if (imgObject.className == _configuration__WEBPACK_IMPORTED_MODULE_1__[\"default\"].get('CASClassName')) {\n var appletCode = imgObject.getAttribute(_configuration__WEBPACK_IMPORTED_MODULE_1__[\"default\"].get('CASMathmlAttribute'));\n appletCode = _mathml__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlDecode(appletCode);\n var appletObject = Util.createObject(appletCode);\n appletObject.setAttribute('src', imgObject.src);\n var object = appletObject;\n var appletCodeToBeInserted = Util.createObjectCode(appletObject);\n\n if (convertToSafeXml) {\n appletCodeToBeInserted = _mathml__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlEncode(appletCodeToBeInserted);\n }\n\n return appletCodeToBeInserted;\n }\n }\n\n return imgCode;\n }\n /**\r\n * Gets the node length in characters.\r\n * @param {Node} node - HTML node.\r\n * @returns {number} node length.\r\n * @static\r\n */\n\n }, {\n key: \"getNodeLength\",\n value: function (_getNodeLength) {\n function getNodeLength(_x) {\n return _getNodeLength.apply(this, arguments);\n }\n\n getNodeLength.toString = function () {\n return _getNodeLength.toString();\n };\n\n return getNodeLength;\n }(function (node) {\n var staticNodeLengths = {\n 'IMG': 1,\n 'BR': 1\n };\n\n if (node.nodeType == 3) {\n // TEXT_NODE.\n return node.nodeValue.length;\n }\n\n if (node.nodeType == 1) {\n // ELEMENT_NODE.\n var length = staticNodeLengths[node.nodeName.toUpperCase()];\n\n if (length === undefined) {\n length = 0;\n }\n\n for (var i = 0; i < node.childNodes.length; ++i) {\n length += getNodeLength(node.childNodes[i]);\n }\n\n return length;\n }\n\n return 0;\n })\n /**\r\n * Gets a selected node or text from an editable HTMLElement.\r\n * If the caret is on a text node, concatenates it with all the previous and next text nodes.\r\n * @param {HTMLElement} target - the editable HTMLElement.\r\n * @param {boolean} isIframe - specifies if the target is an iframe or not\r\n * @param {boolean} forceGetSelection - if true, ignores IE system to get the current selection and uses window.getSelection()\r\n * @returns {object} an object with the 'node' key set if the item is an element or the keys 'node' and 'caretPosition' if the element is text.\r\n * @static\r\n */\n\n }, {\n key: \"getSelectedItem\",\n value: function getSelectedItem(target, isIframe, forceGetSelection) {\n var windowTarget;\n\n if (isIframe) {\n windowTarget = target.contentWindow;\n windowTarget.focus();\n } else {\n windowTarget = window;\n target.focus();\n }\n\n if (document.selection && !forceGetSelection) {\n var range = windowTarget.document.selection.createRange();\n\n if (range.parentElement) {\n if (range.htmlText.length > 0) {\n if (range.text.length == 0) {\n return Util.getSelectedItem(target, isIframe, true);\n }\n\n return null;\n }\n\n windowTarget.document.execCommand('InsertImage', false, '#');\n var temporalObject = range.parentElement();\n\n if (temporalObject.nodeName.toUpperCase() != 'IMG') {\n // IE9 fix: parentElement() does not return the IMG node, returns the parent DIV node. In IE < 9, pasteHTML does not work well.\n range.pasteHTML('');\n temporalObject = windowTarget.document.getElementById('wrs_openEditorWindow_temporalObject');\n }\n\n var node;\n var caretPosition;\n\n if (temporalObject.nextSibling && temporalObject.nextSibling.nodeType == 3) {\n // TEXT_NODE.\n node = temporalObject.nextSibling;\n caretPosition = 0;\n } else if (temporalObject.previousSibling && temporalObject.previousSibling.nodeType == 3) {\n // TEXT_NODE.\n node = temporalObject.previousSibling;\n caretPosition = node.nodeValue.length;\n } else {\n node = windowTarget.document.createTextNode('');\n temporalObject.parentNode.insertBefore(node, temporalObject);\n caretPosition = 0;\n }\n\n temporalObject.parentNode.removeChild(temporalObject);\n return {\n 'node': node,\n 'caretPosition': caretPosition\n };\n }\n\n if (range.length > 1) {\n return null;\n }\n\n return {\n 'node': range.item(0)\n };\n }\n\n if (windowTarget.getSelection) {\n var selection = windowTarget.getSelection();\n\n try {\n var range = selection.getRangeAt(0);\n } catch (e) {\n var range = windowTarget.document.createRange();\n }\n\n var node = range.startContainer;\n\n if (node.nodeType == 3) {\n // TEXT_NODE.\n return {\n 'node': node,\n 'caretPosition': range.startOffset\n };\n }\n\n if (node != range.endContainer) {\n return null;\n }\n\n if (node.nodeType == 1) {\n // ELEMENT_NODE.\n var position = range.startOffset;\n\n if (node.childNodes[position]) {\n return {\n 'node': node.childNodes[position]\n };\n }\n }\n }\n\n return null;\n }\n /**\r\n * Returns null if there isn't any item or if it is malformed.\r\n * Otherwise returns an object containing the node with the MathML image\r\n * and the cursor position inside the textarea.\r\n * @param {HTMLTextAreaElement} textarea - textarea element.\r\n * @returns {Object} An object containing the node, the index of the\r\n * beginning of the selected text, caret position and the start and end position of the\r\n * text node.\r\n * @static\r\n */\n\n }, {\n key: \"getSelectedItemOnTextarea\",\n value: function getSelectedItemOnTextarea(textarea) {\n var textNode = document.createTextNode(textarea.value);\n var textNodeValues = _latex__WEBPACK_IMPORTED_MODULE_2__[\"default\"].getLatexFromTextNode(textNode, textarea.selectionStart);\n\n if (textNodeValues === null) {\n return null;\n }\n\n ;\n return {\n 'node': textNode,\n 'caretPosition': textarea.selectionStart,\n 'startPosition': textNodeValues.startPosition,\n 'endPosition': textNodeValues.endPosition\n };\n }\n /**\r\n * Looks for elements that match the given name in a HTML code string.\r\n * Important: this function is very concrete for WIRIS code. It takes as preconditions lots of behaviors that are not the general case.\r\n * @param {string} code - HTML code.\r\n * @param {string} name - element name.\r\n * @param {boolean} autoClosed - true if the elements are autoClosed.\r\n * @return {Object[]} an object containing all HTML elements of code matching the name argument.\r\n * @static\r\n */\n\n }, {\n key: \"getElementsByNameFromString\",\n value: function getElementsByNameFromString(code, name, autoClosed) {\n var elements = [];\n var code = code.toLowerCase();\n name = name.toLowerCase();\n var start = code.indexOf('<' + name + ' ');\n\n while (start != -1) {\n // Look for nodes.\n var endString;\n\n if (autoClosed) {\n endString = '>';\n } else {\n endString = '';\n }\n\n var end = code.indexOf(endString, start);\n\n if (end != -1) {\n end += endString.length;\n elements.push({\n 'start': start,\n 'end': end\n });\n } else {\n end = start + 1;\n }\n\n start = code.indexOf('<' + name + ' ', end);\n }\n\n return elements;\n }\n /**\r\n * Returns the numeric value of a base64 character.\r\n * @param {string} character - base64 character.\r\n * @returns {number} base64 character numeric value.\r\n * @static\r\n */\n\n }, {\n key: \"decode64\",\n value: function decode64(character) {\n var PLUS = '+'.charCodeAt(0);\n var SLASH = '/'.charCodeAt(0);\n var NUMBER = '0'.charCodeAt(0);\n var LOWER = 'a'.charCodeAt(0);\n var UPPER = 'A'.charCodeAt(0);\n var PLUS_URL_SAFE = '-'.charCodeAt(0);\n var SLASH_URL_SAFE = '_'.charCodeAt(0);\n var code = character.charCodeAt(0);\n\n if (code === PLUS || code === PLUS_URL_SAFE) {\n return 62; // Char '+'.\n }\n\n if (code === SLASH || code === SLASH_URL_SAFE) {\n return 63; // Char '/'.\n }\n\n if (code < NUMBER) {\n return -1; // No match.\n }\n\n if (code < NUMBER + 10) {\n return code - NUMBER + 26 + 26;\n }\n\n if (code < UPPER + 26) {\n return code - UPPER;\n }\n\n if (code < LOWER + 26) {\n return code - LOWER + 26;\n }\n }\n /**\r\n * Converts a base64 string to a array of bytes.\r\n * @param {string} b64String - base64 string.\r\n * @param {number} length - dimension of byte array (by default whole string).\r\n * @return {Object[]} the resultant byte array.\r\n * @static\r\n */\n\n }, {\n key: \"b64ToByteArray\",\n value: function b64ToByteArray(b64String, length) {\n var tmp;\n\n if (b64String.length % 4 > 0) {\n throw new Error('Invalid string. Length must be a multiple of 4'); // Tipped base64. Length is fixed.\n }\n\n var arr = new Array();\n\n if (!length) {\n // All b64String string.\n var placeHolders = b64String.charAt(b64String.length - 2) === '=' ? 2 : b64String.charAt(b64String.length - 1) === '=' ? 1 : 0;\n var l = placeHolders > 0 ? b64String.length - 4 : b64String.length;\n } else {\n var l = length;\n }\n\n for (var i = 0; i < l; i += 4) {\n // Ignoring code checker standards (bitewise operators).\n // See https://tracker.moodle.org/browse/CONTRIB-5862 for further information.\n // @codingStandardsIgnoreStart\n tmp = Util.decode64(b64String.charAt(i)) << 18 | Util.decode64(b64String.charAt(i + 1)) << 12 | Util.decode64(b64String.charAt(i + 2)) << 6 | Util.decode64(b64String.charAt(i + 3));\n arr.push(tmp >> 16 & 0xFF);\n arr.push(tmp >> 8 & 0xFF);\n arr.push(tmp & 0xFF); // @codingStandardsIgnoreEnd\n }\n\n if (placeHolders) {\n if (placeHolders === 2) {\n // Ignoring code checker standards (bitewise operators).\n // @codingStandardsIgnoreStart\n tmp = Util.decode64(b64String.charAt(i)) << 2 | Util.decode64(b64String.charAt(i + 1)) >> 4;\n arr.push(tmp & 0xFF);\n } else if (placeHolders === 1) {\n tmp = Util.decode64(b64String.charAt(i)) << 10 | Util.decode64(b64String.charAt(i + 1)) << 4 | Util.decode64(b64String.charAt(i + 2)) >> 2;\n arr.push(tmp >> 8 & 0xFF);\n arr.push(tmp & 0xFF); // @codingStandardsIgnoreEnd\n }\n }\n\n return arr;\n }\n /**\r\n * Returns the first 32-bit signed integer from a byte array.\r\n * @param {Object[]} bytes - array of bytes.\r\n * @returns {number} the 32-bit signed integer.\r\n * @static\r\n */\n\n }, {\n key: \"readInt32\",\n value: function readInt32(bytes) {\n if (bytes.length < 4) {\n return false;\n }\n\n var int32 = bytes.splice(0, 4); // @codingStandardsIgnoreStart\n\n return int32[0] << 24 | int32[1] << 16 | int32[2] << 8 | int32[3] << 0; // @codingStandardsIgnoreEnd\n }\n /**\r\n * Read the first byte from a byte array.\r\n * @param {Object} bytes - input byte array.\r\n * @returns {number} first byte of the byte array.\r\n * @static\r\n */\n\n }, {\n key: \"readByte\",\n value: function readByte(bytes) {\n // @codingStandardsIgnoreStart\n return bytes.shift() << 0; // @codingStandardsIgnoreEnd\n }\n /**\r\n * Read an arbitrary number of bytes, from a fixed position on a byte array.\r\n * @param {Object[]} bytes - byte array.\r\n * @param {number} pos - start position.\r\n * @param {number} len - number of bytes to read.\r\n * @returns {Object[]} the byte array.\r\n * @static\r\n */\n\n }, {\n key: \"readBytes\",\n value: function readBytes(bytes, pos, len) {\n return bytes.splice(pos, len);\n }\n /**\r\n * Inserts or modifies formulas or CAS on a textarea.\r\n * @param {HTMLTextAreaElement} textarea - textarea target.\r\n * @param {string} text - text to add in the textarea. For example, to add the link to the image,\r\n * call this function as (textarea, Parser.createImageSrc(mathml));\r\n * @static\r\n */\n\n }, {\n key: \"updateTextArea\",\n value: function updateTextArea(textarea, text) {\n if (textarea && text) {\n textarea.focus();\n\n if (textarea.selectionStart != null) {\n var selectionEnd = textarea.selectionEnd;\n textarea.value = textarea.value.substring(0, textarea.selectionStart) + text + textarea.value.substring(textarea.selectionEnd, textarea.value.length);\n textarea.selectionEnd = selectionEnd + text.length;\n } else {\n var selection = document.selection.createRange();\n selection.text = text;\n }\n }\n }\n /**\r\n * Modifies existing formula on a textarea.\r\n * @param {HTMLTextAreaElement} textarea - text area target.\r\n * @param {string} text - text to add in the textarea. For example, if you want to add the link to the image, you can call this function as Util.updateTextarea(textarea, Parser.createImageSrc(mathml));\r\n * @param {number} start - beginning index from textarea where it needs to be replaced by text.\r\n * @param {number} end - ending index from textarea where it needs to be replaced by text\r\n * @static\r\n */\n\n }, {\n key: \"updateExistingTextOnTextarea\",\n value: function updateExistingTextOnTextarea(textarea, text, start, end) {\n textarea.focus();\n textarea.value = textarea.value.substring(0, start) + text + textarea.value.substring(end, textarea.value.length);\n textarea.selectionEnd = start + text.length;\n }\n /**\r\n * Add a parameter with it's correspondent value to an URL (GET).\r\n * @param {string} path - URL path\r\n * @param {string} parameter - parameter\r\n * @param {string} value - value\r\n * @static\r\n */\n\n }, {\n key: \"addArgument\",\n value: function addArgument(path, parameter, value) {\n var sep;\n\n if (path.indexOf(\"?\") > 0) {\n sep = \"&\";\n } else {\n sep = \"?\";\n }\n\n return path + sep + parameter + \"=\" + value;\n }\n }]);\n\n return Util;\n}();\n\n\n\n//# sourceURL=webpack:///./core/src/util.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"default\", function() { return Util; });\n/* harmony import */ var _mathml__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./mathml */ \"./core/src/mathml.js\");\n/* harmony import */ var _configuration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./configuration */ \"./core/src/configuration.js\");\n/* harmony import */ var _latex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./latex */ \"./core/src/latex.js\");\n/* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./constants */ \"./core/src/constants.js\");\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\n\n\n\n\n/**\r\n * This class represents an utility class.\r\n */\n\nvar Util =\n/*#__PURE__*/\nfunction () {\n function Util() {\n _classCallCheck(this, Util);\n }\n\n _createClass(Util, null, [{\n key: \"fireEvent\",\n\n /**\r\n * Fires an event in a target.\r\n * @param {EventTarget} eventTarget - target where event should be fired.\r\n * @param {string} eventName event to fire.\r\n * @static\r\n */\n value: function fireEvent(eventTarget, eventName) {\n if (document.createEvent) {\n var eventObject = document.createEvent('HTMLEvents');\n eventObject.initEvent(eventName, true, true);\n return !eventTarget.dispatchEvent(eventObject);\n }\n\n var eventObject = document.createEventObject();\n return eventTarget.fireEvent('on' + eventName, eventObject);\n }\n /**\r\n * Cross-browser addEventListener/attachEvent function.\r\n * @param {EventTarget} eventTarget - target to add the event.\r\n * @param {string} eventName - specifies the type of event.\r\n * @param {Function} callBackFunction - callback function.\r\n * @static\r\n */\n\n }, {\n key: \"addEvent\",\n value: function addEvent(eventTarget, eventName, callBackFunction) {\n if (eventTarget.addEventListener) {\n eventTarget.addEventListener(eventName, callBackFunction, true);\n } else if (eventTarget.attachEvent) {\n // Backwards compatibility.\n eventTarget.attachEvent('on' + eventName, callBackFunction);\n }\n }\n /**\r\n * Cross-browser removeEventListener/detachEvent function.\r\n * @param {EventTarget} eventTarget - target to add the event.\r\n * @param {string} eventName - specifies the type of event.\r\n * @param {Function} callBackFunction - function to remove from the event target.\r\n * @static\r\n */\n\n }, {\n key: \"removeEvent\",\n value: function removeEvent(eventTarget, eventName, callBackFunction) {\n if (eventTarget.removeEventListener) {\n eventTarget.removeEventListener(eventName, callBackFunction, true);\n } else if (eventTarget.detachEvent) {\n eventTarget.detachEvent('on' + eventName, callBackFunction);\n }\n }\n /**\r\n * Adds the a callback function, for a certain event target, to the following event types:\r\n * - dblclick\r\n * - mousedown\r\n * - mouseup\r\n * @param {EventTarget} eventTarget - event target.\r\n * @param {Function} doubleClickHandler - function to run when on dblclick event.\r\n * @param {Function} mousedownHandler - function to run when on mousedown event.\r\n * @param {Function} mouseupHandler - function to run when on mouseup event.\r\n * @static\r\n */\n\n }, {\n key: \"addElementEvents\",\n value: function addElementEvents(eventTarget, doubleClickHandler, mousedownHandler, mouseupHandler) {\n if (doubleClickHandler) {\n Util.addEvent(eventTarget, 'dblclick', function (event) {\n var realEvent = event ? event : window.event;\n var element = realEvent.srcElement ? realEvent.srcElement : realEvent.target;\n doubleClickHandler(element, realEvent);\n });\n }\n\n if (mousedownHandler) {\n Util.addEvent(eventTarget, 'mousedown', function (event) {\n var realEvent = event ? event : window.event;\n var element = realEvent.srcElement ? realEvent.srcElement : realEvent.target;\n mousedownHandler(element, realEvent);\n });\n }\n\n if (mouseupHandler) {\n Util.addEvent(eventTarget, 'mouseup', function (event) {\n var realEvent = event ? event : window.event;\n var element = realEvent.srcElement ? realEvent.srcElement : realEvent.target;\n mouseupHandler(element, realEvent);\n });\n }\n }\n /**\r\n * Adds a class name to a HTMLElement.\r\n * @param {HTMLElement} element - the HTML element.\r\n * @param {string} className - the class name.\r\n * @static\r\n */\n\n }, {\n key: \"addClass\",\n value: function addClass(element, className) {\n if (!Util.containsClass(element, className)) {\n element.className += \" \" + className;\n }\n }\n /**\r\n * Checks if a HTMLElement contains a certain class.\r\n * @param {HTMLElement} element - the HTML element.\r\n * @param {string} className - the className.\r\n * @returns {boolean} true if the HTMLElement contains the class name. false otherwise.\r\n * @static\r\n */\n\n }, {\n key: \"containsClass\",\n value: function containsClass(element, className) {\n if (element == null || !('className' in element)) {\n return false;\n }\n\n var currentClasses = element.className.split(' ');\n\n for (var i = currentClasses.length - 1; i >= 0; --i) {\n if (currentClasses[i] == className) {\n return true;\n }\n }\n\n return false;\n }\n /**\r\n * Remove a certain class for a HTMLElement.\r\n * @param {HTMLElement} element - the HTML element.\r\n * @param {string} className - the class name.\r\n * @static\r\n */\n\n }, {\n key: \"removeClass\",\n value: function removeClass(element, className) {\n var newClassName = '';\n var classes = element.className.split(\" \");\n\n for (var i = 0; i < classes.length; i++) {\n if (classes[i] != className) {\n newClassName += classes[i] + \" \";\n }\n }\n\n element.className = newClassName.trim();\n }\n /**\r\n * Converts old xml initial text attribute (with «») to the correct one(with §lt;§gt;). It's\r\n * used to parse old applets.\r\n * @param {string} text - string containing safeXml characters\r\n * @returns {string} a string with safeXml characters parsed.\r\n * @static\r\n */\n\n }, {\n key: \"convertOldXmlinitialtextAttribute\",\n value: function convertOldXmlinitialtextAttribute(text) {\n // Used to fix a bug with Cas imported from Moodle 1.9 to Moodle 2.x.\n // This could be removed in future.\n var val = 'value=';\n var xitpos = text.indexOf('xmlinitialtext');\n var valpos = text.indexOf(val, xitpos);\n var quote = text.charAt(valpos + val.length);\n var startquote = valpos + val.length + 1;\n var endquote = text.indexOf(quote, startquote);\n var value = text.substring(startquote, endquote);\n var newvalue = value.split('«').join('§lt;');\n newvalue = newvalue.split('»').join('§gt;');\n newvalue = newvalue.split('&').join('§');\n newvalue = newvalue.split('¨').join('§quot;');\n text = text.split(value).join(newvalue);\n return text;\n }\n /**\r\n * Cross-browser solution for creating new elements.\r\n * @param {string} tagName - tag name of the wished element.\r\n * @param {Object} attributes - an object where each key is a wished attribute name and each value is its value.\r\n * @param {Object} [creator] - if supplied, this function will use the \"createElement\" method from this param. Otherwise\r\n * document will be used as creator.\r\n * @returns {Element} The DOM element with the specified attributes assigned.\r\n * @static\r\n */\n\n }, {\n key: \"createElement\",\n value: function createElement(tagName, attributes, creator) {\n if (attributes === undefined) {\n attributes = {};\n }\n\n if (creator === undefined) {\n creator = document;\n }\n\n var element;\n /*\r\n * Internet Explorer fix:\r\n * If you create a new object dynamically, you can't set a non-standard attribute.\r\n * For example, you can't set the \"src\" attribute on an \"applet\" object.\r\n * Other browsers will throw an exception and will run the standard code.\r\n */\n\n try {\n var html = '<' + tagName;\n\n for (var attributeName in attributes) {\n html += ' ' + attributeName + '=\"' + Util.htmlEntities(attributes[attributeName]) + '\"';\n }\n\n html += '>';\n element = creator.createElement(html);\n } catch (e) {\n element = creator.createElement(tagName);\n\n for (var attributeName in attributes) {\n element.setAttribute(attributeName, attributes[attributeName]);\n }\n }\n\n return element;\n }\n /**\r\n * Creates new HTML from it's HTML code as string.\r\n * @param {string} objectCode - html code\r\n * @returns {Element} the HTML element.\r\n * @static\r\n */\n\n }, {\n key: \"createObject\",\n value: function createObject(objectCode, creator) {\n if (creator === undefined) {\n creator = document;\n } // Internet Explorer can't include \"param\" tag when is setting an innerHTML property.\n\n\n objectCode = objectCode.split('').join('').split('').join('');\n objectCode = objectCode.split('').join('
').split('').join('
');\n var container = Util.createElement('div', {}, creator);\n container.innerHTML = objectCode;\n\n function recursiveParamsFix(object) {\n if (object.getAttribute && object.getAttribute('wirisObject') == 'WirisParam') {\n var attributesParsed = {};\n\n for (var i = 0; i < object.attributes.length; ++i) {\n if (object.attributes[i].nodeValue !== null) {\n attributesParsed[object.attributes[i].nodeName] = object.attributes[i].nodeValue;\n }\n }\n\n var param = Util.createElement('param', attributesParsed, creator); // IE fix.\n\n if (param.NAME) {\n param.name = param.NAME;\n param.value = param.VALUE;\n }\n\n param.removeAttribute('wirisObject');\n object.parentNode.replaceChild(param, object);\n } else if (object.getAttribute && object.getAttribute('wirisObject') == 'WirisApplet') {\n var attributesParsed = {};\n\n for (var i = 0; i < object.attributes.length; ++i) {\n if (object.attributes[i].nodeValue !== null) {\n attributesParsed[object.attributes[i].nodeName] = object.attributes[i].nodeValue;\n }\n }\n\n var applet = Util.createElement('applet', attributesParsed, creator);\n applet.removeAttribute('wirisObject');\n\n for (var i = 0; i < object.childNodes.length; ++i) {\n recursiveParamsFix(object.childNodes[i]);\n\n if (object.childNodes[i].nodeName.toLowerCase() == 'param') {\n applet.appendChild(object.childNodes[i]);\n --i; // When we insert the object child into the applet, object loses one child.\n }\n }\n\n object.parentNode.replaceChild(applet, object);\n } else {\n for (var i = 0; i < object.childNodes.length; ++i) {\n recursiveParamsFix(object.childNodes[i]);\n }\n }\n }\n\n recursiveParamsFix(container);\n return container.firstChild;\n }\n /**\r\n * Converts an Element to its HTML code.\r\n * @param {Element} element - entry element.\r\n * @return {string} the HTML code of the input element.\r\n * @static\r\n */\n\n }, {\n key: \"createObjectCode\",\n value: function createObjectCode(element) {\n // In case that the image was not created, the object can be null or undefined.\n if (typeof element == 'undefined' || element == null) {\n return;\n }\n\n if (element.nodeType == 1) {\n // ELEMENT_NODE.\n var output = '<' + element.tagName;\n\n for (var i = 0; i < element.attributes.length; ++i) {\n if (element.attributes[i].specified) {\n output += ' ' + element.attributes[i].name + '=\"' + Util.htmlEntities(element.attributes[i].value) + '\"';\n }\n }\n\n if (element.childNodes.length > 0) {\n output += '>';\n\n for (var i = 0; i < element.childNodes.length; ++i) {\n output += Util.createObject(element.childNodes[i]);\n }\n\n output += '';\n } else if (element.nodeName == 'DIV' || element.nodeName == 'SCRIPT') {\n output += '>';\n } else {\n output += '/>';\n }\n\n return output;\n }\n\n if (element.nodeType == 3) {\n // TEXT_NODE.\n return Util.htmlEntities(element.nodeValue);\n }\n\n return '';\n }\n /**\r\n * Concatenates two URL paths.\r\n * @param {string} path1 - first URL path\r\n * @param {string} path2 - second URL path\r\n * @returns {string} new URL.\r\n */\n\n }, {\n key: \"concatenateUrl\",\n value: function concatenateUrl(path1, path2) {\n var separator = \"\";\n\n if (path1.indexOf(\"/\") != path1.length && path2.indexOf(\"/\") != 0) {\n separator = \"/\";\n }\n\n return (path1 + separator + path2).replace(/([^:]\\/)\\/+/g, \"$1\");\n }\n /**\r\n * Parses a text and replaces all HTML special characters by their correspondent entities.\r\n * @param {string} input - text to be parsed.\r\n * @returns {string} the input text with all their special characters replaced by their entities.\r\n * @static\r\n */\n\n }, {\n key: \"htmlEntities\",\n value: function htmlEntities(input) {\n return input.split('&').join('&').split('<').join('<').split('>').join('>').split('\"').join('"');\n }\n /**\r\n * Parses a text and replaces all the HTML entities by their characters.\r\n * @param {string} input - text to be parsed\r\n * @returns {string} the input text with all their entities replaced by characters.\r\n * @static\r\n */\n\n }, {\n key: \"htmlEntitiesDecode\",\n value: function htmlEntitiesDecode(input) {\n return input.split('"').join('\"').split('>').join('>').split('<').join('<').split('&').join('&');\n }\n /**\r\n * Returns a cross-browser http request.\r\n * @return {object} httpRequest request object.\r\n * @returns {XMLHttpRequest|ActiveXObject} the proper request object.\r\n */\n\n }, {\n key: \"createHttpRequest\",\n value: function createHttpRequest() {\n var currentPath = window.location.toString().substr(0, window.location.toString().lastIndexOf('/') + 1);\n\n if (currentPath.substr(0, 7) == 'file://') {\n throw Core.getStringManager().getString('exception_cross_site');\n }\n\n if (typeof XMLHttpRequest != 'undefined') {\n return new XMLHttpRequest();\n }\n\n try {\n return new ActiveXObject('Msxml2.XMLHTTP');\n } catch (e) {\n try {\n return new ActiveXObject('Microsoft.XMLHTTP');\n } catch (oc) {}\n }\n\n return false;\n }\n /**\r\n * Converts a hash to a HTTP query.\r\n * @param {Object[]} properties - a key/value object.\r\n * @returns {string} a HTTP query containing all the key value pairs with all the special characters replaced by their entities.\r\n * @static\r\n */\n\n }, {\n key: \"httpBuildQuery\",\n value: function httpBuildQuery(properties) {\n var result = '';\n\n for (var i in properties) {\n if (properties[i] != null) {\n result += Util.urlEncode(i) + '=' + Util.urlEncode(properties[i]) + '&';\n }\n } // Deleting last '&' empty character.\n\n\n if (result.substring(result.length - 1) == '&') {\n result = result.substring(0, result.length - 1);\n }\n\n return result;\n }\n /**\r\n * Convert a hash to string sorting keys to get a deterministic output\r\n * @param {Object[]} hash - a key/value object.\r\n * @returns {string} a string with the form key1=value1...keyn=valuen\r\n * @static\r\n */\n\n }, {\n key: \"propertiesToString\",\n value: function propertiesToString(hash) {\n // 1. Sort keys. We sort the keys because we want a deterministic output.\n var keys = [];\n\n for (var key in hash) {\n if (hash.hasOwnProperty(key)) {\n keys.push(key);\n }\n }\n\n var n = keys.length;\n\n for (var i = 0; i < n; i++) {\n for (var j = i + 1; j < n; j++) {\n var s1 = keys[i];\n var s2 = keys[j];\n\n if (Util.compareStrings(s1, s2) > 0) {\n // Swap.\n keys[i] = s2;\n keys[j] = s1;\n }\n }\n } // 2. Generate output.\n\n\n var output = '';\n\n for (var i = 0; i < n; i++) {\n var key = keys[i];\n output += key;\n output += \"=\";\n var value = hash[key];\n value = value.replace(\"\\\\\", \"\\\\\\\\\");\n value = value.replace(\"\\n\", \"\\\\n\");\n value = value.replace(\"\\r\", \"\\\\r\");\n value = value.replace(\"\\t\", \"\\\\t\");\n output += value;\n output += \"\\n\";\n }\n\n return output;\n }\n /**\r\n * Compare two strings using charCodeAt method\r\n * @param {string} a - first string to compare.\r\n * @param {string} b - second string to compare.\r\n * @returns {number} the difference between a and b\r\n * @static\r\n */\n\n }, {\n key: \"compareStrings\",\n value: function compareStrings(a, b) {\n var i;\n var an = a.length;\n var bn = b.length;\n var n = an > bn ? bn : an;\n\n for (i = 0; i < n; i++) {\n var c = Util.fixedCharCodeAt(a, i) - Util.fixedCharCodeAt(b, i);\n\n if (c != 0) {\n return c;\n }\n }\n\n return a.length - b.length;\n }\n /**\r\n * Fix charCodeAt() JavaScript function to handle non-Basic-Multilingual-Plane characters.\r\n * @param {string} string - input string\r\n * @param {number} idx - an integer greater than or equal to 0 and less than the length of the string\r\n * @returns {number} an integer representing the UTF-16 code of the string at the given index.\r\n * @static\r\n */\n\n }, {\n key: \"fixedCharCodeAt\",\n value: function fixedCharCodeAt(string, idx) {\n idx = idx || 0;\n var code = string.charCodeAt(idx);\n var hi, low;\n /* High surrogate (could change last hex to 0xDB7F to treat high\r\n private surrogates as single characters) */\n\n if (0xD800 <= code && code <= 0xDBFF) {\n hi = code;\n low = string.charCodeAt(idx + 1);\n\n if (isNaN(low)) {\n throw Core.getStringManager().getString('exception_high_surrogate');\n }\n\n return (hi - 0xD800) * 0x400 + (low - 0xDC00) + 0x10000;\n }\n\n if (0xDC00 <= code && code <= 0xDFFF) {\n // Low surrogate.\n\n /* We return false to allow loops to skip this iteration since should have\r\n already handled high surrogate above in the previous iteration. */\n return false;\n }\n\n return code;\n }\n /**\r\n * Returns an URL with it's query params converted into array.\r\n * @param {string} url - input URL.\r\n * @returns {Object[]} an array containing all URL query params.\r\n * @static\r\n */\n\n }, {\n key: \"urlToAssArray\",\n value: function urlToAssArray(url) {\n var i;\n i = url.indexOf(\"?\");\n\n if (i > 0) {\n var query = url.substring(i + 1);\n var ss = query.split(\"&\");\n var h = new Object();\n\n for (i = 0; i < ss.length; i++) {\n var s = ss[i];\n var kv = s.split(\"=\");\n\n if (kv.length > 1) {\n h[kv[0]] = decodeURIComponent(kv[1].replace(/\\+/g, ' '));\n }\n }\n\n return h;\n } else {\n return new Object();\n }\n }\n /**\r\n * Returns an encoded URL by replacing each instance of certain characters by\r\n * one, two, three or four escape sequences using encodeURIComponent method.\r\n * !'()* . will not be encoded.\r\n *\r\n * @param {string} clearString - URL string to be encoded\r\n * @returns {string} URL with it's special characters replaced.\r\n * @static\r\n */\n\n }, {\n key: \"urlEncode\",\n value: function urlEncode(clearString) {\n var output = ''; // Method encodeURIComponent doesn't encode !'()*~ .\n\n output = encodeURIComponent(clearString);\n return output;\n } // TODO: To parser?\n\n /**\r\n * Converts the HTML of a image into the output code that WIRIS must return.\r\n * By default returns the MathML stored on data-mahml attribute (if imgCode is a formula)\r\n * or the Wiriscas attribute of a WIRIS applet.\r\n * @param {string} imgCode - the html code from a formula or a CAS image.\r\n * @param {boolean} convertToXml - true if the image should be converted to XML.\r\n * @param {boolean} convertToSafeXml - true if the image should be converted to safeXML.\r\n * @returns {string} the XML or safeXML of a WIRIS image.\r\n * @static\r\n */\n\n }, {\n key: \"getWIRISImageOutput\",\n value: function getWIRISImageOutput(imgCode, convertToXml, convertToSafeXml) {\n var imgObject = Util.createObject(imgCode);\n\n if (imgObject) {\n if (imgObject.className == _configuration__WEBPACK_IMPORTED_MODULE_1__[\"default\"].get('imageClassName') || imgObject.getAttribute(_configuration__WEBPACK_IMPORTED_MODULE_1__[\"default\"].get('imageMathmlAttribute'))) {\n if (!convertToXml) {\n return imgCode;\n }\n\n var xmlCode = imgObject.getAttribute(_configuration__WEBPACK_IMPORTED_MODULE_1__[\"default\"].get('imageMathmlAttribute'));\n\n if (!_configuration__WEBPACK_IMPORTED_MODULE_1__[\"default\"].get('saveHandTraces')) {\n xmlCode = _mathml__WEBPACK_IMPORTED_MODULE_0__[\"default\"].removeSemanticsOcurrences(xmlCode, _constants__WEBPACK_IMPORTED_MODULE_3__[\"default\"].safeXmlCharacters);\n }\n\n if (xmlCode == null) {\n xmlCode = imgObject.getAttribute('alt');\n }\n\n if (!convertToSafeXml) {\n xmlCode = _mathml__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlDecode(xmlCode);\n }\n\n return xmlCode;\n } else if (imgObject.className == _configuration__WEBPACK_IMPORTED_MODULE_1__[\"default\"].get('CASClassName')) {\n var appletCode = imgObject.getAttribute(_configuration__WEBPACK_IMPORTED_MODULE_1__[\"default\"].get('CASMathmlAttribute'));\n appletCode = _mathml__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlDecode(appletCode);\n var appletObject = Util.createObject(appletCode);\n appletObject.setAttribute('src', imgObject.src);\n var object = appletObject;\n var appletCodeToBeInserted = Util.createObjectCode(appletObject);\n\n if (convertToSafeXml) {\n appletCodeToBeInserted = _mathml__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlEncode(appletCodeToBeInserted);\n }\n\n return appletCodeToBeInserted;\n }\n }\n\n return imgCode;\n }\n /**\r\n * Gets the node length in characters.\r\n * @param {Node} node - HTML node.\r\n * @returns {number} node length.\r\n * @static\r\n */\n\n }, {\n key: \"getNodeLength\",\n value: function (_getNodeLength) {\n function getNodeLength(_x) {\n return _getNodeLength.apply(this, arguments);\n }\n\n getNodeLength.toString = function () {\n return _getNodeLength.toString();\n };\n\n return getNodeLength;\n }(function (node) {\n var staticNodeLengths = {\n 'IMG': 1,\n 'BR': 1\n };\n\n if (node.nodeType == 3) {\n // TEXT_NODE.\n return node.nodeValue.length;\n }\n\n if (node.nodeType == 1) {\n // ELEMENT_NODE.\n var length = staticNodeLengths[node.nodeName.toUpperCase()];\n\n if (length === undefined) {\n length = 0;\n }\n\n for (var i = 0; i < node.childNodes.length; ++i) {\n length += getNodeLength(node.childNodes[i]);\n }\n\n return length;\n }\n\n return 0;\n })\n /**\r\n * Gets a selected node or text from an editable HTMLElement.\r\n * If the caret is on a text node, concatenates it with all the previous and next text nodes.\r\n * @param {HTMLElement} target - the editable HTMLElement.\r\n * @param {boolean} isIframe - specifies if the target is an iframe or not\r\n * @param {boolean} forceGetSelection - if true, ignores IE system to get the current selection and uses window.getSelection()\r\n * @returns {object} an object with the 'node' key set if the item is an element or the keys 'node' and 'caretPosition' if the element is text.\r\n * @static\r\n */\n\n }, {\n key: \"getSelectedItem\",\n value: function getSelectedItem(target, isIframe, forceGetSelection) {\n var windowTarget;\n\n if (isIframe) {\n windowTarget = target.contentWindow;\n windowTarget.focus();\n } else {\n windowTarget = window;\n target.focus();\n }\n\n if (document.selection && !forceGetSelection) {\n var range = windowTarget.document.selection.createRange();\n\n if (range.parentElement) {\n if (range.htmlText.length > 0) {\n if (range.text.length == 0) {\n return Util.getSelectedItem(target, isIframe, true);\n }\n\n return null;\n }\n\n windowTarget.document.execCommand('InsertImage', false, '#');\n var temporalObject = range.parentElement();\n\n if (temporalObject.nodeName.toUpperCase() != 'IMG') {\n // IE9 fix: parentElement() does not return the IMG node, returns the parent DIV node. In IE < 9, pasteHTML does not work well.\n range.pasteHTML('');\n temporalObject = windowTarget.document.getElementById('wrs_openEditorWindow_temporalObject');\n }\n\n var node;\n var caretPosition;\n\n if (temporalObject.nextSibling && temporalObject.nextSibling.nodeType == 3) {\n // TEXT_NODE.\n node = temporalObject.nextSibling;\n caretPosition = 0;\n } else if (temporalObject.previousSibling && temporalObject.previousSibling.nodeType == 3) {\n // TEXT_NODE.\n node = temporalObject.previousSibling;\n caretPosition = node.nodeValue.length;\n } else {\n node = windowTarget.document.createTextNode('');\n temporalObject.parentNode.insertBefore(node, temporalObject);\n caretPosition = 0;\n }\n\n temporalObject.parentNode.removeChild(temporalObject);\n return {\n 'node': node,\n 'caretPosition': caretPosition\n };\n }\n\n if (range.length > 1) {\n return null;\n }\n\n return {\n 'node': range.item(0)\n };\n }\n\n if (windowTarget.getSelection) {\n var selection = windowTarget.getSelection();\n\n try {\n var range = selection.getRangeAt(0);\n } catch (e) {\n var range = windowTarget.document.createRange();\n }\n\n var node = range.startContainer;\n\n if (node.nodeType == 3) {\n // TEXT_NODE.\n return {\n 'node': node,\n 'caretPosition': range.startOffset\n };\n }\n\n if (node != range.endContainer) {\n return null;\n }\n\n if (node.nodeType == 1) {\n // ELEMENT_NODE.\n var position = range.startOffset;\n\n if (node.childNodes[position]) {\n return {\n 'node': node.childNodes[position]\n };\n }\n }\n }\n\n return null;\n }\n /**\r\n * Returns null if there isn't any item or if it is malformed.\r\n * Otherwise returns an object containing the node with the MathML image\r\n * and the cursor position inside the textarea.\r\n * @param {HTMLTextAreaElement} textarea - textarea element.\r\n * @returns {Object} An object containing the node, the index of the\r\n * beginning of the selected text, caret position and the start and end position of the\r\n * text node.\r\n * @static\r\n */\n\n }, {\n key: \"getSelectedItemOnTextarea\",\n value: function getSelectedItemOnTextarea(textarea) {\n var textNode = document.createTextNode(textarea.value);\n var textNodeValues = _latex__WEBPACK_IMPORTED_MODULE_2__[\"default\"].getLatexFromTextNode(textNode, textarea.selectionStart);\n\n if (textNodeValues === null) {\n return null;\n }\n\n ;\n return {\n 'node': textNode,\n 'caretPosition': textarea.selectionStart,\n 'startPosition': textNodeValues.startPosition,\n 'endPosition': textNodeValues.endPosition\n };\n }\n /**\r\n * Looks for elements that match the given name in a HTML code string.\r\n * Important: this function is very concrete for WIRIS code. It takes as preconditions lots of behaviors that are not the general case.\r\n * @param {string} code - HTML code.\r\n * @param {string} name - element name.\r\n * @param {boolean} autoClosed - true if the elements are autoClosed.\r\n * @return {Object[]} an object containing all HTML elements of code matching the name argument.\r\n * @static\r\n */\n\n }, {\n key: \"getElementsByNameFromString\",\n value: function getElementsByNameFromString(code, name, autoClosed) {\n var elements = [];\n var code = code.toLowerCase();\n name = name.toLowerCase();\n var start = code.indexOf('<' + name + ' ');\n\n while (start != -1) {\n // Look for nodes.\n var endString;\n\n if (autoClosed) {\n endString = '>';\n } else {\n endString = '';\n }\n\n var end = code.indexOf(endString, start);\n\n if (end != -1) {\n end += endString.length;\n elements.push({\n 'start': start,\n 'end': end\n });\n } else {\n end = start + 1;\n }\n\n start = code.indexOf('<' + name + ' ', end);\n }\n\n return elements;\n }\n /**\r\n * Returns the numeric value of a base64 character.\r\n * @param {string} character - base64 character.\r\n * @returns {number} base64 character numeric value.\r\n * @static\r\n */\n\n }, {\n key: \"decode64\",\n value: function decode64(character) {\n var PLUS = '+'.charCodeAt(0);\n var SLASH = '/'.charCodeAt(0);\n var NUMBER = '0'.charCodeAt(0);\n var LOWER = 'a'.charCodeAt(0);\n var UPPER = 'A'.charCodeAt(0);\n var PLUS_URL_SAFE = '-'.charCodeAt(0);\n var SLASH_URL_SAFE = '_'.charCodeAt(0);\n var code = character.charCodeAt(0);\n\n if (code === PLUS || code === PLUS_URL_SAFE) {\n return 62; // Char '+'.\n }\n\n if (code === SLASH || code === SLASH_URL_SAFE) {\n return 63; // Char '/'.\n }\n\n if (code < NUMBER) {\n return -1; // No match.\n }\n\n if (code < NUMBER + 10) {\n return code - NUMBER + 26 + 26;\n }\n\n if (code < UPPER + 26) {\n return code - UPPER;\n }\n\n if (code < LOWER + 26) {\n return code - LOWER + 26;\n }\n }\n /**\r\n * Converts a base64 string to a array of bytes.\r\n * @param {string} b64String - base64 string.\r\n * @param {number} length - dimension of byte array (by default whole string).\r\n * @return {Object[]} the resultant byte array.\r\n * @static\r\n */\n\n }, {\n key: \"b64ToByteArray\",\n value: function b64ToByteArray(b64String, length) {\n var tmp;\n\n if (b64String.length % 4 > 0) {\n throw new Error('Invalid string. Length must be a multiple of 4'); // Tipped base64. Length is fixed.\n }\n\n var arr = new Array();\n\n if (!length) {\n // All b64String string.\n var placeHolders = b64String.charAt(b64String.length - 2) === '=' ? 2 : b64String.charAt(b64String.length - 1) === '=' ? 1 : 0;\n var l = placeHolders > 0 ? b64String.length - 4 : b64String.length;\n } else {\n var l = length;\n }\n\n for (var i = 0; i < l; i += 4) {\n // Ignoring code checker standards (bitewise operators).\n // See https://tracker.moodle.org/browse/CONTRIB-5862 for further information.\n // @codingStandardsIgnoreStart\n tmp = Util.decode64(b64String.charAt(i)) << 18 | Util.decode64(b64String.charAt(i + 1)) << 12 | Util.decode64(b64String.charAt(i + 2)) << 6 | Util.decode64(b64String.charAt(i + 3));\n arr.push(tmp >> 16 & 0xFF);\n arr.push(tmp >> 8 & 0xFF);\n arr.push(tmp & 0xFF); // @codingStandardsIgnoreEnd\n }\n\n if (placeHolders) {\n if (placeHolders === 2) {\n // Ignoring code checker standards (bitewise operators).\n // @codingStandardsIgnoreStart\n tmp = Util.decode64(b64String.charAt(i)) << 2 | Util.decode64(b64String.charAt(i + 1)) >> 4;\n arr.push(tmp & 0xFF);\n } else if (placeHolders === 1) {\n tmp = Util.decode64(b64String.charAt(i)) << 10 | Util.decode64(b64String.charAt(i + 1)) << 4 | Util.decode64(b64String.charAt(i + 2)) >> 2;\n arr.push(tmp >> 8 & 0xFF);\n arr.push(tmp & 0xFF); // @codingStandardsIgnoreEnd\n }\n }\n\n return arr;\n }\n /**\r\n * Returns the first 32-bit signed integer from a byte array.\r\n * @param {Object[]} bytes - array of bytes.\r\n * @returns {number} the 32-bit signed integer.\r\n * @static\r\n */\n\n }, {\n key: \"readInt32\",\n value: function readInt32(bytes) {\n if (bytes.length < 4) {\n return false;\n }\n\n var int32 = bytes.splice(0, 4); // @codingStandardsIgnoreStart\n\n return int32[0] << 24 | int32[1] << 16 | int32[2] << 8 | int32[3] << 0; // @codingStandardsIgnoreEnd\n }\n /**\r\n * Read the first byte from a byte array.\r\n * @param {Object} bytes - input byte array.\r\n * @returns {number} first byte of the byte array.\r\n * @static\r\n */\n\n }, {\n key: \"readByte\",\n value: function readByte(bytes) {\n // @codingStandardsIgnoreStart\n return bytes.shift() << 0; // @codingStandardsIgnoreEnd\n }\n /**\r\n * Read an arbitrary number of bytes, from a fixed position on a byte array.\r\n * @param {Object[]} bytes - byte array.\r\n * @param {number} pos - start position.\r\n * @param {number} len - number of bytes to read.\r\n * @returns {Object[]} the byte array.\r\n * @static\r\n */\n\n }, {\n key: \"readBytes\",\n value: function readBytes(bytes, pos, len) {\n return bytes.splice(pos, len);\n }\n /**\r\n * Inserts or modifies formulas or CAS on a textarea.\r\n * @param {HTMLTextAreaElement} textarea - textarea target.\r\n * @param {string} text - text to add in the textarea. For example, to add the link to the image,\r\n * call this function as (textarea, Parser.createImageSrc(mathml));\r\n * @static\r\n */\n\n }, {\n key: \"updateTextArea\",\n value: function updateTextArea(textarea, text) {\n if (textarea && text) {\n textarea.focus();\n\n if (textarea.selectionStart != null) {\n var selectionEnd = textarea.selectionEnd;\n textarea.value = textarea.value.substring(0, textarea.selectionStart) + text + textarea.value.substring(textarea.selectionEnd, textarea.value.length);\n textarea.selectionEnd = selectionEnd + text.length;\n } else {\n var selection = document.selection.createRange();\n selection.text = text;\n }\n }\n }\n /**\r\n * Modifies existing formula on a textarea.\r\n * @param {HTMLTextAreaElement} textarea - text area target.\r\n * @param {string} text - text to add in the textarea. For example, if you want to add the link to the image, you can call this function as Util.updateTextarea(textarea, Parser.createImageSrc(mathml));\r\n * @param {number} start - beginning index from textarea where it needs to be replaced by text.\r\n * @param {number} end - ending index from textarea where it needs to be replaced by text\r\n * @static\r\n */\n\n }, {\n key: \"updateExistingTextOnTextarea\",\n value: function updateExistingTextOnTextarea(textarea, text, start, end) {\n textarea.focus();\n textarea.value = textarea.value.substring(0, start) + text + textarea.value.substring(end, textarea.value.length);\n textarea.selectionEnd = start + text.length;\n }\n /**\r\n * Add a parameter with it's correspondent value to an URL (GET).\r\n * @param {string} path - URL path\r\n * @param {string} parameter - parameter\r\n * @param {string} value - value\r\n * @static\r\n */\n\n }, {\n key: \"addArgument\",\n value: function addArgument(path, parameter, value) {\n var sep;\n\n if (path.indexOf(\"?\") > 0) {\n sep = \"&\";\n } else {\n sep = \"?\";\n }\n\n return path + sep + parameter + \"=\" + value;\n }\n }]);\n\n return Util;\n}();\n\n\n\n//# sourceURL=webpack:///./core/src/util.js?"); /***/ }), @@ -393,7 +393,7 @@ eval("\nvar content = __webpack_require__(/*! !../node_modules/mini-css-extract- /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"TinyMceIntegration\", function() { return TinyMceIntegration; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"instances\", function() { return instances; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"currentInstance\", function() { return currentInstance; });\n/* harmony import */ var _core_src_integrationmodel_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./core/src/integrationmodel.js */ \"./core/src/integrationmodel.js\");\n/* harmony import */ var _core_src_configuration_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./core/src/configuration.js */ \"./core/src/configuration.js\");\n/* harmony import */ var _core_src_parser_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./core/src/parser.js */ \"./core/src/parser.js\");\n/* harmony import */ var _core_src_util__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./core/src/util */ \"./core/src/util.js\");\n/* harmony import */ var _core_src_listeners__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./core/src/listeners */ \"./core/src/listeners.js\");\nfunction _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) { return call; } return _assertThisInitialized(self); }\n\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\n\nfunction _get(target, property, receiver) { if (typeof Reflect !== \"undefined\" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(receiver); } return desc.value; }; } return _get(target, property, receiver || target); }\n\nfunction _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }\n\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function\"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }\n\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\n\n\n\n\n\n\n/**\n * TinyMCE integration class. This class extends IntegrationModel class.\n */\n\nvar TinyMceIntegration =\n/*#__PURE__*/\nfunction (_IntegrationModel) {\n _inherits(TinyMceIntegration, _IntegrationModel);\n\n function TinyMceIntegration(integrationModelProperties) {\n var _this;\n\n _classCallCheck(this, TinyMceIntegration);\n\n _this = _possibleConstructorReturn(this, _getPrototypeOf(TinyMceIntegration).call(this, integrationModelProperties));\n /**\n * Indicates if the content of the TinyMCe editor has\n * been parsed.\n * @type {boolean}\n */\n\n _this.initParsed = integrationModelProperties.initParsed;\n /**\n * Indicates if the TinyMCE is integrated in Moodle.\n * @type {boolean}\n */\n\n _this.isMoodle = integrationModelProperties.isMoodle;\n /**\n * Indicates if the plugin is loaded as an external plugin by TinyMCE.\n * @type {boolean}\n */\n\n _this.isExternal = integrationModelProperties.isExternal;\n return _this;\n }\n /**\n * Returns the absolute path of the integration script. Depends on\n * TinyMCE integration (Moodle or standard).\n * @returns {boolean} - Absolute path for the integration script.\n */\n\n\n _createClass(TinyMceIntegration, [{\n key: \"getPath\",\n value: function getPath() {\n if (this.isMoodle) {\n var search = 'lib/editor/tinymce';\n var pos = tinymce.baseURL.indexOf(search);\n var baseURL = tinymce.baseURL.substr(0, pos + search.length);\n return baseURL + '/plugins/tiny_mce_wiris/tinymce/';\n } else if (this.isExternal) {\n var externalUrl = this.editorObject.getParam('external_plugins')['tiny_mce_wiris'];\n return externalUrl.substring(0, externalUrl.lastIndexOf('/') + 1);\n } else {\n return tinymce.baseURL + '/plugins/tiny_mce_wiris/';\n }\n }\n /**\n * Returns the absolute path of plugin icons. A set of different\n * icons is needed for TinyMCE and Moodle 2.5-\n * @returns {string} - Absolute path of the icons folder.\n */\n\n }, {\n key: \"getIconsPath\",\n value: function getIconsPath() {\n if (this.isMoodle && _core_src_configuration_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].get('versionPlatform') < 2013111800) {\n return this.getPath() + 'icons/tinymce3/';\n } else {\n return this.getPath() + 'icons/';\n }\n }\n /**\n * Returns the integration language. TinyMCE language is inherited.\n * @returns {string} - Integration language.\n */\n\n }, {\n key: \"getLanguage\",\n value: function getLanguage() {\n if (this.editorObject.settings['wirisformulaeditorlang']) {\n return editor.settings['wirisformulaeditorlang'];\n }\n\n return this.editorObject.getParam('language');\n }\n /**\n * Callback function called before 'onTargetLoad' is fired. All the logic here is to\n * avoid TinyMCE change MathType formulas.\n */\n\n }, {\n key: \"callbackFunction\",\n value: function callbackFunction() {\n var dataImgFiltered = [];\n\n _get(_getPrototypeOf(TinyMceIntegration.prototype), \"callbackFunction\", this).call(this); // Avoid to change class of image formulas.\n\n\n var imageClassName = _core_src_configuration_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].get('imageClassName');\n\n if (this.isIframe) {\n // Attaching observers to wiris images.\n if (typeof _core_src_parser_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].observer != 'undefined') {\n Array.prototype.forEach.call(this.target.contentDocument.getElementsByClassName(imageClassName), function (wirisImages) {\n _core_src_parser_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].observer.observe(wirisImages);\n });\n }\n } else {\n // Inline.\n // Attaching observers to wiris images.\n Array.prototype.forEach.call(document.getElementsByClassName(imageClassName), function (wirisImages) {\n _core_src_parser_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].observer.observe(wirisImages);\n });\n } // When a formula is updated TinyMCE 'Change' event must be fired.\n // See https://www.tiny.cloud/docs/advanced/events/#change for further information.\n\n\n var listener = _core_src_listeners__WEBPACK_IMPORTED_MODULE_4__[\"default\"].newListener('onAfterFormulaInsertion', function () {\n if (typeof this.editorObject.fire != 'undefined') {\n this.editorObject.fire('Change');\n }\n }.bind(this));\n this.getCore().addListener(listener); // Avoid filter formulas with performance enabled.\n\n dataImgFiltered[this.editorObject.id] = this.editorObject.settings.images_dataimg_filter;\n\n this.editorObject.settings.images_dataimg_filter = function (img) {\n if (img.hasAttribute('class') && img.getAttribute('class').indexOf(_core_src_configuration_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].get(imageClassName)) != -1) {\n return img.hasAttribute('internal-blob');\n } else {\n // If the client put an image data filter, run. Otherwise default behaviour (put blob).\n if (typeof dataImgFiltered[this.editorObject.id] != 'undefined') {\n return dataImgFiltered[this.editorObject.id](img);\n }\n\n return true;\n }\n };\n }\n }]);\n\n return TinyMceIntegration;\n}(_core_src_integrationmodel_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"]);\n/**\n * Object containing all TinyMCE integration instances. One for each TinyMCE editor.\n * @type {Object}\n */\n\nvar instances = {};\n/**\n * TinyMCE integration current instance. The current instance\n * is the instance related with the focused editor.\n * @type {TinyMceIntegration}\n */\n\nvar currentInstance = null;\n/* Plugin integration */\n\n(function () {\n tinymce.create('tinymce.plugins.tiny_mce_wiris', {\n init: function init(editor, url) {\n // Array with MathML valid alements.\n var validMathML = ['math[*]', 'maction[*]]', 'malignmark[*]', 'maligngroup[*]', 'menclose[*]', 'merror[*]', 'mfenced[*]', 'mfrac[*]', 'mglyph[*]', 'mi[*]', 'mlabeledtr[*]', 'mlongdiv[*]', 'mmultiscripts[*]', 'mn[*]', 'mo[*]', 'mover[*]', 'mpadded[*]', 'mphantom[*]', 'mprescripts[*]', 'mroot[*]', 'mrow[*]', 'ms[*]', 'mscarries[*]', 'mscarry[*]', 'msgroup[*]', 'msline[*]', 'mspace[*]', 'msqrt[*]', 'msrow[*]', 'mstack[*]', 'mstyle[*]', 'msub[*]', 'msubsup[*]', 'msup[*]', 'mtable[*]', 'mtd[*]', 'mtext[*]', 'mtr[*]', 'munder[*]', 'munderover[*]', 'semantics[*]', 'annotation[*]'];\n editor.settings.extended_valid_elements += ',' + validMathML.join();\n var callbackMethodArguments = {};\n /**\n * Integration model properties\n * @type {object}\n * @property {object} target - Integration DOM target.\n * @property {string} configurationService - Configuration integration service.\n * @property {string} version - Plugin version.\n * @property {string} scriptName - Integration script name.\n * @property {object} environment - Integration environment properties.\n * @property {string} editor - Editor name.\n */\n\n var integrationModelProperties = {};\n integrationModelProperties.configurationService = '' + M.cfg.wwwroot + '/filter/wiris/integration/configurationjs.php';\n integrationModelProperties.version = '7.6.1.1393';\n integrationModelProperties.isMoodle = true;\n\n if (typeof editor.getParam('wiriscontextpath') !== 'undefined') {\n integrationModelProperties.configurationService = _core_src_util__WEBPACK_IMPORTED_MODULE_3__[\"default\"].concatenateUrl(editor.getParam('wiriscontextpath'), integrationModelProperties.configurationService);\n editor.getParam('wiriscontextpath') + '/' + integrationModelProperties.configurationService;\n }\n\n integrationModelProperties.version = '7.5.0.1414';\n integrationModelProperties.scriptName = \"plugin.min.js\";\n integrationModelProperties.environment = {};\n integrationModelProperties.environment.editor = \"TinyMCE 4.x\";\n integrationModelProperties.callbackMethodArguments = callbackMethodArguments;\n integrationModelProperties.editorObject = editor;\n integrationModelProperties.initParsed = false; // We need to create the instance before TinyMce initialization in order to register commands.\n // However, as TinyMCE is not initialized at this point the HTML target is not created.\n // Here we create the target as null and onInit object the target is updated.\n\n integrationModelProperties.target = null;\n var isExternalPlugin = typeof editor.getParam('external_plugins') !== 'undefined' && 'tiny_mce_wiris' in editor.getParam('external_plugins');\n integrationModelProperties.isExternal = isExternalPlugin;\n integrationModelProperties.rtl = editor.getParam('directionality') === 'rtl'; // GenericIntegration instance.\n\n var tinyMceIntegrationInstance = new TinyMceIntegration(integrationModelProperties);\n tinyMceIntegrationInstance.init();\n WirisPlugin.instances[tinyMceIntegrationInstance.editorObject.id] = tinyMceIntegrationInstance;\n WirisPlugin.currentInstance = tinyMceIntegrationInstance;\n\n var onInit = function onInit(editor) {\n var integrationInstance = WirisPlugin.instances[tinyMceIntegrationInstance.editorObject.id];\n\n if (!editor.inline) {\n integrationInstance.setTarget(editor.getContentAreaContainer().firstChild);\n } else {\n integrationInstance.setTarget(editor.getElement());\n }\n\n integrationInstance.setEditorObject(editor);\n integrationInstance.listeners.fire('onTargetReady', {});\n\n if ('wiriseditorparameters' in editor.settings) {\n _core_src_configuration_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].update('_wrs_conf_editorParameters', editor.settings.wiriseditorparameters);\n }\n\n var content = editor.getContent(); // Bug fix: In Moodle2.x when TinyMCE is set to full screen\n // the content doesn't need to be filtered.\n\n if (!editor.getParam('fullscreen_is_enabled') && content !== \"\") {\n // We set content in html because other tiny plugins need data-mce\n // and this is not posibil with raw format.\n editor.setContent(_core_src_parser_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].initParse(content, editor.getParam('language')), {\n format: \"html\"\n }); // This clean undoQueue for prevent onChange and Dirty state.\n\n editor.undoManager.clear();\n } // Init parsing OK. If a setContent method is called\n // wrs_initParse is called again.\n // Now if source code is edited the returned code is parsed.\n // PLUGINS-1070: We set this variable out of condition to parse content after.\n\n\n WirisPlugin.instances[editor.id].initParsed = true;\n };\n\n if ('onInit' in editor) {\n editor.onInit.add(onInit);\n } else {\n editor.on('init', function () {\n onInit(editor);\n });\n }\n\n if ('onActivate' in editor) {\n editor.onActivate.add(function (editor) {\n WirisPlugin.currentInstance = WirisPlugin.instances[tinymce.activeEditor.id];\n });\n } else {\n editor.on('focus', function (event) {\n WirisPlugin.currentInstance = WirisPlugin.instances[tinymce.activeEditor.id];\n });\n }\n\n var onSave = function onSave(editor, params) {\n params.content = _core_src_parser_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].endParse(params.content, editor.getParam('language'));\n };\n\n if ('onSaveContent' in editor) {\n editor.onSaveContent.add(onSave);\n } else {\n editor.on('saveContent', function (params) {\n onSave(editor, params);\n });\n }\n\n if ('onGetContent' in editor) {\n editor.onGetContent.add(onSave);\n } else {\n editor.on('getContent', function (params) {\n onSave(editor, params);\n });\n }\n\n if ('onBeforeSetContent' in editor) {\n editor.onBeforeSetContent.add(function (e, params) {\n if (WirisPlugin.instances[editor.id].initParsed) {\n params.content = Parse.initParse(params.content, editor.getParam('language'));\n }\n });\n } else {\n editor.on('beforeSetContent', function (params) {\n if (WirisPlugin.instances[editor.id].initParsed) {\n params.content = _core_src_parser_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].initParse(params.content, editor.getParam('language'));\n }\n });\n } // We use a mutation to observe iframe of tiny and filter to remove data-mce.\n\n\n var observerConfig = {\n attributes: true,\n childList: true,\n characterData: true,\n subtree: true\n };\n\n function onMutations(mutations) {\n Array.prototype.forEach.call(mutations, function (mutation) {\n Array.prototype.forEach.call(mutation.addedNodes, function (node) {\n // We search only in element nodes.\n if (node.nodeType == 1) {\n Array.prototype.forEach.call(node.getElementsByClassName(WirisPlugin.Configuration.get('imageMathmlAttribute')), function (image) {\n image.removeAttribute('data-mce-src');\n image.removeAttribute('data-mce-style');\n });\n }\n });\n });\n }\n\n var mutationInstance = new MutationObserver(onMutations); // We wait for iframe definition for observe this.\n\n function waitForIframeBody() {\n if (typeof editor.contentDocument != 'undefined') {\n mutationInstance.observe(editor.getBody(), observerConfig);\n } else {\n setTimeout(waitForIframeBody, 50);\n }\n }\n\n waitForIframeBody(); // MathType button.\n\n editor.addCommand('tiny_mce_wiris_openFormulaEditor', function () {\n WirisPlugin.instances[editor.id].openNewFormulaEditor();\n });\n editor.addButton('tiny_mce_wiris_formulaEditor', {\n title: 'Insert a math equation - MathType',\n cmd: 'tiny_mce_wiris_openFormulaEditor',\n image: WirisPlugin.instances[editor.id].getIconsPath() + 'formula.png'\n }); // }\n // Dynamic customEditors buttons.\n\n var customEditors = WirisPlugin.instances[tinyMCE.activeEditor.id].getCore().getCustomEditors();\n\n for (var customEditor in customEditors.editors) {\n if (customEditors.editors[customEditor].confVariable) {\n var cmd = 'tiny_mce_wiris_openFormulaEditor' + customEditors.editors[customEditor].name;\n editor.addCommand(cmd, function () {\n customEditors.enable(customEditor);\n WirisPlugin.instances[editor.id].openNewFormulaEditor();\n });\n editor.addButton('tiny_mce_wiris_formulaEditor' + customEditors.editors[customEditor].name, {\n title: customEditors.editors[customEditor].tooltip,\n cmd: cmd,\n image: WirisPlugin.instances[editor.id].getIconsPath() + customEditors.editors[customEditor].icon\n });\n }\n }\n },\n // All versions.\n getInfo: function getInfo() {\n return {\n longname: 'tiny_mce_wiris',\n author: 'Maths for More',\n authorurl: 'http://www.wiris.com',\n infourl: 'http://www.wiris.com',\n version: '7.6.1.1393'\n };\n }\n });\n tinymce.PluginManager.add('tiny_mce_wiris', tinymce.plugins.tiny_mce_wiris);\n})();\n\n//# sourceURL=webpack:///./editor_plugin.src.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"TinyMceIntegration\", function() { return TinyMceIntegration; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"instances\", function() { return instances; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"currentInstance\", function() { return currentInstance; });\n/* harmony import */ var _core_src_integrationmodel_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./core/src/integrationmodel.js */ \"./core/src/integrationmodel.js\");\n/* harmony import */ var _core_src_configuration_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./core/src/configuration.js */ \"./core/src/configuration.js\");\n/* harmony import */ var _core_src_parser_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./core/src/parser.js */ \"./core/src/parser.js\");\n/* harmony import */ var _core_src_util__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./core/src/util */ \"./core/src/util.js\");\n/* harmony import */ var _core_src_listeners__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./core/src/listeners */ \"./core/src/listeners.js\");\nfunction _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) { return call; } return _assertThisInitialized(self); }\n\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\n\nfunction _get(target, property, receiver) { if (typeof Reflect !== \"undefined\" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(receiver); } return desc.value; }; } return _get(target, property, receiver || target); }\n\nfunction _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }\n\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function\"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }\n\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\n\n\n\n\n\n\n/**\n * TinyMCE integration class. This class extends IntegrationModel class.\n */\n\nvar TinyMceIntegration =\n/*#__PURE__*/\nfunction (_IntegrationModel) {\n _inherits(TinyMceIntegration, _IntegrationModel);\n\n function TinyMceIntegration(integrationModelProperties) {\n var _this;\n\n _classCallCheck(this, TinyMceIntegration);\n\n _this = _possibleConstructorReturn(this, _getPrototypeOf(TinyMceIntegration).call(this, integrationModelProperties));\n /**\n * Indicates if the content of the TinyMCe editor has\n * been parsed.\n * @type {boolean}\n */\n\n _this.initParsed = integrationModelProperties.initParsed;\n /**\n * Indicates if the TinyMCE is integrated in Moodle.\n * @type {boolean}\n */\n\n _this.isMoodle = integrationModelProperties.isMoodle;\n /**\n * Indicates if the plugin is loaded as an external plugin by TinyMCE.\n * @type {boolean}\n */\n\n _this.isExternal = integrationModelProperties.isExternal;\n return _this;\n }\n /**\n * Returns the absolute path of the integration script. Depends on\n * TinyMCE integration (Moodle or standard).\n * @returns {boolean} - Absolute path for the integration script.\n */\n\n\n _createClass(TinyMceIntegration, [{\n key: \"getPath\",\n value: function getPath() {\n if (this.isMoodle) {\n var search = 'lib/editor/tinymce';\n var pos = tinymce.baseURL.indexOf(search);\n var baseURL = tinymce.baseURL.substr(0, pos + search.length);\n return baseURL + '/plugins/tiny_mce_wiris/tinymce/';\n } else if (this.isExternal) {\n var externalUrl = this.editorObject.getParam('external_plugins')['tiny_mce_wiris'];\n return externalUrl.substring(0, externalUrl.lastIndexOf('/') + 1);\n } else {\n return tinymce.baseURL + '/plugins/tiny_mce_wiris/';\n }\n }\n /**\n * Returns the absolute path of plugin icons. A set of different\n * icons is needed for TinyMCE and Moodle 2.5-\n * @returns {string} - Absolute path of the icons folder.\n */\n\n }, {\n key: \"getIconsPath\",\n value: function getIconsPath() {\n if (this.isMoodle && _core_src_configuration_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].get('versionPlatform') < 2013111800) {\n return this.getPath() + 'icons/tinymce3/';\n } else {\n return this.getPath() + 'icons/';\n }\n }\n /**\n * Returns the integration language. TinyMCE language is inherited.\n * @returns {string} - Integration language.\n */\n\n }, {\n key: \"getLanguage\",\n value: function getLanguage() {\n if (this.editorObject.settings['wirisformulaeditorlang']) {\n return editor.settings['wirisformulaeditorlang'];\n }\n\n return this.editorObject.getParam('language');\n }\n /**\n * Callback function called before 'onTargetLoad' is fired. All the logic here is to\n * avoid TinyMCE change MathType formulas.\n */\n\n }, {\n key: \"callbackFunction\",\n value: function callbackFunction() {\n var dataImgFiltered = [];\n\n _get(_getPrototypeOf(TinyMceIntegration.prototype), \"callbackFunction\", this).call(this); // Avoid to change class of image formulas.\n\n\n var imageClassName = _core_src_configuration_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].get('imageClassName');\n\n if (this.isIframe) {\n // Attaching observers to wiris images.\n if (typeof _core_src_parser_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].observer != 'undefined') {\n Array.prototype.forEach.call(this.target.contentDocument.getElementsByClassName(imageClassName), function (wirisImages) {\n _core_src_parser_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].observer.observe(wirisImages);\n });\n }\n } else {\n // Inline.\n // Attaching observers to wiris images.\n Array.prototype.forEach.call(document.getElementsByClassName(imageClassName), function (wirisImages) {\n _core_src_parser_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].observer.observe(wirisImages);\n });\n } // When a formula is updated TinyMCE 'Change' event must be fired.\n // See https://www.tiny.cloud/docs/advanced/events/#change for further information.\n\n\n var listener = _core_src_listeners__WEBPACK_IMPORTED_MODULE_4__[\"default\"].newListener('onAfterFormulaInsertion', function () {\n if (typeof this.editorObject.fire != 'undefined') {\n this.editorObject.fire('Change');\n }\n }.bind(this));\n this.getCore().addListener(listener); // Avoid filter formulas with performance enabled.\n\n dataImgFiltered[this.editorObject.id] = this.editorObject.settings.images_dataimg_filter;\n\n this.editorObject.settings.images_dataimg_filter = function (img) {\n if (img.hasAttribute('class') && img.getAttribute('class').indexOf(_core_src_configuration_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].get(imageClassName)) != -1) {\n return img.hasAttribute('internal-blob');\n } else {\n // If the client put an image data filter, run. Otherwise default behaviour (put blob).\n if (typeof dataImgFiltered[this.editorObject.id] != 'undefined') {\n return dataImgFiltered[this.editorObject.id](img);\n }\n\n return true;\n }\n };\n }\n }]);\n\n return TinyMceIntegration;\n}(_core_src_integrationmodel_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"]);\n/**\n * Object containing all TinyMCE integration instances. One for each TinyMCE editor.\n * @type {Object}\n */\n\nvar instances = {};\n/**\n * TinyMCE integration current instance. The current instance\n * is the instance related with the focused editor.\n * @type {TinyMceIntegration}\n */\n\nvar currentInstance = null;\n/* Plugin integration */\n\n(function () {\n tinymce.create('tinymce.plugins.tiny_mce_wiris', {\n init: function init(editor, url) {\n // Array with MathML valid alements.\n var validMathML = ['math[*]', 'maction[*]]', 'malignmark[*]', 'maligngroup[*]', 'menclose[*]', 'merror[*]', 'mfenced[*]', 'mfrac[*]', 'mglyph[*]', 'mi[*]', 'mlabeledtr[*]', 'mlongdiv[*]', 'mmultiscripts[*]', 'mn[*]', 'mo[*]', 'mover[*]', 'mpadded[*]', 'mphantom[*]', 'mprescripts[*]', 'mroot[*]', 'mrow[*]', 'ms[*]', 'mscarries[*]', 'mscarry[*]', 'msgroup[*]', 'msline[*]', 'mspace[*]', 'msqrt[*]', 'msrow[*]', 'mstack[*]', 'mstyle[*]', 'msub[*]', 'msubsup[*]', 'msup[*]', 'mtable[*]', 'mtd[*]', 'mtext[*]', 'mtr[*]', 'munder[*]', 'munderover[*]', 'semantics[*]', 'annotation[*]'];\n editor.settings.extended_valid_elements += ',' + validMathML.join();\n var callbackMethodArguments = {};\n /**\n * Integration model properties\n * @type {object}\n * @property {object} target - Integration DOM target.\n * @property {string} configurationService - Configuration integration service.\n * @property {string} version - Plugin version.\n * @property {string} scriptName - Integration script name.\n * @property {object} environment - Integration environment properties.\n * @property {string} editor - Editor name.\n */\n\n var integrationModelProperties = {};\n integrationModelProperties.configurationService = '' + M.cfg.wwwroot + '/filter/wiris/integration/configurationjs.php';\n integrationModelProperties.version = '7.7.0.1394';\n integrationModelProperties.isMoodle = true;\n\n if (typeof editor.getParam('wiriscontextpath') !== 'undefined') {\n integrationModelProperties.configurationService = _core_src_util__WEBPACK_IMPORTED_MODULE_3__[\"default\"].concatenateUrl(editor.getParam('wiriscontextpath'), integrationModelProperties.configurationService);\n editor.getParam('wiriscontextpath') + '/' + integrationModelProperties.configurationService;\n }\n\n integrationModelProperties.version = '7.5.0.1414';\n integrationModelProperties.scriptName = \"plugin.min.js\";\n integrationModelProperties.environment = {};\n integrationModelProperties.environment.editor = \"TinyMCE 4.x\";\n integrationModelProperties.callbackMethodArguments = callbackMethodArguments;\n integrationModelProperties.editorObject = editor;\n integrationModelProperties.initParsed = false; // We need to create the instance before TinyMce initialization in order to register commands.\n // However, as TinyMCE is not initialized at this point the HTML target is not created.\n // Here we create the target as null and onInit object the target is updated.\n\n integrationModelProperties.target = null;\n var isExternalPlugin = typeof editor.getParam('external_plugins') !== 'undefined' && 'tiny_mce_wiris' in editor.getParam('external_plugins');\n integrationModelProperties.isExternal = isExternalPlugin;\n integrationModelProperties.rtl = editor.getParam('directionality') === 'rtl'; // GenericIntegration instance.\n\n var tinyMceIntegrationInstance = new TinyMceIntegration(integrationModelProperties);\n tinyMceIntegrationInstance.init();\n WirisPlugin.instances[tinyMceIntegrationInstance.editorObject.id] = tinyMceIntegrationInstance;\n WirisPlugin.currentInstance = tinyMceIntegrationInstance;\n\n var onInit = function onInit(editor) {\n var integrationInstance = WirisPlugin.instances[tinyMceIntegrationInstance.editorObject.id];\n\n if (!editor.inline) {\n integrationInstance.setTarget(editor.getContentAreaContainer().firstChild);\n } else {\n integrationInstance.setTarget(editor.getElement());\n }\n\n integrationInstance.setEditorObject(editor);\n integrationInstance.listeners.fire('onTargetReady', {});\n\n if ('wiriseditorparameters' in editor.settings) {\n _core_src_configuration_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].update('_wrs_conf_editorParameters', editor.settings.wiriseditorparameters);\n }\n\n var content = editor.getContent(); // Bug fix: In Moodle2.x when TinyMCE is set to full screen\n // the content doesn't need to be filtered.\n\n if (!editor.getParam('fullscreen_is_enabled') && content !== \"\") {\n // We set content in html because other tiny plugins need data-mce\n // and this is not posibil with raw format.\n editor.setContent(_core_src_parser_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].initParse(content, editor.getParam('language')), {\n format: \"html\"\n }); // This clean undoQueue for prevent onChange and Dirty state.\n\n editor.undoManager.clear();\n } // Init parsing OK. If a setContent method is called\n // wrs_initParse is called again.\n // Now if source code is edited the returned code is parsed.\n // PLUGINS-1070: We set this variable out of condition to parse content after.\n\n\n WirisPlugin.instances[editor.id].initParsed = true;\n };\n\n if ('onInit' in editor) {\n editor.onInit.add(onInit);\n } else {\n editor.on('init', function () {\n onInit(editor);\n });\n }\n\n if ('onActivate' in editor) {\n editor.onActivate.add(function (editor) {\n WirisPlugin.currentInstance = WirisPlugin.instances[tinymce.activeEditor.id];\n });\n } else {\n editor.on('focus', function (event) {\n WirisPlugin.currentInstance = WirisPlugin.instances[tinymce.activeEditor.id];\n });\n }\n\n var onSave = function onSave(editor, params) {\n params.content = _core_src_parser_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].endParse(params.content, editor.getParam('language'));\n };\n\n if ('onSaveContent' in editor) {\n editor.onSaveContent.add(onSave);\n } else {\n editor.on('saveContent', function (params) {\n onSave(editor, params);\n });\n }\n\n if ('onGetContent' in editor) {\n editor.onGetContent.add(onSave);\n } else {\n editor.on('getContent', function (params) {\n onSave(editor, params);\n });\n }\n\n if ('onBeforeSetContent' in editor) {\n editor.onBeforeSetContent.add(function (e, params) {\n if (WirisPlugin.instances[editor.id].initParsed) {\n params.content = Parse.initParse(params.content, editor.getParam('language'));\n }\n });\n } else {\n editor.on('beforeSetContent', function (params) {\n if (WirisPlugin.instances[editor.id].initParsed) {\n params.content = _core_src_parser_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].initParse(params.content, editor.getParam('language'));\n }\n });\n } // We use a mutation to observe iframe of tiny and filter to remove data-mce.\n\n\n var observerConfig = {\n attributes: true,\n childList: true,\n characterData: true,\n subtree: true\n };\n\n function onMutations(mutations) {\n Array.prototype.forEach.call(mutations, function (mutation) {\n Array.prototype.forEach.call(mutation.addedNodes, function (node) {\n // We search only in element nodes.\n if (node.nodeType == 1) {\n Array.prototype.forEach.call(node.getElementsByClassName(WirisPlugin.Configuration.get('imageMathmlAttribute')), function (image) {\n image.removeAttribute('data-mce-src');\n image.removeAttribute('data-mce-style');\n });\n }\n });\n });\n }\n\n var mutationInstance = new MutationObserver(onMutations); // We wait for iframe definition for observe this.\n\n function waitForIframeBody() {\n if (typeof editor.contentDocument != 'undefined') {\n mutationInstance.observe(editor.getBody(), observerConfig);\n } else {\n setTimeout(waitForIframeBody, 50);\n }\n }\n\n waitForIframeBody(); // MathType button.\n\n editor.addCommand('tiny_mce_wiris_openFormulaEditor', function () {\n WirisPlugin.instances[editor.id].openNewFormulaEditor();\n });\n editor.addButton('tiny_mce_wiris_formulaEditor', {\n title: 'Insert a math equation - MathType',\n cmd: 'tiny_mce_wiris_openFormulaEditor',\n image: WirisPlugin.instances[editor.id].getIconsPath() + 'formula.png'\n }); // }\n // Dynamic customEditors buttons.\n\n var customEditors = WirisPlugin.instances[tinyMCE.activeEditor.id].getCore().getCustomEditors();\n\n for (var customEditor in customEditors.editors) {\n if (customEditors.editors[customEditor].confVariable) {\n var cmd = 'tiny_mce_wiris_openFormulaEditor' + customEditors.editors[customEditor].name;\n editor.addCommand(cmd, function () {\n customEditors.enable(customEditor);\n WirisPlugin.instances[editor.id].openNewFormulaEditor();\n });\n editor.addButton('tiny_mce_wiris_formulaEditor' + customEditors.editors[customEditor].name, {\n title: customEditors.editors[customEditor].tooltip,\n cmd: cmd,\n image: WirisPlugin.instances[editor.id].getIconsPath() + customEditors.editors[customEditor].icon\n });\n }\n }\n },\n // All versions.\n getInfo: function getInfo() {\n return {\n longname: 'tiny_mce_wiris',\n author: 'Maths for More',\n authorurl: 'http://www.wiris.com',\n infourl: 'http://www.wiris.com',\n version: '7.7.0.1394'\n };\n }\n });\n tinymce.PluginManager.add('tiny_mce_wiris', tinymce.plugins.tiny_mce_wiris);\n})();\n\n//# sourceURL=webpack:///./editor_plugin.src.js?"); /***/ }), diff --git a/tinymce/package-lock.json b/tinymce/package-lock.json index 5d51ad8..a98b5e1 100644 --- a/tinymce/package-lock.json +++ b/tinymce/package-lock.json @@ -13,18 +13,18 @@ } }, "@babel/core": { - "version": "7.1.0", - "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.1.0.tgz", - "integrity": "sha512-9EWmD0cQAbcXSc+31RIoYgEHx3KQ2CCSMDBhnXrShWvo45TMw+3/55KVxlhkG53kw9tl87DqINgHDgFVhZJV/Q==", + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.1.2.tgz", + "integrity": "sha512-IFeSSnjXdhDaoysIlev//UzHZbdEmm7D0EIH2qtse9xK7mXEZQpYjs2P00XlP1qYsYvid79p+Zgg6tz1mp6iVw==", "dev": true, "requires": { "@babel/code-frame": "7.0.0", - "@babel/generator": "7.0.0", - "@babel/helpers": "7.1.0", - "@babel/parser": "7.1.0", - "@babel/template": "7.1.0", + "@babel/generator": "7.1.2", + "@babel/helpers": "7.1.2", + "@babel/parser": "7.1.2", + "@babel/template": "7.1.2", "@babel/traverse": "7.1.0", - "@babel/types": "7.0.0", + "@babel/types": "7.1.2", "convert-source-map": "1.6.0", "debug": "3.2.5", "json5": "0.5.1", @@ -35,12 +35,12 @@ } }, "@babel/generator": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.0.0.tgz", - "integrity": "sha512-/BM2vupkpbZXq22l1ALO7MqXJZH2k8bKVv8Y+pABFnzWdztDB/ZLveP5At21vLz5c2YtSE6p7j2FZEsqafMz5Q==", + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.1.2.tgz", + "integrity": "sha512-70A9HWLS/1RHk3Ck8tNHKxOoKQuSKocYgwDN85Pyl/RBduss6AKxUR7RIZ/lzduQMSYfWEM4DDBu6A+XGbkFig==", "dev": true, "requires": { - "@babel/types": "7.0.0", + "@babel/types": "7.1.2", "jsesc": "2.5.1", "lodash": "4.17.11", "source-map": "0.5.7", @@ -53,7 +53,7 @@ "integrity": "sha512-3UYcJUj9kvSLbLbUIfQTqzcy5VX7GRZ/CCDrnOaZorFFM01aXp1+GJwuFGV4NDDoAS+mOUyHcO6UD/RfqOks3Q==", "dev": true, "requires": { - "@babel/types": "7.0.0" + "@babel/types": "7.1.2" } }, "@babel/helper-builder-binary-assignment-operator-visitor": { @@ -63,7 +63,7 @@ "dev": true, "requires": { "@babel/helper-explode-assignable-expression": "7.1.0", - "@babel/types": "7.0.0" + "@babel/types": "7.1.2" } }, "@babel/helper-call-delegate": { @@ -74,7 +74,7 @@ "requires": { "@babel/helper-hoist-variables": "7.0.0", "@babel/traverse": "7.1.0", - "@babel/types": "7.0.0" + "@babel/types": "7.1.2" } }, "@babel/helper-define-map": { @@ -84,7 +84,7 @@ "dev": true, "requires": { "@babel/helper-function-name": "7.1.0", - "@babel/types": "7.0.0", + "@babel/types": "7.1.2", "lodash": "4.17.11" } }, @@ -95,7 +95,7 @@ "dev": true, "requires": { "@babel/traverse": "7.1.0", - "@babel/types": "7.0.0" + "@babel/types": "7.1.2" } }, "@babel/helper-function-name": { @@ -105,8 +105,8 @@ "dev": true, "requires": { "@babel/helper-get-function-arity": "7.0.0", - "@babel/template": "7.1.0", - "@babel/types": "7.0.0" + "@babel/template": "7.1.2", + "@babel/types": "7.1.2" } }, "@babel/helper-get-function-arity": { @@ -115,7 +115,7 @@ "integrity": "sha512-r2DbJeg4svYvt3HOS74U4eWKsUAMRH01Z1ds1zx8KNTPtpTL5JAsdFv8BNyOpVqdFhHkkRDIg5B4AsxmkjAlmQ==", "dev": true, "requires": { - "@babel/types": "7.0.0" + "@babel/types": "7.1.2" } }, "@babel/helper-hoist-variables": { @@ -124,7 +124,7 @@ "integrity": "sha512-Ggv5sldXUeSKsuzLkddtyhyHe2YantsxWKNi7A+7LeD12ExRDWTRk29JCXpaHPAbMaIPZSil7n+lq78WY2VY7w==", "dev": true, "requires": { - "@babel/types": "7.0.0" + "@babel/types": "7.1.2" } }, "@babel/helper-member-expression-to-functions": { @@ -133,7 +133,7 @@ "integrity": "sha512-avo+lm/QmZlv27Zsi0xEor2fKcqWG56D5ae9dzklpIaY7cQMK5N8VSpaNVPPagiqmy7LrEjK1IWdGMOqPu5csg==", "dev": true, "requires": { - "@babel/types": "7.0.0" + "@babel/types": "7.1.2" } }, "@babel/helper-module-imports": { @@ -142,7 +142,7 @@ "integrity": "sha512-aP/hlLq01DWNEiDg4Jn23i+CXxW/owM4WpDLFUbpjxe4NS3BhLVZQ5i7E0ZrxuQ/vwekIeciyamgB1UIYxxM6A==", "dev": true, "requires": { - "@babel/types": "7.0.0" + "@babel/types": "7.1.2" } }, "@babel/helper-module-transforms": { @@ -154,8 +154,8 @@ "@babel/helper-module-imports": "7.0.0", "@babel/helper-simple-access": "7.1.0", "@babel/helper-split-export-declaration": "7.0.0", - "@babel/template": "7.1.0", - "@babel/types": "7.0.0", + "@babel/template": "7.1.2", + "@babel/types": "7.1.2", "lodash": "4.17.11" } }, @@ -165,7 +165,7 @@ "integrity": "sha512-u8nd9NQePYNQV8iPWu/pLLYBqZBa4ZaY1YWRFMuxrid94wKI1QNt67NEZ7GAe5Kc/0LLScbim05xZFWkAdrj9g==", "dev": true, "requires": { - "@babel/types": "7.0.0" + "@babel/types": "7.1.2" } }, "@babel/helper-plugin-utils": { @@ -191,9 +191,9 @@ "requires": { "@babel/helper-annotate-as-pure": "7.0.0", "@babel/helper-wrap-function": "7.1.0", - "@babel/template": "7.1.0", + "@babel/template": "7.1.2", "@babel/traverse": "7.1.0", - "@babel/types": "7.0.0" + "@babel/types": "7.1.2" } }, "@babel/helper-replace-supers": { @@ -205,7 +205,7 @@ "@babel/helper-member-expression-to-functions": "7.0.0", "@babel/helper-optimise-call-expression": "7.0.0", "@babel/traverse": "7.1.0", - "@babel/types": "7.0.0" + "@babel/types": "7.1.2" } }, "@babel/helper-simple-access": { @@ -214,8 +214,8 @@ "integrity": "sha512-Vk+78hNjRbsiu49zAPALxTb+JUQCz1aolpd8osOF16BGnLtseD21nbHgLPGUwrXEurZgiCOUmvs3ExTu4F5x6w==", "dev": true, "requires": { - "@babel/template": "7.1.0", - "@babel/types": "7.0.0" + "@babel/template": "7.1.2", + "@babel/types": "7.1.2" } }, "@babel/helper-split-export-declaration": { @@ -224,7 +224,7 @@ "integrity": "sha512-MXkOJqva62dfC0w85mEf/LucPPS/1+04nmmRMPEBUB++hiiThQ2zPtX/mEWQ3mtzCEjIJvPY8nuwxXtQeQwUag==", "dev": true, "requires": { - "@babel/types": "7.0.0" + "@babel/types": "7.1.2" } }, "@babel/helper-wrap-function": { @@ -234,20 +234,20 @@ "dev": true, "requires": { "@babel/helper-function-name": "7.1.0", - "@babel/template": "7.1.0", + "@babel/template": "7.1.2", "@babel/traverse": "7.1.0", - "@babel/types": "7.0.0" + "@babel/types": "7.1.2" } }, "@babel/helpers": { - "version": "7.1.0", - "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.1.0.tgz", - "integrity": "sha512-V1jXUTNdTpBn37wqqN73U+eBpzlLHmxA4aDaghJBggmzly/FpIJMHXse9lgdzQQT4gs5jZ5NmYxOL8G3ROc29g==", + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.1.2.tgz", + "integrity": "sha512-Myc3pUE8eswD73aWcartxB16K6CGmHDv9KxOmD2CeOs/FaEAQodr3VYGmlvOmog60vNQ2w8QbatuahepZwrHiA==", "dev": true, "requires": { - "@babel/template": "7.1.0", + "@babel/template": "7.1.2", "@babel/traverse": "7.1.0", - "@babel/types": "7.0.0" + "@babel/types": "7.1.2" } }, "@babel/highlight": { @@ -262,9 +262,9 @@ } }, "@babel/parser": { - "version": "7.1.0", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.1.0.tgz", - "integrity": "sha512-SmjnXCuPAlai75AFtzv+KCBcJ3sDDWbIn+WytKw1k+wAtEy6phqI2RqKh/zAnw53i1NR8su3Ep/UoqaKcimuLg==", + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.1.2.tgz", + "integrity": "sha512-x5HFsW+E/nQalGMw7hu+fvPqnBeBaIr0lWJ2SG0PPL2j+Pm9lYvCrsZJGIgauPIENx0v10INIyFjmSNUD/gSqQ==", "dev": true }, "@babel/plugin-proposal-async-generator-functions": { @@ -407,7 +407,7 @@ "@babel/helper-plugin-utils": "7.0.0", "@babel/helper-replace-supers": "7.1.0", "@babel/helper-split-export-declaration": "7.0.0", - "globals": "11.7.0" + "globals": "11.8.0" } }, "@babel/plugin-transform-computed-properties": { @@ -420,9 +420,9 @@ } }, "@babel/plugin-transform-destructuring": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-destructuring/-/plugin-transform-destructuring-7.0.0.tgz", - "integrity": "sha512-Fr2GtF8YJSXGTyFPakPFB4ODaEKGU04bPsAllAIabwoXdFrPxL0LVXQX5dQWoxOjjgozarJcC9eWGsj0fD6Zsg==", + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-destructuring/-/plugin-transform-destructuring-7.1.2.tgz", + "integrity": "sha512-cvToXvp/OsYxtEn57XJu9BvsGSEYjAh9UeUuXpoi7x6QHB7YdWyQ4lRU/q0Fu1IJNT0o0u4FQ1DMQBzJ8/8vZg==", "dev": true, "requires": { "@babel/helper-plugin-utils": "7.0.0" @@ -646,7 +646,7 @@ "@babel/plugin-transform-block-scoping": "7.0.0", "@babel/plugin-transform-classes": "7.1.0", "@babel/plugin-transform-computed-properties": "7.0.0", - "@babel/plugin-transform-destructuring": "7.0.0", + "@babel/plugin-transform-destructuring": "7.1.2", "@babel/plugin-transform-dotall-regex": "7.0.0", "@babel/plugin-transform-duplicate-keys": "7.0.0", "@babel/plugin-transform-exponentiation-operator": "7.1.0", @@ -667,21 +667,21 @@ "@babel/plugin-transform-template-literals": "7.0.0", "@babel/plugin-transform-typeof-symbol": "7.0.0", "@babel/plugin-transform-unicode-regex": "7.0.0", - "browserslist": "4.1.1", + "browserslist": "4.2.0", "invariant": "2.2.4", - "js-levenshtein": "1.1.3", + "js-levenshtein": "1.1.4", "semver": "5.5.1" } }, "@babel/template": { - "version": "7.1.0", - "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.1.0.tgz", - "integrity": "sha512-yZ948B/pJrwWGY6VxG6XRFsVTee3IQ7bihq9zFpM00Vydu6z5Xwg0C3J644kxI9WOTzd+62xcIsQ+AT1MGhqhA==", + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.1.2.tgz", + "integrity": "sha512-SY1MmplssORfFiLDcOETrW7fCLl+PavlwMh92rrGcikQaRq4iWPVH0MpwPpY3etVMx6RnDjXtr6VZYr/IbP/Ag==", "dev": true, "requires": { "@babel/code-frame": "7.0.0", - "@babel/parser": "7.1.0", - "@babel/types": "7.0.0" + "@babel/parser": "7.1.2", + "@babel/types": "7.1.2" } }, "@babel/traverse": { @@ -691,20 +691,20 @@ "dev": true, "requires": { "@babel/code-frame": "7.0.0", - "@babel/generator": "7.0.0", + "@babel/generator": "7.1.2", "@babel/helper-function-name": "7.1.0", "@babel/helper-split-export-declaration": "7.0.0", - "@babel/parser": "7.1.0", - "@babel/types": "7.0.0", + "@babel/parser": "7.1.2", + "@babel/types": "7.1.2", "debug": "3.2.5", - "globals": "11.7.0", + "globals": "11.8.0", "lodash": "4.17.11" } }, "@babel/types": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.0.0.tgz", - "integrity": "sha512-5tPDap4bGKTLPtci2SUl/B7Gv8RnuJFuQoWx26RJobS0fFrz4reUA3JnwIM+HVHEmWE0C1mzKhDtTp8NsWY02Q==", + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.1.2.tgz", + "integrity": "sha512-pb1I05sZEKiSlMUV9UReaqsCPUpgbHHHu2n1piRm7JkuBkm6QxcaIzKu6FMnMtCbih/cEYTR+RGYYC96Yk9HAg==", "dev": true, "requires": { "esutils": "2.0.2", @@ -1105,9 +1105,9 @@ } }, "babel-loader": { - "version": "8.0.2", - "resolved": "https://registry.npmjs.org/babel-loader/-/babel-loader-8.0.2.tgz", - "integrity": "sha512-Law0PGtRV1JL8Y9Wpzc0d6EE0GD7LzXWCfaeWwboUMcBWNG6gvaWTK1/+BK7a4X5EmeJiGEuDDFxUsOa8RSWCw==", + "version": "8.0.4", + "resolved": "https://registry.npmjs.org/babel-loader/-/babel-loader-8.0.4.tgz", + "integrity": "sha512-fhBhNkUToJcW9nV46v8w87AJOwAJDz84c1CL57n3Stj73FANM/b9TbCUK4YhdOwEyZ+OxhYpdeZDNzSI29Firw==", "dev": true, "requires": { "find-cache-dir": "1.0.0", @@ -1330,14 +1330,14 @@ } }, "browserslist": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.1.1.tgz", - "integrity": "sha512-VBorw+tgpOtZ1BYhrVSVTzTt/3+vSE3eFUh0N2GCFK1HffceOaf32YS/bs6WiFhjDAblAFrx85jMy3BG9fBK2Q==", + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.2.0.tgz", + "integrity": "sha512-Berls1CHL7qfQz8Lct6QxYA5d2Tvt4doDWHcjvAISybpd+EKZVppNtXgXhaN6SdrPKo7YLTSZuYBs5cYrSWN8w==", "dev": true, "requires": { - "caniuse-lite": "1.0.30000887", - "electron-to-chromium": "1.3.70", - "node-releases": "1.0.0-alpha.11" + "caniuse-lite": "1.0.30000890", + "electron-to-chromium": "1.3.75", + "node-releases": "1.0.0-alpha.12" } }, "buffer": { @@ -1419,16 +1419,16 @@ "integrity": "sha512-bsTwuIg/BZZK/vreVTYYbSWoe2F+71P7K5QGEX+pT250DZbfU1MQ5prOKpPR+LL6uWKK3KMwMCAS74QB3Um1uw==", "dev": true, "requires": { - "browserslist": "4.1.1", - "caniuse-lite": "1.0.30000887", + "browserslist": "4.2.0", + "caniuse-lite": "1.0.30000890", "lodash.memoize": "4.1.2", "lodash.uniq": "4.5.0" } }, "caniuse-lite": { - "version": "1.0.30000887", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30000887.tgz", - "integrity": "sha512-AHpONWuGFWO8yY9igdXH94tikM6ERS84286r0cAMAXYFtJBk76lhiMhtCxBJNBZsD6hzlvpWZ2AtbVFEkf4JQA==", + "version": "1.0.30000890", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30000890.tgz", + "integrity": "sha512-4NI3s4Y6ROm+SgZN5sLUG4k7nVWQnedis3c/RWkynV5G6cHSY7+a8fwFyn2yoBDE3E6VswhTNNwR3PvzGqlTkg==", "dev": true }, "chalk": { @@ -1719,7 +1719,7 @@ "requires": { "cipher-base": "1.0.4", "inherits": "2.0.3", - "md5.js": "1.3.4", + "md5.js": "1.3.5", "ripemd160": "2.0.2", "sha.js": "2.4.11" } @@ -1764,8 +1764,8 @@ "create-hmac": "1.1.7", "diffie-hellman": "5.0.3", "inherits": "2.0.3", - "pbkdf2": "3.0.16", - "public-encrypt": "4.0.2", + "pbkdf2": "3.0.17", + "public-encrypt": "4.0.3", "randombytes": "2.0.6", "randomfill": "1.0.4" } @@ -1777,13 +1777,32 @@ "dev": true }, "css-declaration-sorter": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/css-declaration-sorter/-/css-declaration-sorter-3.0.1.tgz", - "integrity": "sha512-jH4024SHZ3e0M7ann9VxpFpH3moplRXNz9ZBqvFMZqi09Yo5ARbs2wdPH8GqN9iRTlQynrbGbraNbBxBLei85Q==", + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/css-declaration-sorter/-/css-declaration-sorter-4.0.1.tgz", + "integrity": "sha512-BcxQSKTSEEQUftYpBVnsH4SF05NTuBokb19/sBt6asXGKZ/6VP7PLG1CBCkFDYOnhXhPh0jMhO6xZ71oYHXHBA==", "dev": true, "requires": { - "postcss": "6.0.23", + "postcss": "7.0.5", "timsort": "0.3.0" + }, + "dependencies": { + "postcss": { + "version": "7.0.5", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-7.0.5.tgz", + "integrity": "sha512-HBNpviAUFCKvEh7NZhw1e8MBPivRszIiUnhrJ+sBFVSYSqubrzwX3KG51mYgcRHX8j/cAgZJedONZcm5jTBdgQ==", + "dev": true, + "requires": { + "chalk": "2.4.1", + "source-map": "0.6.1", + "supports-color": "5.5.0" + } + }, + "source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true + } } }, "css-loader": { @@ -1904,21 +1923,21 @@ "dev": true }, "cssnano": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/cssnano/-/cssnano-4.1.1.tgz", - "integrity": "sha512-lexmDEYdXZaavIXOaQjz1FXlQDiHavvQxkmRxb9PLn3o8SXQzlNEL9CZdEjJRdls+9IKikI3BI0Womnd7ap0kA==", + "version": "4.1.4", + "resolved": "https://registry.npmjs.org/cssnano/-/cssnano-4.1.4.tgz", + "integrity": "sha512-wP0wbOM9oqsek14CiNRYrK9N3w3jgadtGZKHXysgC/OMVpy0KZgWVPdNqODSZbz7txO9Gekr9taOfcCgL0pOOw==", "dev": true, "requires": { "cosmiconfig": "5.0.6", - "cssnano-preset-default": "4.0.1", + "cssnano-preset-default": "4.0.2", "is-resolvable": "1.1.0", - "postcss": "7.0.2" + "postcss": "7.0.5" }, "dependencies": { "postcss": { - "version": "7.0.2", - "resolved": "https://registry.npmjs.org/postcss/-/postcss-7.0.2.tgz", - "integrity": "sha512-fmaUY5370keLUTx+CnwRxtGiuFTcNBLQBqr1oE3WZ/euIYmGAo0OAgOhVJ3ByDnVmOR3PK+0V9VebzfjRIUcqw==", + "version": "7.0.5", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-7.0.5.tgz", + "integrity": "sha512-HBNpviAUFCKvEh7NZhw1e8MBPivRszIiUnhrJ+sBFVSYSqubrzwX3KG51mYgcRHX8j/cAgZJedONZcm5jTBdgQ==", "dev": true, "requires": { "chalk": "2.4.1", @@ -1935,28 +1954,28 @@ } }, "cssnano-preset-default": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/cssnano-preset-default/-/cssnano-preset-default-4.0.1.tgz", - "integrity": "sha512-ZJ4b70JdYwXknE0zGtBoF12wUZ4itgc652ITApw+j+FT6DDGL4ZLjYPnkGAh9cG8uKm2IPVf50RfMrKVbduT9w==", + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/cssnano-preset-default/-/cssnano-preset-default-4.0.2.tgz", + "integrity": "sha512-zO9PeP84l1E4kbrdyF7NSLtA/JrJY1paX5FHy5+w/ziIXO2kDqDMfJ/mosXkaHHSa3RPiIY3eB6aEgwx3IiGqA==", "dev": true, "requires": { - "css-declaration-sorter": "3.0.1", + "css-declaration-sorter": "4.0.1", "cssnano-util-raw-cache": "4.0.1", - "postcss": "7.0.2", - "postcss-calc": "6.0.1", + "postcss": "7.0.5", + "postcss-calc": "6.0.2", "postcss-colormin": "4.0.2", "postcss-convert-values": "4.0.1", "postcss-discard-comments": "4.0.1", - "postcss-discard-duplicates": "4.0.1", + "postcss-discard-duplicates": "4.0.2", "postcss-discard-empty": "4.0.1", "postcss-discard-overridden": "4.0.1", "postcss-merge-longhand": "4.0.6", "postcss-merge-rules": "4.0.2", - "postcss-minify-font-values": "4.0.1", + "postcss-minify-font-values": "4.0.2", "postcss-minify-gradients": "4.0.1", "postcss-minify-params": "4.0.1", "postcss-minify-selectors": "4.0.1", - "postcss-normalize-charset": "4.0.0", + "postcss-normalize-charset": "4.0.1", "postcss-normalize-display-values": "4.0.1", "postcss-normalize-positions": "4.0.1", "postcss-normalize-repeat-style": "4.0.1", @@ -1968,14 +1987,14 @@ "postcss-ordered-values": "4.1.1", "postcss-reduce-initial": "4.0.2", "postcss-reduce-transforms": "4.0.1", - "postcss-svgo": "4.0.0", + "postcss-svgo": "4.0.1", "postcss-unique-selectors": "4.0.1" }, "dependencies": { "postcss": { - "version": "7.0.2", - "resolved": "https://registry.npmjs.org/postcss/-/postcss-7.0.2.tgz", - "integrity": "sha512-fmaUY5370keLUTx+CnwRxtGiuFTcNBLQBqr1oE3WZ/euIYmGAo0OAgOhVJ3ByDnVmOR3PK+0V9VebzfjRIUcqw==", + "version": "7.0.5", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-7.0.5.tgz", + "integrity": "sha512-HBNpviAUFCKvEh7NZhw1e8MBPivRszIiUnhrJ+sBFVSYSqubrzwX3KG51mYgcRHX8j/cAgZJedONZcm5jTBdgQ==", "dev": true, "requires": { "chalk": "2.4.1", @@ -2009,13 +2028,13 @@ "integrity": "sha512-qLuYtWK2b2Dy55I8ZX3ky1Z16WYsx544Q0UWViebptpwn/xDBmog2TLg4f+DBMg1rJ6JDWtn96WHbOKDWt1WQA==", "dev": true, "requires": { - "postcss": "7.0.2" + "postcss": "7.0.5" }, "dependencies": { "postcss": { - "version": "7.0.2", - "resolved": "https://registry.npmjs.org/postcss/-/postcss-7.0.2.tgz", - "integrity": "sha512-fmaUY5370keLUTx+CnwRxtGiuFTcNBLQBqr1oE3WZ/euIYmGAo0OAgOhVJ3ByDnVmOR3PK+0V9VebzfjRIUcqw==", + "version": "7.0.5", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-7.0.5.tgz", + "integrity": "sha512-HBNpviAUFCKvEh7NZhw1e8MBPivRszIiUnhrJ+sBFVSYSqubrzwX3KG51mYgcRHX8j/cAgZJedONZcm5jTBdgQ==", "dev": true, "requires": { "chalk": "2.4.1", @@ -2227,9 +2246,9 @@ } }, "electron-to-chromium": { - "version": "1.3.70", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.70.tgz", - "integrity": "sha512-WYMjqCnPVS5JA+XvwEnpwucJpVi2+q9cdCFpbhxgWGsCtforFBEkuP9+nCyy/wnU/0SyLcLRIeZct9ayMGcXoQ==", + "version": "1.3.75", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.75.tgz", + "integrity": "sha512-nLo03Qpw++8R6BxDZL/B1c8SQvUe/htdgc5LWYHe5YotV2jVvRUMP5AlOmxOsyeOzgMiXrNln2mC05Ixz6vuUQ==", "dev": true }, "elliptic": { @@ -2303,7 +2322,7 @@ "integrity": "sha512-C8Fx/0jFmV5IPoMOFPA9P9G5NtqW+4cOPit3MIuvR2t7Ag2K15EJTpxnHAYTzL+aYQJIESYeXZmDBfOBE1HcpA==", "dev": true, "requires": { - "es-to-primitive": "1.1.1", + "es-to-primitive": "1.2.0", "function-bind": "1.1.1", "has": "1.0.3", "is-callable": "1.1.4", @@ -2311,9 +2330,9 @@ } }, "es-to-primitive": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.1.1.tgz", - "integrity": "sha1-RTVSSKiJeQNLZ5Lhm7gfK3l13Q0=", + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.2.0.tgz", + "integrity": "sha512-qZryBOJjV//LaxLTV6UC//WewneB3LcXOL9NP++ozKVXsIIIpm/2c13UDiD9Jp2eThsecw9m3jPqDwTyobcdbg==", "dev": true, "requires": { "is-callable": "1.1.4", @@ -2366,7 +2385,7 @@ }, "events": { "version": "1.1.1", - "resolved": "https://registry.npmjs.org/events/-/events-1.1.1.tgz", + "resolved": "http://registry.npmjs.org/events/-/events-1.1.1.tgz", "integrity": "sha1-nr23Y1rQmccNzEwqH1AEKI6L2SQ=", "dev": true }, @@ -2376,7 +2395,7 @@ "integrity": "sha512-/f2Go4TognH/KvCISP7OUsHn85hT9nUkxxA9BEWxFn+Oj9o8ZNLm/40hdlgSLyuOimsrTKLUMEorQexp/aPQeA==", "dev": true, "requires": { - "md5.js": "1.3.4", + "md5.js": "1.3.5", "safe-buffer": "5.1.2" } }, @@ -2665,7 +2684,7 @@ }, "get-stream": { "version": "3.0.0", - "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", + "resolved": "http://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", "integrity": "sha1-jpQ9E1jcN1VQVOy+LtsFqhdO3hQ=", "dev": true }, @@ -2717,9 +2736,9 @@ "dev": true }, "globals": { - "version": "11.7.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-11.7.0.tgz", - "integrity": "sha512-K8BNSPySfeShBQXsahYB/AbbWruVOTyVpgoIDnl8odPpeSfP2J5QO2oLFFdl2j7GfDCtZj2bMKar2T49itTPCg==", + "version": "11.8.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-11.8.0.tgz", + "integrity": "sha512-io6LkyPVuzCHBSQV9fmOwxZkUk6nIaGmxheLDgmuFv89j0fm2aqDbIXKAGfzCMHqz3HLF2Zf8WSG6VqMh2qFmA==", "dev": true }, "graceful-fs": { @@ -3241,9 +3260,9 @@ "dev": true }, "js-levenshtein": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/js-levenshtein/-/js-levenshtein-1.1.3.tgz", - "integrity": "sha512-/812MXr9RBtMObviZ8gQBhHO8MOrGj8HlEE+4ccMTElNA/6I3u39u+bhny55Lk921yn44nSZFy9naNLElL5wgQ==", + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/js-levenshtein/-/js-levenshtein-1.1.4.tgz", + "integrity": "sha512-PxfGzSs0ztShKrUYPIn5r0MtyAhYcCwmndozzpz8YObbPnD1jFxzlBGbRnX2mIu6Z13xN6+PTu05TQFnZFlzow==", "dev": true }, "js-tokens": { @@ -3282,7 +3301,7 @@ }, "json5": { "version": "0.5.1", - "resolved": "https://registry.npmjs.org/json5/-/json5-0.5.1.tgz", + "resolved": "http://registry.npmjs.org/json5/-/json5-0.5.1.tgz", "integrity": "sha1-Hq3nrMASA0rYTiOWdn6tn6VJWCE=", "dev": true }, @@ -3421,13 +3440,14 @@ } }, "md5.js": { - "version": "1.3.4", - "resolved": "https://registry.npmjs.org/md5.js/-/md5.js-1.3.4.tgz", - "integrity": "sha1-6b296UogpawYsENA/Fdk1bCdkB0=", + "version": "1.3.5", + "resolved": "https://registry.npmjs.org/md5.js/-/md5.js-1.3.5.tgz", + "integrity": "sha512-xitP+WxNPcTTOgnTJcrhM0xvdPepipPSf3I8EIpGKeFLjt3PlJLIDG3u8EX53ZIubkb+5U2+3rELYpEhHhzdkg==", "dev": true, "requires": { "hash-base": "3.0.4", - "inherits": "2.0.3" + "inherits": "2.0.3", + "safe-buffer": "5.1.2" } }, "mdn-data": { @@ -3677,9 +3697,9 @@ } }, "node-releases": { - "version": "1.0.0-alpha.11", - "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-1.0.0-alpha.11.tgz", - "integrity": "sha512-CaViu+2FqTNYOYNihXa5uPS/zry92I3vPU4nCB6JB3OeZ2UGtOpF5gRwuN4+m3hbEcL47bOXyun1jX2iC+3uEQ==", + "version": "1.0.0-alpha.12", + "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-1.0.0-alpha.12.tgz", + "integrity": "sha512-VPB4rTPqpVyWKBHbSa4YPFme3+8WHsOSpvbp0Mfj0bWsC8TEjt4HQrLl1hsBDELlp1nB4lflSgSuGTYiuyaP7Q==", "dev": true, "requires": { "semver": "5.5.1" @@ -3816,7 +3836,7 @@ "integrity": "sha512-Rqm6sSjWtx9FchdP0uzTQDc7GXDKnwVEGoSxjezPkzMewx7gEWE9IMUYKmigTRC4U3RaNSwYVnUDLuIdtTpm0A==", "dev": true, "requires": { - "cssnano": "4.1.1", + "cssnano": "4.1.4", "last-call-webpack-plugin": "3.0.0" } }, @@ -3906,7 +3926,7 @@ "browserify-aes": "1.2.0", "create-hash": "1.2.0", "evp_bytestokey": "1.0.3", - "pbkdf2": "3.0.16" + "pbkdf2": "3.0.17" } }, "parse-json": { @@ -3962,9 +3982,9 @@ "dev": true }, "pbkdf2": { - "version": "3.0.16", - "resolved": "https://registry.npmjs.org/pbkdf2/-/pbkdf2-3.0.16.tgz", - "integrity": "sha512-y4CXP3thSxqf7c0qmOF+9UeOTrifiVTIM+u7NWlq+PRsHbr7r7dpCmvzrZxa96JJUNi0Y5w9VqG5ZNeCVMoDcA==", + "version": "3.0.17", + "resolved": "https://registry.npmjs.org/pbkdf2/-/pbkdf2-3.0.17.tgz", + "integrity": "sha512-U/il5MsrZp7mGg3mSQfn742na2T+1/vHDCG5/iTI3X9MKUuYUZVLQhyRsg06mCgDBTd57TxzgZt7P+fYfjRLtA==", "dev": true, "requires": { "create-hash": "1.2.0", @@ -4015,15 +4035,34 @@ } }, "postcss-calc": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/postcss-calc/-/postcss-calc-6.0.1.tgz", - "integrity": "sha1-PSQXG79udinUIqQ26/5t2VEfQzA=", + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/postcss-calc/-/postcss-calc-6.0.2.tgz", + "integrity": "sha512-fiznXjEN5T42Qm7qqMCVJXS3roaj9r4xsSi+meaBVe7CJBl8t/QLOXu02Z2E6oWAMWIvCuF6JrvzFekmVEbOKA==", "dev": true, "requires": { "css-unit-converter": "1.1.1", - "postcss": "6.0.23", + "postcss": "7.0.5", "postcss-selector-parser": "2.2.3", "reduce-css-calc": "2.1.5" + }, + "dependencies": { + "postcss": { + "version": "7.0.5", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-7.0.5.tgz", + "integrity": "sha512-HBNpviAUFCKvEh7NZhw1e8MBPivRszIiUnhrJ+sBFVSYSqubrzwX3KG51mYgcRHX8j/cAgZJedONZcm5jTBdgQ==", + "dev": true, + "requires": { + "chalk": "2.4.1", + "source-map": "0.6.1", + "supports-color": "5.5.0" + } + }, + "source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true + } } }, "postcss-colormin": { @@ -4032,17 +4071,17 @@ "integrity": "sha512-1QJc2coIehnVFsz0otges8kQLsryi4lo19WD+U5xCWvXd0uw/Z+KKYnbiNDCnO9GP+PvErPHCG0jNvWTngk9Rw==", "dev": true, "requires": { - "browserslist": "4.1.1", + "browserslist": "4.2.0", "color": "3.0.0", "has": "1.0.3", - "postcss": "7.0.2", + "postcss": "7.0.5", "postcss-value-parser": "3.3.0" }, "dependencies": { "postcss": { - "version": "7.0.2", - "resolved": "https://registry.npmjs.org/postcss/-/postcss-7.0.2.tgz", - "integrity": "sha512-fmaUY5370keLUTx+CnwRxtGiuFTcNBLQBqr1oE3WZ/euIYmGAo0OAgOhVJ3ByDnVmOR3PK+0V9VebzfjRIUcqw==", + "version": "7.0.5", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-7.0.5.tgz", + "integrity": "sha512-HBNpviAUFCKvEh7NZhw1e8MBPivRszIiUnhrJ+sBFVSYSqubrzwX3KG51mYgcRHX8j/cAgZJedONZcm5jTBdgQ==", "dev": true, "requires": { "chalk": "2.4.1", @@ -4064,14 +4103,14 @@ "integrity": "sha512-Kisdo1y77KUC0Jmn0OXU/COOJbzM8cImvw1ZFsBgBgMgb1iL23Zs/LXRe3r+EZqM3vGYKdQ2YJVQ5VkJI+zEJQ==", "dev": true, "requires": { - "postcss": "7.0.2", + "postcss": "7.0.5", "postcss-value-parser": "3.3.0" }, "dependencies": { "postcss": { - "version": "7.0.2", - "resolved": "https://registry.npmjs.org/postcss/-/postcss-7.0.2.tgz", - "integrity": "sha512-fmaUY5370keLUTx+CnwRxtGiuFTcNBLQBqr1oE3WZ/euIYmGAo0OAgOhVJ3ByDnVmOR3PK+0V9VebzfjRIUcqw==", + "version": "7.0.5", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-7.0.5.tgz", + "integrity": "sha512-HBNpviAUFCKvEh7NZhw1e8MBPivRszIiUnhrJ+sBFVSYSqubrzwX3KG51mYgcRHX8j/cAgZJedONZcm5jTBdgQ==", "dev": true, "requires": { "chalk": "2.4.1", @@ -4093,13 +4132,13 @@ "integrity": "sha512-Ay+rZu1Sz6g8IdzRjUgG2NafSNpp2MSMOQUb+9kkzzzP+kh07fP0yNbhtFejURnyVXSX3FYy2nVNW1QTnNjgBQ==", "dev": true, "requires": { - "postcss": "7.0.2" + "postcss": "7.0.5" }, "dependencies": { "postcss": { - "version": "7.0.2", - "resolved": "https://registry.npmjs.org/postcss/-/postcss-7.0.2.tgz", - "integrity": "sha512-fmaUY5370keLUTx+CnwRxtGiuFTcNBLQBqr1oE3WZ/euIYmGAo0OAgOhVJ3ByDnVmOR3PK+0V9VebzfjRIUcqw==", + "version": "7.0.5", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-7.0.5.tgz", + "integrity": "sha512-HBNpviAUFCKvEh7NZhw1e8MBPivRszIiUnhrJ+sBFVSYSqubrzwX3KG51mYgcRHX8j/cAgZJedONZcm5jTBdgQ==", "dev": true, "requires": { "chalk": "2.4.1", @@ -4116,12 +4155,31 @@ } }, "postcss-discard-duplicates": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/postcss-discard-duplicates/-/postcss-discard-duplicates-4.0.1.tgz", - "integrity": "sha512-5LIsU0rWhKF5keAKCjPFuda76vjlO/2aZtdxW/NiJkPigf5J37ubLq4xQM/s24vzsePCEWH7/VveVd6fUAnwqA==", + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/postcss-discard-duplicates/-/postcss-discard-duplicates-4.0.2.tgz", + "integrity": "sha512-ZNQfR1gPNAiXZhgENFfEglF93pciw0WxMkJeVmw8eF+JZBbMD7jp6C67GqJAXVZP2BWbOztKfbsdmMp/k8c6oQ==", "dev": true, "requires": { - "postcss": "6.0.23" + "postcss": "7.0.5" + }, + "dependencies": { + "postcss": { + "version": "7.0.5", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-7.0.5.tgz", + "integrity": "sha512-HBNpviAUFCKvEh7NZhw1e8MBPivRszIiUnhrJ+sBFVSYSqubrzwX3KG51mYgcRHX8j/cAgZJedONZcm5jTBdgQ==", + "dev": true, + "requires": { + "chalk": "2.4.1", + "source-map": "0.6.1", + "supports-color": "5.5.0" + } + }, + "source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true + } } }, "postcss-discard-empty": { @@ -4130,13 +4188,13 @@ "integrity": "sha512-B9miTzbznhDjTfjvipfHoqbWKwd0Mj+/fL5s1QOz06wufguil+Xheo4XpOnc4NqKYBCNqqEzgPv2aPBIJLox0w==", "dev": true, "requires": { - "postcss": "7.0.2" + "postcss": "7.0.5" }, "dependencies": { "postcss": { - "version": "7.0.2", - "resolved": "https://registry.npmjs.org/postcss/-/postcss-7.0.2.tgz", - "integrity": "sha512-fmaUY5370keLUTx+CnwRxtGiuFTcNBLQBqr1oE3WZ/euIYmGAo0OAgOhVJ3ByDnVmOR3PK+0V9VebzfjRIUcqw==", + "version": "7.0.5", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-7.0.5.tgz", + "integrity": "sha512-HBNpviAUFCKvEh7NZhw1e8MBPivRszIiUnhrJ+sBFVSYSqubrzwX3KG51mYgcRHX8j/cAgZJedONZcm5jTBdgQ==", "dev": true, "requires": { "chalk": "2.4.1", @@ -4158,13 +4216,13 @@ "integrity": "sha512-IYY2bEDD7g1XM1IDEsUT4//iEYCxAmP5oDSFMVU/JVvT7gh+l4fmjciLqGgwjdWpQIdb0Che2VX00QObS5+cTg==", "dev": true, "requires": { - "postcss": "7.0.2" + "postcss": "7.0.5" }, "dependencies": { "postcss": { - "version": "7.0.2", - "resolved": "https://registry.npmjs.org/postcss/-/postcss-7.0.2.tgz", - "integrity": "sha512-fmaUY5370keLUTx+CnwRxtGiuFTcNBLQBqr1oE3WZ/euIYmGAo0OAgOhVJ3ByDnVmOR3PK+0V9VebzfjRIUcqw==", + "version": "7.0.5", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-7.0.5.tgz", + "integrity": "sha512-HBNpviAUFCKvEh7NZhw1e8MBPivRszIiUnhrJ+sBFVSYSqubrzwX3KG51mYgcRHX8j/cAgZJedONZcm5jTBdgQ==", "dev": true, "requires": { "chalk": "2.4.1", @@ -4187,15 +4245,15 @@ "dev": true, "requires": { "css-color-names": "0.0.4", - "postcss": "7.0.2", + "postcss": "7.0.5", "postcss-value-parser": "3.3.0", "stylehacks": "4.0.1" }, "dependencies": { "postcss": { - "version": "7.0.2", - "resolved": "https://registry.npmjs.org/postcss/-/postcss-7.0.2.tgz", - "integrity": "sha512-fmaUY5370keLUTx+CnwRxtGiuFTcNBLQBqr1oE3WZ/euIYmGAo0OAgOhVJ3ByDnVmOR3PK+0V9VebzfjRIUcqw==", + "version": "7.0.5", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-7.0.5.tgz", + "integrity": "sha512-HBNpviAUFCKvEh7NZhw1e8MBPivRszIiUnhrJ+sBFVSYSqubrzwX3KG51mYgcRHX8j/cAgZJedONZcm5jTBdgQ==", "dev": true, "requires": { "chalk": "2.4.1", @@ -4217,18 +4275,18 @@ "integrity": "sha512-UiuXwCCJtQy9tAIxsnurfF0mrNHKc4NnNx6NxqmzNNjXpQwLSukUxELHTRF0Rg1pAmcoKLih8PwvZbiordchag==", "dev": true, "requires": { - "browserslist": "4.1.1", + "browserslist": "4.2.0", "caniuse-api": "3.0.0", "cssnano-util-same-parent": "4.0.1", - "postcss": "7.0.2", + "postcss": "7.0.5", "postcss-selector-parser": "3.1.1", "vendors": "1.0.2" }, "dependencies": { "postcss": { - "version": "7.0.2", - "resolved": "https://registry.npmjs.org/postcss/-/postcss-7.0.2.tgz", - "integrity": "sha512-fmaUY5370keLUTx+CnwRxtGiuFTcNBLQBqr1oE3WZ/euIYmGAo0OAgOhVJ3ByDnVmOR3PK+0V9VebzfjRIUcqw==", + "version": "7.0.5", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-7.0.5.tgz", + "integrity": "sha512-HBNpviAUFCKvEh7NZhw1e8MBPivRszIiUnhrJ+sBFVSYSqubrzwX3KG51mYgcRHX8j/cAgZJedONZcm5jTBdgQ==", "dev": true, "requires": { "chalk": "2.4.1", @@ -4256,13 +4314,32 @@ } }, "postcss-minify-font-values": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/postcss-minify-font-values/-/postcss-minify-font-values-4.0.1.tgz", - "integrity": "sha512-qP/Nc+I0MheyiC41hYx5yFeRu1XGQdWjVC8Lfr2UE/PtnIdGgoyPOfVrVhGB+KnjhjS2NNyuYJRn4iBC9CpY3A==", + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/postcss-minify-font-values/-/postcss-minify-font-values-4.0.2.tgz", + "integrity": "sha512-j85oO6OnRU9zPf04+PZv1LYIYOprWm6IA6zkXkrJXyRveDEuQggG6tvoy8ir8ZwjLxLuGfNkCZEQG7zan+Hbtg==", "dev": true, "requires": { - "postcss": "6.0.23", + "postcss": "7.0.5", "postcss-value-parser": "3.3.0" + }, + "dependencies": { + "postcss": { + "version": "7.0.5", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-7.0.5.tgz", + "integrity": "sha512-HBNpviAUFCKvEh7NZhw1e8MBPivRszIiUnhrJ+sBFVSYSqubrzwX3KG51mYgcRHX8j/cAgZJedONZcm5jTBdgQ==", + "dev": true, + "requires": { + "chalk": "2.4.1", + "source-map": "0.6.1", + "supports-color": "5.5.0" + } + }, + "source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true + } } }, "postcss-minify-gradients": { @@ -4273,14 +4350,14 @@ "requires": { "cssnano-util-get-arguments": "4.0.0", "is-color-stop": "1.1.0", - "postcss": "7.0.2", + "postcss": "7.0.5", "postcss-value-parser": "3.3.0" }, "dependencies": { "postcss": { - "version": "7.0.2", - "resolved": "https://registry.npmjs.org/postcss/-/postcss-7.0.2.tgz", - "integrity": "sha512-fmaUY5370keLUTx+CnwRxtGiuFTcNBLQBqr1oE3WZ/euIYmGAo0OAgOhVJ3ByDnVmOR3PK+0V9VebzfjRIUcqw==", + "version": "7.0.5", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-7.0.5.tgz", + "integrity": "sha512-HBNpviAUFCKvEh7NZhw1e8MBPivRszIiUnhrJ+sBFVSYSqubrzwX3KG51mYgcRHX8j/cAgZJedONZcm5jTBdgQ==", "dev": true, "requires": { "chalk": "2.4.1", @@ -4303,17 +4380,17 @@ "dev": true, "requires": { "alphanum-sort": "1.0.2", - "browserslist": "4.1.1", + "browserslist": "4.2.0", "cssnano-util-get-arguments": "4.0.0", - "postcss": "7.0.2", + "postcss": "7.0.5", "postcss-value-parser": "3.3.0", "uniqs": "2.0.0" }, "dependencies": { "postcss": { - "version": "7.0.2", - "resolved": "https://registry.npmjs.org/postcss/-/postcss-7.0.2.tgz", - "integrity": "sha512-fmaUY5370keLUTx+CnwRxtGiuFTcNBLQBqr1oE3WZ/euIYmGAo0OAgOhVJ3ByDnVmOR3PK+0V9VebzfjRIUcqw==", + "version": "7.0.5", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-7.0.5.tgz", + "integrity": "sha512-HBNpviAUFCKvEh7NZhw1e8MBPivRszIiUnhrJ+sBFVSYSqubrzwX3KG51mYgcRHX8j/cAgZJedONZcm5jTBdgQ==", "dev": true, "requires": { "chalk": "2.4.1", @@ -4337,14 +4414,14 @@ "requires": { "alphanum-sort": "1.0.2", "has": "1.0.3", - "postcss": "7.0.2", + "postcss": "7.0.5", "postcss-selector-parser": "3.1.1" }, "dependencies": { "postcss": { - "version": "7.0.2", - "resolved": "https://registry.npmjs.org/postcss/-/postcss-7.0.2.tgz", - "integrity": "sha512-fmaUY5370keLUTx+CnwRxtGiuFTcNBLQBqr1oE3WZ/euIYmGAo0OAgOhVJ3ByDnVmOR3PK+0V9VebzfjRIUcqw==", + "version": "7.0.5", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-7.0.5.tgz", + "integrity": "sha512-HBNpviAUFCKvEh7NZhw1e8MBPivRszIiUnhrJ+sBFVSYSqubrzwX3KG51mYgcRHX8j/cAgZJedONZcm5jTBdgQ==", "dev": true, "requires": { "chalk": "2.4.1", @@ -4411,12 +4488,31 @@ } }, "postcss-normalize-charset": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/postcss-normalize-charset/-/postcss-normalize-charset-4.0.0.tgz", - "integrity": "sha1-JFJyknAtXoEp6vo9HeSe1RpqtzA=", + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/postcss-normalize-charset/-/postcss-normalize-charset-4.0.1.tgz", + "integrity": "sha512-gMXCrrlWh6G27U0hF3vNvR3w8I1s2wOBILvA87iNXaPvSNo5uZAMYsZG7XjCUf1eVxuPfyL4TJ7++SGZLc9A3g==", "dev": true, "requires": { - "postcss": "6.0.23" + "postcss": "7.0.5" + }, + "dependencies": { + "postcss": { + "version": "7.0.5", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-7.0.5.tgz", + "integrity": "sha512-HBNpviAUFCKvEh7NZhw1e8MBPivRszIiUnhrJ+sBFVSYSqubrzwX3KG51mYgcRHX8j/cAgZJedONZcm5jTBdgQ==", + "dev": true, + "requires": { + "chalk": "2.4.1", + "source-map": "0.6.1", + "supports-color": "5.5.0" + } + }, + "source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true + } } }, "postcss-normalize-display-values": { @@ -4426,14 +4522,14 @@ "dev": true, "requires": { "cssnano-util-get-match": "4.0.0", - "postcss": "7.0.2", + "postcss": "7.0.5", "postcss-value-parser": "3.3.0" }, "dependencies": { "postcss": { - "version": "7.0.2", - "resolved": "https://registry.npmjs.org/postcss/-/postcss-7.0.2.tgz", - "integrity": "sha512-fmaUY5370keLUTx+CnwRxtGiuFTcNBLQBqr1oE3WZ/euIYmGAo0OAgOhVJ3ByDnVmOR3PK+0V9VebzfjRIUcqw==", + "version": "7.0.5", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-7.0.5.tgz", + "integrity": "sha512-HBNpviAUFCKvEh7NZhw1e8MBPivRszIiUnhrJ+sBFVSYSqubrzwX3KG51mYgcRHX8j/cAgZJedONZcm5jTBdgQ==", "dev": true, "requires": { "chalk": "2.4.1", @@ -4457,14 +4553,14 @@ "requires": { "cssnano-util-get-arguments": "4.0.0", "has": "1.0.3", - "postcss": "7.0.2", + "postcss": "7.0.5", "postcss-value-parser": "3.3.0" }, "dependencies": { "postcss": { - "version": "7.0.2", - "resolved": "https://registry.npmjs.org/postcss/-/postcss-7.0.2.tgz", - "integrity": "sha512-fmaUY5370keLUTx+CnwRxtGiuFTcNBLQBqr1oE3WZ/euIYmGAo0OAgOhVJ3ByDnVmOR3PK+0V9VebzfjRIUcqw==", + "version": "7.0.5", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-7.0.5.tgz", + "integrity": "sha512-HBNpviAUFCKvEh7NZhw1e8MBPivRszIiUnhrJ+sBFVSYSqubrzwX3KG51mYgcRHX8j/cAgZJedONZcm5jTBdgQ==", "dev": true, "requires": { "chalk": "2.4.1", @@ -4488,14 +4584,14 @@ "requires": { "cssnano-util-get-arguments": "4.0.0", "cssnano-util-get-match": "4.0.0", - "postcss": "7.0.2", + "postcss": "7.0.5", "postcss-value-parser": "3.3.0" }, "dependencies": { "postcss": { - "version": "7.0.2", - "resolved": "https://registry.npmjs.org/postcss/-/postcss-7.0.2.tgz", - "integrity": "sha512-fmaUY5370keLUTx+CnwRxtGiuFTcNBLQBqr1oE3WZ/euIYmGAo0OAgOhVJ3ByDnVmOR3PK+0V9VebzfjRIUcqw==", + "version": "7.0.5", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-7.0.5.tgz", + "integrity": "sha512-HBNpviAUFCKvEh7NZhw1e8MBPivRszIiUnhrJ+sBFVSYSqubrzwX3KG51mYgcRHX8j/cAgZJedONZcm5jTBdgQ==", "dev": true, "requires": { "chalk": "2.4.1", @@ -4518,14 +4614,14 @@ "dev": true, "requires": { "has": "1.0.3", - "postcss": "7.0.2", + "postcss": "7.0.5", "postcss-value-parser": "3.3.0" }, "dependencies": { "postcss": { - "version": "7.0.2", - "resolved": "https://registry.npmjs.org/postcss/-/postcss-7.0.2.tgz", - "integrity": "sha512-fmaUY5370keLUTx+CnwRxtGiuFTcNBLQBqr1oE3WZ/euIYmGAo0OAgOhVJ3ByDnVmOR3PK+0V9VebzfjRIUcqw==", + "version": "7.0.5", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-7.0.5.tgz", + "integrity": "sha512-HBNpviAUFCKvEh7NZhw1e8MBPivRszIiUnhrJ+sBFVSYSqubrzwX3KG51mYgcRHX8j/cAgZJedONZcm5jTBdgQ==", "dev": true, "requires": { "chalk": "2.4.1", @@ -4548,14 +4644,14 @@ "dev": true, "requires": { "cssnano-util-get-match": "4.0.0", - "postcss": "7.0.2", + "postcss": "7.0.5", "postcss-value-parser": "3.3.0" }, "dependencies": { "postcss": { - "version": "7.0.2", - "resolved": "https://registry.npmjs.org/postcss/-/postcss-7.0.2.tgz", - "integrity": "sha512-fmaUY5370keLUTx+CnwRxtGiuFTcNBLQBqr1oE3WZ/euIYmGAo0OAgOhVJ3ByDnVmOR3PK+0V9VebzfjRIUcqw==", + "version": "7.0.5", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-7.0.5.tgz", + "integrity": "sha512-HBNpviAUFCKvEh7NZhw1e8MBPivRszIiUnhrJ+sBFVSYSqubrzwX3KG51mYgcRHX8j/cAgZJedONZcm5jTBdgQ==", "dev": true, "requires": { "chalk": "2.4.1", @@ -4577,15 +4673,15 @@ "integrity": "sha512-od18Uq2wCYn+vZ/qCOeutvHjB5jm57ToxRaMeNuf0nWVHaP9Hua56QyMF6fs/4FSUnVIw0CBPsU0K4LnBPwYwg==", "dev": true, "requires": { - "browserslist": "4.1.1", - "postcss": "7.0.2", + "browserslist": "4.2.0", + "postcss": "7.0.5", "postcss-value-parser": "3.3.0" }, "dependencies": { "postcss": { - "version": "7.0.2", - "resolved": "https://registry.npmjs.org/postcss/-/postcss-7.0.2.tgz", - "integrity": "sha512-fmaUY5370keLUTx+CnwRxtGiuFTcNBLQBqr1oE3WZ/euIYmGAo0OAgOhVJ3ByDnVmOR3PK+0V9VebzfjRIUcqw==", + "version": "7.0.5", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-7.0.5.tgz", + "integrity": "sha512-HBNpviAUFCKvEh7NZhw1e8MBPivRszIiUnhrJ+sBFVSYSqubrzwX3KG51mYgcRHX8j/cAgZJedONZcm5jTBdgQ==", "dev": true, "requires": { "chalk": "2.4.1", @@ -4609,14 +4705,14 @@ "requires": { "is-absolute-url": "2.1.0", "normalize-url": "3.3.0", - "postcss": "7.0.2", + "postcss": "7.0.5", "postcss-value-parser": "3.3.0" }, "dependencies": { "postcss": { - "version": "7.0.2", - "resolved": "https://registry.npmjs.org/postcss/-/postcss-7.0.2.tgz", - "integrity": "sha512-fmaUY5370keLUTx+CnwRxtGiuFTcNBLQBqr1oE3WZ/euIYmGAo0OAgOhVJ3ByDnVmOR3PK+0V9VebzfjRIUcqw==", + "version": "7.0.5", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-7.0.5.tgz", + "integrity": "sha512-HBNpviAUFCKvEh7NZhw1e8MBPivRszIiUnhrJ+sBFVSYSqubrzwX3KG51mYgcRHX8j/cAgZJedONZcm5jTBdgQ==", "dev": true, "requires": { "chalk": "2.4.1", @@ -4638,14 +4734,14 @@ "integrity": "sha512-U8MBODMB2L+nStzOk6VvWWjZgi5kQNShCyjRhMT3s+W9Jw93yIjOnrEkKYD3Ul7ChWbEcjDWmXq0qOL9MIAnAw==", "dev": true, "requires": { - "postcss": "7.0.2", + "postcss": "7.0.5", "postcss-value-parser": "3.3.0" }, "dependencies": { "postcss": { - "version": "7.0.2", - "resolved": "https://registry.npmjs.org/postcss/-/postcss-7.0.2.tgz", - "integrity": "sha512-fmaUY5370keLUTx+CnwRxtGiuFTcNBLQBqr1oE3WZ/euIYmGAo0OAgOhVJ3ByDnVmOR3PK+0V9VebzfjRIUcqw==", + "version": "7.0.5", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-7.0.5.tgz", + "integrity": "sha512-HBNpviAUFCKvEh7NZhw1e8MBPivRszIiUnhrJ+sBFVSYSqubrzwX3KG51mYgcRHX8j/cAgZJedONZcm5jTBdgQ==", "dev": true, "requires": { "chalk": "2.4.1", @@ -4668,14 +4764,14 @@ "dev": true, "requires": { "cssnano-util-get-arguments": "4.0.0", - "postcss": "7.0.2", + "postcss": "7.0.5", "postcss-value-parser": "3.3.0" }, "dependencies": { "postcss": { - "version": "7.0.2", - "resolved": "https://registry.npmjs.org/postcss/-/postcss-7.0.2.tgz", - "integrity": "sha512-fmaUY5370keLUTx+CnwRxtGiuFTcNBLQBqr1oE3WZ/euIYmGAo0OAgOhVJ3ByDnVmOR3PK+0V9VebzfjRIUcqw==", + "version": "7.0.5", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-7.0.5.tgz", + "integrity": "sha512-HBNpviAUFCKvEh7NZhw1e8MBPivRszIiUnhrJ+sBFVSYSqubrzwX3KG51mYgcRHX8j/cAgZJedONZcm5jTBdgQ==", "dev": true, "requires": { "chalk": "2.4.1", @@ -4697,16 +4793,16 @@ "integrity": "sha512-epUiC39NonKUKG+P3eAOKKZtm5OtAtQJL7Ye0CBN1f+UQTHzqotudp+hki7zxXm7tT0ZAKDMBj1uihpPjP25ug==", "dev": true, "requires": { - "browserslist": "4.1.1", + "browserslist": "4.2.0", "caniuse-api": "3.0.0", "has": "1.0.3", - "postcss": "7.0.2" + "postcss": "7.0.5" }, "dependencies": { "postcss": { - "version": "7.0.2", - "resolved": "https://registry.npmjs.org/postcss/-/postcss-7.0.2.tgz", - "integrity": "sha512-fmaUY5370keLUTx+CnwRxtGiuFTcNBLQBqr1oE3WZ/euIYmGAo0OAgOhVJ3ByDnVmOR3PK+0V9VebzfjRIUcqw==", + "version": "7.0.5", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-7.0.5.tgz", + "integrity": "sha512-HBNpviAUFCKvEh7NZhw1e8MBPivRszIiUnhrJ+sBFVSYSqubrzwX3KG51mYgcRHX8j/cAgZJedONZcm5jTBdgQ==", "dev": true, "requires": { "chalk": "2.4.1", @@ -4730,14 +4826,14 @@ "requires": { "cssnano-util-get-match": "4.0.0", "has": "1.0.3", - "postcss": "7.0.2", + "postcss": "7.0.5", "postcss-value-parser": "3.3.0" }, "dependencies": { "postcss": { - "version": "7.0.2", - "resolved": "https://registry.npmjs.org/postcss/-/postcss-7.0.2.tgz", - "integrity": "sha512-fmaUY5370keLUTx+CnwRxtGiuFTcNBLQBqr1oE3WZ/euIYmGAo0OAgOhVJ3ByDnVmOR3PK+0V9VebzfjRIUcqw==", + "version": "7.0.5", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-7.0.5.tgz", + "integrity": "sha512-HBNpviAUFCKvEh7NZhw1e8MBPivRszIiUnhrJ+sBFVSYSqubrzwX3KG51mYgcRHX8j/cAgZJedONZcm5jTBdgQ==", "dev": true, "requires": { "chalk": "2.4.1", @@ -4765,15 +4861,34 @@ } }, "postcss-svgo": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/postcss-svgo/-/postcss-svgo-4.0.0.tgz", - "integrity": "sha1-wLutAlIPxjbJ14sOhAPi5RXDIoU=", + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/postcss-svgo/-/postcss-svgo-4.0.1.tgz", + "integrity": "sha512-YD5uIk5NDRySy0hcI+ZJHwqemv2WiqqzDgtvgMzO8EGSkK5aONyX8HMVFRFJSdO8wUWTuisUFn/d7yRRbBr5Qw==", "dev": true, "requires": { "is-svg": "3.0.0", - "postcss": "6.0.23", + "postcss": "7.0.5", "postcss-value-parser": "3.3.0", "svgo": "1.1.1" + }, + "dependencies": { + "postcss": { + "version": "7.0.5", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-7.0.5.tgz", + "integrity": "sha512-HBNpviAUFCKvEh7NZhw1e8MBPivRszIiUnhrJ+sBFVSYSqubrzwX3KG51mYgcRHX8j/cAgZJedONZcm5jTBdgQ==", + "dev": true, + "requires": { + "chalk": "2.4.1", + "source-map": "0.6.1", + "supports-color": "5.5.0" + } + }, + "source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true + } } }, "postcss-unique-selectors": { @@ -4783,14 +4898,14 @@ "dev": true, "requires": { "alphanum-sort": "1.0.2", - "postcss": "7.0.2", + "postcss": "7.0.5", "uniqs": "2.0.0" }, "dependencies": { "postcss": { - "version": "7.0.2", - "resolved": "https://registry.npmjs.org/postcss/-/postcss-7.0.2.tgz", - "integrity": "sha512-fmaUY5370keLUTx+CnwRxtGiuFTcNBLQBqr1oE3WZ/euIYmGAo0OAgOhVJ3ByDnVmOR3PK+0V9VebzfjRIUcqw==", + "version": "7.0.5", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-7.0.5.tgz", + "integrity": "sha512-HBNpviAUFCKvEh7NZhw1e8MBPivRszIiUnhrJ+sBFVSYSqubrzwX3KG51mYgcRHX8j/cAgZJedONZcm5jTBdgQ==", "dev": true, "requires": { "chalk": "2.4.1", @@ -4849,16 +4964,17 @@ "dev": true }, "public-encrypt": { - "version": "4.0.2", - "resolved": "http://registry.npmjs.org/public-encrypt/-/public-encrypt-4.0.2.tgz", - "integrity": "sha512-4kJ5Esocg8X3h8YgJsKAuoesBgB7mqH3eowiDzMUPKiRDDE7E/BqqZD1hnTByIaAFiwAw246YEltSq7tdrOH0Q==", + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/public-encrypt/-/public-encrypt-4.0.3.tgz", + "integrity": "sha512-zVpa8oKZSz5bTMTFClc1fQOnyyEzpl5ozpi1B5YcvBrdohMjH2rfsBtyXcuNuwjsDIXmBYlF2N5FlJYhR29t8Q==", "dev": true, "requires": { "bn.js": "4.11.8", "browserify-rsa": "4.0.1", "create-hash": "1.2.0", "parse-asn1": "5.1.1", - "randombytes": "2.0.6" + "randombytes": "2.0.6", + "safe-buffer": "5.1.2" } }, "pump": { @@ -5546,7 +5662,7 @@ }, "strip-ansi": { "version": "3.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "resolved": "http://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", "dev": true, "requires": { @@ -5587,15 +5703,15 @@ "integrity": "sha512-TK5zEPeD9NyC1uPIdjikzsgWxdQQN/ry1X3d1iOz1UkYDCmcr928gWD1KHgyC27F50UnE0xCTrBOO1l6KR8M4w==", "dev": true, "requires": { - "browserslist": "4.1.1", - "postcss": "7.0.2", + "browserslist": "4.2.0", + "postcss": "7.0.5", "postcss-selector-parser": "3.1.1" }, "dependencies": { "postcss": { - "version": "7.0.2", - "resolved": "https://registry.npmjs.org/postcss/-/postcss-7.0.2.tgz", - "integrity": "sha512-fmaUY5370keLUTx+CnwRxtGiuFTcNBLQBqr1oE3WZ/euIYmGAo0OAgOhVJ3ByDnVmOR3PK+0V9VebzfjRIUcqw==", + "version": "7.0.5", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-7.0.5.tgz", + "integrity": "sha512-HBNpviAUFCKvEh7NZhw1e8MBPivRszIiUnhrJ+sBFVSYSqubrzwX3KG51mYgcRHX8j/cAgZJedONZcm5jTBdgQ==", "dev": true, "requires": { "chalk": "2.4.1", @@ -6067,9 +6183,9 @@ } }, "webpack": { - "version": "4.20.0", - "resolved": "https://registry.npmjs.org/webpack/-/webpack-4.20.0.tgz", - "integrity": "sha512-QxF4RSMcZSDLdHtCUgQO7t/qHVZtcYdHMGVB+dkyMAVXHgcwg3A2X95mMXDWli44QoCsKJVXx6b/nBx9PNdjXg==", + "version": "4.20.2", + "resolved": "https://registry.npmjs.org/webpack/-/webpack-4.20.2.tgz", + "integrity": "sha512-75WFUMblcWYcocjSLlXCb71QuGyH7egdBZu50FtBGl2Nso8CK3Ej+J7bTZz2FPFq5l6fzCisD9modB7t30ikuA==", "dev": true, "requires": { "@webassemblyjs/ast": "1.7.8", @@ -6111,9 +6227,9 @@ } }, "webpack-cli": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/webpack-cli/-/webpack-cli-3.1.1.tgz", - "integrity": "sha512-th5EUyVeGcAAVlFOcJg11fapD/xoLRE4j/eSfrmMAo3olPjvB7lgEPUtCbRP0OGmstvnQBl4VZP+zluXWDiBxg==", + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/webpack-cli/-/webpack-cli-3.1.2.tgz", + "integrity": "sha512-Cnqo7CeqeSvC6PTdts+dywNi5CRlIPbLx1AoUPK2T6vC1YAugMG3IOoO9DmEscd+Dghw7uRlnzV1KwOe5IrtgQ==", "dev": true, "requires": { "chalk": "2.4.1", diff --git a/tinymce/plugin.js b/tinymce/plugin.js index d4235da..3c513d9 100644 --- a/tinymce/plugin.js +++ b/tinymce/plugin.js @@ -154,7 +154,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) * /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"default\", function() { return ContentManager; });\n/* harmony import */ var _configuration_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./configuration.js */ \"./core/src/configuration.js\");\n/* harmony import */ var _editorlistener_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./editorlistener.js */ \"./core/src/editorlistener.js\");\n/* harmony import */ var _listeners_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./listeners.js */ \"./core/src/listeners.js\");\n/* harmony import */ var _mathml_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./mathml.js */ \"./core/src/mathml.js\");\n/* harmony import */ var _util_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./util.js */ \"./core/src/util.js\");\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\n\n\n\n\n\n/**\r\n * This class represents the content of a ModalDialog class managing the following:\r\n * - Insertion in the ModalDialog.\r\n * - Actions to be done once the modal object has been submitted (submitAction() method).\r\n * - Updates itself when ModalDialog is updated, for example when ModalDialog\r\n * is re-opened (update(modalObject) method).\r\n * - Communicates ModalDialog if some changes have be done (hasChanges() method).\r\n */\n\nvar ContentManager =\n/*#__PURE__*/\nfunction () {\n /**\r\n * Class constructor\r\n * @param {Object} contentManagerAttributes - Object containing all attributes needed to\r\n * create a new instance of ContentManager class.\r\n * @param {Object} contentManagerAttributes.editorAttributes - Object containing MathType editor parameters.\r\n */\n function ContentManager(contentManagerAttributes) {\n _classCallCheck(this, ContentManager);\n\n /**\r\n * An object containing MathType editor parameters. See\r\n * http://docs.wiris.com/en/mathtype/mathtype_web/sdk-api/parameters for further information.\r\n * @type {Object}\r\n */\n this.contentManagerAttributes = {};\n\n if ('editorAttributes' in contentManagerAttributes) {\n this.editorAttributes = contentManagerAttributes.editorAttributes;\n } else {\n throw new Error('ContentManager constructor error: editorAttributes property missed.');\n }\n /**\r\n * CustomEditors instance. Contains the custom editors.\r\n * @type {CustomEditors}\r\n */\n\n\n this.customEditors = null;\n\n if ('customEditors' in contentManagerAttributes) {\n this.customEditors = contentManagerAttributes.customEditors;\n }\n /**\r\n * Environment properties. This object contains data about the integration platform.\r\n * @type {Object}\r\n * @property {string} editor - Editor name. Usually the HTML editor.\r\n * @property {string} mode - Save mode. Xml by default\r\n * @property {string} version - Plugin version.\r\n */\n\n\n this.environment = {};\n\n if ('environment' in contentManagerAttributes) {\n this.environment = contentManagerAttributes.environment;\n } else {\n throw new Error('ContentManager constructor error: environment property missed');\n }\n /**\r\n * ContentManager language.\r\n * @type {string}\r\n */\n\n\n this.language = '';\n\n if ('language' in contentManagerAttributes) {\n this.language = contentManagerAttributes.language;\n } else {\n throw new Error('ContentManager constructor error: language property missed');\n }\n /**\r\n * Editor listener. Needed to get control about editor changes.\r\n * @type {EditorListener}\r\n */\n\n\n this.editorListener = new _editorlistener_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"]();\n /**\r\n * MathType editor instance.\r\n * @type {JsEditor}\r\n */\n\n this.editor = null;\n /**\r\n * Navigator user agent.\r\n * @type {string}\r\n */\n\n this.ua = navigator.userAgent.toLowerCase();\n /**\r\n * Mobile device properties object\r\n * @type {Object}\r\n * @property {boolean} isAndroid - True if the device is android. False otherwise.\r\n * @property {boolean} isIOS - True if the device is iOS. False otherwise.\r\n */\n\n this.deviceProperties = {};\n this.deviceProperties.isAndroid = this.ua.indexOf(\"android\") > -1;\n this.deviceProperties.isIOS = this.ua.indexOf(\"ipad\") > -1 || this.ua.indexOf(\"iphone\") > -1;\n /**\r\n * Custom editor toolbar.\r\n * @type {string} toolbar\r\n */\n\n this.toolbar = null;\n /**\r\n * Instance of the ModalDialog class associated to the ContentManager instance.\r\n * @type {ModalDialog}\r\n */\n\n this.modalDialogInstance = null;\n /**\r\n * ContentManager listeners.\r\n * @type {Listeners}\r\n */\n\n this.listeners = new _listeners_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"]();\n /**\r\n * MathML associated to the ContentManager instance.\r\n * @type {string}\r\n */\n\n this.mathML = null;\n /**\r\n * Indicates if the edited element is a new element or not.\r\n * @type {boolean}\r\n */\n\n this.isNewElement = true;\n /**\r\n * IntegrationModel instance. Needed to call wrapper methods.\r\n * @type {IntegrationModel}\r\n */\n\n this.integrationModel = null;\n /**\r\n * Indicates if the editor is loaded.\r\n * @type {boolean}\r\n */\n\n this.isEditorLoaded = false;\n }\n /**\r\n * Add a new listener to ContentManager class.\r\n * @param {Object} listener - listener to be added.\r\n */\n\n\n _createClass(ContentManager, [{\n key: \"addListener\",\n value: function addListener(listener) {\n this.listeners.add(listener);\n }\n /**\r\n * Sets an instance of an IntegrationModel\r\n * @param {IntegrationModel} integrationModel\r\n */\n\n }, {\n key: \"setIntegrationModel\",\n value: function setIntegrationModel(integrationModel) {\n this.integrationModel = integrationModel;\n }\n /**\r\n * Sets a modal dialog instance.\r\n * @param {ModalDialog} - a ModalDialog instance\r\n */\n\n }, {\n key: \"setModalDialogInstance\",\n value: function setModalDialogInstance(modalDialogInstance) {\n this.modalDialogInstance = modalDialogInstance;\n }\n /**\r\n * Mandatory method. Inserts editor into modal object content container.\r\n */\n\n }, {\n key: \"insert\",\n value: function insert() {\n // Before insert the editor we update the modal object title to avoid weird render display.\n this.updateTitle(this.modalDialogInstance);\n this.insertEditor(this.modalDialogInstance);\n }\n /**\r\n * Method to insert MathType into modal object. This method\r\n * waits until editor JavaScript is loaded to insert the editor into\r\n * contentContainer modal object element.\r\n */\n\n }, {\n key: \"insertEditor\",\n value: function insertEditor() {\n // To know if editor JavaScript is loaded we need to wait until com.wiris.jsEditor namespace is ready.\n if ('com' in window && 'wiris' in window.com && 'jsEditor' in window.com.wiris) {\n this.editor = com.wiris.jsEditor.JsEditor.newInstance(this.editorAttributes);\n this.editor.insertInto(this.modalDialogInstance.contentContainer);\n this.editor.focus();\n\n if (this.modalDialogInstance.rtl) {\n this.editor.action('rtl');\n } // Setting div in rtl in case of it's activated.\n\n\n if (this.editor.getEditorModel().isRTL()) {\n this.editor.element.style.direction = 'rtl';\n } // Editor listener: this object manages the changes logic of editor.\n\n\n this.editor.getEditorModel().addEditorListener(this.editorListener); // iOS events.\n\n if (this.modalDialogInstance.deviceProperties['isIOS']) {\n setTimeout(function () {\n this.modalDialogInstance.hideKeyboard();\n }, 400);\n var formulaDisplayDiv = document.getElementsByClassName('wrs_formulaDisplay')[0];\n _util_js__WEBPACK_IMPORTED_MODULE_4__[\"default\"].addEvent(formulaDisplayDiv, 'focus', this.modalDialogInstance.openedIosSoftkeyboard.bind());\n _util_js__WEBPACK_IMPORTED_MODULE_4__[\"default\"].addEvent(formulaDisplayDiv, 'blur', this.modalDialogInstance.closedIosSoftkeyboard.bind());\n } // Fire onLoad event. Necessary to set the MathML into the editor\n // after is loaded.\n\n\n this.listeners.fire('onLoad', {});\n this.isEditorLoaded = true;\n } else {\n setTimeout(ContentManager.prototype.insertEditor.bind(this, this.modalDialogInstance), 100);\n }\n }\n /**\r\n * Loads MathType script.\r\n */\n\n }, {\n key: \"init\",\n value: function init() {\n var queryParams = window.location.search.substring(1).split(\"&\");\n\n for (var i = 0; i < queryParams.length; i++) {\n var pos = queryParams[i].indexOf(\"v=\");\n\n if (pos >= 0) {\n version = queryParams[i].substring(2);\n }\n }\n\n var script = document.createElement('script');\n script.type = 'text/javascript';\n var editorUrl = _configuration_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get('editorUrl'); // We create an object url for parse url string and work more efficiently.\n\n var urlObject = document.createElement('a');\n urlObject.href = editorUrl; // Change to https if necessary.\n\n if (window.location.href.indexOf(\"https://\") == 0) {\n // It check if browser is https and configuration is http. If this is so, we will replace protocol.\n if (urlObject.protocol == 'http:') {\n urlObject.protocol = 'https:';\n }\n } // Check protocol and remove port if it's standard.\n\n\n if (urlObject.port == '80' || urlObject.port == '443') {\n editorUrl = urlObject.protocol + '//' + urlObject.hostname + '/' + urlObject.pathname;\n } else {\n editorUrl = urlObject.protocol + '//' + urlObject.hostname + ':' + urlObject.port + '/' + urlObject.pathname;\n } // Editor stats. Use environment property to set it.\n\n\n var stats = {};\n\n if ('editor' in this.environment) {\n stats.editor = this.environment.editor;\n } else {\n stats.editor = 'unknown';\n }\n\n if ('mode' in this.environment) {\n stats.mode = this.environment.mode;\n } else {\n stats.mode = _configuration_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get('saveMode');\n }\n\n if ('version' in this.environment) {\n stats.version = this.environment.version;\n } else {\n stats.version = _configuration_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get('version');\n } // Load editor URL. We add stats as GET params.\n\n\n script.src = editorUrl + \"?lang=\" + this.language + '&stats-editor=' + stats.editor + '&stats-mode=' + stats.mode + '&stats-version=' + stats.version;\n document.getElementsByTagName('head')[0].appendChild(script);\n }\n /**\r\n * Set the editor initial content: an existing formula or a blank MathML\r\n */\n\n }, {\n key: \"setInitialContent\",\n value: function setInitialContent() {\n if (!this.isNewElement) {\n this.setMathML(this.mathML);\n }\n }\n /**\r\n * Set a MathML into editor.\r\n * @param {string} mathml - MathML string.\r\n * @param {bool} focusDisabled - if true editor don't get focus after the MathML is set. false by default.\r\n */\n\n }, {\n key: \"setMathML\",\n value: function setMathML(mathml, focusDisabled) {\n // By default focus is enabled\n if (typeof focusDisabled === 'undefined') {\n focusDisabled = false;\n } // Using setMathML method is not a change produced by the user but for the API\n // so we set to false the contentChange property of editorListener.\n\n\n this.editor.setMathMLWithCallback(mathml, function () {\n this.editorListener.setWaitingForChanges(true);\n }.bind(this)); // We need to wait a little until the callback finish.\n\n setTimeout(function () {\n this.editorListener.setIsContentChanged(false);\n }.bind(this), 500); // In some scenarios - like closing modal object - editor mustn't be focused.\n\n if (!focusDisabled) {\n this.onFocus();\n }\n }\n /**\r\n * Set focus on editor.\r\n */\n\n }, {\n key: \"onFocus\",\n value: function onFocus() {\n if (typeof this.editor !== 'undefined' && this.editor != null) {\n this.editor.focus();\n }\n }\n /**\r\n * Mandatory method: modal object calls this method to execute a callback action\r\n * on submit.\r\n * This method updates the edition area (inserting a new formula or update an older one),\r\n * and focus the edition area too.\r\n */\n\n }, {\n key: \"submitAction\",\n value: function submitAction() {\n var mathML = this.editor.getMathML(); // Add class for custom editors.\n\n if (this.customEditors.getActiveEditor() != null) {\n mathML = _mathml_js__WEBPACK_IMPORTED_MODULE_3__[\"default\"].addCustomEditorClassAttribute(mathML, this.customEditors.getActiveEditor().toolbar);\n } else {\n // We need - if exists - the editor name from MathML\n // class attribute.\n for (var key in this.customEditors.editors) {\n mathML = _mathml_js__WEBPACK_IMPORTED_MODULE_3__[\"default\"].removeCustomEditorClassAttribute(mathML, key);\n }\n }\n\n var mathmlEntitiesEncoded = _mathml_js__WEBPACK_IMPORTED_MODULE_3__[\"default\"].mathMLEntities(mathML);\n this.integrationModel.updateFormula(mathmlEntitiesEncoded);\n this.customEditors.disable();\n this.integrationModel.notifyWindowClosed(); // Set disabled focus to prevent lost focus.\n\n this.setEmptyMathML();\n this.customEditors.disable(); // Recovering editing area focus.\n\n setTimeout(function () {\n if (typeof _wrs_currentEditor !== 'undefined' && _wrs_currentEditor) {\n _wrs_currentEditor.focus();\n }\n }, 100);\n }\n /**\r\n * Set an empty MathML into the editor in order to clean the edit area.\r\n */\n\n }, {\n key: \"setEmptyMathML\",\n value: function setEmptyMathML() {\n // As second argument we pass\n if (this.deviceProperties.isAndroid || this.deviceProperties.isIOS) {\n // We need to set a empty annotation in order to maintain editor in Hand mode.\n // Adding dir rtl in case of it's activated.\n if (this.editor.getEditorModel().isRTL()) {\n this.setMathML('[]\"', true);\n } else {\n this.setMathML('[]\"', true);\n }\n } else {\n if (this.editor.getEditorModel().isRTL()) {\n this.setMathML('', true);\n } else {\n this.setMathML('', true);\n }\n }\n }\n /**\r\n * Mandatory method: modal object calls this method when is updated, for example re-editing a formula when the\r\n * editor is open with another formula. This method updates the editor content (with an empty MathML or an existing formula),\r\n * updates - if needed - the editor toolbar (math --> chem or chem --> math) and recover the focus.\r\n */\n\n }, {\n key: \"onOpen\",\n value: function onOpen() {\n if (this.isNewElement) {\n this.setEmptyMathML();\n } else {\n this.setMathML(this.mathML);\n }\n\n this.updateToolbar();\n this.onFocus();\n }\n /**\r\n * Sets the correct toolbar depending if exist other custom toolbars at the same time (e.g: Chemistry)\r\n */\n\n }, {\n key: \"updateToolbar\",\n value: function updateToolbar() {\n this.updateTitle(this.modalDialogInstance);\n var customEditor;\n\n if (customEditor = this.customEditors.getActiveEditor()) {\n var toolbar = customEditor.toolbar ? customEditor.toolbar : _wrs_int_wirisProperties['toolbar'];\n\n if (this.toolbar == null || this.toolbar != toolbar) {\n this.setToolbar(toolbar);\n }\n } else {\n var toolbar = this.getToolbar();\n\n if (this.toolbar == null || this.toolbar != toolbar) {\n this.setToolbar(toolbar);\n this.customEditors.disable();\n }\n }\n }\n /**\r\n * Updates the modalObject title: if a custom editor (with a custom toolbar) is enabled\r\n * picks the custom editor title. Otherwise default title.\r\n */\n\n }, {\n key: \"updateTitle\",\n value: function updateTitle() {\n var customEditor;\n\n if (customEditor = this.customEditors.getActiveEditor()) {\n this.modalDialogInstance.setTitle(customEditor.title);\n } else {\n this.modalDialogInstance.setTitle('MathType');\n }\n }\n /**\r\n * Returns toolbar depending on the configuration local or server side.\r\n */\n\n }, {\n key: \"getToolbar\",\n value: function getToolbar() {\n var toolbar;\n\n if ('toolbar' in this.editorAttributes) {\n toolbar = this.editorAttributes.toolbar;\n } else {\n toolbar = \"general\";\n } // TODO: Change global integration variable for integration custom toolbar\n\n\n if (toolbar == 'general') {\n toolbar = typeof _wrs_int_wirisProperties == 'undefined' || typeof _wrs_int_wirisProperties['toolbar'] == 'undefined' ? 'general' : _wrs_int_wirisProperties['toolbar'];\n }\n\n return toolbar;\n }\n /**\r\n * Set a toolbar into editor.\r\n * @param {string} toolbar - toolbar name.\r\n */\n\n }, {\n key: \"setToolbar\",\n value: function setToolbar(toolbar) {\n this.toolbar = toolbar;\n this.editor.setParams({\n 'toolbar': this.toolbar\n });\n }\n /**\r\n * Returns true if the content of the editor has been changed. The logic of the changes\r\n * is delegated to editorListener object.\r\n */\n\n }, {\n key: \"hasChanges\",\n value: function hasChanges() {\n return !this.editor.isFormulaEmpty() && this.editorListener.getIsContentChanged();\n }\n }]);\n\n return ContentManager;\n}();\n\n\n\n//# sourceURL=webpack:///./core/src/contentmanager.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"default\", function() { return ContentManager; });\n/* harmony import */ var _configuration_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./configuration.js */ \"./core/src/configuration.js\");\n/* harmony import */ var _editorlistener_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./editorlistener.js */ \"./core/src/editorlistener.js\");\n/* harmony import */ var _listeners_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./listeners.js */ \"./core/src/listeners.js\");\n/* harmony import */ var _mathml_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./mathml.js */ \"./core/src/mathml.js\");\n/* harmony import */ var _util_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./util.js */ \"./core/src/util.js\");\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\n\n\n\n\n\n/**\r\n * This class represents the content of a ModalDialog class managing the following:\r\n * - Insertion in the ModalDialog.\r\n * - Actions to be done once the modal object has been submitted (submitAction() method).\r\n * - Updates itself when ModalDialog is updated, for example when ModalDialog\r\n * is re-opened (update(modalObject) method).\r\n * - Communicates ModalDialog if some changes have be done (hasChanges() method).\r\n */\n\nvar ContentManager =\n/*#__PURE__*/\nfunction () {\n /**\r\n * Class constructor\r\n * @param {Object} contentManagerAttributes - Object containing all attributes needed to\r\n * create a new instance of ContentManager class.\r\n * @param {Object} contentManagerAttributes.editorAttributes - Object containing MathType editor parameters.\r\n */\n function ContentManager(contentManagerAttributes) {\n _classCallCheck(this, ContentManager);\n\n /**\r\n * An object containing MathType editor parameters. See\r\n * http://docs.wiris.com/en/mathtype/mathtype_web/sdk-api/parameters for further information.\r\n * @type {Object}\r\n */\n this.contentManagerAttributes = {};\n\n if ('editorAttributes' in contentManagerAttributes) {\n this.editorAttributes = contentManagerAttributes.editorAttributes;\n } else {\n throw new Error('ContentManager constructor error: editorAttributes property missed.');\n }\n /**\r\n * CustomEditors instance. Contains the custom editors.\r\n * @type {CustomEditors}\r\n */\n\n\n this.customEditors = null;\n\n if ('customEditors' in contentManagerAttributes) {\n this.customEditors = contentManagerAttributes.customEditors;\n }\n /**\r\n * Environment properties. This object contains data about the integration platform.\r\n * @type {Object}\r\n * @property {string} editor - Editor name. Usually the HTML editor.\r\n * @property {string} mode - Save mode. Xml by default\r\n * @property {string} version - Plugin version.\r\n */\n\n\n this.environment = {};\n\n if ('environment' in contentManagerAttributes) {\n this.environment = contentManagerAttributes.environment;\n } else {\n throw new Error('ContentManager constructor error: environment property missed');\n }\n /**\r\n * ContentManager language.\r\n * @type {string}\r\n */\n\n\n this.language = '';\n\n if ('language' in contentManagerAttributes) {\n this.language = contentManagerAttributes.language;\n } else {\n throw new Error('ContentManager constructor error: language property missed');\n }\n /**\r\n * Editor listener. Needed to get control about editor changes.\r\n * @type {EditorListener}\r\n */\n\n\n this.editorListener = new _editorlistener_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"]();\n /**\r\n * MathType editor instance.\r\n * @type {JsEditor}\r\n */\n\n this.editor = null;\n /**\r\n * Navigator user agent.\r\n * @type {string}\r\n */\n\n this.ua = navigator.userAgent.toLowerCase();\n /**\r\n * Mobile device properties object\r\n * @type {Object}\r\n * @property {boolean} isAndroid - True if the device is android. False otherwise.\r\n * @property {boolean} isIOS - True if the device is iOS. False otherwise.\r\n */\n\n this.deviceProperties = {};\n this.deviceProperties.isAndroid = this.ua.indexOf(\"android\") > -1;\n this.deviceProperties.isIOS = this.ua.indexOf(\"ipad\") > -1 || this.ua.indexOf(\"iphone\") > -1;\n /**\r\n * Custom editor toolbar.\r\n * @type {string} toolbar\r\n */\n\n this.toolbar = null;\n /**\r\n * Instance of the ModalDialog class associated to the ContentManager instance.\r\n * @type {ModalDialog}\r\n */\n\n this.modalDialogInstance = null;\n /**\r\n * ContentManager listeners.\r\n * @type {Listeners}\r\n */\n\n this.listeners = new _listeners_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"]();\n /**\r\n * MathML associated to the ContentManager instance.\r\n * @type {string}\r\n */\n\n this.mathML = null;\n /**\r\n * Indicates if the edited element is a new element or not.\r\n * @type {boolean}\r\n */\n\n this.isNewElement = true;\n /**\r\n * IntegrationModel instance. Needed to call wrapper methods.\r\n * @type {IntegrationModel}\r\n */\n\n this.integrationModel = null;\n /**\r\n * Indicates if the editor is loaded.\r\n * @type {boolean}\r\n */\n\n this.isEditorLoaded = false;\n }\n /**\r\n * Add a new listener to ContentManager class.\r\n * @param {Object} listener - listener to be added.\r\n */\n\n\n _createClass(ContentManager, [{\n key: \"addListener\",\n value: function addListener(listener) {\n this.listeners.add(listener);\n }\n /**\r\n * Sets an instance of an IntegrationModel\r\n * @param {IntegrationModel} integrationModel\r\n */\n\n }, {\n key: \"setIntegrationModel\",\n value: function setIntegrationModel(integrationModel) {\n this.integrationModel = integrationModel;\n }\n /**\r\n * Sets a modal dialog instance.\r\n * @param {ModalDialog} - a ModalDialog instance\r\n */\n\n }, {\n key: \"setModalDialogInstance\",\n value: function setModalDialogInstance(modalDialogInstance) {\n this.modalDialogInstance = modalDialogInstance;\n }\n /**\r\n * Mandatory method. Inserts editor into modal object content container.\r\n */\n\n }, {\n key: \"insert\",\n value: function insert() {\n // Before insert the editor we update the modal object title to avoid weird render display.\n this.updateTitle(this.modalDialogInstance);\n this.insertEditor(this.modalDialogInstance);\n }\n /**\r\n * Method to insert MathType into modal object. This method\r\n * waits until editor JavaScript is loaded to insert the editor into\r\n * contentContainer modal object element.\r\n */\n\n }, {\n key: \"insertEditor\",\n value: function insertEditor() {\n // To know if editor JavaScript is loaded we need to wait until com.wiris.jsEditor namespace is ready.\n if ('com' in window && 'wiris' in window.com && 'jsEditor' in window.com.wiris) {\n this.editor = com.wiris.jsEditor.JsEditor.newInstance(this.editorAttributes);\n this.editor.insertInto(this.modalDialogInstance.contentContainer);\n this.editor.focus();\n\n if (this.modalDialogInstance.rtl) {\n this.editor.action('rtl');\n } // Setting div in rtl in case of it's activated.\n\n\n if (this.editor.getEditorModel().isRTL()) {\n this.editor.element.style.direction = 'rtl';\n } // Editor listener: this object manages the changes logic of editor.\n\n\n this.editor.getEditorModel().addEditorListener(this.editorListener); // iOS events.\n\n if (this.modalDialogInstance.deviceProperties['isIOS']) {\n setTimeout(function () {\n this.modalDialogInstance.hideKeyboard();\n }, 400);\n var formulaDisplayDiv = document.getElementsByClassName('wrs_formulaDisplay')[0];\n _util_js__WEBPACK_IMPORTED_MODULE_4__[\"default\"].addEvent(formulaDisplayDiv, 'focus', this.modalDialogInstance.handleOpenedIosSoftkeyboard);\n _util_js__WEBPACK_IMPORTED_MODULE_4__[\"default\"].addEvent(formulaDisplayDiv, 'blur', this.modalDialogInstance.handleClosedIosSoftkeyboard);\n } // Fire onLoad event. Necessary to set the MathML into the editor\n // after is loaded.\n\n\n this.listeners.fire('onLoad', {});\n this.isEditorLoaded = true;\n } else {\n setTimeout(ContentManager.prototype.insertEditor.bind(this, this.modalDialogInstance), 100);\n }\n }\n /**\r\n * Loads MathType script.\r\n */\n\n }, {\n key: \"init\",\n value: function init() {\n var queryParams = window.location.search.substring(1).split(\"&\");\n\n for (var i = 0; i < queryParams.length; i++) {\n var pos = queryParams[i].indexOf(\"v=\");\n\n if (pos >= 0) {\n version = queryParams[i].substring(2);\n }\n }\n\n var script = document.createElement('script');\n script.type = 'text/javascript';\n var editorUrl = _configuration_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get('editorUrl'); // We create an object url for parse url string and work more efficiently.\n\n var urlObject = document.createElement('a');\n urlObject.href = editorUrl; // Change to https if necessary.\n\n if (window.location.href.indexOf(\"https://\") == 0) {\n // It check if browser is https and configuration is http. If this is so, we will replace protocol.\n if (urlObject.protocol == 'http:') {\n urlObject.protocol = 'https:';\n }\n } // Check protocol and remove port if it's standard.\n\n\n if (urlObject.port == '80' || urlObject.port == '443') {\n editorUrl = urlObject.protocol + '//' + urlObject.hostname + '/' + urlObject.pathname;\n } else {\n editorUrl = urlObject.protocol + '//' + urlObject.hostname + ':' + urlObject.port + '/' + urlObject.pathname;\n } // Editor stats. Use environment property to set it.\n\n\n var stats = {};\n\n if ('editor' in this.environment) {\n stats.editor = this.environment.editor;\n } else {\n stats.editor = 'unknown';\n }\n\n if ('mode' in this.environment) {\n stats.mode = this.environment.mode;\n } else {\n stats.mode = _configuration_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get('saveMode');\n }\n\n if ('version' in this.environment) {\n stats.version = this.environment.version;\n } else {\n stats.version = _configuration_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get('version');\n } // Load editor URL. We add stats as GET params.\n\n\n script.src = editorUrl + \"?lang=\" + this.language + '&stats-editor=' + stats.editor + '&stats-mode=' + stats.mode + '&stats-version=' + stats.version;\n document.getElementsByTagName('head')[0].appendChild(script);\n }\n /**\r\n * Set the editor initial content: an existing formula or a blank MathML\r\n */\n\n }, {\n key: \"setInitialContent\",\n value: function setInitialContent() {\n if (!this.isNewElement) {\n this.setMathML(this.mathML);\n }\n }\n /**\r\n * Set a MathML into editor.\r\n * @param {string} mathml - MathML string.\r\n * @param {bool} focusDisabled - if true editor don't get focus after the MathML is set. false by default.\r\n */\n\n }, {\n key: \"setMathML\",\n value: function setMathML(mathml, focusDisabled) {\n // By default focus is enabled\n if (typeof focusDisabled === 'undefined') {\n focusDisabled = false;\n } // Using setMathML method is not a change produced by the user but for the API\n // so we set to false the contentChange property of editorListener.\n\n\n this.editor.setMathMLWithCallback(mathml, function () {\n this.editorListener.setWaitingForChanges(true);\n }.bind(this)); // We need to wait a little until the callback finish.\n\n setTimeout(function () {\n this.editorListener.setIsContentChanged(false);\n }.bind(this), 500); // In some scenarios - like closing modal object - editor mustn't be focused.\n\n if (!focusDisabled) {\n this.onFocus();\n }\n }\n /**\r\n * Set focus on editor.\r\n */\n\n }, {\n key: \"onFocus\",\n value: function onFocus() {\n if (typeof this.editor !== 'undefined' && this.editor != null) {\n this.editor.focus();\n }\n }\n /**\r\n * Mandatory method: modal object calls this method to execute a callback action\r\n * on submit.\r\n * This method updates the edition area (inserting a new formula or update an older one),\r\n * and focus the edition area too.\r\n */\n\n }, {\n key: \"submitAction\",\n value: function submitAction() {\n if (!this.editor.isFormulaEmpty()) {\n var mathML = this.editor.getMathMLWithSemantics(); // Add class for custom editors.\n\n if (this.customEditors.getActiveEditor() != null) {\n mathML = _mathml_js__WEBPACK_IMPORTED_MODULE_3__[\"default\"].addCustomEditorClassAttribute(mathML, this.customEditors.getActiveEditor().toolbar);\n } else {\n // We need - if exists - the editor name from MathML\n // class attribute.\n for (var key in this.customEditors.editors) {\n mathML = _mathml_js__WEBPACK_IMPORTED_MODULE_3__[\"default\"].removeCustomEditorClassAttribute(mathML, key);\n }\n }\n\n var mathmlEntitiesEncoded = _mathml_js__WEBPACK_IMPORTED_MODULE_3__[\"default\"].mathMLEntities(mathML);\n this.integrationModel.updateFormula(mathmlEntitiesEncoded);\n } else {\n this.integrationModel.updateFormula(null);\n }\n\n this.customEditors.disable();\n this.integrationModel.notifyWindowClosed(); // Set disabled focus to prevent lost focus.\n\n this.setEmptyMathML();\n this.customEditors.disable();\n }\n /**\r\n * Set an empty MathML into the editor in order to clean the edit area.\r\n */\n\n }, {\n key: \"setEmptyMathML\",\n value: function setEmptyMathML() {\n // As second argument we pass\n if (this.deviceProperties.isAndroid || this.deviceProperties.isIOS) {\n // We need to set a empty annotation in order to maintain editor in Hand mode.\n // Adding dir rtl in case of it's activated.\n if (this.editor.getEditorModel().isRTL()) {\n this.setMathML('[]\"', true);\n } else {\n this.setMathML('[]\"', true);\n }\n } else {\n if (this.editor.getEditorModel().isRTL()) {\n this.setMathML('', true);\n } else {\n this.setMathML('', true);\n }\n }\n }\n /**\r\n * Mandatory method: modal object calls this method when is updated, for example re-editing a formula when the\r\n * editor is open with another formula. This method updates the editor content (with an empty MathML or an existing formula),\r\n * updates - if needed - the editor toolbar (math --> chem or chem --> math) and recover the focus.\r\n */\n\n }, {\n key: \"onOpen\",\n value: function onOpen() {\n if (this.isNewElement) {\n this.setEmptyMathML();\n } else {\n this.setMathML(this.mathML);\n }\n\n this.updateToolbar();\n this.onFocus();\n }\n /**\r\n * Sets the correct toolbar depending if exist other custom toolbars at the same time (e.g: Chemistry)\r\n */\n\n }, {\n key: \"updateToolbar\",\n value: function updateToolbar() {\n this.updateTitle(this.modalDialogInstance);\n var customEditor;\n\n if (customEditor = this.customEditors.getActiveEditor()) {\n var toolbar = customEditor.toolbar ? customEditor.toolbar : _wrs_int_wirisProperties['toolbar'];\n\n if (this.toolbar == null || this.toolbar != toolbar) {\n this.setToolbar(toolbar);\n }\n } else {\n var toolbar = this.getToolbar();\n\n if (this.toolbar == null || this.toolbar != toolbar) {\n this.setToolbar(toolbar);\n this.customEditors.disable();\n }\n }\n }\n /**\r\n * Updates the modalObject title: if a custom editor (with a custom toolbar) is enabled\r\n * picks the custom editor title. Otherwise default title.\r\n */\n\n }, {\n key: \"updateTitle\",\n value: function updateTitle() {\n var customEditor;\n\n if (customEditor = this.customEditors.getActiveEditor()) {\n this.modalDialogInstance.setTitle(customEditor.title);\n } else {\n this.modalDialogInstance.setTitle('MathType');\n }\n }\n /**\r\n * Returns toolbar depending on the configuration local or server side.\r\n */\n\n }, {\n key: \"getToolbar\",\n value: function getToolbar() {\n var toolbar;\n\n if ('toolbar' in this.editorAttributes) {\n toolbar = this.editorAttributes.toolbar;\n } else {\n toolbar = \"general\";\n } // TODO: Change global integration variable for integration custom toolbar\n\n\n if (toolbar == 'general') {\n toolbar = typeof _wrs_int_wirisProperties == 'undefined' || typeof _wrs_int_wirisProperties['toolbar'] == 'undefined' ? 'general' : _wrs_int_wirisProperties['toolbar'];\n }\n\n return toolbar;\n }\n /**\r\n * Set a toolbar into editor.\r\n * @param {string} toolbar - toolbar name.\r\n */\n\n }, {\n key: \"setToolbar\",\n value: function setToolbar(toolbar) {\n this.toolbar = toolbar;\n this.editor.setParams({\n 'toolbar': this.toolbar\n });\n }\n /**\r\n * Returns true if the content of the editor has been changed. The logic of the changes\r\n * is delegated to editorListener object.\r\n */\n\n }, {\n key: \"hasChanges\",\n value: function hasChanges() {\n return !this.editor.isFormulaEmpty() && this.editorListener.getIsContentChanged();\n }\n }]);\n\n return ContentManager;\n}();\n\n\n\n//# sourceURL=webpack:///./core/src/contentmanager.js?"); /***/ }), @@ -166,7 +166,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) * /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"default\", function() { return Core; });\n/* harmony import */ var _util_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./util.js */ \"./core/src/util.js\");\n/* harmony import */ var _stringmanager_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./stringmanager.js */ \"./core/src/stringmanager.js\");\n/* harmony import */ var _contentmanager_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./contentmanager.js */ \"./core/src/contentmanager.js\");\n/* harmony import */ var _modal_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./modal.js */ \"./core/src/modal.js\");\n/* harmony import */ var _serviceprovider_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./serviceprovider.js */ \"./core/src/serviceprovider.js\");\n/* harmony import */ var _parser_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./parser.js */ \"./core/src/parser.js\");\n/* harmony import */ var _latex_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./latex.js */ \"./core/src/latex.js\");\n/* harmony import */ var _mathml_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./mathml.js */ \"./core/src/mathml.js\");\n/* harmony import */ var _customeditors_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./customeditors.js */ \"./core/src/customeditors.js\");\n/* harmony import */ var _configuration_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./configuration.js */ \"./core/src/configuration.js\");\n/* harmony import */ var _jsvariables_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./jsvariables.js */ \"./core/src/jsvariables.js\");\n/* harmony import */ var _event_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./event.js */ \"./core/src/event.js\");\n/* harmony import */ var _listeners_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./listeners.js */ \"./core/src/listeners.js\");\n/* harmony import */ var _integrationmodel_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./integrationmodel.js */ \"./core/src/integrationmodel.js\");\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n/**\n * Class representing MathType integration Core. This class is the integration entry point. Manages integration\n * initialization (services, languages), events, and the insertion of the formulas in the edit area.\n */\n\nvar Core =\n/*#__PURE__*/\nfunction () {\n /**\n * Core class constructor. Admits a string containing the configurationjs service\n * which loads all JavaScript configuration generated in the backend. This file is needed\n * to instantiate the serviceProvider class (all services lives in the same path).\n */\n function Core() {\n _classCallCheck(this, Core);\n\n /**\n * Language. Needed for accessibility and locales. 'en' by default.\n * @type {string}\n */\n this.language = 'en';\n /**\n * Edit mode. Admit 'images' and 'latex' values.\n * @type {string}\n */\n\n this.editMode = 'images';\n /**\n * Modal dialog instance.\n * @type {ModalDialog}\n */\n\n this.modalDialog = null;\n /**\n * Core custom editors. By default only chemistry editor.\n * @type {CustomEditors}\n */\n\n this.customEditors = new _customeditors_js__WEBPACK_IMPORTED_MODULE_8__[\"default\"]();\n var chemEditorParams = {\n name: 'Chemistry',\n toolbar: 'chemistry',\n icon: 'chem.png',\n confVariable: 'chemEnabled',\n title: 'ChemType',\n tooltip: 'Insert a chemistry formula - ChemType' // TODO: Localize tooltip.\n\n };\n this.customEditors.addEditor('chemistry', chemEditorParams);\n /**\n * Environment properties. This object contains data about the integration platform.\n * @type {Object}\n * @property {string} editor - Editor name. Usually the HTML editor.\n * @property {string} mode - Save mode. Xml by default\n * @property {string} version - Plugin version.\n */\n\n this.environment = {};\n /**\n * Edit properties.\n * @type {Object}\n * @property {boolean} isNewElement - Indicates if the edit formula is a new one or not.\n * @property {Img} temporalImage - Image of the formula edited. Null if the formula is a new one.\n * @property {Range} latexRange - LaTeX formula range.\n * @property {Range} range - Image range.\n * @property {string} editMode - Edition mode. Images by default.\n */\n\n this.editionProperties = {\n isNewElement: true,\n temporalImage: null,\n latexRange: null,\n range: null\n /**\n * Integration model instance.\n * @type {IntegrationModel}\n */\n\n };\n this.integrationModel = null;\n /**\n * ContentManager instance.\n * @type {ContentManager}\n */\n\n this.contentManager = null;\n /**\n * Information about the current browser.\n * @type {string}\n */\n\n this.browser = function get_browser() {\n var ua = navigator.userAgent;\n\n if (ua.search(\"Edge/\") >= 0) {\n return \"EDGE\";\n } else if (ua.search(\"Chrome/\") >= 0) {\n return \"CHROME\";\n } else if (ua.search(\"Trident/\") >= 0) {\n return \"IE\";\n } else if (ua.search(\"Firefox/\") >= 0) {\n return \"FIREFOX\";\n } else if (ua.search(\"Safari/\") >= 0) {\n return \"SAFARI\";\n }\n }();\n /**\n * Plugin listeners.\n * @type {Object[]}\n */\n\n\n this.listeners = new _listeners_js__WEBPACK_IMPORTED_MODULE_12__[\"default\"]();\n }\n /**\n * Initializes the core.\n * @param {string} integrationPath - integration root folder path.\n */\n\n\n _createClass(Core, [{\n key: \"init\",\n value: function init(integrationPath) {\n this.load(integrationPath);\n }\n /**\n * Sets the instance of the integration model object.\n * @param {IntegrationModel} integrationModel - integrationModel instance.\n */\n\n }, {\n key: \"setIntegrationModel\",\n value: function setIntegrationModel(integrationModel) {\n this.integrationModel = integrationModel;\n }\n /**\n * This method set an object containing environment properties. The structure for the an\n * environment object is the following:\n * @param {Object} environmentObject - And object containing environment properties.\n * @param {string} environmentObject.editor - Integration editor (usually HTML editor).\n * @param {string} environmentObject.mode - Save mode.\n * @param {string} environmentObject.version - Integration version.\n */\n\n }, {\n key: \"setEnvironment\",\n value: function setEnvironment(environmentObject) {\n if ('editor' in environmentObject) {\n this.environment.editor = environmentObject.editor;\n }\n\n if ('mode' in environmentObject) {\n this.environment.mode = environmentObject.mode;\n }\n\n if ('version' in environmentObject) {\n this.environment.version = environmentObject.version;\n }\n }\n /**\n * Get modal dialog\n * @returns {ModalDialog} Modal Window core instance.\n */\n\n }, {\n key: \"getModalDialog\",\n value: function getModalDialog() {\n return this.modalDialog;\n }\n /**\n * This method inits the Core class doing the following:\n * - Calls (async) to configurationjs service, converting the response JSON into javascript variables.\n * - Updates Configuration class with the previous configuration properties.\n * - Updates the ServiceProvider class using configurationjs service path as reference.\n * - Load lang strings and CSS.\n * - Once the previous is ready fires 'onLoad' event.\n */\n\n }, {\n key: \"load\",\n value: function load(integrationPath) {\n var httpRequest = typeof XMLHttpRequest != 'undefined' ? new XMLHttpRequest() : new ActiveXObject('Microsoft.XMLHTTP');\n this.integrationPath = integrationPath.indexOf(\"/\") == 0 || integrationPath.indexOf(\"http\") == 0 ? integrationPath : _util_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].concatenateUrl(this.integrationModel.getPath(), integrationPath);\n httpRequest.open('GET', this.integrationPath, false); // Async request.\n\n httpRequest.onload = function (e) {\n var _this = this;\n\n if (httpRequest.readyState === 4) {\n // Loading configuration variables.\n var jsonConfiguration = JSON.parse(httpRequest.responseText);\n var variables = Object.keys(jsonConfiguration);\n _configuration_js__WEBPACK_IMPORTED_MODULE_9__[\"default\"].addConfiguration(jsonConfiguration); // Adding JavaScript (not backend) configuration variables.\n\n _configuration_js__WEBPACK_IMPORTED_MODULE_9__[\"default\"].addConfiguration(_jsvariables_js__WEBPACK_IMPORTED_MODULE_10__[\"default\"]); // Load service paths.\n\n this.loadServicePaths(); // Load lang file.\n\n this.loadLangFile();\n this.loadCSS(); // Fire 'onLoad' event. All integration must listen this event in order to know if the plugin has been properly loaded.\n // We need to wait until stringManager has been loaded.\n\n if (Core.stringManager === null) {\n var stringManagerListener = _listeners_js__WEBPACK_IMPORTED_MODULE_12__[\"default\"].newListener('onLoad', function () {\n _this.listeners.fire('onLoad', {});\n });\n Core.stringManager.addListener(stringManagerListener);\n } else {\n this.listeners.fire('onLoad', {});\n }\n }\n }.bind(this);\n\n httpRequest.send(null);\n }\n /**\n * Instantiate a new ServiceProvider path (static) and calculate all the backend services\n * paths using Core integrationPath as base path.\n */\n\n }, {\n key: \"loadServicePaths\",\n value: function loadServicePaths() {\n // Services path (tech dependant).\n var createImagePath = this.integrationPath.replace('configurationjs', 'createimage');\n var showImagePath = this.integrationPath.replace('configurationjs', 'showimage');\n var createImagePath = this.integrationPath.replace('configurationjs', 'createimage');\n var getMathMLPath = this.integrationPath.replace('configurationjs', 'getmathml');\n var servicePath = this.integrationPath.replace('configurationjs', 'service'); // Some backend integrations (like Java o Ruby) have an absolute backend path,\n // for example: /app/service. For them we calculate the absolute URL path, i.e\n // protocol://domain:port/app/service\n\n if (this.integrationPath.indexOf(\"/\") == 0) {\n var serverPath = this.getServerPath();\n showImagePath = serverPath + showImagePath;\n createImagePath = serverPath + createImagePath;\n getMathMLPath = serverPath + getMathMLPath;\n servicePath = serverPath + servicePath;\n }\n\n _serviceprovider_js__WEBPACK_IMPORTED_MODULE_4__[\"default\"].setServicePath('showimage', showImagePath);\n _serviceprovider_js__WEBPACK_IMPORTED_MODULE_4__[\"default\"].setServicePath('createimage', createImagePath);\n _serviceprovider_js__WEBPACK_IMPORTED_MODULE_4__[\"default\"].setServicePath('service', servicePath);\n _serviceprovider_js__WEBPACK_IMPORTED_MODULE_4__[\"default\"].setServicePath('getmathml', getMathMLPath);\n }\n /**\n * Returns the client side server path on integration script lives.\n * @return {string} client side server path.\n */\n\n }, {\n key: \"getServerPath\",\n value: function getServerPath() {\n var url = this.integrationModel.getPath();\n var hostNameIndex = url.indexOf(\"/\", url.indexOf(\"/\") + 2);\n return url.substr(0, hostNameIndex);\n }\n /**\n * Loads language file using integration script path as base path. Then\n * load the string into the core StringManager instance.\n */\n\n }, {\n key: \"loadLangFile\",\n value: function loadLangFile() {\n // Translated languages.\n var languages = 'ar,ca,cs,da,de,en,es,et,eu,fi,fr,gl,he,hr,hu,it,ja,ko,nl,no,pl,pt,pt_br,ru,sv,tr,zh,el';\n var langArray = languages.split(',');\n var lang = this.language;\n\n if (langArray.indexOf(lang) == -1) {\n lang = lang.substr(0, 2);\n }\n\n if (langArray.indexOf(lang) == -1) {\n lang = 'en';\n }\n\n var script = document.createElement('script');\n script.type = 'text/javascript';\n script.src = this.integrationModel.getPath() + '/' + this.integrationModel.langFolderName + '/' + lang + '/strings.js'; // When strings are loaded, it loads into stringManager\n\n script.onload = function () {\n Core.getStringManager().loadStrings(wrs_strings);\n };\n\n document.getElementsByTagName('head')[0].appendChild(script);\n }\n /**\n * Appends CSS file to header.\n */\n\n }, {\n key: \"loadCSS\",\n value: function loadCSS() {\n var fileRef = document.createElement(\"link\");\n fileRef.setAttribute(\"rel\", \"stylesheet\");\n fileRef.setAttribute(\"type\", \"text/css\");\n fileRef.setAttribute(\"href\", _util_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].concatenateUrl(this.integrationModel.getPath(), '/core/styles.css'));\n document.getElementsByTagName(\"head\")[0].appendChild(fileRef);\n }\n /**\n * Adds a listener to Listeners core property.\n * @param {Object} listener - listener to be added.\n */\n\n }, {\n key: \"addListener\",\n value: function addListener(listener) {\n this.listeners.add(listener);\n }\n /**\n * Adds a listener to global core listeners.\n * @param {Object} listener - listener to be added.\n * @static\n */\n\n }, {\n key: \"updateFormula\",\n\n /**\n * Transform a MathML into a image formula. Then the image formula is inserted in the specified target, creating\n * a new image (new formula) or updating an existing one.\n * @param {Object} focusElement - element to be focused\n * @param {Object} windowTarget - window where the editable content is\n * @param {string} mathml - Mathml code\n * @param {Object[]} wirisProperties - extra attributes for the formula (like background color or font size).\n */\n value: function updateFormula(focusElement, windowTarget, mathml, wirisProperties) {\n /**\n * This event is fired after update the formula.\n * @type {Object}\n * @property {string} mathml - MathML to be transformed.\n * @property {string} editMode - edit mode.\n * @property {Object} wirisProperties - extra attributes for the formula.\n * @property {string} language - formula language.\n */\n var beforeUpdateEvent = new _event_js__WEBPACK_IMPORTED_MODULE_11__[\"default\"]();\n beforeUpdateEvent.mathml = mathml; // Cloning wirisProperties object\n // We don't want wirisProperties object modified.\n\n beforeUpdateEvent.wirisProperties = {};\n\n for (var attr in wirisProperties) {\n beforeUpdateEvent.wirisProperties[attr] = wirisProperties[attr];\n } // Read only.\n\n\n beforeUpdateEvent.language = this.language;\n beforeUpdateEvent.editMode = this.editMode;\n\n if (this.listeners.fire('onBeforeFormulaInsertion', beforeUpdateEvent)) {\n return;\n }\n\n if (Core.globalListeners.fire('onBeforeFormulaInsertion', beforeUpdateEvent)) {\n return;\n }\n\n mathml = beforeUpdateEvent.mathml;\n wirisProperties = beforeUpdateEvent.wirisProperties;\n /**\n * This event is fired after update the formula.\n * @type {Object}\n * @param {string} editMode - edit mode.\n * @param {Object} windowTarget - target window.\n * @param {Object} focusElement - target element to be focused after update.\n * @param {string} latex - LaTeX generated by the formula (editMode=latex).\n * @param {Object} node - node generated after update the formula (text if LaTeX img otherwise).\n */\n\n var afterUpdateEvent = new _event_js__WEBPACK_IMPORTED_MODULE_11__[\"default\"]();\n afterUpdateEvent.editMode = this.editMode;\n afterUpdateEvent.windowTarget = windowTarget;\n afterUpdateEvent.focusElement = focusElement;\n\n if (mathml.length == 0) {\n this.insertElementOnSelection(null, focusElement, windowTarget);\n } else if (this.editMode == 'latex') {\n afterUpdateEvent.latex = _latex_js__WEBPACK_IMPORTED_MODULE_6__[\"default\"].getLatexFromMathML(mathml); // this.integrationModel.getNonLatexNode is an integration wrapper to have special behaviours for nonLatex.\n // Not all the integrations have special behaviours for nonLatex.\n\n if (!!this.integrationModel.fillNonLatexNode && typeof afterUpdateEvent.latex === 'undefined') {\n this.integrationModel.fillNonLatexNode(afterUpdateEvent, windowTarget, mathml);\n } else {\n afterUpdateEvent.node = windowTarget.document.createTextNode('$$' + afterUpdateEvent.latex + '$$');\n }\n\n this.insertElementOnSelection(afterUpdateEvent.node, focusElement, windowTarget);\n } else if (this.editMode == 'iframes') {\n var iframe = wrs_mathmlToIframeObject(windowTarget, mathml);\n this.insertElementOnSelection(iframe, focusElement, windowTarget);\n } else {\n afterUpdateEvent.node = _parser_js__WEBPACK_IMPORTED_MODULE_5__[\"default\"].mathmlToImgObject(windowTarget.document, mathml, wirisProperties, this.language);\n this.insertElementOnSelection(afterUpdateEvent.node, focusElement, windowTarget);\n }\n\n if (this.listeners.fire('onAfterFormulaInsertion', afterUpdateEvent)) {\n return;\n }\n\n if (Core.globalListeners.fire('onAfterFormulaInsertion', afterUpdateEvent)) {\n return;\n }\n }\n /**\n * Sets the caret after 'node' and focus node owner document.\n * @param {Object} node - node that it will be behind the caret after the execution.\n */\n\n }, {\n key: \"placeCaretAfterNode\",\n value: function placeCaretAfterNode(node) {\n this.integrationModel.getSelection();\n var nodeDocument = node.ownerDocument;\n\n if (typeof nodeDocument.getSelection !== 'undefined') {\n var range = nodeDocument.createRange();\n range.setStartAfter(node);\n range.collapse(true);\n var selection = nodeDocument.getSelection();\n selection.removeAllRanges();\n selection.addRange(range);\n nodeDocument.body.focus();\n }\n }\n /**\n * Replaces a selection with an element.\n * @param {Object} element - element to replace the selection.\n * @param {Object} focusElement - element to be focused after the replace.\n * @param {Object} windowTarget - target window.\n */\n\n }, {\n key: \"insertElementOnSelection\",\n value: function insertElementOnSelection(element, focusElement, windowTarget) {\n if (this.editionProperties.isNewElement) {\n if (focusElement.type == \"textarea\") {\n _util_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].updateTextArea(focusElement, element.textContent);\n } else if (document.selection && document.getSelection == 0) {\n var range = windowTarget.document.selection.createRange();\n windowTarget.document.execCommand('InsertImage', false, element.src);\n\n if (!('parentElement' in range)) {\n windowTarget.document.execCommand('delete', false);\n range = windowTarget.document.selection.createRange();\n windowTarget.document.execCommand('InsertImage', false, element.src);\n }\n\n if ('parentElement' in range) {\n var temporalObject = range.parentElement();\n\n if (temporalObject.nodeName.toUpperCase() == 'IMG') {\n temporalObject.parentNode.replaceChild(element, temporalObject);\n } else {\n // IE9 fix: parentNode() does not return the IMG node, returns the parent DIV node. In IE < 9, pasteHTML does not work well.\n range.pasteHTML(_util_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].createObjectCode(element));\n }\n }\n } else {\n var editorSelection = this.integrationModel.getSelection();\n\n var _range; // In IE is needed keep the range due to after focus the modal window it can't be retrieved the last selection.\n\n\n if (this.editionProperties.range) {\n _range = this.editionProperties.range;\n this.editionProperties.range = null;\n } else {\n _range = editorSelection.getRangeAt(0);\n } // Delete if something was surrounded.\n\n\n _range.deleteContents();\n\n var node = _range.startContainer;\n var position = _range.startOffset;\n\n if (node.nodeType == 3) {\n // TEXT_NODE.\n node = node.splitText(position);\n node.parentNode.insertBefore(element, node);\n } else if (node.nodeType == 1) {\n // ELEMENT_NODE.\n node.insertBefore(element, node.childNodes[position]);\n }\n\n this.placeCaretAfterNode(element);\n }\n } else if (this.editionProperties.latexRange) {\n if (document.selection && document.getSelection == 0) {\n this.editionProperties.isNewElement = true;\n this.editionProperties.latexRange.select();\n this.insertElementOnSelection(element, focusElement, windowTarget);\n } else {\n var parentNode = this.editionProperties.latexRange.startContainer;\n this.editionProperties.latexRange.deleteContents();\n this.editionProperties.latexRange.insertNode(element);\n this.placeCaretAfterNode(element);\n }\n } else if (focusElement.type == \"textarea\") {\n var item; // Wrapper for some integrations that can have special behaviours to show latex.\n\n if (typeof this.integrationModel.getSelectedItem !== 'undefined') {\n item = this.integrationModel.getSelectedItem(focusElement, false);\n } else {\n item = _util_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].getSelectedItemOnTextarea(focusElement);\n }\n\n _util_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].updateExistingTextOnTextarea(focusElement, element.textContent, item.startPosition, item.endPosition);\n } else {\n if (!element) {\n // Editor empty, formula has been erased on edit.\n this.editionProperties.temporalImage.parentNode.removeChild(this.editionProperties.temporalImage);\n }\n\n this.editionProperties.temporalImage.parentNode.replaceChild(element, this.editionProperties.temporalImage);\n this.placeCaretAfterNode(element);\n }\n }\n /**\n * Opens a new modal dialog.\n * @param {object} target - target element.\n * @param {boolean} isIframe - specifies if the target is an iframe.\n */\n\n }, {\n key: \"openModalDialog\",\n value: function openModalDialog(target, isIframe) {\n // Textarea elements don't have normal document ranges. It only accepts latex edit.\n this.editMode = 'images'; // In IE is needed keep the range due to after focus the modal window it can't be retrieved the last selection.\n\n try {\n if (isIframe) {\n // Is needed focus the target first.\n target.contentWindow.focus();\n var selection = target.contentWindow.getSelection();\n this.editionProperties.range = selection.getRangeAt(0);\n } else {\n // Is needed focus the target first.\n target.focus();\n\n var _selection = getSelection();\n\n this.editionProperties.range = _selection.getRangeAt(0);\n }\n } catch (e) {\n this.editionProperties.range = null;\n }\n\n if (isIframe === undefined) {\n isIframe = true;\n }\n\n this.editionProperties.latexRange = null;\n\n if (target) {\n var selectedItem;\n\n if (typeof this.integrationModel.getSelectedItem !== 'undefined') {\n selectedItem = this.integrationModel.getSelectedItem(target, isIframe);\n } else {\n selectedItem = _util_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].getSelectedItem(target, isIframe);\n } // Check LaTeX if and only if the node is a text node (nodeType==3).\n\n\n if (selectedItem) {\n // Case when image was selected and button pressed.\n if (!selectedItem.caretPosition && _util_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].containsClass(selectedItem.node, _configuration_js__WEBPACK_IMPORTED_MODULE_9__[\"default\"].get('imageClassName'))) {\n this.editionProperties.temporalImage = selectedItem.node;\n this.editionProperties.isNewElement = false;\n } else if (selectedItem.node.nodeType === 3) {\n // If it's a text node means that editor is working with LaTeX.\n if (!!this.integrationModel.getMathmlFromTextNode) {\n // If integration has this function it isn't set range due to we don't\n // know if it will be put into a textarea as a text or image.\n var mathml = this.integrationModel.getMathmlFromTextNode(selectedItem.node, selectedItem.caretPosition);\n\n if (mathml) {\n this.editMode = 'latex';\n this.editionProperties.isNewElement = false;\n this.editionProperties.temporalImage = document.createElement('img');\n this.editionProperties.temporalImage.setAttribute(_configuration_js__WEBPACK_IMPORTED_MODULE_9__[\"default\"].get('imageMathmlAttribute'), _mathml_js__WEBPACK_IMPORTED_MODULE_7__[\"default\"].safeXmlEncode(mathml));\n }\n } else {\n var latexResult = _latex_js__WEBPACK_IMPORTED_MODULE_6__[\"default\"].getLatexFromTextNode(selectedItem.node, selectedItem.caretPosition);\n\n if (latexResult) {\n var _mathml = _latex_js__WEBPACK_IMPORTED_MODULE_6__[\"default\"].getMathMLFromLatex(latexResult.latex);\n\n this.editMode = 'latex';\n this.editionProperties.isNewElement = false;\n this.editionProperties.temporalImage = document.createElement('img');\n this.editionProperties.temporalImage.setAttribute(_configuration_js__WEBPACK_IMPORTED_MODULE_9__[\"default\"].get('imageMathmlAttribute'), _mathml_js__WEBPACK_IMPORTED_MODULE_7__[\"default\"].safeXmlEncode(_mathml));\n var windowTarget = isIframe ? target.contentWindow : window;\n\n if (target.tagName.toLowerCase() !== 'textarea') {\n if (document.selection) {\n var leftOffset = 0;\n var previousNode = latexResult.startNode.previousSibling;\n\n while (previousNode) {\n leftOffset += _util_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].getNodeLength(previousNode);\n previousNode = previousNode.previousSibling;\n }\n\n this.editionProperties.latexRange = windowTarget.document.selection.createRange();\n this.editionProperties.latexRange.moveToElementText(latexResult.startNode.parentNode);\n this.editionProperties.latexRange.move('character', leftOffset + latexResult.startPosition);\n this.editionProperties.latexRange.moveEnd('character', latexResult.latex.length + 4); // Plus 4 for the '$$' characters.\n } else {\n this.editionProperties.latexRange = windowTarget.document.createRange();\n this.editionProperties.latexRange.setStart(latexResult.startNode, latexResult.startPosition);\n this.editionProperties.latexRange.setEnd(latexResult.endNode, latexResult.endPosition);\n }\n }\n }\n }\n }\n } else if (target.tagName.toLowerCase() === 'textarea') {\n // By default editMode is 'images', but when target is a textarea it needs to be 'latex'.\n this.editMode = 'latex';\n }\n } // Setting an object with the editor parameters.\n // Editor parameters can be customized in several ways:\n // 1 - editorAttributes: Contains the default editor attributes, usually the metrics in a comma separated string. Always exists.\n // 2 - editorParameters: Object containing custom editor parameters. These parameters are defined in the backend. So they affects\n // all integration instances.\n // The backend send the default editor attributes in a coma separated with the following structure:\n // key1=value1,key2=value2...\n\n\n var defaultEditorAttributesArray = _configuration_js__WEBPACK_IMPORTED_MODULE_9__[\"default\"].get('editorAttributes').split(\", \");\n var defaultEditorAttributes = {};\n\n for (var i = 0, len = defaultEditorAttributesArray.length; i < len; i++) {\n var tempAttribute = defaultEditorAttributesArray[i].split('=');\n var key = tempAttribute[0];\n var value = tempAttribute[1];\n defaultEditorAttributes[key] = value;\n } // Custom editor parameters.\n\n\n var editorAttributes = {};\n Object.assign(editorAttributes, defaultEditorAttributes, _configuration_js__WEBPACK_IMPORTED_MODULE_9__[\"default\"].get('editorParameters'));\n editorAttributes.language = this.language;\n editorAttributes.rtl = this.integrationModel.rtl;\n var contentManagerAttributes = {};\n contentManagerAttributes.editorAttributes = editorAttributes;\n contentManagerAttributes.language = this.language;\n contentManagerAttributes.customEditors = this.customEditors;\n contentManagerAttributes.environment = this.environment;\n\n if (this.modalDialog == null) {\n this.modalDialog = new _modal_js__WEBPACK_IMPORTED_MODULE_3__[\"default\"](editorAttributes);\n this.contentManager = new _contentmanager_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"](contentManagerAttributes); // When an instance of ContentManager is created we need to wait until the ContentManager is ready\n // by listening 'onLoad' event.\n\n var listener = _listeners_js__WEBPACK_IMPORTED_MODULE_12__[\"default\"].newListener('onLoad', function () {\n this.contentManager.isNewElement = this.editionProperties.isNewElement;\n\n if (this.editionProperties.temporalImage != null) {\n var mathML = _mathml_js__WEBPACK_IMPORTED_MODULE_7__[\"default\"].safeXmlDecode(this.editionProperties.temporalImage.getAttribute(_configuration_js__WEBPACK_IMPORTED_MODULE_9__[\"default\"].get('imageMathmlAttribute')));\n this.contentManager.mathML = mathML;\n }\n }.bind(this));\n this.contentManager.addListener(listener);\n this.contentManager.init();\n this.modalDialog.setContentManager(this.contentManager);\n this.contentManager.setModalDialogInstance(this.modalDialog);\n } else {\n this.contentManager.isNewElement = this.editionProperties.isNewElement;\n\n if (this.editionProperties.temporalImage != null) {\n var mathML = _mathml_js__WEBPACK_IMPORTED_MODULE_7__[\"default\"].safeXmlDecode(this.editionProperties.temporalImage.getAttribute(_configuration_js__WEBPACK_IMPORTED_MODULE_9__[\"default\"].get('imageMathmlAttribute')));\n this.contentManager.mathML = mathML;\n }\n }\n\n this.contentManager.setIntegrationModel(this.integrationModel);\n this.modalDialog.open();\n }\n /**\n * Returns the instance of the ServiceProvider class.\n * @returns {ServiceProvider} ServiceProvider instance.\n * @static\n */\n\n }, {\n key: \"getCustomEditors\",\n\n /**\n * Return an object with all instance custom editors.\n * @return {CustomEditors}\n */\n value: function getCustomEditors() {\n return this.customEditors;\n }\n }], [{\n key: \"addGlobalListener\",\n value: function addGlobalListener(listener) {\n Core.globalListeners.add(listener);\n }\n }, {\n key: \"getServiceProvider\",\n value: function getServiceProvider() {\n return Core.serviceProvider;\n }\n /**\n * Returns the instance of the StringManager class.\n * @returns {StringManager} StringManager instance\n */\n\n }, {\n key: \"getStringManager\",\n value: function getStringManager() {\n return Core.stringManager;\n }\n }]);\n\n return Core;\n}();\n/**\n * Plugin static listeners.\n * @type {Object[]}\n * @static\n */\n\n\n\nCore.globalListeners = new _listeners_js__WEBPACK_IMPORTED_MODULE_12__[\"default\"]();\n/**\n * Class to manage plugin locales.\n * @type {StringManager}\n * @static\n */\n\nCore.stringManager = new _stringmanager_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"]();\n\n//# sourceURL=webpack:///./core/src/core.src.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"default\", function() { return Core; });\n/* harmony import */ var _util_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./util.js */ \"./core/src/util.js\");\n/* harmony import */ var _stringmanager_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./stringmanager.js */ \"./core/src/stringmanager.js\");\n/* harmony import */ var _contentmanager_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./contentmanager.js */ \"./core/src/contentmanager.js\");\n/* harmony import */ var _modal_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./modal.js */ \"./core/src/modal.js\");\n/* harmony import */ var _serviceprovider_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./serviceprovider.js */ \"./core/src/serviceprovider.js\");\n/* harmony import */ var _parser_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./parser.js */ \"./core/src/parser.js\");\n/* harmony import */ var _latex_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./latex.js */ \"./core/src/latex.js\");\n/* harmony import */ var _mathml_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./mathml.js */ \"./core/src/mathml.js\");\n/* harmony import */ var _customeditors_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./customeditors.js */ \"./core/src/customeditors.js\");\n/* harmony import */ var _configuration_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./configuration.js */ \"./core/src/configuration.js\");\n/* harmony import */ var _jsvariables_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./jsvariables.js */ \"./core/src/jsvariables.js\");\n/* harmony import */ var _event_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./event.js */ \"./core/src/event.js\");\n/* harmony import */ var _listeners_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./listeners.js */ \"./core/src/listeners.js\");\n/* harmony import */ var _integrationmodel_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./integrationmodel.js */ \"./core/src/integrationmodel.js\");\n/* harmony import */ var _image_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./image.js */ \"./core/src/image.js\");\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n/**\n * Class representing MathType integration Core. This class is the integration entry point. Manages integration\n * initialization (services, languages), events, and the insertion of the formulas in the edit area.\n */\n\nvar Core =\n/*#__PURE__*/\nfunction () {\n /**\n * Core class constructor. Admits a string containing the configurationjs service\n * which loads all JavaScript configuration generated in the backend. This file is needed\n * to instantiate the serviceProvider class (all services lives in the same path).\n */\n function Core() {\n _classCallCheck(this, Core);\n\n /**\n * Language. Needed for accessibility and locales. 'en' by default.\n * @type {string}\n */\n this.language = 'en';\n /**\n * Edit mode. Admit 'images' and 'latex' values.\n * @type {string}\n */\n\n this.editMode = 'images';\n /**\n * Modal dialog instance.\n * @type {ModalDialog}\n */\n\n this.modalDialog = null;\n /**\n * Core custom editors. By default only chemistry editor.\n * @type {CustomEditors}\n */\n\n this.customEditors = new _customeditors_js__WEBPACK_IMPORTED_MODULE_8__[\"default\"]();\n var chemEditorParams = {\n name: 'Chemistry',\n toolbar: 'chemistry',\n icon: 'chem.png',\n confVariable: 'chemEnabled',\n title: 'ChemType',\n tooltip: 'Insert a chemistry formula - ChemType' // TODO: Localize tooltip.\n\n };\n this.customEditors.addEditor('chemistry', chemEditorParams);\n /**\n * Environment properties. This object contains data about the integration platform.\n * @type {Object}\n * @property {string} editor - Editor name. Usually the HTML editor.\n * @property {string} mode - Save mode. Xml by default\n * @property {string} version - Plugin version.\n */\n\n this.environment = {};\n /**\n * Edit properties.\n * @type {Object}\n * @property {boolean} isNewElement - Indicates if the edit formula is a new one or not.\n * @property {Img} temporalImage - Image of the formula edited. Null if the formula is a new one.\n * @property {Range} latexRange - LaTeX formula range.\n * @property {Range} range - Image range.\n * @property {string} editMode - Edition mode. Images by default.\n */\n\n this.editionProperties = {\n isNewElement: true,\n temporalImage: null,\n latexRange: null,\n range: null\n /**\n * Integration model instance.\n * @type {IntegrationModel}\n */\n\n };\n this.integrationModel = null;\n /**\n * ContentManager instance.\n * @type {ContentManager}\n */\n\n this.contentManager = null;\n /**\n * Information about the current browser.\n * @type {string}\n */\n\n this.browser = function get_browser() {\n var ua = navigator.userAgent;\n\n if (ua.search(\"Edge/\") >= 0) {\n return \"EDGE\";\n } else if (ua.search(\"Chrome/\") >= 0) {\n return \"CHROME\";\n } else if (ua.search(\"Trident/\") >= 0) {\n return \"IE\";\n } else if (ua.search(\"Firefox/\") >= 0) {\n return \"FIREFOX\";\n } else if (ua.search(\"Safari/\") >= 0) {\n return \"SAFARI\";\n }\n }();\n /**\n * Plugin listeners.\n * @type {Object[]}\n */\n\n\n this.listeners = new _listeners_js__WEBPACK_IMPORTED_MODULE_12__[\"default\"]();\n }\n /**\n * Initializes the core.\n * @param {string} integrationPath - integration root folder path.\n */\n\n\n _createClass(Core, [{\n key: \"init\",\n value: function init(integrationPath) {\n this.load(integrationPath);\n }\n /**\n * Sets the instance of the integration model object.\n * @param {IntegrationModel} integrationModel - integrationModel instance.\n */\n\n }, {\n key: \"setIntegrationModel\",\n value: function setIntegrationModel(integrationModel) {\n this.integrationModel = integrationModel;\n }\n /**\n * This method set an object containing environment properties. The structure for the an\n * environment object is the following:\n * @param {Object} environmentObject - And object containing environment properties.\n * @param {string} environmentObject.editor - Integration editor (usually HTML editor).\n * @param {string} environmentObject.mode - Save mode.\n * @param {string} environmentObject.version - Integration version.\n */\n\n }, {\n key: \"setEnvironment\",\n value: function setEnvironment(environmentObject) {\n if ('editor' in environmentObject) {\n this.environment.editor = environmentObject.editor;\n }\n\n if ('mode' in environmentObject) {\n this.environment.mode = environmentObject.mode;\n }\n\n if ('version' in environmentObject) {\n this.environment.version = environmentObject.version;\n }\n }\n /**\n * Get modal dialog\n * @returns {ModalDialog} Modal Window core instance.\n */\n\n }, {\n key: \"getModalDialog\",\n value: function getModalDialog() {\n return this.modalDialog;\n }\n /**\n * This method inits the Core class doing the following:\n * - Calls (async) to configurationjs service, converting the response JSON into javascript variables.\n * - Updates Configuration class with the previous configuration properties.\n * - Updates the ServiceProvider class using configurationjs service path as reference.\n * - Load lang strings and CSS.\n * - Once the previous is ready fires 'onLoad' event.\n */\n\n }, {\n key: \"load\",\n value: function load(integrationPath) {\n var httpRequest = typeof XMLHttpRequest != 'undefined' ? new XMLHttpRequest() : new ActiveXObject('Microsoft.XMLHTTP');\n this.integrationPath = integrationPath.indexOf(\"/\") == 0 || integrationPath.indexOf(\"http\") == 0 ? integrationPath : _util_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].concatenateUrl(this.integrationModel.getPath(), integrationPath);\n httpRequest.open('GET', this.integrationPath, false); // Async request.\n\n httpRequest.onload = function (e) {\n var _this = this;\n\n if (httpRequest.readyState === 4) {\n // Loading configuration variables.\n var jsonConfiguration = JSON.parse(httpRequest.responseText);\n var variables = Object.keys(jsonConfiguration);\n _configuration_js__WEBPACK_IMPORTED_MODULE_9__[\"default\"].addConfiguration(jsonConfiguration); // Adding JavaScript (not backend) configuration variables.\n\n _configuration_js__WEBPACK_IMPORTED_MODULE_9__[\"default\"].addConfiguration(_jsvariables_js__WEBPACK_IMPORTED_MODULE_10__[\"default\"]); // Load service paths.\n\n this.loadServicePaths(); // Load lang file.\n\n this.loadLangFile();\n this.loadCSS(); // Fire 'onLoad' event. All integration must listen this event in order to know if the plugin has been properly loaded.\n // We need to wait until stringManager has been loaded.\n\n if (Core.stringManager === null) {\n var stringManagerListener = _listeners_js__WEBPACK_IMPORTED_MODULE_12__[\"default\"].newListener('onLoad', function () {\n _this.listeners.fire('onLoad', {});\n });\n Core.stringManager.addListener(stringManagerListener);\n } else {\n this.listeners.fire('onLoad', {});\n }\n }\n }.bind(this);\n\n httpRequest.send(null);\n }\n /**\n * Instantiate a new ServiceProvider path (static) and calculate all the backend services\n * paths using Core integrationPath as base path.\n */\n\n }, {\n key: \"loadServicePaths\",\n value: function loadServicePaths() {\n // Services path (tech dependant).\n var createImagePath = this.integrationPath.replace('configurationjs', 'createimage');\n var showImagePath = this.integrationPath.replace('configurationjs', 'showimage');\n var createImagePath = this.integrationPath.replace('configurationjs', 'createimage');\n var getMathMLPath = this.integrationPath.replace('configurationjs', 'getmathml');\n var servicePath = this.integrationPath.replace('configurationjs', 'service'); // Some backend integrations (like Java o Ruby) have an absolute backend path,\n // for example: /app/service. For them we calculate the absolute URL path, i.e\n // protocol://domain:port/app/service\n\n if (this.integrationPath.indexOf(\"/\") == 0) {\n var serverPath = this.getServerPath();\n showImagePath = serverPath + showImagePath;\n createImagePath = serverPath + createImagePath;\n getMathMLPath = serverPath + getMathMLPath;\n servicePath = serverPath + servicePath;\n }\n\n _serviceprovider_js__WEBPACK_IMPORTED_MODULE_4__[\"default\"].setServicePath('showimage', showImagePath);\n _serviceprovider_js__WEBPACK_IMPORTED_MODULE_4__[\"default\"].setServicePath('createimage', createImagePath);\n _serviceprovider_js__WEBPACK_IMPORTED_MODULE_4__[\"default\"].setServicePath('service', servicePath);\n _serviceprovider_js__WEBPACK_IMPORTED_MODULE_4__[\"default\"].setServicePath('getmathml', getMathMLPath);\n }\n /**\n * Returns the client side server path on integration script lives.\n * @return {string} client side server path.\n */\n\n }, {\n key: \"getServerPath\",\n value: function getServerPath() {\n var url = this.integrationModel.getPath();\n var hostNameIndex = url.indexOf(\"/\", url.indexOf(\"/\") + 2);\n return url.substr(0, hostNameIndex);\n }\n /**\n * Loads language file using integration script path as base path. Then\n * load the string into the core StringManager instance.\n */\n\n }, {\n key: \"loadLangFile\",\n value: function loadLangFile() {\n // Translated languages.\n var languages = 'ar,ca,cs,da,de,en,es,et,eu,fi,fr,gl,he,hr,hu,it,ja,ko,nl,no,pl,pt,pt_br,ru,sv,tr,zh,el';\n var langArray = languages.split(',');\n var lang = this.language;\n\n if (langArray.indexOf(lang) == -1) {\n lang = lang.substr(0, 2);\n }\n\n if (langArray.indexOf(lang) == -1) {\n lang = 'en';\n }\n\n var script = document.createElement('script');\n script.type = 'text/javascript';\n script.src = this.integrationModel.getPath() + '/' + this.integrationModel.langFolderName + '/' + lang + '/strings.js'; // When strings are loaded, it loads into stringManager\n\n script.onload = function () {\n Core.getStringManager().loadStrings(wrs_strings);\n };\n\n document.getElementsByTagName('head')[0].appendChild(script);\n }\n /**\n * Appends CSS file to header.\n */\n\n }, {\n key: \"loadCSS\",\n value: function loadCSS() {\n var fileRef = document.createElement(\"link\");\n fileRef.setAttribute(\"rel\", \"stylesheet\");\n fileRef.setAttribute(\"type\", \"text/css\");\n fileRef.setAttribute(\"href\", _util_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].concatenateUrl(this.integrationModel.getPath(), '/core/styles.css'));\n document.getElementsByTagName(\"head\")[0].appendChild(fileRef);\n }\n /**\n * Adds a listener to Listeners core property.\n * @param {Object} listener - listener to be added.\n */\n\n }, {\n key: \"addListener\",\n value: function addListener(listener) {\n this.listeners.add(listener);\n }\n /**\n * Adds a listener to global core listeners.\n * @param {Object} listener - listener to be added.\n * @static\n */\n\n }, {\n key: \"updateFormula\",\n\n /**\n * Transform a MathML into a image formula. Then the image formula is inserted in the specified target, creating\n * a new image (new formula) or updating an existing one.\n * @param {Object} focusElement - element to be focused\n * @param {Object} windowTarget - window where the editable content is\n * @param {string} mathml - Mathml code\n * @param {Object[]} wirisProperties - extra attributes for the formula (like background color or font size).\n */\n value: function updateFormula(focusElement, windowTarget, mathml, wirisProperties) {\n /**\n * This event is fired after update the formula.\n * @type {Object}\n * @property {string} mathml - MathML to be transformed.\n * @property {string} editMode - edit mode.\n * @property {Object} wirisProperties - extra attributes for the formula.\n * @property {string} language - formula language.\n */\n var beforeUpdateEvent = new _event_js__WEBPACK_IMPORTED_MODULE_11__[\"default\"]();\n beforeUpdateEvent.mathml = mathml; // Cloning wirisProperties object\n // We don't want wirisProperties object modified.\n\n beforeUpdateEvent.wirisProperties = {};\n\n for (var attr in wirisProperties) {\n beforeUpdateEvent.wirisProperties[attr] = wirisProperties[attr];\n } // Read only.\n\n\n beforeUpdateEvent.language = this.language;\n beforeUpdateEvent.editMode = this.editMode;\n\n if (this.listeners.fire('onBeforeFormulaInsertion', beforeUpdateEvent)) {\n return;\n }\n\n if (Core.globalListeners.fire('onBeforeFormulaInsertion', beforeUpdateEvent)) {\n return;\n }\n\n mathml = beforeUpdateEvent.mathml;\n wirisProperties = beforeUpdateEvent.wirisProperties;\n /**\n * This event is fired after update the formula.\n * @type {Object}\n * @param {string} editMode - edit mode.\n * @param {Object} windowTarget - target window.\n * @param {Object} focusElement - target element to be focused after update.\n * @param {string} latex - LaTeX generated by the formula (editMode=latex).\n * @param {Object} node - node generated after update the formula (text if LaTeX img otherwise).\n */\n\n var afterUpdateEvent = new _event_js__WEBPACK_IMPORTED_MODULE_11__[\"default\"]();\n afterUpdateEvent.editMode = this.editMode;\n afterUpdateEvent.windowTarget = windowTarget;\n afterUpdateEvent.focusElement = focusElement;\n\n if (!mathml) {\n this.insertElementOnSelection(null, focusElement, windowTarget);\n } else if (this.editMode == 'latex') {\n afterUpdateEvent.latex = _latex_js__WEBPACK_IMPORTED_MODULE_6__[\"default\"].getLatexFromMathML(mathml); // this.integrationModel.getNonLatexNode is an integration wrapper to have special behaviours for nonLatex.\n // Not all the integrations have special behaviours for nonLatex.\n\n if (!!this.integrationModel.fillNonLatexNode && !afterUpdateEvent.latex) {\n this.integrationModel.fillNonLatexNode(afterUpdateEvent, windowTarget, mathml);\n } else {\n afterUpdateEvent.node = windowTarget.document.createTextNode('$$' + afterUpdateEvent.latex + '$$');\n }\n\n this.insertElementOnSelection(afterUpdateEvent.node, focusElement, windowTarget);\n } else if (this.editMode == 'iframes') {\n var iframe = wrs_mathmlToIframeObject(windowTarget, mathml);\n this.insertElementOnSelection(iframe, focusElement, windowTarget);\n } else {\n afterUpdateEvent.node = _parser_js__WEBPACK_IMPORTED_MODULE_5__[\"default\"].mathmlToImgObject(windowTarget.document, mathml, wirisProperties, this.language);\n this.insertElementOnSelection(afterUpdateEvent.node, focusElement, windowTarget);\n }\n\n if (this.listeners.fire('onAfterFormulaInsertion', afterUpdateEvent)) {\n return;\n }\n\n if (Core.globalListeners.fire('onAfterFormulaInsertion', afterUpdateEvent)) {\n return;\n }\n }\n /**\n * Sets the caret after 'node' and focus node owner document.\n * @param {Object} node - node that it will be behind the caret after the execution.\n */\n\n }, {\n key: \"placeCaretAfterNode\",\n value: function placeCaretAfterNode(node) {\n this.integrationModel.getSelection();\n var nodeDocument = node.ownerDocument;\n\n if (typeof nodeDocument.getSelection !== 'undefined' && !!node.parentElement) {\n var range = nodeDocument.createRange();\n range.setStartAfter(node);\n range.collapse(true);\n var selection = nodeDocument.getSelection();\n selection.removeAllRanges();\n selection.addRange(range);\n nodeDocument.body.focus();\n }\n }\n /**\n * Replaces a selection with an element.\n * @param {Object} element - element to replace the selection.\n * @param {Object} focusElement - element to be focused after the replace.\n * @param {Object} windowTarget - target window.\n */\n\n }, {\n key: \"insertElementOnSelection\",\n value: function insertElementOnSelection(element, focusElement, windowTarget) {\n if (this.editionProperties.isNewElement) {\n if (element) {\n if (focusElement.type == 'textarea') {\n _util_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].updateTextArea(focusElement, element.textContent);\n } else if (document.selection && document.getSelection == 0) {\n var range = windowTarget.document.selection.createRange();\n windowTarget.document.execCommand('InsertImage', false, element.src);\n\n if (!('parentElement' in range)) {\n windowTarget.document.execCommand('delete', false);\n range = windowTarget.document.selection.createRange();\n windowTarget.document.execCommand('InsertImage', false, element.src);\n }\n\n if ('parentElement' in range) {\n var temporalObject = range.parentElement();\n\n if (temporalObject.nodeName.toUpperCase() == 'IMG') {\n temporalObject.parentNode.replaceChild(element, temporalObject);\n } else {\n // IE9 fix: parentNode() does not return the IMG node, returns the parent DIV node. In IE < 9, pasteHTML does not work well.\n range.pasteHTML(_util_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].createObjectCode(element));\n }\n }\n } else {\n var editorSelection = this.integrationModel.getSelection();\n\n var _range; // In IE is needed keep the range due to after focus the modal window it can't be retrieved the last selection.\n\n\n if (this.editionProperties.range) {\n _range = this.editionProperties.range;\n this.editionProperties.range = null;\n } else {\n _range = editorSelection.getRangeAt(0);\n } // Delete if something was surrounded.\n\n\n _range.deleteContents();\n\n var node = _range.startContainer;\n var position = _range.startOffset;\n\n if (node.nodeType == 3) {\n // TEXT_NODE.\n node = node.splitText(position);\n node.parentNode.insertBefore(element, node);\n } else if (node.nodeType == 1) {\n // ELEMENT_NODE.\n node.insertBefore(element, node.childNodes[position]);\n }\n\n this.placeCaretAfterNode(element);\n }\n } else if (focusElement.type == 'textarea') {\n focusElement.focus();\n } else {\n var _editorSelection = this.integrationModel.getSelection();\n\n _editorSelection.removeAllRanges();\n\n if (this.editionProperties.range) {\n var _range2 = this.editionProperties.range;\n this.editionProperties.range = null;\n\n _editorSelection.addRange(_range2);\n }\n }\n } else if (this.editionProperties.latexRange) {\n if (document.selection && document.getSelection == 0) {\n this.editionProperties.isNewElement = true;\n this.editionProperties.latexRange.select();\n this.insertElementOnSelection(element, focusElement, windowTarget);\n } else {\n this.editionProperties.latexRange.deleteContents();\n this.editionProperties.latexRange.insertNode(element);\n this.placeCaretAfterNode(element);\n }\n } else if (focusElement.type == \"textarea\") {\n var item; // Wrapper for some integrations that can have special behaviours to show latex.\n\n if (typeof this.integrationModel.getSelectedItem !== 'undefined') {\n item = this.integrationModel.getSelectedItem(focusElement, false);\n } else {\n item = _util_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].getSelectedItemOnTextarea(focusElement);\n }\n\n _util_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].updateExistingTextOnTextarea(focusElement, element.textContent, item.startPosition, item.endPosition);\n } else {\n if (element && element.nodeName.toLowerCase() === 'img') {\n // Editor empty, formula has been erased on edit.\n // Clone is needed to maintain event references to temporalImage.\n _image_js__WEBPACK_IMPORTED_MODULE_14__[\"default\"].clone(element, this.editionProperties.temporalImage);\n } else {\n this.editionProperties.temporalImage.remove();\n }\n\n this.placeCaretAfterNode(this.editionProperties.temporalImage);\n }\n }\n /**\n * Opens a new modal dialog.\n * @param {object} target - target element.\n * @param {boolean} isIframe - specifies if the target is an iframe.\n */\n\n }, {\n key: \"openModalDialog\",\n value: function openModalDialog(target, isIframe) {\n // Textarea elements don't have normal document ranges. It only accepts latex edit.\n this.editMode = 'images'; // In IE is needed keep the range due to after focus the modal window it can't be retrieved the last selection.\n\n try {\n if (isIframe) {\n // Is needed focus the target first.\n target.contentWindow.focus();\n var selection = target.contentWindow.getSelection();\n this.editionProperties.range = selection.getRangeAt(0);\n } else {\n // Is needed focus the target first.\n target.focus();\n\n var _selection = getSelection();\n\n this.editionProperties.range = _selection.getRangeAt(0);\n }\n } catch (e) {\n this.editionProperties.range = null;\n }\n\n if (isIframe === undefined) {\n isIframe = true;\n }\n\n this.editionProperties.latexRange = null;\n\n if (target) {\n var selectedItem;\n\n if (typeof this.integrationModel.getSelectedItem !== 'undefined') {\n selectedItem = this.integrationModel.getSelectedItem(target, isIframe);\n } else {\n selectedItem = _util_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].getSelectedItem(target, isIframe);\n } // Check LaTeX if and only if the node is a text node (nodeType==3).\n\n\n if (selectedItem) {\n // Case when image was selected and button pressed.\n if (!selectedItem.caretPosition && _util_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].containsClass(selectedItem.node, _configuration_js__WEBPACK_IMPORTED_MODULE_9__[\"default\"].get('imageClassName'))) {\n this.editionProperties.temporalImage = selectedItem.node;\n this.editionProperties.isNewElement = false;\n } else if (selectedItem.node.nodeType === 3) {\n // If it's a text node means that editor is working with LaTeX.\n if (!!this.integrationModel.getMathmlFromTextNode) {\n // If integration has this function it isn't set range due to we don't\n // know if it will be put into a textarea as a text or image.\n var mathml = this.integrationModel.getMathmlFromTextNode(selectedItem.node, selectedItem.caretPosition);\n\n if (mathml) {\n this.editMode = 'latex';\n this.editionProperties.isNewElement = false;\n this.editionProperties.temporalImage = document.createElement('img');\n this.editionProperties.temporalImage.setAttribute(_configuration_js__WEBPACK_IMPORTED_MODULE_9__[\"default\"].get('imageMathmlAttribute'), _mathml_js__WEBPACK_IMPORTED_MODULE_7__[\"default\"].safeXmlEncode(mathml));\n }\n } else {\n var latexResult = _latex_js__WEBPACK_IMPORTED_MODULE_6__[\"default\"].getLatexFromTextNode(selectedItem.node, selectedItem.caretPosition);\n\n if (latexResult) {\n var _mathml = _latex_js__WEBPACK_IMPORTED_MODULE_6__[\"default\"].getMathMLFromLatex(latexResult.latex);\n\n this.editMode = 'latex';\n this.editionProperties.isNewElement = false;\n this.editionProperties.temporalImage = document.createElement('img');\n this.editionProperties.temporalImage.setAttribute(_configuration_js__WEBPACK_IMPORTED_MODULE_9__[\"default\"].get('imageMathmlAttribute'), _mathml_js__WEBPACK_IMPORTED_MODULE_7__[\"default\"].safeXmlEncode(_mathml));\n var windowTarget = isIframe ? target.contentWindow : window;\n\n if (target.tagName.toLowerCase() !== 'textarea') {\n if (document.selection) {\n var leftOffset = 0;\n var previousNode = latexResult.startNode.previousSibling;\n\n while (previousNode) {\n leftOffset += _util_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].getNodeLength(previousNode);\n previousNode = previousNode.previousSibling;\n }\n\n this.editionProperties.latexRange = windowTarget.document.selection.createRange();\n this.editionProperties.latexRange.moveToElementText(latexResult.startNode.parentNode);\n this.editionProperties.latexRange.move('character', leftOffset + latexResult.startPosition);\n this.editionProperties.latexRange.moveEnd('character', latexResult.latex.length + 4); // Plus 4 for the '$$' characters.\n } else {\n this.editionProperties.latexRange = windowTarget.document.createRange();\n this.editionProperties.latexRange.setStart(latexResult.startNode, latexResult.startPosition);\n this.editionProperties.latexRange.setEnd(latexResult.endNode, latexResult.endPosition);\n }\n }\n }\n }\n }\n } else if (target.tagName.toLowerCase() === 'textarea') {\n // By default editMode is 'images', but when target is a textarea it needs to be 'latex'.\n this.editMode = 'latex';\n }\n } // Setting an object with the editor parameters.\n // Editor parameters can be customized in several ways:\n // 1 - editorAttributes: Contains the default editor attributes, usually the metrics in a comma separated string. Always exists.\n // 2 - editorParameters: Object containing custom editor parameters. These parameters are defined in the backend. So they affects\n // all integration instances.\n // The backend send the default editor attributes in a coma separated with the following structure:\n // key1=value1,key2=value2...\n\n\n var defaultEditorAttributesArray = _configuration_js__WEBPACK_IMPORTED_MODULE_9__[\"default\"].get('editorAttributes').split(\", \");\n var defaultEditorAttributes = {};\n\n for (var i = 0, len = defaultEditorAttributesArray.length; i < len; i++) {\n var tempAttribute = defaultEditorAttributesArray[i].split('=');\n var key = tempAttribute[0];\n var value = tempAttribute[1];\n defaultEditorAttributes[key] = value;\n } // Custom editor parameters.\n\n\n var editorAttributes = {};\n Object.assign(editorAttributes, defaultEditorAttributes, _configuration_js__WEBPACK_IMPORTED_MODULE_9__[\"default\"].get('editorParameters'));\n editorAttributes.language = this.language;\n editorAttributes.rtl = this.integrationModel.rtl;\n var contentManagerAttributes = {};\n contentManagerAttributes.editorAttributes = editorAttributes;\n contentManagerAttributes.language = this.language;\n contentManagerAttributes.customEditors = this.customEditors;\n contentManagerAttributes.environment = this.environment;\n\n if (this.modalDialog == null) {\n this.modalDialog = new _modal_js__WEBPACK_IMPORTED_MODULE_3__[\"default\"](editorAttributes);\n this.contentManager = new _contentmanager_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"](contentManagerAttributes); // When an instance of ContentManager is created we need to wait until the ContentManager is ready\n // by listening 'onLoad' event.\n\n var listener = _listeners_js__WEBPACK_IMPORTED_MODULE_12__[\"default\"].newListener('onLoad', function () {\n this.contentManager.isNewElement = this.editionProperties.isNewElement;\n\n if (this.editionProperties.temporalImage != null) {\n var mathML = _mathml_js__WEBPACK_IMPORTED_MODULE_7__[\"default\"].safeXmlDecode(this.editionProperties.temporalImage.getAttribute(_configuration_js__WEBPACK_IMPORTED_MODULE_9__[\"default\"].get('imageMathmlAttribute')));\n this.contentManager.mathML = mathML;\n }\n }.bind(this));\n this.contentManager.addListener(listener);\n this.contentManager.init();\n this.modalDialog.setContentManager(this.contentManager);\n this.contentManager.setModalDialogInstance(this.modalDialog);\n } else {\n this.contentManager.isNewElement = this.editionProperties.isNewElement;\n\n if (this.editionProperties.temporalImage != null) {\n var mathML = _mathml_js__WEBPACK_IMPORTED_MODULE_7__[\"default\"].safeXmlDecode(this.editionProperties.temporalImage.getAttribute(_configuration_js__WEBPACK_IMPORTED_MODULE_9__[\"default\"].get('imageMathmlAttribute')));\n this.contentManager.mathML = mathML;\n }\n }\n\n this.contentManager.setIntegrationModel(this.integrationModel);\n this.modalDialog.open();\n }\n /**\n * Returns the instance of the ServiceProvider class.\n * @returns {ServiceProvider} ServiceProvider instance.\n * @static\n */\n\n }, {\n key: \"getCustomEditors\",\n\n /**\n * Return an object with all instance custom editors.\n * @return {CustomEditors}\n */\n value: function getCustomEditors() {\n return this.customEditors;\n }\n }], [{\n key: \"addGlobalListener\",\n value: function addGlobalListener(listener) {\n Core.globalListeners.add(listener);\n }\n }, {\n key: \"getServiceProvider\",\n value: function getServiceProvider() {\n return Core.serviceProvider;\n }\n /**\n * Returns the instance of the StringManager class.\n * @returns {StringManager} StringManager instance\n */\n\n }, {\n key: \"getStringManager\",\n value: function getStringManager() {\n return Core.stringManager;\n }\n }]);\n\n return Core;\n}();\n/**\n * Plugin static listeners.\n * @type {Object[]}\n * @static\n */\n\n\n\nCore.globalListeners = new _listeners_js__WEBPACK_IMPORTED_MODULE_12__[\"default\"]();\n/**\n * Class to manage plugin locales.\n * @type {StringManager}\n * @static\n */\n\nCore.stringManager = new _stringmanager_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"]();\n\n//# sourceURL=webpack:///./core/src/core.src.js?"); /***/ }), @@ -214,7 +214,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) * /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"default\", function() { return Image; });\n/* harmony import */ var _configuration_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./configuration.js */ \"./core/src/configuration.js\");\n/* harmony import */ var _util_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./util.js */ \"./core/src/util.js\");\nfunction _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\n\n\n/**\r\n * This class contains all the logic related to image manipulation.\r\n */\n\nvar Image =\n/*#__PURE__*/\nfunction () {\n function Image() {\n _classCallCheck(this, Image);\n }\n\n _createClass(Image, null, [{\n key: \"setImgSize\",\n\n /**\r\n * Calculates the metrics of an img dom object given the response URI.\r\n * @param {Object} img - DOM image object.\r\n * @param {string} uri - URI generated by the image service: can be a data URI scheme or a URL.\r\n * @param {boolean} jsonResponse - indicates if the response of the image service is a JSON object.\r\n */\n value: function setImgSize(img, uri, jsonResponse) {\n if (jsonResponse) {\n // Cleaning data:image/png;base64.\n if (_configuration_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get('imageFormat') == 'svg') {\n // SVG format.\n // If SVG is encoded in base64 we need to convert the base64 bytes into a SVG string.\n if (_configuration_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get('saveMode') != 'base64') {\n var ar = Image.getMetricsFromSvgString(uri);\n } else {\n var base64String = img.src.substr(img.src.indexOf('base64,') + 7, img.src.length);\n var svgString = '';\n var bytes = _util_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].b64ToByteArray(base64String, base64String.length);\n\n for (var i = 0; i < bytes.length; i++) {\n svgString += String.fromCharCode(bytes[i]);\n }\n\n var ar = Image.getMetricsFromSvgString(svgString);\n } // PNG format: we store all metrics information in the first 88 bytes.\n\n } else {\n var base64String = img.src.substr(img.src.indexOf('base64,') + 7, img.src.length);\n var bytes = _util_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].b64ToByteArray(base64String, 88);\n var ar = Image.getMetricsFromBytes(bytes);\n } // Backwards compatibility: we store the metrics into createimage response.\n\n } else {\n var ar = _util_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].urlToAssArray(uri);\n }\n\n var width = ar['cw'];\n\n if (!width) {\n return;\n }\n\n var height = ar['ch'];\n var baseline = ar['cb'];\n var dpi = ar['dpi'];\n\n if (dpi) {\n width = width * 96 / dpi;\n height = height * 96 / dpi;\n baseline = baseline * 96 / dpi;\n }\n\n img.width = width;\n img.height = height;\n img.style.verticalAlign = \"-\" + (height - baseline) + \"px\";\n }\n /**\r\n * Re-calculates the metrics of a image which has been resized.\r\n * @param {Object} img - DOM image object.\r\n */\n\n }, {\n key: \"fixAfterResize\",\n value: function fixAfterResize(img) {\n img.removeAttribute('style');\n img.removeAttribute('width');\n img.removeAttribute('height'); // In order to avoid resize with max-width css property.\n\n img.style.maxWidth = 'none';\n\n if (img.src.indexOf(\"data:image\") != -1) {\n if (_configuration_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get('imageFormat') == 'svg') {\n // ...data:image/svg+xml;charset=utf8, = 32.\n var svg = decodeURIComponent(img.src.substring(32, img.src.length));\n Image.setImgSize(img, svg, true);\n } else {\n // ...data:image/png;base64, == 22.\n var base64 = img.src.substring(22, img.src.length);\n Image.setImgSize(img, base64, true);\n }\n } else {\n Image.setImgSize(img, img.src);\n }\n }\n /**\r\n * Returns the metrics (height, width and baseline) contained in SVG image generated\r\n * by the MathType image service. This image contains as an extra attribute the image baseline (wrs:baseline).\r\n * @param {string} svgString - a string containing an svg image.\r\n * @return {Object[]} - Array object containing the image metrics.\r\n */\n\n }, {\n key: \"getMetricsFromSvgString\",\n value: function getMetricsFromSvgString(svgString) {\n var first = svgString.indexOf('height=\"');\n var last = svgString.indexOf('\"', first + 8, svgString.length);\n var height = svgString.substring(first + 8, last);\n first = svgString.indexOf('width=\"');\n last = svgString.indexOf('\"', first + 7, svgString.length);\n var width = svgString.substring(first + 7, last);\n first = svgString.indexOf('wrs:baseline=\"');\n last = svgString.indexOf('\"', first + 14, svgString.length);\n var baseline = svgString.substring(first + 14, last);\n\n if (_typeof(width != 'undefined')) {\n var arr = new Array();\n arr['cw'] = width;\n arr['ch'] = height;\n\n if (typeof baseline != 'undefined') {\n arr['cb'] = baseline;\n }\n\n return arr;\n }\n }\n /**\r\n * Get metrics (width, height, baseline and dpi) from a png byte array.\r\n * @param {Object[]} bytes - png byte array.\r\n * @return {Object[]} a array containing the png metrics.\r\n * @static\r\n */\n\n }, {\n key: \"getMetricsFromBytes\",\n value: function getMetricsFromBytes(bytes) {\n _util_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].readBytes(bytes, 0, 8);\n var alloc = 10;\n var i = 0;\n\n while (bytes.length >= 4) {\n var len = _util_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].readInt32(bytes);\n var typ = _util_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].readInt32(bytes);\n\n if (typ == 0x49484452) {\n var width = _util_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].readInt32(bytes);\n var height = _util_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].readInt32(bytes); // Read 5 bytes.\n\n _util_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].readInt32(bytes);\n _util_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].readByte(bytes);\n } else if (typ == 0x62615345) {\n // Baseline: 'baSE'.\n var baseline = _util_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].readInt32(bytes);\n } else if (typ == 0x70485973) {\n // Dpis: 'pHYs'.\n var dpi = _util_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].readInt32(bytes);\n dpi = Math.round(dpi / 39.37);\n _util_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].readInt32(bytes);\n _util_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].readByte(bytes);\n }\n\n _util_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].readInt32(bytes);\n }\n\n if (typeof width != 'undefined') {\n var arr = new Array();\n arr['cw'] = width;\n arr['ch'] = height;\n arr['dpi'] = dpi;\n\n if (baseline) {\n arr['cb'] = baseline;\n }\n\n return arr;\n }\n }\n }]);\n\n return Image;\n}();\n\n\n\n//# sourceURL=webpack:///./core/src/image.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"default\", function() { return Image; });\n/* harmony import */ var _configuration_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./configuration.js */ \"./core/src/configuration.js\");\n/* harmony import */ var _util_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./util.js */ \"./core/src/util.js\");\nfunction _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\n\n\n/**\r\n * This class contains all the logic related to image manipulation.\r\n */\n\nvar Image =\n/*#__PURE__*/\nfunction () {\n function Image() {\n _classCallCheck(this, Image);\n }\n\n _createClass(Image, null, [{\n key: \"clone\",\n\n /**\r\n * Clone Wirisformula attributes from 'originImg' to 'destImg'.\r\n * @param {HTMLImageElement} originImg - formula to copy to 'destImg'. Is a Wirisformula.\r\n * @param {HTMLImageElement} destImg - formula where 'destImg' copies. Is a Wirisformula.\r\n */\n value: function clone(originImg, destImg) {\n var customEditorAttributeName = 'data-custom-editor';\n\n if (!originImg.hasAttribute(customEditorAttributeName)) {\n destImg.removeAttribute(customEditorAttributeName);\n }\n\n var mathmlAttributeName = _configuration_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get('imageMathmlAttribute');\n var imgAttributes = [mathmlAttributeName, customEditorAttributeName, 'alt', 'height', 'width', 'style', 'src', 'role'];\n\n for (var _i = 0; _i < imgAttributes.length; _i++) {\n var iterator = imgAttributes[_i];\n var originAttribute = originImg.getAttribute(iterator);\n\n if (originAttribute) {\n destImg.setAttribute(iterator, originAttribute);\n }\n }\n }\n /**\r\n * Calculates the metrics of an img dom object given the response URI.\r\n * @param {Object} img - DOM image object.\r\n * @param {string} uri - URI generated by the image service: can be a data URI scheme or a URL.\r\n * @param {boolean} jsonResponse - indicates if the response of the image service is a JSON object.\r\n */\n\n }, {\n key: \"setImgSize\",\n value: function setImgSize(img, uri, jsonResponse) {\n if (jsonResponse) {\n // Cleaning data:image/png;base64.\n if (_configuration_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get('imageFormat') == 'svg') {\n // SVG format.\n // If SVG is encoded in base64 we need to convert the base64 bytes into a SVG string.\n if (_configuration_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get('saveMode') != 'base64') {\n var ar = Image.getMetricsFromSvgString(uri);\n } else {\n var base64String = img.src.substr(img.src.indexOf('base64,') + 7, img.src.length);\n var svgString = '';\n var bytes = _util_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].b64ToByteArray(base64String, base64String.length);\n\n for (var i = 0; i < bytes.length; i++) {\n svgString += String.fromCharCode(bytes[i]);\n }\n\n var ar = Image.getMetricsFromSvgString(svgString);\n } // PNG format: we store all metrics information in the first 88 bytes.\n\n } else {\n var base64String = img.src.substr(img.src.indexOf('base64,') + 7, img.src.length);\n var bytes = _util_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].b64ToByteArray(base64String, 88);\n var ar = Image.getMetricsFromBytes(bytes);\n } // Backwards compatibility: we store the metrics into createimage response.\n\n } else {\n var ar = _util_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].urlToAssArray(uri);\n }\n\n var width = ar['cw'];\n\n if (!width) {\n return;\n }\n\n var height = ar['ch'];\n var baseline = ar['cb'];\n var dpi = ar['dpi'];\n\n if (dpi) {\n width = width * 96 / dpi;\n height = height * 96 / dpi;\n baseline = baseline * 96 / dpi;\n }\n\n img.width = width;\n img.height = height;\n img.style.verticalAlign = \"-\" + (height - baseline) + \"px\";\n }\n /**\r\n * Re-calculates the metrics of a image which has been resized.\r\n * @param {Object} img - DOM image object.\r\n */\n\n }, {\n key: \"fixAfterResize\",\n value: function fixAfterResize(img) {\n img.removeAttribute('style');\n img.removeAttribute('width');\n img.removeAttribute('height'); // In order to avoid resize with max-width css property.\n\n img.style.maxWidth = 'none';\n\n if (img.src.indexOf(\"data:image\") != -1) {\n if (_configuration_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get('imageFormat') == 'svg') {\n // ...data:image/svg+xml;charset=utf8, = 32.\n var svg = decodeURIComponent(img.src.substring(32, img.src.length));\n Image.setImgSize(img, svg, true);\n } else {\n // ...data:image/png;base64, == 22.\n var base64 = img.src.substring(22, img.src.length);\n Image.setImgSize(img, base64, true);\n }\n } else {\n Image.setImgSize(img, img.src);\n }\n }\n /**\r\n * Returns the metrics (height, width and baseline) contained in SVG image generated\r\n * by the MathType image service. This image contains as an extra attribute the image baseline (wrs:baseline).\r\n * @param {string} svgString - a string containing an svg image.\r\n * @return {Object[]} - Array object containing the image metrics.\r\n */\n\n }, {\n key: \"getMetricsFromSvgString\",\n value: function getMetricsFromSvgString(svgString) {\n var first = svgString.indexOf('height=\"');\n var last = svgString.indexOf('\"', first + 8, svgString.length);\n var height = svgString.substring(first + 8, last);\n first = svgString.indexOf('width=\"');\n last = svgString.indexOf('\"', first + 7, svgString.length);\n var width = svgString.substring(first + 7, last);\n first = svgString.indexOf('wrs:baseline=\"');\n last = svgString.indexOf('\"', first + 14, svgString.length);\n var baseline = svgString.substring(first + 14, last);\n\n if (_typeof(width != 'undefined')) {\n var arr = new Array();\n arr['cw'] = width;\n arr['ch'] = height;\n\n if (typeof baseline != 'undefined') {\n arr['cb'] = baseline;\n }\n\n return arr;\n }\n }\n /**\r\n * Get metrics (width, height, baseline and dpi) from a png byte array.\r\n * @param {Object[]} bytes - png byte array.\r\n * @return {Object[]} a array containing the png metrics.\r\n * @static\r\n */\n\n }, {\n key: \"getMetricsFromBytes\",\n value: function getMetricsFromBytes(bytes) {\n _util_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].readBytes(bytes, 0, 8);\n var alloc = 10;\n var i = 0;\n\n while (bytes.length >= 4) {\n var len = _util_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].readInt32(bytes);\n var typ = _util_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].readInt32(bytes);\n\n if (typ == 0x49484452) {\n var width = _util_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].readInt32(bytes);\n var height = _util_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].readInt32(bytes); // Read 5 bytes.\n\n _util_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].readInt32(bytes);\n _util_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].readByte(bytes);\n } else if (typ == 0x62615345) {\n // Baseline: 'baSE'.\n var baseline = _util_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].readInt32(bytes);\n } else if (typ == 0x70485973) {\n // Dpis: 'pHYs'.\n var dpi = _util_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].readInt32(bytes);\n dpi = Math.round(dpi / 39.37);\n _util_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].readInt32(bytes);\n _util_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].readByte(bytes);\n }\n\n _util_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].readInt32(bytes);\n }\n\n if (typeof width != 'undefined') {\n var arr = new Array();\n arr['cw'] = width;\n arr['ch'] = height;\n arr['dpi'] = dpi;\n\n if (baseline) {\n arr['cb'] = baseline;\n }\n\n return arr;\n }\n }\n }]);\n\n return Image;\n}();\n\n\n\n//# sourceURL=webpack:///./core/src/image.js?"); /***/ }), @@ -250,7 +250,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/**\r\n * Represents the conf /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"default\", function() { return Latex; });\n/* harmony import */ var _cache_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./cache.js */ \"./core/src/cache.js\");\n/* harmony import */ var _mathml_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./mathml.js */ \"./core/src/mathml.js\");\n/* harmony import */ var _serviceprovider_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./serviceprovider.js */ \"./core/src/serviceprovider.js\");\n/* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./constants.js */ \"./core/src/constants.js\");\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\n\n\n\n\n/**\r\n * This class represents a LaTeX parser. Manages the services which allows to convert\r\n * LaTeX into MathML and MathML into LaTeX.\r\n */\n\nvar Latex =\n/*#__PURE__*/\nfunction () {\n function Latex() {\n _classCallCheck(this, Latex);\n }\n\n _createClass(Latex, null, [{\n key: \"getLatexFromMathML\",\n\n /**\r\n * Converts MathML to LaTeX by calling mathml2latex service. For text services\r\n * we call a text service with the param mathml2latex.\r\n * @param {string} mathml - MathML String\r\n * @return {string} LaTeX string generated by the MathML argument.\r\n */\n value: function getLatexFromMathML(mathml) {\n /**\r\n * @type {TextCache}\r\n */\n var cache = Latex.cache;\n var data = {\n 'service': 'mathml2latex',\n 'mml': mathml\n };\n var jsonResponse = JSON.parse(_serviceprovider_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].getService('service', data)); //TODO: Error handling.\n\n var latex = '';\n\n if (jsonResponse.status == \"ok\") {\n latex = jsonResponse.result.text; // Inserting LaTeX semantics.\n\n mathml = _mathml_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].insertSemanticsMathml(mathml, latex, 'LaTeX');\n cache.populate(latex, mathml);\n }\n\n return latex;\n }\n /**\r\n * Converts LaTeX to MathML by calling latex2mathml service. For text services\r\n * we call a text service with the param latex2mathml.\r\n * @param {string} latex - string containing a LaTeX formula.\r\n * @param {boolean} includeLatexOnSemantics - if true LaTeX would me included into MathML semantics.\r\n * @return {string} MathML string generated by the LaTeX argument.\r\n */\n\n }, {\n key: \"getMathMLFromLatex\",\n value: function getMathMLFromLatex(latex, includeLatexOnSemantics) {\n /**\r\n * @type {TextCache}\r\n */\n var latexCache = Latex.cache;\n\n if (Latex.cache.get(latex)) {\n return Latex.cache.get(latex);\n }\n\n var data = {\n 'service': 'latex2mathml',\n 'latex': latex\n };\n\n if (includeLatexOnSemantics) {\n data['saveLatex'] = '';\n }\n\n var jsonResponse = JSON.parse(_serviceprovider_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].getService('service', data));\n var output;\n\n if (jsonResponse.status == \"ok\") {\n var mathml = jsonResponse.result.text;\n mathml = mathml.split(\"\\r\").join('').split(\"\\n\").join(' '); // Populate LatexCache.\n\n if (mathml.indexOf('semantics') == -1 && mathml.indexOf('annotation') == -1) {\n mathml = _mathml_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].insertSemanticsMathml(mathml, latex, 'LaTeX');\n output = mathml;\n }\n\n if (!latexCache.get(latex)) {\n latexCache.populate(latex, mathml);\n }\n } else {\n output = \"$$\" + latex + \"$$\";\n }\n\n return output;\n }\n /**\r\n * Converts all occurrences of MathML code to LaTeX. The MathML code should containing to be converted.\r\n * @param {string} content - a string containing MathML valid code.\r\n * @param {Object} characters - an object containing special characters.\r\n * @return {string} a string containing all MathML annotated occurrences replaced by the corresponding LaTeX code.\r\n */\n\n }, {\n key: \"parseMathmlToLatex\",\n value: function parseMathmlToLatex(content, characters) {\n var output = '';\n var mathTagBegin = characters.tagOpener + 'math';\n var mathTagEnd = characters.tagOpener + '/math' + characters.tagCloser;\n var openTarget = characters.tagOpener + 'annotation encoding=' + characters.doubleQuote + 'LaTeX' + characters.doubleQuote + characters.tagCloser;\n var closeTarget = characters.tagOpener + '/annotation' + characters.tagCloser;\n var start = content.indexOf(mathTagBegin);\n var end = 0;\n var mathml, startAnnotation, closeAnnotation;\n\n while (start != -1) {\n output += content.substring(end, start);\n end = content.indexOf(mathTagEnd, start);\n\n if (end == -1) {\n end = content.length - 1;\n } else {\n end += mathTagEnd.length;\n }\n\n mathml = content.substring(start, end);\n startAnnotation = mathml.indexOf(openTarget);\n\n if (startAnnotation != -1) {\n startAnnotation += openTarget.length;\n closeAnnotation = mathml.indexOf(closeTarget);\n var latex = mathml.substring(startAnnotation, closeAnnotation);\n\n if (characters == _constants_js__WEBPACK_IMPORTED_MODULE_3__[\"default\"].safeXmlCharacters) {\n latex = _mathml_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].safeXmlDecode(latex);\n }\n\n output += '$$' + latex + '$$'; // Populate latex into cache.\n\n Latex.cache.populate(latex, mathml);\n } else {\n output += mathml;\n }\n\n start = content.indexOf(mathTagBegin, end);\n }\n\n output += content.substring(end, content.length);\n return output;\n }\n /**\r\n * Extracts the latex of a determined position in a text.\r\n * @param {Node} textNode - textNode to extract the LaTeX\r\n * @param {number} caretPosition - starting position to find LaTeX.\r\n * @param {Object} latexTags - optional parameter representing tags between latex is inserted. It has the 'open' attribute for the open tag and the 'close' attribute for the close tag.\r\n * \"$$\" by default.\r\n * @return {Object} An object with 3 keys: 'latex', 'start' and 'end'. Null if latex is not found.\r\n * @static\r\n */\n\n }, {\n key: \"getLatexFromTextNode\",\n value: function getLatexFromTextNode(textNode, caretPosition, latexTags) {\n // TODO: Set LaTeX Tags as Core variable. Fix the call to this function (third argument).\n // Tags used for LaTeX formulas.\n var defaultLatexTags = {\n 'open': '$$',\n 'close': '$$'\n }; // latexTags is an optional parameter. If is not set, use default latexTags.\n\n if (typeof latexTags == 'undefined' || latexTags == null) {\n latexTags = defaultLatexTags;\n } // Looking for the first textNode.\n\n\n var startNode = textNode;\n\n while (startNode.previousSibling && startNode.previousSibling.nodeType == 3) {\n // TEXT_NODE.\n startNode = startNode.previousSibling;\n } // Finding latex.\n\n /**\r\n * Returns the next latex position and node from a specific node and position.\r\n * @param {Node} currentNode - node where searching latex.\r\n * @param {number} currentPosition - current position inside the currentNode.\r\n * @param {Object} latexTagsToUse - tags used at latex beginning and latex final. \"$$\" by default.\r\n * @param {boolean} tag - tag containing the current search.\r\n * @returns {object} object containing the current node and the position.\r\n */\n\n\n function getNextLatexPosition(currentNode, currentPosition, tag) {\n var position = currentNode.nodeValue.indexOf(tag, currentPosition);\n\n while (position == -1) {\n currentNode = currentNode.nextSibling;\n\n if (!currentNode) {\n // TEXT_NODE.\n return null; // Not found.\n }\n\n position = currentNode.nodeValue ? currentNode.nodeValue.indexOf(latexTags.close) : -1;\n }\n\n return {\n 'node': currentNode,\n 'position': position\n };\n }\n /**\r\n * Determines if a node is previous, or not, to a second one.\r\n * @param {Node} node - start node.\r\n * @param {number} position - start node position.\r\n * @param {Node} endNode - end node.\r\n * @param {number} endPosition - end node position.\r\n * @returns {boolean} true if the starting node is previous thant the en node. false otherwise.\r\n */\n\n\n function isPrevious(node, position, endNode, endPosition) {\n if (node == endNode) {\n return position <= endPosition;\n }\n\n while (node && node != endNode) {\n node = node.nextSibling;\n }\n\n return node == endNode;\n }\n\n var start;\n var end = {\n 'node': startNode,\n 'position': 0\n }; // Is supposed that open and close tags has the same length.\n\n var tagLength = latexTags.open.length;\n\n do {\n var start = getNextLatexPosition(end.node, end.position, latexTags.open);\n\n if (start == null || isPrevious(textNode, caretPosition, start.node, start.position)) {\n return null;\n }\n\n var end = getNextLatexPosition(start.node, start.position + tagLength, latexTags.close);\n\n if (end == null) {\n return null;\n }\n\n end.position += tagLength;\n } while (isPrevious(end.node, end.position, textNode, caretPosition)); // Isolating latex.\n\n\n var latex;\n\n if (start.node == end.node) {\n latex = start.node.nodeValue.substring(start.position + tagLength, end.position - tagLength);\n } else {\n latex = start.node.nodeValue.substring(start.position + tagLength, start.node.nodeValue.length);\n var currentNode = start.node;\n\n do {\n currentNode = currentNode.nextSibling;\n\n if (currentNode == end.node) {\n latex += end.node.nodeValue.substring(0, end.position - tagLength);\n } else {\n latex += currentNode.nodeValue ? currentNode.nodeValue : '';\n }\n } while (currentNode != end.node);\n }\n\n return {\n 'latex': latex,\n 'startNode': start.node,\n 'startPosition': start.position,\n 'endNode': end.node,\n 'endPosition': end.position\n };\n }\n }]);\n\n return Latex;\n}();\n/**\r\n * Text cache. Stores all processed LaTeX strings and it's correspondent MathML string.\r\n * @type {Cache}\r\n * @static\r\n */\n\n\n\nLatex.cache = new _cache_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"]();\n\n//# sourceURL=webpack:///./core/src/latex.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"default\", function() { return Latex; });\n/* harmony import */ var _cache_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./cache.js */ \"./core/src/cache.js\");\n/* harmony import */ var _mathml_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./mathml.js */ \"./core/src/mathml.js\");\n/* harmony import */ var _serviceprovider_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./serviceprovider.js */ \"./core/src/serviceprovider.js\");\n/* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./constants.js */ \"./core/src/constants.js\");\n/* harmony import */ var _util_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./util.js */ \"./core/src/util.js\");\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\n\n\n\n\n\n/**\r\n * This class represents a LaTeX parser. Manages the services which allows to convert\r\n * LaTeX into MathML and MathML into LaTeX.\r\n */\n\nvar Latex =\n/*#__PURE__*/\nfunction () {\n function Latex() {\n _classCallCheck(this, Latex);\n }\n\n _createClass(Latex, null, [{\n key: \"getLatexFromMathML\",\n\n /**\r\n * Converts MathML to LaTeX by calling mathml2latex service. For text services\r\n * we call a text service with the param mathml2latex.\r\n * @param {string} mathml - MathML String\r\n * @return {string} LaTeX string generated by the MathML argument.\r\n */\n value: function getLatexFromMathML(mathml) {\n /**\r\n * @type {TextCache}\r\n */\n var cache = Latex.cache;\n var data = {\n 'service': 'mathml2latex',\n 'mml': mathml\n };\n var jsonResponse = JSON.parse(_serviceprovider_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].getService('service', data)); //TODO: Error handling.\n\n var latex = '';\n\n if (jsonResponse.status == \"ok\") {\n latex = jsonResponse.result.text;\n var latexHtmlEntitiesEncoded = _util_js__WEBPACK_IMPORTED_MODULE_4__[\"default\"].htmlEntities(latex); // Inserting LaTeX semantics.\n\n mathml = _mathml_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].insertSemanticsMathml(mathml, latexHtmlEntitiesEncoded, 'LaTeX');\n cache.populate(latex, mathml);\n }\n\n return latex;\n }\n /**\r\n * Converts LaTeX to MathML by calling latex2mathml service. For text services\r\n * we call a text service with the param latex2mathml.\r\n * @param {string} latex - string containing a LaTeX formula.\r\n * @param {boolean} includeLatexOnSemantics - if true LaTeX would me included into MathML semantics.\r\n * @return {string} MathML string generated by the LaTeX argument.\r\n */\n\n }, {\n key: \"getMathMLFromLatex\",\n value: function getMathMLFromLatex(latex, includeLatexOnSemantics) {\n /**\r\n * @type {TextCache}\r\n */\n var latexCache = Latex.cache;\n\n if (Latex.cache.get(latex)) {\n return Latex.cache.get(latex);\n }\n\n var data = {\n 'service': 'latex2mathml',\n 'latex': latex\n };\n\n if (includeLatexOnSemantics) {\n data['saveLatex'] = '';\n }\n\n var jsonResponse = JSON.parse(_serviceprovider_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].getService('service', data));\n var output;\n\n if (jsonResponse.status == \"ok\") {\n var mathml = jsonResponse.result.text;\n mathml = mathml.split(\"\\r\").join('').split(\"\\n\").join(' '); // Populate LatexCache.\n\n if (mathml.indexOf('semantics') == -1 && mathml.indexOf('annotation') == -1) {\n mathml = _mathml_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].insertSemanticsMathml(mathml, latex, 'LaTeX');\n output = mathml;\n }\n\n if (!latexCache.get(latex)) {\n latexCache.populate(latex, mathml);\n }\n } else {\n output = \"$$\" + latex + \"$$\";\n }\n\n return output;\n }\n /**\r\n * Converts all occurrences of MathML code to LaTeX. The MathML code should containing to be converted.\r\n * @param {string} content - a string containing MathML valid code.\r\n * @param {Object} characters - an object containing special characters.\r\n * @return {string} a string containing all MathML annotated occurrences replaced by the corresponding LaTeX code.\r\n */\n\n }, {\n key: \"parseMathmlToLatex\",\n value: function parseMathmlToLatex(content, characters) {\n var output = '';\n var mathTagBegin = characters.tagOpener + 'math';\n var mathTagEnd = characters.tagOpener + '/math' + characters.tagCloser;\n var openTarget = characters.tagOpener + 'annotation encoding=' + characters.doubleQuote + 'LaTeX' + characters.doubleQuote + characters.tagCloser;\n var closeTarget = characters.tagOpener + '/annotation' + characters.tagCloser;\n var start = content.indexOf(mathTagBegin);\n var end = 0;\n var mathml, startAnnotation, closeAnnotation;\n\n while (start != -1) {\n output += content.substring(end, start);\n end = content.indexOf(mathTagEnd, start);\n\n if (end == -1) {\n end = content.length - 1;\n } else {\n end += mathTagEnd.length;\n }\n\n mathml = content.substring(start, end);\n startAnnotation = mathml.indexOf(openTarget);\n\n if (startAnnotation != -1) {\n startAnnotation += openTarget.length;\n closeAnnotation = mathml.indexOf(closeTarget);\n var latex = mathml.substring(startAnnotation, closeAnnotation);\n\n if (characters == _constants_js__WEBPACK_IMPORTED_MODULE_3__[\"default\"].safeXmlCharacters) {\n latex = _mathml_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].safeXmlDecode(latex);\n }\n\n output += '$$' + latex + '$$'; // Populate latex into cache.\n\n Latex.cache.populate(latex, mathml);\n } else {\n output += mathml;\n }\n\n start = content.indexOf(mathTagBegin, end);\n }\n\n output += content.substring(end, content.length);\n return output;\n }\n /**\r\n * Extracts the latex of a determined position in a text.\r\n * @param {Node} textNode - textNode to extract the LaTeX\r\n * @param {number} caretPosition - starting position to find LaTeX.\r\n * @param {Object} latexTags - optional parameter representing tags between latex is inserted. It has the 'open' attribute for the open tag and the 'close' attribute for the close tag.\r\n * \"$$\" by default.\r\n * @return {Object} An object with 3 keys: 'latex', 'start' and 'end'. Null if latex is not found.\r\n * @static\r\n */\n\n }, {\n key: \"getLatexFromTextNode\",\n value: function getLatexFromTextNode(textNode, caretPosition, latexTags) {\n // TODO: Set LaTeX Tags as Core variable. Fix the call to this function (third argument).\n // Tags used for LaTeX formulas.\n var defaultLatexTags = {\n 'open': '$$',\n 'close': '$$'\n }; // latexTags is an optional parameter. If is not set, use default latexTags.\n\n if (typeof latexTags == 'undefined' || latexTags == null) {\n latexTags = defaultLatexTags;\n } // Looking for the first textNode.\n\n\n var startNode = textNode;\n\n while (startNode.previousSibling && startNode.previousSibling.nodeType == 3) {\n // TEXT_NODE.\n startNode = startNode.previousSibling;\n } // Finding latex.\n\n /**\r\n * Returns the next latex position and node from a specific node and position.\r\n * @param {Node} currentNode - node where searching latex.\r\n * @param {number} currentPosition - current position inside the currentNode.\r\n * @param {Object} latexTagsToUse - tags used at latex beginning and latex final. \"$$\" by default.\r\n * @param {boolean} tag - tag containing the current search.\r\n * @returns {object} object containing the current node and the position.\r\n */\n\n\n function getNextLatexPosition(currentNode, currentPosition, tag) {\n var position = currentNode.nodeValue.indexOf(tag, currentPosition);\n\n while (position == -1) {\n currentNode = currentNode.nextSibling;\n\n if (!currentNode) {\n // TEXT_NODE.\n return null; // Not found.\n }\n\n position = currentNode.nodeValue ? currentNode.nodeValue.indexOf(latexTags.close) : -1;\n }\n\n return {\n 'node': currentNode,\n 'position': position\n };\n }\n /**\r\n * Determines if a node is previous, or not, to a second one.\r\n * @param {Node} node - start node.\r\n * @param {number} position - start node position.\r\n * @param {Node} endNode - end node.\r\n * @param {number} endPosition - end node position.\r\n * @returns {boolean} true if the starting node is previous thant the en node. false otherwise.\r\n */\n\n\n function isPrevious(node, position, endNode, endPosition) {\n if (node == endNode) {\n return position <= endPosition;\n }\n\n while (node && node != endNode) {\n node = node.nextSibling;\n }\n\n return node == endNode;\n }\n\n var start;\n var end = {\n 'node': startNode,\n 'position': 0\n }; // Is supposed that open and close tags has the same length.\n\n var tagLength = latexTags.open.length;\n\n do {\n var start = getNextLatexPosition(end.node, end.position, latexTags.open);\n\n if (start == null || isPrevious(textNode, caretPosition, start.node, start.position)) {\n return null;\n }\n\n var end = getNextLatexPosition(start.node, start.position + tagLength, latexTags.close);\n\n if (end == null) {\n return null;\n }\n\n end.position += tagLength;\n } while (isPrevious(end.node, end.position, textNode, caretPosition)); // Isolating latex.\n\n\n var latex;\n\n if (start.node == end.node) {\n latex = start.node.nodeValue.substring(start.position + tagLength, end.position - tagLength);\n } else {\n latex = start.node.nodeValue.substring(start.position + tagLength, start.node.nodeValue.length);\n var currentNode = start.node;\n\n do {\n currentNode = currentNode.nextSibling;\n\n if (currentNode == end.node) {\n latex += end.node.nodeValue.substring(0, end.position - tagLength);\n } else {\n latex += currentNode.nodeValue ? currentNode.nodeValue : '';\n }\n } while (currentNode != end.node);\n }\n\n return {\n 'latex': latex,\n 'startNode': start.node,\n 'startPosition': start.position,\n 'endNode': end.node,\n 'endPosition': end.position\n };\n }\n }]);\n\n return Latex;\n}();\n/**\r\n * Text cache. Stores all processed LaTeX strings and it's correspondent MathML string.\r\n * @type {Cache}\r\n * @static\r\n */\n\n\n\nLatex.cache = new _cache_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"]();\n\n//# sourceURL=webpack:///./core/src/latex.js?"); /***/ }), @@ -274,7 +274,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) * /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"default\", function() { return MathML; });\n/* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./constants.js */ \"./core/src/constants.js\");\n/* harmony import */ var _util_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./util.js */ \"./core/src/util.js\");\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\n\n\n/**\r\n * This class represents a class to manage MathML objects.\r\n */\n\nvar MathML =\n/*#__PURE__*/\nfunction () {\n function MathML() {\n _classCallCheck(this, MathML);\n }\n\n _createClass(MathML, null, [{\n key: \"isMathmlInAttribute\",\n\n /**\r\n * Checks if the mathml at position i is inside an HTML attribute or not.\r\n * @param {string} content - a string containing MathML code.\r\n * @param {number} i - search index.\r\n * @return {boolean} true if is inside an HTML attribute. false otherwise.\r\n */\n value: function isMathmlInAttribute(content, i) {\n // Regex = '^[\\'\"][\\\\s]*=[\\\\s]*[\\\\w-]+([\\\\s]*(\"[^\"]*\"|\\'[^\\']*\\')[\\\\s]*=[\\\\s]*[\\\\w-]+[\\\\s]*)*[\\\\s]+gmi<';\n var math_att = '[\\'\"][\\\\s]*=[\\\\s]*[\\\\w-]+'; // \"=att OR '=att\n\n var att_content = '\"[^\"]*\"|\\'[^\\']*\\''; // \"blabla\" OR 'blabla'\n\n var att = '[\\\\s]*(' + att_content + ')[\\\\s]*=[\\\\s]*[\\\\w-]+[\\\\s]*'; // \"blabla\"=att OR 'blabla'=att\n\n var atts = '(' + att + ')*'; // \"blabla\"=att1 \"blabla\"=att2\n\n var regex = '^' + math_att + atts + '[\\\\s]+gmi<'; // \"=att \"blabla\"=att1 \"blabla\"=att2 gmi< .\n\n var expression = new RegExp(regex);\n var actual_content = content.substring(0, i);\n var reversed = actual_content.split('').reverse().join('');\n var exists = expression.test(reversed);\n return exists;\n }\n /**\r\n * Decodes an encoded MathML with standard XML tags.\r\n * We use these entities because IE doesn't support html entities on its attributes sometimes. Yes, sometimes.\r\n * @param {string} input - string to be decoded.\r\n * @return {string} decoded string.\r\n */\n\n }, {\n key: \"safeXmlDecode\",\n value: function safeXmlDecode(input) {\n // Decoding entities.\n input = input.split(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlCharactersEntities.tagOpener).join(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlCharacters.tagOpener);\n input = input.split(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlCharactersEntities.tagCloser).join(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlCharacters.tagCloser);\n input = input.split(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlCharactersEntities.doubleQuote).join(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlCharacters.doubleQuote); // Added to fix problem due to import from 1.9.x.\n\n input = input.split(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlCharactersEntities.realDoubleQuote).join(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlCharacters.realDoubleQuote); // Blackboard.\n\n if ('_wrs_blackboard' in window && window._wrs_blackboard) {\n input = input.split(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeBadBlackboardCharacters.ltElement).join(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeGoodBlackboardCharacters.ltElement);\n input = input.split(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeBadBlackboardCharacters.gtElement).join(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeGoodBlackboardCharacters.gtElement);\n input = input.split(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeBadBlackboardCharacters.ampElement).join(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeGoodBlackboardCharacters.ampElement);\n } // Decoding characters.\n\n\n input = input.split(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlCharacters.tagOpener).join(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].xmlCharacters.tagOpener);\n input = input.split(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlCharacters.tagCloser).join(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].xmlCharacters.tagCloser);\n input = input.split(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlCharacters.doubleQuote).join(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].xmlCharacters.doubleQuote);\n input = input.split(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlCharacters.ampersand).join(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].xmlCharacters.ampersand);\n input = input.split(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlCharacters.quote).join(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].xmlCharacters.quote); // We are replacing $ by & when its part of an entity for retrocompatibility. Now, the standard is replace § by &.\n\n var returnValue = '';\n var currentEntity = null;\n\n for (var i = 0; i < input.length; ++i) {\n var character = input.charAt(i);\n\n if (currentEntity == null) {\n if (character == '$') {\n currentEntity = '';\n } else {\n returnValue += character;\n }\n } else {\n if (character == ';') {\n returnValue += '&' + currentEntity + ';';\n currentEntity = null;\n } else if (character.match(/([a-zA-Z0-9#._-] | '-')/)) {\n // Character is part of an entity.\n currentEntity += character;\n } else {\n returnValue += '$' + currentEntity; // Is not an entity.\n\n currentEntity = null;\n --i; // Parse again the current character.\n }\n }\n }\n\n return returnValue;\n }\n /**\r\n * Encodes a MathML with standard XML tags to a MMathML encoded with safe XML tags.\r\n * We use these entities because IE doesn't support html entities on its attributes sometimes. Yes, sometimes.\r\n * @param {string} input - input string to be encoded\r\n * @returns {string} encoded string.\r\n */\n\n }, {\n key: \"safeXmlEncode\",\n value: function safeXmlEncode(input) {\n input = input.split(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].xmlCharacters.tagOpener).join(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlCharacters.tagOpener);\n input = input.split(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].xmlCharacters.tagCloser).join(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlCharacters.tagCloser);\n input = input.split(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].xmlCharacters.doubleQuote).join(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlCharacters.doubleQuote);\n input = input.split(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].xmlCharacters.ampersand).join(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlCharacters.ampersand);\n input = input.split(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].xmlCharacters.quote).join(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlCharacters.quote);\n return input;\n }\n /**\r\n * Converts special symbols (> 128) to entities and replaces all textual entities by its number entities.\r\n * @param {string} mathml - MathML string containing - or not - special symbols\r\n * @returns {string} MathML with all textual entities replaced.\r\n */\n\n }, {\n key: \"mathMLEntities\",\n value: function mathMLEntities(mathml) {\n var toReturn = '';\n\n for (var i = 0; i < mathml.length; ++i) {\n var character = mathml.charAt(i); // Parsing > 128 characters.\n\n if (mathml.codePointAt(i) > 128) {\n toReturn += '&#' + mathml.codePointAt(i) + ';'; // For UTF-32 characters we need to move the index one position.\n\n if (mathml.codePointAt(i) > 0xffff) {\n i++;\n }\n } else if (character == '&') {\n var end = mathml.indexOf(';', i + 1);\n\n if (end >= 0) {\n var container = document.createElement('span');\n container.innerHTML = mathml.substring(i, end + 1);\n toReturn += '&#' + _util_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].fixedCharCodeAt(container.innerText || container.textContent, 0) + ';';\n i = end;\n } else {\n toReturn += character;\n }\n } else {\n toReturn += character;\n }\n }\n\n return toReturn;\n }\n /**\r\n * Add a custom editor name with the prefix wrs_ to a MathML class attribute.\r\n * @param {string} mathml - a MathML string created with a custom editor, like chemistry.\r\n * @param {string} customEditor - custom editor name.\r\n * @returns {string} MathML string with his class containing the editor toolbar string.\r\n */\n\n }, {\n key: \"addCustomEditorClassAttribute\",\n value: function addCustomEditorClassAttribute(mathml, customEditor) {\n var toReturn = '';\n var start = mathml.indexOf('');\n\n if (mathml.indexOf(\"class\") == -1) {\n // Adding custom editor type.\n toReturn = mathml.substr(start, end) + ' class=\"wrs_' + customEditor + '\">';\n toReturn += mathml.substr(end + 1, mathml.length);\n return toReturn;\n }\n }\n\n return mathml;\n }\n /**\r\n * Remove a custom editor name from the MathML class attribute.\r\n * @param {string} mathml - a MathML string.\r\n * @param {string} customEditor - custom editor name.\r\n * @returns {string} The input MathML without customEditor name in his class.\r\n */\n\n }, {\n key: \"removeCustomEditorClassAttribute\",\n value: function removeCustomEditorClassAttribute(mathml, customEditor) {\n // Discard MathML without the specified class.\n if (mathml.indexOf('class') == -1 || mathml.indexOf('wrs_' + customEditor)) {\n return mathml;\n } // Trivial case: class attribute value equal to editor name. Then\n // class attribute is removed.\n\n\n if (mathml.indexOf('class=\"wrs_' + customEditor + '\"') !== -1) {\n return mathml.replace('class=\"wrs_' + customEditor + '\"', '');\n } // Non Trivial case: class attribute contains editor name.\n\n\n return mathml.replace('wrs_' + customEditor, '');\n }\n /**\r\n * Add annotation tag to mathml without it (mathml comes from LaTeX string)\r\n * @param {string} mathml - MathML code generated by a LaTeX string.\r\n * @param {string} latex - original LaTeX string\r\n * @param {string} withoutLatexTranslate - true if not exists latex translation from mathml. false otherwise.\r\n * @param {string} encoding - encoding attribute.\r\n * @returns {string} MathML containing LaTeX code on annotation tag.\r\n */\n\n }, {\n key: \"insertSemanticsMathml\",\n value: function insertSemanticsMathml(mathml, latex, encoding) {\n // If latex is empty, insert semantics doesn't provide information. We can avoid semantics insertion and return the mathml.\n if (latex == \"\") {\n return mathml;\n }\n\n var firstEndTag = '>';\n var mathTagEnd = '<' + '/math' + '>';\n var openSemantics = '<' + 'semantics' + '>';\n var closeSemantics = '<' + '/semantics' + '>';\n var openTarget = '';\n var closeTarget = '<' + '/annotation' + '>';\n var mrowOpen = '';\n var mrowClose = '';\n var indexMathBegin = mathml.indexOf(firstEndTag);\n var indexMathEnd = mathml.indexOf(mathTagEnd);\n var mathBeginExists = mathml.substring(mathml.indexOf('<'), mathml.indexOf('>')).indexOf('math');\n\n if (indexMathBegin != -1 && indexMathEnd != -1 && mathBeginExists) {\n var mathmlContent = mathml.substring(indexMathBegin + 1, indexMathEnd);\n\n if (mathmlContent.indexOf(mrowOpen) != 0) {\n var mathmlContentSemantics = openSemantics + mrowOpen + mathmlContent + mrowClose + openTarget + latex + closeTarget + closeSemantics;\n } else {\n var mathmlContentSemantics = openSemantics + mathmlContent + openTarget + latex + closeTarget + closeSemantics;\n }\n\n return mathml.replace(mathmlContent, mathmlContentSemantics);\n } else {\n return mathml;\n }\n }\n /**\r\n * Removes annotation tag to mathml.\r\n * @param {string} mathml - MathML string\r\n * @param {string} encoding - string containing annotation encoding.\r\n * @returns {string} MathML with an annotation tag.\r\n */\n\n }, {\n key: \"removeSemanticsMathml\",\n value: function removeSemanticsMathml(mathml, encoding) {\n var mathTagEnd = '<' + '/math' + '>';\n var openSemantics = '<' + 'semantics' + '>';\n var openAnnotation = '';\n var mathmlWithoutSemantics = mathml;\n var startSemantics = mathml.indexOf(openSemantics);\n\n if (startSemantics != -1) {\n var startAnnotation = mathml.indexOf(openAnnotation, startSemantics + openSemantics.length);\n\n if (startAnnotation != -1) {\n mathmlWithoutSemantics = mathml.substring(0, startSemantics) + mathml.substring(startSemantics + openSemantics.length, startAnnotation) + mathTagEnd;\n }\n }\n\n return mathmlWithoutSemantics;\n }\n /**\r\n * Returns true if a MathML contains a certain class.\r\n * @param {string} mathML - input MathML.\r\n * @param {string} className - className.\r\n * @returns {boolean} true if the input MathML contains the input class.\r\n * false otherwise.\r\n * @static\r\n */\n\n }, {\n key: \"containClass\",\n value: function containClass(mathML, className) {\n var classIndex = mathML.indexOf('class');\n\n if (classIndex == -1) {\n return false;\n } else {\n var classTagEndIndex = mathML.indexOf('>', classIndex);\n var classTag = mathML.substring(classIndex, classTagEndIndex);\n\n if (classTag.indexOf(className) != -1) {\n return true;\n } else {\n return false;\n }\n }\n }\n }]);\n\n return MathML;\n}();\n\n\n\n//# sourceURL=webpack:///./core/src/mathml.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"default\", function() { return MathML; });\n/* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./constants.js */ \"./core/src/constants.js\");\n/* harmony import */ var _util_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./util.js */ \"./core/src/util.js\");\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\n\n\n/**\r\n * This class represents a class to manage MathML objects.\r\n */\n\nvar MathML =\n/*#__PURE__*/\nfunction () {\n function MathML() {\n _classCallCheck(this, MathML);\n }\n\n _createClass(MathML, null, [{\n key: \"isMathmlInAttribute\",\n\n /**\r\n * Checks if the mathml at position i is inside an HTML attribute or not.\r\n * @param {string} content - a string containing MathML code.\r\n * @param {number} i - search index.\r\n * @return {boolean} true if is inside an HTML attribute. false otherwise.\r\n */\n value: function isMathmlInAttribute(content, i) {\n // Regex = '^[\\'\"][\\\\s]*=[\\\\s]*[\\\\w-]+([\\\\s]*(\"[^\"]*\"|\\'[^\\']*\\')[\\\\s]*=[\\\\s]*[\\\\w-]+[\\\\s]*)*[\\\\s]+gmi<';\n var math_att = '[\\'\"][\\\\s]*=[\\\\s]*[\\\\w-]+'; // \"=att OR '=att\n\n var att_content = '\"[^\"]*\"|\\'[^\\']*\\''; // \"blabla\" OR 'blabla'\n\n var att = '[\\\\s]*(' + att_content + ')[\\\\s]*=[\\\\s]*[\\\\w-]+[\\\\s]*'; // \"blabla\"=att OR 'blabla'=att\n\n var atts = '(' + att + ')*'; // \"blabla\"=att1 \"blabla\"=att2\n\n var regex = '^' + math_att + atts + '[\\\\s]+gmi<'; // \"=att \"blabla\"=att1 \"blabla\"=att2 gmi< .\n\n var expression = new RegExp(regex);\n var actual_content = content.substring(0, i);\n var reversed = actual_content.split('').reverse().join('');\n var exists = expression.test(reversed);\n return exists;\n }\n /**\r\n * Decodes an encoded MathML with standard XML tags.\r\n * We use these entities because IE doesn't support html entities on its attributes sometimes. Yes, sometimes.\r\n * @param {string} input - string to be decoded.\r\n * @return {string} decoded string.\r\n */\n\n }, {\n key: \"safeXmlDecode\",\n value: function safeXmlDecode(input) {\n // Decoding entities.\n input = input.split(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlCharactersEntities.tagOpener).join(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlCharacters.tagOpener);\n input = input.split(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlCharactersEntities.tagCloser).join(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlCharacters.tagCloser);\n input = input.split(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlCharactersEntities.doubleQuote).join(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlCharacters.doubleQuote); // Added to fix problem due to import from 1.9.x.\n\n input = input.split(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlCharactersEntities.realDoubleQuote).join(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlCharacters.realDoubleQuote); // Blackboard.\n\n if ('_wrs_blackboard' in window && window._wrs_blackboard) {\n input = input.split(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeBadBlackboardCharacters.ltElement).join(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeGoodBlackboardCharacters.ltElement);\n input = input.split(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeBadBlackboardCharacters.gtElement).join(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeGoodBlackboardCharacters.gtElement);\n input = input.split(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeBadBlackboardCharacters.ampElement).join(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeGoodBlackboardCharacters.ampElement);\n } // Decoding characters.\n\n\n input = input.split(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlCharacters.tagOpener).join(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].xmlCharacters.tagOpener);\n input = input.split(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlCharacters.tagCloser).join(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].xmlCharacters.tagCloser);\n input = input.split(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlCharacters.doubleQuote).join(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].xmlCharacters.doubleQuote);\n input = input.split(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlCharacters.ampersand).join(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].xmlCharacters.ampersand);\n input = input.split(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlCharacters.quote).join(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].xmlCharacters.quote); // We are replacing $ by & when its part of an entity for retrocompatibility. Now, the standard is replace § by &.\n\n var returnValue = '';\n var currentEntity = null;\n\n for (var i = 0; i < input.length; ++i) {\n var character = input.charAt(i);\n\n if (currentEntity == null) {\n if (character == '$') {\n currentEntity = '';\n } else {\n returnValue += character;\n }\n } else {\n if (character == ';') {\n returnValue += '&' + currentEntity + ';';\n currentEntity = null;\n } else if (character.match(/([a-zA-Z0-9#._-] | '-')/)) {\n // Character is part of an entity.\n currentEntity += character;\n } else {\n returnValue += '$' + currentEntity; // Is not an entity.\n\n currentEntity = null;\n --i; // Parse again the current character.\n }\n }\n }\n\n return returnValue;\n }\n /**\r\n * Encodes a MathML with standard XML tags to a MMathML encoded with safe XML tags.\r\n * We use these entities because IE doesn't support html entities on its attributes sometimes. Yes, sometimes.\r\n * @param {string} input - input string to be encoded\r\n * @returns {string} encoded string.\r\n */\n\n }, {\n key: \"safeXmlEncode\",\n value: function safeXmlEncode(input) {\n input = input.split(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].xmlCharacters.tagOpener).join(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlCharacters.tagOpener);\n input = input.split(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].xmlCharacters.tagCloser).join(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlCharacters.tagCloser);\n input = input.split(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].xmlCharacters.doubleQuote).join(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlCharacters.doubleQuote);\n input = input.split(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].xmlCharacters.ampersand).join(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlCharacters.ampersand);\n input = input.split(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].xmlCharacters.quote).join(_constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlCharacters.quote);\n return input;\n }\n /**\r\n * Converts special symbols (> 128) to entities and replaces all textual entities by its number entities.\r\n * @param {string} mathml - MathML string containing - or not - special symbols\r\n * @returns {string} MathML with all textual entities replaced.\r\n */\n\n }, {\n key: \"mathMLEntities\",\n value: function mathMLEntities(mathml) {\n var toReturn = '';\n\n for (var i = 0; i < mathml.length; ++i) {\n var character = mathml.charAt(i); // Parsing > 128 characters.\n\n if (mathml.codePointAt(i) > 128) {\n toReturn += '&#' + mathml.codePointAt(i) + ';'; // For UTF-32 characters we need to move the index one position.\n\n if (mathml.codePointAt(i) > 0xffff) {\n i++;\n }\n } else if (character == '&') {\n var end = mathml.indexOf(';', i + 1);\n\n if (end >= 0) {\n var container = document.createElement('span');\n container.innerHTML = mathml.substring(i, end + 1);\n toReturn += '&#' + _util_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].fixedCharCodeAt(container.innerText || container.textContent, 0) + ';';\n i = end;\n } else {\n toReturn += character;\n }\n } else {\n toReturn += character;\n }\n }\n\n return toReturn;\n }\n /**\r\n * Add a custom editor name with the prefix wrs_ to a MathML class attribute.\r\n * @param {string} mathml - a MathML string created with a custom editor, like chemistry.\r\n * @param {string} customEditor - custom editor name.\r\n * @returns {string} MathML string with his class containing the editor toolbar string.\r\n */\n\n }, {\n key: \"addCustomEditorClassAttribute\",\n value: function addCustomEditorClassAttribute(mathml, customEditor) {\n var toReturn = '';\n var start = mathml.indexOf('');\n\n if (mathml.indexOf(\"class\") == -1) {\n // Adding custom editor type.\n toReturn = mathml.substr(start, end) + ' class=\"wrs_' + customEditor + '\">';\n toReturn += mathml.substr(end + 1, mathml.length);\n return toReturn;\n }\n }\n\n return mathml;\n }\n /**\r\n * Remove a custom editor name from the MathML class attribute.\r\n * @param {string} mathml - a MathML string.\r\n * @param {string} customEditor - custom editor name.\r\n * @returns {string} The input MathML without customEditor name in his class.\r\n */\n\n }, {\n key: \"removeCustomEditorClassAttribute\",\n value: function removeCustomEditorClassAttribute(mathml, customEditor) {\n // Discard MathML without the specified class.\n if (mathml.indexOf('class') === -1 || mathml.indexOf('wrs_' + customEditor) === -1) {\n return mathml;\n } // Trivial case: class attribute value equal to editor name. Then\n // class attribute is removed.\n\n\n if (mathml.indexOf('class=\"wrs_' + customEditor + '\"') !== -1) {\n return mathml.replace('class=\"wrs_' + customEditor + '\"', '');\n } // Non Trivial case: class attribute contains editor name.\n\n\n return mathml.replace('wrs_' + customEditor, '');\n }\n /**\r\n * Add annotation tag to mathml without it (mathml comes from LaTeX string)\r\n * @param {string} mathml - MathML code generated by a LaTeX string.\r\n * @param {string} latex - original LaTeX string\r\n * @param {string} withoutLatexTranslate - true if not exists latex translation from mathml. false otherwise.\r\n * @param {string} encoding - encoding attribute.\r\n * @returns {string} MathML containing LaTeX code on annotation tag.\r\n */\n\n }, {\n key: \"insertSemanticsMathml\",\n value: function insertSemanticsMathml(mathml, latex, encoding) {\n // If latex is empty, insert semantics doesn't provide information. We can avoid semantics insertion and return the mathml.\n if (latex == \"\") {\n return mathml;\n }\n\n var firstEndTag = '>';\n var mathTagEnd = '<' + '/math' + '>';\n var openSemantics = '<' + 'semantics' + '>';\n var closeSemantics = '<' + '/semantics' + '>';\n var openTarget = '';\n var closeTarget = '<' + '/annotation' + '>';\n var mrowOpen = '';\n var mrowClose = '';\n var indexMathBegin = mathml.indexOf(firstEndTag);\n var indexMathEnd = mathml.indexOf(mathTagEnd);\n var mathBeginExists = mathml.substring(mathml.indexOf('<'), mathml.indexOf('>')).indexOf('math');\n\n if (indexMathBegin != -1 && indexMathEnd != -1 && mathBeginExists) {\n var mathmlContent = mathml.substring(indexMathBegin + 1, indexMathEnd);\n\n if (mathmlContent.indexOf(mrowOpen) != 0) {\n var mathmlContentSemantics = openSemantics + mrowOpen + mathmlContent + mrowClose + openTarget + latex + closeTarget + closeSemantics;\n } else {\n var mathmlContentSemantics = openSemantics + mathmlContent + openTarget + latex + closeTarget + closeSemantics;\n }\n\n return mathml.replace(mathmlContent, mathmlContentSemantics);\n } else {\n return mathml;\n }\n }\n /**\r\n * Removes annotation tag to mathml.\r\n * @param {string} mathml - MathML string\r\n * @param {string} encoding - string containing annotation encoding.\r\n * @returns {string} MathML with an annotation tag.\r\n */\n\n }, {\n key: \"removeSemantics\",\n value: function removeSemantics(mathml, encoding) {\n var mathTagEnd = '<' + '/math' + '>';\n var openSemantics = '<' + 'semantics' + '>';\n var openAnnotation = '';\n var mathmlWithoutSemantics = mathml;\n var startSemantics = mathml.indexOf(openSemantics);\n\n if (startSemantics != -1) {\n var startAnnotation = mathml.indexOf(openAnnotation, startSemantics + openSemantics.length);\n\n if (startAnnotation != -1) {\n mathmlWithoutSemantics = mathml.substring(0, startSemantics) + mathml.substring(startSemantics + openSemantics.length, startAnnotation) + mathTagEnd;\n }\n }\n\n return mathmlWithoutSemantics;\n }\n /**\r\n * Transforms all xml mathml ocurrences that contain semantics to the same\r\n * xml mathml ocurrences without semantics.\r\n * @param {string} text - string that can contain xml mathml ocurrences.\r\n * @param {string} [encoding] - encoding name that semantics need to have to be removed.\r\n * 'application/json' by default. 'application/json' removes hand traces.\r\n * @param {Constants} [characters] - Constant object containing xmlCharacters or safeXmlCharacters relation.\r\n * xmlCharacters by default.\r\n * @returns {string} - 'text' with all xml mathml ocurrences without annotation tag.\r\n */\n\n }, {\n key: \"removeSemanticsOcurrences\",\n value: function removeSemanticsOcurrences(text) {\n var characters = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _constants_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].xmlCharacters;\n var encoding = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'application/json';\n var mathTagStart = characters.tagOpener + 'math';\n var mathTagEnd = characters.tagOpener + '/math' + characters.tagCloser;\n var mathTagEndline = '/' + characters.tagCloser;\n var tagCloser = characters.tagCloser;\n var semanticsTagStart = characters.tagOpener + 'semantics' + characters.tagCloser;\n var annotationTagStart = characters.tagOpener + 'annotation encoding=' + characters.doubleQuote + encoding + characters.doubleQuote + characters.tagCloser;\n var output = '';\n var start = text.indexOf(mathTagStart);\n var end = 0;\n\n while (start !== -1) {\n output += text.substring(end, start); // MathML can be written as '' or ''.\n\n var mathTagEndIndex = text.indexOf(mathTagEnd, start);\n var mathTagEndlineIndex = text.indexOf(mathTagEndline, start);\n var firstTagCloser = text.indexOf(tagCloser, start);\n\n if (mathTagEndIndex !== -1) {\n end = mathTagEndIndex;\n } else if (mathTagEndlineIndex === firstTagCloser - 1) {\n end = mathTagEndlineIndex;\n }\n\n var semanticsIndex = text.indexOf(semanticsTagStart, start);\n\n if (semanticsIndex !== -1) {\n var mmlTagStart = text.substring(start, semanticsIndex);\n var annotationIndex = text.indexOf(annotationTagStart, start);\n\n if (annotationIndex !== -1) {\n var mmlContent = text.substring(semanticsIndex + semanticsTagStart.length, annotationIndex);\n output += mmlTagStart + mmlContent + mathTagEnd;\n start = text.indexOf(mathTagStart, start + mathTagStart.length);\n end += mathTagEnd.length;\n } else {\n end = start;\n start = text.indexOf(mathTagStart, start + mathTagStart.length);\n }\n } else {\n end = start;\n start = text.indexOf(mathTagStart, start + mathTagStart.length);\n }\n }\n\n output += text.substring(end, text.length);\n return output;\n }\n /**\r\n * Returns true if a MathML contains a certain class.\r\n * @param {string} mathML - input MathML.\r\n * @param {string} className - className.\r\n * @returns {boolean} true if the input MathML contains the input class.\r\n * false otherwise.\r\n * @static\r\n */\n\n }, {\n key: \"containClass\",\n value: function containClass(mathML, className) {\n var classIndex = mathML.indexOf('class');\n\n if (classIndex == -1) {\n return false;\n } else {\n var classTagEndIndex = mathML.indexOf('>', classIndex);\n var classTag = mathML.substring(classIndex, classTagEndIndex);\n\n if (classTag.indexOf(className) != -1) {\n return true;\n } else {\n return false;\n }\n }\n }\n }]);\n\n return MathML;\n}();\n\n\n\n//# sourceURL=webpack:///./core/src/mathml.js?"); /***/ }), @@ -298,7 +298,7 @@ eval("__webpack_require__.r(__webpack_exports__);\nfunction _typeof(obj) { if (t /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"default\", function() { return ModalDialog; });\n/* harmony import */ var _popupmessage_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./popupmessage.js */ \"./core/src/popupmessage.js\");\n/* harmony import */ var _core_src_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./core.src.js */ \"./core/src/core.src.js\");\n/* harmony import */ var _util_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./util.js */ \"./core/src/util.js\");\n/* harmony import */ var _configuration_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./configuration.js */ \"./core/src/configuration.js\");\n/* harmony import */ var _listeners__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./listeners */ \"./core/src/listeners.js\");\n/* harmony import */ var _contentmanager_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./contentmanager.js */ \"./core/src/contentmanager.js\");\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\n\n\n\n\n\n\n/**\r\n * This class represents a modal dialog. The modal dialog admits a ContentManager instance in order\r\n * to manage the content of the dialog.\r\n */\n\nvar ModalDialog =\n/*#__PURE__*/\nfunction () {\n /**\r\n * Modal dialog constructor\r\n * @param {Object} modalDialogAttributes - An object containing all modal dialog attributes.\r\n */\n function ModalDialog(modalDialogAttributes) {\n _classCallCheck(this, ModalDialog);\n\n this.attributes = modalDialogAttributes; // Metrics\n\n var ua = navigator.userAgent.toLowerCase();\n var isAndroid = ua.indexOf(\"android\") > -1;\n var isIOS = ua.indexOf(\"ipad\") > -1 || ua.indexOf(\"iphone\") > -1;\n this.iosSoftkeyboardOpened = false;\n this.iosMeasureUnit = ua.indexOf(\"crios\") == -1 ? \"%\" : \"vh\";\n this.iosDivHeight = \"100\" + this.iosMeasureUnit;\n var deviceWidth = window.outerWidth;\n var deviceHeight = window.outerHeight;\n var landscape = deviceWidth > deviceHeight;\n var portrait = deviceWidth < deviceHeight; // TODO: Detect isMobile without using editor metrics.\n\n var isMobile = landscape && this.attributes.height > deviceHeight || portrait && this.attributes.width > deviceWidth ? true : false; // Obtain number of current instance\n\n this.instanceId = document.getElementsByClassName(\"wrs_modal_dialogContainer\").length; // Device object properties.\n\n this.deviceProperties = {\n orientation: landscape ? 'landscape' : 'portait',\n isAndroid: isAndroid ? true : false,\n isIOS: isIOS ? true : false,\n isMobile: isMobile,\n isDesktop: !isMobile && !isIOS && !isAndroid\n };\n this.properties = {\n created: false,\n state: '',\n previousState: '',\n position: {\n bottom: 0,\n right: 10\n },\n size: {\n height: 338,\n width: 580\n }\n };\n var attributes = {};\n attributes.class = 'wrs_modal_overlay';\n attributes.id = this.getElementId(attributes.class);\n this.overlay = _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].createElement('div', attributes);\n attributes = {};\n attributes.class = 'wrs_modal_title_bar';\n attributes.id = this.getElementId(attributes.class);\n this.titleBar = _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].createElement('div', attributes);\n attributes = {};\n attributes.class = 'wrs_modal_title';\n attributes.id = this.getElementId(attributes.class);\n this.title = _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].createElement('div', attributes);\n this.title.innerHTML = '';\n attributes = {};\n attributes.class = 'wrs_modal_close_button';\n attributes.id = this.getElementId(attributes.class);\n attributes.title = _core_src_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].getStringManager().getString('close');\n this.closeDiv = _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].createElement('a', attributes);\n ;\n this.closeDiv.setAttribute('role', 'button');\n attributes = {};\n attributes.class = 'wrs_modal_stack_button';\n attributes.id = this.getElementId(attributes.class);\n attributes.title = \"Exit full-screen\";\n this.stackDiv = _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].createElement('a', attributes);\n this.stackDiv.setAttribute('role', 'button');\n attributes = {};\n attributes.class = 'wrs_modal_maximize_button';\n attributes.id = this.getElementId(attributes.class);\n attributes.title = _core_src_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].getStringManager().getString('fullscreen');\n this.maximizeDiv = _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].createElement('a', attributes);\n this.maximizeDiv.setAttribute('role', 'button');\n attributes = {};\n attributes.class = 'wrs_modal_minimize_button';\n attributes.id = this.getElementId(attributes.class);\n attributes.title = _core_src_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].getStringManager().getString('minimise');\n this.minimizeDiv = _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].createElement('a', attributes);\n this.minimizeDiv.setAttribute('role', 'button');\n attributes = {};\n attributes.class = 'wrs_modal_dialogContainer';\n attributes.id = this.getElementId(attributes.class);\n this.container = _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].createElement('div', attributes);\n attributes = {};\n attributes.class = 'wrs_modal_wrapper';\n attributes.id = this.getElementId(attributes.class);\n this.wrapper = _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].createElement('div', attributes);\n attributes = {};\n attributes.class = 'wrs_content_container';\n attributes.id = this.getElementId(attributes.class);\n this.contentContainer = _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].createElement('div', attributes);\n attributes = {};\n attributes.class = 'wrs_modal_controls';\n attributes.id = this.getElementId(attributes.class);\n this.controls = _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].createElement('div', attributes);\n attributes = {};\n attributes.class = 'wrs_modal_buttons_container';\n attributes.id = this.getElementId(attributes.class);\n this.buttonContainer = _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].createElement('div', attributes); // Buttons: all button must be created using createSubmitButton method.\n\n this.submitButton = this.createSubmitButton({\n id: this.getElementId('wrs_modal_button_accept'),\n class: 'wrs_modal_button_accept',\n innerHTML: _core_src_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].getStringManager().getString('accept')\n }, this.submitAction.bind(this));\n this.cancelButton = this.createSubmitButton({\n id: this.getElementId('wrs_modal_button_cancel'),\n class: 'wrs_modal_button_cancel',\n innerHTML: _core_src_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].getStringManager().getString('cancel')\n }, this.cancelAction.bind(this));\n this.contentManager = null; // Overlay popup.\n\n var popupStrings = {\n 'cancelString': _core_src_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].getStringManager().getString('cancel'),\n 'submitString': _core_src_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].getStringManager().getString('close'),\n 'message': _core_src_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].getStringManager().getString('close_modal_warning')\n };\n var callbacks = {\n 'closeCallback': function () {\n this.close();\n }.bind(this),\n 'cancelCallback': function () {\n this.focus();\n }.bind(this)\n };\n var popupupProperties = {\n 'overlayElement': this.container,\n 'callbacks': callbacks,\n 'strings': popupStrings\n };\n this.popup = new _popupmessage_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"](popupupProperties);\n /**\r\n * Indicates if directionality of the modal dialog is RTL. false by default.\r\n * @type {boolean}\r\n */\n\n this.rtl = false;\n\n if ('rtl' in this.attributes) {\n this.rtl = this.attributes.rtl;\n }\n }\n /**\r\n * This method sets an ContentManager instance to ModalDialog. ContentManager\r\n * manages the logic of ModalDialog content: submit, update, close and changes.\r\n * @param {ContentManager} contentManager - ContentManager instance.\r\n */\n\n\n _createClass(ModalDialog, [{\n key: \"setContentManager\",\n value: function setContentManager(contentManager) {\n this.contentManager = contentManager;\n }\n /**\r\n * Returns the modal contentElement object.\r\n * @returns {ContentManager} the instance of the ContentManager class.\r\n */\n\n }, {\n key: \"getContentManager\",\n value: function getContentManager() {\n return this.contentManager;\n }\n /**\r\n * This method is called when the modal object has been submitted. Calls\r\n * contentElement submitAction method - if exists - and closes the modal\r\n * object. No logic about the content should be placed here,\r\n * contentElement.submitAction is the responsible of the content logic.\r\n */\n\n }, {\n key: \"submitAction\",\n value: function submitAction() {\n if (typeof this.contentManager.submitAction !== 'undefined') {\n this.contentManager.submitAction();\n }\n\n this.close();\n }\n /**\r\n * This method is called when the modal object has been cancelled. If\r\n * contentElement has implemented hasChanges method, a confirm popup\r\n * will be shown if hasChanges returns true.\r\n */\n\n }, {\n key: \"cancelAction\",\n value: function cancelAction() {\n if (typeof this.contentManager.hasChanges === 'undefined') {\n this.close();\n } else if (!this.contentManager.hasChanges()) {\n this.close();\n } else {\n this.showPopUpMessage();\n }\n }\n /**\r\n * Returns a button element.\r\n * @param {Object} properties - input button properties.\r\n * @param {string} properties.class - input button class.\r\n * @param {string} properties.innerHTML - input button innerHTML.\r\n * @param {Object} callback - callback function associated to click event.\r\n * @returns {HTMLButtonElement} the button element.\r\n *\r\n */\n\n }, {\n key: \"createSubmitButton\",\n value: function createSubmitButton(properties, callback) {\n function SubmitButton(properties, callback) {\n this.element = document.createElement('button');\n this.element.id = properties.id;\n this.element.className = properties.class;\n this.element.innerHTML = properties.innerHTML;\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addEvent(this.element, 'click', callback);\n }\n\n SubmitButton.prototype.getElement = function () {\n return this.element;\n };\n\n return new SubmitButton(properties, callback).getElement();\n }\n /**\r\n * Creates the modal window object inserting a contentElement object.\r\n */\n\n }, {\n key: \"create\",\n value: function create() {\n /*Modal Window Structure\r\n _____________________________________________________________________________________\r\n |wrs_modal_dialog_Container |\r\n | _________________________________________________________________________________ |\r\n | |title_bar minimize_button stack_button close_button | |\r\n | |_______________________________________________________________________________| |\r\n | |wrapper | |\r\n | | _____________________________________________________________________________ | |\r\n | | |content | | |\r\n | | | | | |\r\n | | | | | |\r\n | | |___________________________________________________________________________| | |\r\n | | _____________________________________________________________________________ | |\r\n | | |controls | | |\r\n | | | ___________________________________ | | |\r\n | | | |buttonContainer | | | |\r\n | | | | _______________________________ | | | |\r\n | | | | |button_accept | button_cancel| | | | |\r\n | | | |_|_____________ |______________|_| | | |\r\n | | |___________________________________________________________________________| | |\r\n | |_______________________________________________________________________________| |\r\n |___________________________________________________________________________________|*/\n this.titleBar.appendChild(this.closeDiv);\n this.titleBar.appendChild(this.stackDiv);\n this.titleBar.appendChild(this.maximizeDiv);\n this.titleBar.appendChild(this.minimizeDiv);\n this.titleBar.appendChild(this.title);\n\n if (this.deviceProperties['isDesktop']) {\n this.container.appendChild(this.titleBar);\n }\n\n this.wrapper.appendChild(this.contentContainer);\n this.wrapper.appendChild(this.controls);\n this.controls.appendChild(this.buttonContainer);\n this.buttonContainer.appendChild(this.submitButton);\n this.buttonContainer.appendChild(this.cancelButton);\n this.container.appendChild(this.wrapper); // Check if browser has scrollBar before modal has modified.\n\n this.recalculateScrollBar();\n document.body.appendChild(this.container);\n document.body.appendChild(this.overlay);\n\n if (this.deviceProperties['isDesktop']) {\n // Desktop.\n this.createModalWindowDesktop();\n this.createResizeButtons();\n this.addListeners(); // Maximize window only when the configuration is set and the device is not iOS or Android.\n\n if (_configuration_js__WEBPACK_IMPORTED_MODULE_3__[\"default\"].get('modalWindowFullScreen')) {\n this.maximize();\n }\n } else if (this.deviceProperties['isAndroid']) {\n this.createModalWindowAndroid();\n } else if (this.deviceProperties['isIOS'] && !this.deviceProperties['isMobile']) {\n this.createModalWindowIos();\n }\n\n if (this.contentManager != null) {\n this.contentManager.insert(this);\n }\n\n this.properties.open = true;\n this.properties.created = true; // Checks language directionality.\n\n if (this.isRTL()) {\n this.container.style.right = window.innerWidth - this.scrollbarWidth - this.container.offsetWidth + 'px';\n this.container.className += ' wrs_modal_rtl';\n }\n }\n /**\r\n * Creates a button in the modal object to resize it.\r\n */\n\n }, {\n key: \"createResizeButtons\",\n value: function createResizeButtons() {\n // This is a definition of Resize Button Bottom-Right\n this.resizerBR = document.createElement('div');\n this.resizerBR.className = 'wrs_bottom_right_resizer';\n this.resizerBR.innerHTML = '◢'; // This is a definition of Resize Button Top-Left\n\n this.resizerTL = document.createElement('div');\n this.resizerTL.className = 'wrs_bottom_left_resizer'; // Append resize buttons to modal\n\n this.container.appendChild(this.resizerBR);\n this.titleBar.appendChild(this.resizerTL); // Add events to resize on click and drag\n\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addEvent(this.resizerBR, 'mousedown', this.activateResizeStateBR.bind(this));\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addEvent(this.resizerTL, 'mousedown', this.activateResizeStateTL.bind(this));\n }\n /**\r\n * Initialize variables for Bottom-Right resize button\r\n * @param {MouseEvent} mouseEvent - mouse event.\r\n */\n\n }, {\n key: \"activateResizeStateBR\",\n value: function activateResizeStateBR(mouseEvent) {\n this.initializeResizeProperties(mouseEvent, false);\n }\n /**\r\n * Initialize variables for Top-Left resize button\r\n * @param {MouseEvent} mouseEvent - mouse event.\r\n */\n\n }, {\n key: \"activateResizeStateTL\",\n value: function activateResizeStateTL(mouseEvent) {\n this.initializeResizeProperties(mouseEvent, true);\n }\n /**\r\n * Common method to initialize variables at resize\r\n * @param {MouseEvent} mouseEvent - mouse event.\r\n */\n\n }, {\n key: \"initializeResizeProperties\",\n value: function initializeResizeProperties(mouseEvent, leftOption) {\n // Apply class for disable involuntary select text when drag.\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addClass(document.body, 'wrs_noselect');\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addClass(this.overlay, 'wrs_overlay_active');\n this.resizeDataObject = {\n x: this.eventClient(mouseEvent).X,\n y: this.eventClient(mouseEvent).Y\n }; // Save Initial state of modal to compare on drag and obtain the difference.\n\n this.initialWidth = parseInt(this.container.style.width);\n this.initialHeight = parseInt(this.container.style.height);\n\n if (!leftOption) {\n this.initialRight = parseInt(this.container.style.right);\n this.initialBottom = parseInt(this.container.style.bottom);\n } else {\n this.leftScale = true;\n }\n\n if (!this.initialRight) {\n this.initialRight = 0;\n }\n\n if (!this.initialBottom) {\n this.initialBottom = 0;\n } // Disable mouse events on editor when we start to drag modal.\n\n\n document.body.style['user-select'] = 'none';\n }\n /**\r\n * This method opens the modal window, restoring the previous state, position and metrics,\r\n * if exists. By default the modal object opens in stack mode.\r\n */\n\n }, {\n key: \"open\",\n value: function open() {\n //Removing close class.\n this.removeClass('wrs_closed'); // Hiding keyboard for mobile devices.\n\n if (this.deviceProperties['isIOS'] || this.deviceProperties['isAndroid'] || this.deviceProperties['isMobile']) {\n // Restore scale to 1\n this.restoreWebsiteScale();\n this.blockWebsiteScroll(); // Due to editor wait we need to wait until editor focus.\n\n setTimeout(function () {\n this.hideKeyboard();\n }.bind(this), 400);\n } // New modal window. He need to create the whole object.\n\n\n if (!this.properties.created) {\n this.create();\n } else {\n // Previous state closed. Open method can be called even the previous state is open,\n // for example updating the content of the modal object.\n if (!this.properties.open) {\n this.properties.open = true; // Restoring the previous open state: if the modal object has been closed\n // re-open it should preserve the state and the metrics.\n\n if (!this.deviceProperties.isAndroid && !this.deviceProperties.isIOS) {\n this.restoreState();\n }\n } // Maximize window only when the configuration is set and the device is not iOs or Android.\n\n\n if (this.deviceProperties['isDesktop'] && _configuration_js__WEBPACK_IMPORTED_MODULE_3__[\"default\"].get('modalWindowFullScreen')) {\n this.maximize();\n } // In iOS we need to recalculate the size of the modal object because\n // iOS keyboard is a float div which can overlay the modal object.\n\n\n if (this.deviceProperties['isIOS']) {\n this.iosSoftkeyboardOpened = false;\n this.setContainerHeight(\"100\" + this.iosMeasureUnit);\n }\n }\n\n if (this.contentManager.isEditorLoaded === false) {\n var listener = _listeners__WEBPACK_IMPORTED_MODULE_4__[\"default\"].newListener('onLoad', function () {\n this.contentManager.onOpen(this);\n }.bind(this));\n this.contentManager.addListener(listener);\n } else {\n this.contentManager.onOpen(this);\n }\n }\n /**\r\n * Closes modal window and restores viewport header.\r\n */\n\n }, {\n key: \"close\",\n value: function close() {\n this.removeClass('wrs_maximized');\n this.removeClass('wrs_minimized');\n this.removeClass('wrs_stack');\n this.addClass('wrs_closed');\n this.saveModalProperties();\n this.unblockWebsiteScroll();\n this.properties.open = false;\n }\n /**\r\n * Sets the website scale to one.\r\n */\n\n }, {\n key: \"restoreWebsiteScale\",\n value: function restoreWebsiteScale() {\n var viewportmeta = document.querySelector('meta[name=viewport]'); // Let the equal symbols in order to search and make meta's final content.\n\n var contentAttrsToUpdate = ['initial-scale=', 'minimum-scale=', 'maximum-scale='];\n var contentAttrsValuesToUpdate = ['1.0', '1.0', '1.0'];\n\n var setMetaAttrFunc = function setMetaAttrFunc(viewportelement, contentAttrsToUpdate) {\n var contentAttr = viewportelement.getAttribute('content'); // If it exists, we need to maintain old values and put our values.\n\n if (contentAttr) {\n var attrArray = contentAttr.split(',');\n var finalContentMeta = \"\";\n var oldAttrs = [];\n\n for (var i = 0; i < attrArray.length; i++) {\n var isAttrToUpdate = false;\n var j = 0;\n\n while (!isAttrToUpdate && j < contentAttrsToUpdate.length) {\n if (attrArray[i].indexOf(contentAttrsToUpdate[j])) {\n isAttrToUpdate = true;\n }\n\n j++;\n }\n\n if (!isAttrToUpdate) {\n oldAttrs.push(attrArray[i]);\n }\n }\n\n for (var _i = 0; _i < contentAttrsToUpdate.length; _i++) {\n var attr = contentAttrsToUpdate[_i] + contentAttrsValuesToUpdate[_i];\n finalContentMeta += _i == 0 ? attr : ',' + attr;\n }\n\n for (var _i2 = 0; _i2 < oldAttrs.length; _i2++) {\n finalContentMeta += ',' + oldAttrs[_i2];\n }\n\n viewportelement.setAttribute('content', finalContentMeta);\n viewportelement.setAttribute('content', contentAttr);\n } else {\n viewportelement.setAttribute('content', 'initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0');\n viewportelement.removeAttribute('content');\n }\n };\n\n if (!viewportmeta) {\n viewportmeta = document.createElement('meta');\n document.getElementsByTagName('head')[0].appendChild(viewportmeta);\n setMetaAttrFunc(viewportmeta, contentAttrsToUpdate, contentAttrsValuesToUpdate);\n viewportmeta.remove();\n } else {\n setMetaAttrFunc(viewportmeta, contentAttrsToUpdate, contentAttrsValuesToUpdate);\n }\n }\n /**\r\n * Adds an event to avoid touch scrolling.\r\n */\n\n }, {\n key: \"blockWebsiteScroll\",\n value: function blockWebsiteScroll() {\n document.body.addEventListener('touchmove', this.disableTouchMove, {\n passive: false\n });\n }\n /**\r\n * Removes the event to avoid touch scrolling.\r\n */\n\n }, {\n key: \"unblockWebsiteScroll\",\n value: function unblockWebsiteScroll() {\n document.body.removeEventListener('touchmove', this.disableTouchMove, {\n passive: false\n });\n }\n /**\r\n * Prevents the default event behavior to a MouseEvent.\r\n * @param {MouseEvent} mouseEvent - mouse event.\r\n */\n\n }, {\n key: \"disableTouchMove\",\n value: function disableTouchMove(mouseEvent) {\n mouseEvent.preventDefault();\n }\n /**\r\n * Util function to known if browser is IE11.\r\n * @returns {boolean} true if the browser is IE11. false otherwise.\r\n */\n\n }, {\n key: \"isIE11\",\n value: function isIE11() {\n if (navigator.userAgent.search(\"Msie/\") >= 0 || navigator.userAgent.search(\"Trident/\") >= 0 || navigator.userAgent.search(\"Edge/\") >= 0) {\n return true;\n }\n\n return false;\n }\n /**\r\n * Returns if the current language type is RTL.\r\n * @return {boolean} true if current language is RTL. false otherwise.\r\n */\n\n }, {\n key: \"isRTL\",\n value: function isRTL() {\n if (this.attributes.language == 'ar' || this.attributes.language == 'he') {\n return true;\n } else {\n return this.rtl;\n }\n\n ;\n }\n /**\r\n * Adds a class to all modal ModalDialog DOM elements.\r\n * @param {string} className - class name.\r\n */\n\n }, {\n key: \"addClass\",\n value: function addClass(className) {\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addClass(this.overlay, className);\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addClass(this.titleBar, className);\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addClass(this.overlay, className);\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addClass(this.container, className);\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addClass(this.contentContainer, className);\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addClass(this.stackDiv, className);\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addClass(this.minimizeDiv, className);\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addClass(this.maximizeDiv, className);\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addClass(this.wrapper, className);\n }\n /**\r\n * Remove a class from all modal DOM elements.\r\n * @param {string} className - class name.\r\n */\n\n }, {\n key: \"removeClass\",\n value: function removeClass(className) {\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].removeClass(this.overlay, className);\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].removeClass(this.titleBar, className);\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].removeClass(this.overlay, className);\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].removeClass(this.container, className);\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].removeClass(this.contentContainer, className);\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].removeClass(this.stackDiv, className);\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].removeClass(this.minimizeDiv, className);\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].removeClass(this.maximizeDiv, className);\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].removeClass(this.wrapper, className);\n }\n /**\r\n * Create modal dialog for desktop.\r\n */\n\n }, {\n key: \"createModalWindowDesktop\",\n value: function createModalWindowDesktop() {\n this.addClass('wrs_modal_desktop');\n this.stack();\n }\n /**\r\n * Create modal dialog for non android devices.\r\n */\n\n }, {\n key: \"createModalWindowAndroid\",\n value: function createModalWindowAndroid() {\n this.addClass('wrs_modal_android');\n window.addEventListener('resize', this.orientationChangeAndroidSoftkeyboard.bind(this));\n }\n /**\r\n * Create modal dialog for iOS devices.\r\n */\n\n }, {\n key: \"createModalWindowIos\",\n value: function createModalWindowIos() {\n this.addClass('wrs_modal_ios'); // Refresh the size when the orientation is changed\n\n window.addEventListener('resize', this.orientationChangeIosSoftkeyboard.bind(this));\n }\n /**\r\n * Restore previous state, position and size of previous stacked modal dialog.\r\n */\n\n }, {\n key: \"restoreState\",\n value: function restoreState() {\n if (this.properties.state == 'maximized') {\n // Reset states for prevent return to stack state.\n this.maximize();\n } else if (this.properties.state == 'minimized') {\n // Reset states for prevent return to stack state.\n this.properties.state = this.properties.previousState;\n this.properties.previousState = '';\n this.minimize();\n } else {\n this.stack();\n }\n }\n /**\r\n * Stacks the modal object.\r\n */\n\n }, {\n key: \"stack\",\n value: function stack() {\n this.properties.previousState = this.properties.state;\n this.properties.state = 'stack';\n this.removeClass('wrs_maximized');\n this.minimizeDiv.title = \"Minimise\";\n this.removeClass('wrs_minimized');\n this.addClass('wrs_stack');\n this.restoreModalProperties();\n\n if (typeof this.resizerBR !== 'undefined' && typeof this.resizerTL !== 'undefined') {\n this.setResizeButtonsVisibility();\n } // Need recalculate position of actual modal because window can was changed in fullscreenmode\n\n\n this.recalculateScrollBar();\n this.recalculatePosition();\n this.recalculateScale();\n this.focus();\n }\n /**\r\n * Minimizes the modal object\r\n */\n\n }, {\n key: \"minimize\",\n value: function minimize() {\n // Saving width, height, top and bottom parameters to restore when open\n this.saveModalProperties();\n\n if (this.properties.state == 'minimized' && this.properties.previousState == 'stack') {\n this.stack();\n } else if (this.properties.state == 'minimized' && this.properties.previousState == 'maximized') {\n this.maximize();\n } else {\n // Setting css to prevent important tag into css style\n this.container.style.height = \"30px\";\n this.container.style.width = \"250px\";\n this.container.style.bottom = \"0px\";\n this.container.style.right = \"10px\";\n this.removeListeners();\n this.properties.previousState = this.properties.state;\n this.properties.state = \"minimized\";\n this.setResizeButtonsVisibility();\n this.minimizeDiv.title = \"Maximise\";\n\n if (_util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].containsClass(this.overlay, 'wrs_stack')) {\n this.removeClass('wrs_stack');\n } else {\n this.removeClass('wrs_maximized');\n }\n\n this.addClass('wrs_minimized');\n }\n }\n /**\r\n * Maximizes the modal object.\r\n */\n\n }, {\n key: \"maximize\",\n value: function maximize() {\n // Saving width, height, top and bottom parameters to restore when open\n this.saveModalProperties();\n\n if (this.properties.state != 'maximized') {\n this.properties.previousState = this.properties.state;\n this.properties.state = 'maximized';\n } // Don't permit resize on maximize mode.\n\n\n this.setResizeButtonsVisibility();\n\n if (_util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].containsClass(this.overlay, 'wrs_minimized')) {\n this.minimizeDiv.title = \"Minimise\";\n this.removeClass('wrs_minimized');\n } else if (_util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].containsClass(this.overlay, 'wrs_stack')) {\n this.container.style.left = null;\n this.container.style.top = null;\n this.removeClass('wrs_stack');\n }\n\n this.addClass('wrs_maximized'); // Set size to 80% screen with a max size.\n\n this.setSize(parseInt(window.innerHeight * 0.8), parseInt(window.innerWidth * 0.8));\n var sizeModificated = false;\n\n if (this.container.clientHeight > 700) {\n this.container.style.height = '700px';\n sizeModificated = true;\n }\n\n if (this.container.clientWidth > 1200) {\n this.container.style.width = '1200px';\n sizeModificated = true;\n } // Setting modal position in center on screen.\n\n\n this.setPosition(window.innerHeight / 2 - this.container.offsetHeight / 2, window.innerWidth / 2 - this.container.offsetWidth / 2);\n this.recalculateScale();\n this.recalculatePosition();\n this.recalculateSize();\n this.focus();\n }\n /**\r\n * Sets modal size.\r\n * @param {number} height - height of the ModalDialog\r\n * @param {number} width - width of the ModalDialog.\r\n */\n\n }, {\n key: \"setSize\",\n value: function setSize(height, width) {\n this.container.style.height = height + 'px';\n this.container.style.width = width + 'px';\n this.recalculateSize();\n }\n /**\r\n * Sets modal position using bottom and right style attributes.\r\n * @param {number} bottom - bottom attribute.\r\n * @param {number} right - right attribute.\r\n */\n\n }, {\n key: \"setPosition\",\n value: function setPosition(bottom, right) {\n this.container.style.bottom = bottom + 'px';\n this.container.style.right = right + 'px';\n }\n /**\r\n * Saves position and size parameters of and open ModalDialog. This attributes\r\n * are needed to restore it on re-open.\r\n */\n\n }, {\n key: \"saveModalProperties\",\n value: function saveModalProperties() {\n // Saving values of modal only when modal is in stack state.\n if (this.properties.state == 'stack') {\n this.properties.position.bottom = parseInt(this.container.style.bottom);\n this.properties.position.right = parseInt(this.container.style.right);\n this.properties.size.width = parseInt(this.container.style.width);\n this.properties.size.height = parseInt(this.container.style.height);\n }\n }\n /**\r\n * Restore ModalDialog position and size parameters.\r\n */\n\n }, {\n key: \"restoreModalProperties\",\n value: function restoreModalProperties() {\n if (this.properties.state == 'stack') {\n // Restoring Bottom and Right values from last modal\n this.setPosition(this.properties.position.bottom, this.properties.position.right); // Restoring Height and Left values from last modal\n\n this.setSize(this.properties.size.height, this.properties.size.width);\n }\n }\n /**\r\n * Sets the modal dialog initial size.\r\n */\n\n }, {\n key: \"recalculateSize\",\n value: function recalculateSize() {\n this.wrapper.style.width = this.container.clientWidth - 12 + 'px';\n this.wrapper.style.height = this.container.clientHeight - 38 + 'px';\n this.contentContainer.style.height = parseInt(this.wrapper.offsetHeight - 50) + 'px';\n }\n /**\r\n * Enable or disable visibility of resize buttons in modal window depend on state.\r\n */\n\n }, {\n key: \"setResizeButtonsVisibility\",\n value: function setResizeButtonsVisibility() {\n if (this.properties.state == 'stack') {\n this.resizerTL.style.visibility = 'visible';\n this.resizerBR.style.visibility = 'visible';\n } else {\n this.resizerTL.style.visibility = 'hidden';\n this.resizerBR.style.visibility = 'hidden';\n }\n }\n /**\r\n * Makes an object draggable adding mouse and touch events.\r\n */\n\n }, {\n key: \"addListeners\",\n value: function addListeners() {\n // Button events (maximize, minimize, stack and close).\n this.maximizeDiv.addEventListener('click', this.maximize.bind(this), true);\n this.stackDiv.addEventListener('click', this.stack.bind(this), true);\n this.minimizeDiv.addEventListener('click', this.minimize.bind(this), true);\n this.closeDiv.addEventListener('click', this.cancelAction.bind(this)); // Mouse events.\n\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addEvent(window, 'mousedown', this.startDrag.bind(this));\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addEvent(window, 'mouseup', this.stopDrag.bind(this));\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addEvent(window, 'mousemove', this.drag.bind(this));\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addEvent(window, 'resize', this.onWindowResize.bind(this)); // Key events.\n\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addEvent(window, 'keydown', this.onKeyDown.bind(this));\n }\n /**\r\n * Removes draggable events from an object.\r\n */\n\n }, {\n key: \"removeListeners\",\n value: function removeListeners() {\n // Mouse events.\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].removeEvent(window, 'mousedown', this.startDrag);\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].removeEvent(window, 'mouseup', this.stopDrag);\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].removeEvent(window, 'mousemove', this.drag);\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].removeEvent(window, 'resize', this.onWindowResize); // Key events\n\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].removeEvent(window, 'keydown', this.onKeyDown);\n }\n /**\r\n * Returns mouse or touch coordinates (on touch events ev.ClientX doesn't exists)\r\n * @param {MouseEvent} mouseEvent - mouse event.\r\n * @return {Object} with the X and Y coordinates.\r\n */\n\n }, {\n key: \"eventClient\",\n value: function eventClient(mouseEvent) {\n if (typeof mouseEvent.clientX == 'undefined' && mouseEvent.changedTouches) {\n var client = {\n X: mouseEvent.changedTouches[0].clientX,\n Y: mouseEvent.changedTouches[0].clientY\n };\n return client;\n } else {\n client = {\n X: mouseEvent.clientX,\n Y: mouseEvent.clientY\n };\n return client;\n }\n }\n /**\r\n * Start drag function: set the object dragDataObject with the draggable object offsets coordinates.\r\n * when drag starts (on touchstart or mousedown events).\r\n * @param {MouseEvent} mouseEvent - touchstart or mousedown event.\r\n */\n\n }, {\n key: \"startDrag\",\n value: function startDrag(mouseEvent) {\n if (this.properties.state == 'minimized') {\n return;\n }\n\n if (mouseEvent.target === this.title) {\n if (typeof this.dragDataObject === 'undefined' || this.dragDataObject === null) {\n mouseEvent = mouseEvent || event; // Save first click mouse point on screen\n\n this.dragDataObject = {\n x: this.eventClient(mouseEvent).X,\n y: this.eventClient(mouseEvent).Y\n }; // Reset last drag position when start drag\n\n this.lastDrag = {\n x: \"0px\",\n y: \"0px\"\n }; // Init right and bottom values for window modal if it isn't exist.\n\n if (this.container.style.right == '') {\n this.container.style.right = \"0px\";\n }\n\n if (this.container.style.bottom == '') {\n this.container.style.bottom = \"0px\";\n } // Needed for IE11 for apply disabled mouse events on editor because iexplorer need a dinamic object to apply this property.\n\n\n if (this.isIE11()) {} // this.iframe.style['position'] = 'relative';\n // Apply class for disable involuntary select text when drag.\n\n\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addClass(document.body, 'wrs_noselect');\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addClass(this.overlay, 'wrs_overlay_active'); // Obtain screen limits for prevent overflow.\n\n this.limitWindow = this.getLimitWindow();\n }\n }\n }\n /**\r\n * Updates dragDataObject with the draggable object coordinates when the draggable object is being moved.\r\n * @param {MouseEvent} mouseEvent - the mouse event.\r\n */\n\n }, {\n key: \"drag\",\n value: function drag(mouseEvent) {\n if (this.dragDataObject) {\n mouseEvent.preventDefault();\n mouseEvent = mouseEvent || event; // Calculate max and min between actual mouse position and limit of screeen. It restric the movement of modal into window.\n\n var limitY = Math.min(this.eventClient(mouseEvent).Y, this.limitWindow.minPointer.y);\n limitY = Math.max(this.limitWindow.maxPointer.y, limitY);\n var limitX = Math.min(this.eventClient(mouseEvent).X, this.limitWindow.minPointer.x);\n limitX = Math.max(this.limitWindow.maxPointer.x, limitX); // Substract limit with first position to obtain relative pixels increment to the anchor point.\n\n var dragX = limitX - this.dragDataObject.x + \"px\";\n var dragY = limitY - this.dragDataObject.y + \"px\"; // Save last valid position of modal before window overflow.\n\n this.lastDrag = {\n x: dragX,\n y: dragY\n }; // This move modal with hadware acceleration.\n\n this.container.style.transform = \"translate3d(\" + dragX + \",\" + dragY + \",0)\";\n }\n\n if (this.resizeDataObject) {\n var limitX = Math.min(this.eventClient(mouseEvent).X, window.innerWidth - this.scrollbarWidth - 7);\n var limitY = Math.min(this.eventClient(mouseEvent).Y, window.innerHeight - 7);\n\n if (limitX < 0) {\n limitX = 0;\n }\n\n if (limitY < 0) {\n limitY = 0;\n }\n\n var scaleMultiplier;\n\n if (this.leftScale) {\n scaleMultiplier = -1;\n } else {\n scaleMultiplier = 1;\n }\n\n this.container.style.width = this.initialWidth + scaleMultiplier * (limitX - this.resizeDataObject.x) + 'px';\n this.container.style.height = this.initialHeight + scaleMultiplier * (limitY - this.resizeDataObject.y) + 'px';\n\n if (!this.leftScale) {\n if (this.resizeDataObject.x - limitX - this.initialWidth < -580) {\n this.container.style.right = this.initialRight - (limitX - this.resizeDataObject.x) + 'px';\n } else {\n this.container.style.right = this.initialRight + this.initialWidth - 580 + \"px\";\n this.container.style.width = \"580px\";\n }\n\n if (this.resizeDataObject.y - limitY < this.initialHeight - 338) {\n this.container.style.bottom = this.initialBottom - (limitY - this.resizeDataObject.y) + 'px';\n } else {\n this.container.style.bottom = this.initialBottom + this.initialHeight - 338 + \"px\";\n this.container.style.height = \"338px\";\n }\n }\n\n this.recalculateScale();\n this.recalculatePosition();\n }\n }\n /**\r\n * Returns the boundaries of actual window to limit modal movement.\r\n * @return {Object} Object containing mouseX and mouseY coordinates of actual mouse on screen.\r\n */\n\n }, {\n key: \"getLimitWindow\",\n value: function getLimitWindow() {\n // Obtain dimensions of window page.\n var maxWidth = window.innerWidth;\n var maxHeight = window.innerHeight; // Calculate relative position of mouse point into window.\n\n var offSetToolbarY = this.container.offsetHeight + parseInt(this.container.style.bottom) - (maxHeight - (this.dragDataObject.y - window.pageXOffset));\n var offSetToolbarX = maxWidth - this.scrollbarWidth - (this.dragDataObject.x - window.pageXOffset) - parseInt(this.container.style.right); // Calculate limits with sizes of window, modal and mouse position.\n\n var minPointerY = maxHeight - this.container.offsetHeight + offSetToolbarY;\n var maxPointerY = this.title.offsetHeight - (this.title.offsetHeight - offSetToolbarY);\n var minPointerX = maxWidth - offSetToolbarX - this.scrollbarWidth;\n var maxPointerX = this.container.offsetWidth - offSetToolbarX;\n var minPointer = {\n x: minPointerX,\n y: minPointerY\n };\n var maxPointer = {\n x: maxPointerX,\n y: maxPointerY\n };\n return {\n minPointer: minPointer,\n maxPointer: maxPointer\n };\n }\n /**\r\n * Returns the scrollbar width size of browser\r\n * @returns {number} the scrollbar width.\r\n */\n\n }, {\n key: \"getScrollBarWidth\",\n value: function getScrollBarWidth() {\n // Create a paragraph with full width of page.\n var inner = document.createElement('p');\n inner.style.width = \"100%\";\n inner.style.height = \"200px\"; // Create a hidden div to compare sizes.\n\n var outer = document.createElement('div');\n outer.style.position = \"absolute\";\n outer.style.top = \"0px\";\n outer.style.left = \"0px\";\n outer.style.visibility = \"hidden\";\n outer.style.width = \"200px\";\n outer.style.height = \"150px\";\n outer.style.overflow = \"hidden\";\n outer.appendChild(inner);\n document.body.appendChild(outer);\n var widthOuter = inner.offsetWidth; // Change type overflow of paragraph for measure scrollbar.\n\n outer.style.overflow = 'scroll';\n var widthInner = inner.offsetWidth; // If measure is the same, we compare with internal div.\n\n if (widthOuter == widthInner) {\n widthInner = outer.clientWidth;\n }\n\n document.body.removeChild(outer);\n return widthOuter - widthInner;\n }\n /**\r\n * Set the dragDataObject to null.\r\n */\n\n }, {\n key: \"stopDrag\",\n value: function stopDrag() {\n // Due to we have multiple events that call this function, we need only to execute the next modifiers one time,\n // when the user stops to drag and dragDataObject is not null (the object to drag is attached).\n if (this.dragDataObject || this.resizeDataObject) {\n // If modal doesn't change, it's not necessary to set position with interpolation\n this.container.style.transform = '';\n\n if (this.dragDataObject) {\n this.container.style.right = parseInt(this.container.style.right) - parseInt(this.lastDrag.x) + \"px\";\n this.container.style.bottom = parseInt(this.container.style.bottom) - parseInt(this.lastDrag.y) + \"px\";\n } // We make focus on editor after drag modal windows to prevent lose focus.\n\n\n this.focus(); // Restore mouse events on iframe\n // this.iframe.style['pointer-events'] = 'auto';\n\n document.body.style['user-select'] = ''; // Restore static state of iframe if we use Internet Explorer.\n\n if (this.isIE11()) {} // this.iframe.style['position'] = null;\n // Active text select event\n\n\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].removeClass(document.body, 'wrs_noselect');\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].removeClass(this.overlay, 'wrs_overlay_active');\n }\n\n this.dragDataObject = null;\n this.resizeDataObject = null;\n this.initialWidth = null;\n this.leftScale = null;\n }\n /**\r\n * Recalculates scale for modal when resize browser window.\r\n */\n\n }, {\n key: \"onWindowResize\",\n value: function onWindowResize() {\n this.recalculateScrollBar();\n this.recalculatePosition();\n this.recalculateScale();\n }\n /**\r\n * Triggers keyboard events:\r\n * - Tab key tab to go to submit button.\r\n * - Esc key to close the modal dialog.\r\n * @param {KeyboardEvent} keyboardEvent - the keyboard event.\r\n */\n\n }, {\n key: \"onKeyDown\",\n value: function onKeyDown(keyboardEvent) {\n if (keyboardEvent.key !== undefined && keyboardEvent.repeat === false) {\n // Code for detect Esc event\n if (keyboardEvent.key === \"Escape\" || keyboardEvent.key === 'Esc') {\n if (this.properties.open) {\n this.cancelAction();\n }\n } // Code for detect Tab event\n\n\n if (keyboardEvent.key === \"Tab\") {\n this.submitButton.focus();\n keyboardEvent.preventDefault();\n }\n }\n }\n /**\r\n * Recalculating position for modal dialog when the browser is resized.\r\n */\n\n }, {\n key: \"recalculatePosition\",\n value: function recalculatePosition() {\n this.container.style.right = Math.min(parseInt(this.container.style.right), window.innerWidth - this.scrollbarWidth - this.container.offsetWidth) + \"px\";\n\n if (parseInt(this.container.style.right) < 0) {\n this.container.style.right = \"0px\";\n }\n\n this.container.style.bottom = Math.min(parseInt(this.container.style.bottom), window.innerHeight - this.container.offsetHeight) + \"px\";\n\n if (parseInt(this.container.style.bottom) < 0) {\n this.container.style.bottom = \"0px\";\n }\n }\n /**\r\n * Recalculating scale for modal when the browser is resized.\r\n */\n\n }, {\n key: \"recalculateScale\",\n value: function recalculateScale() {\n var sizeModificated = false;\n\n if (parseInt(this.container.style.width) > 580) {\n this.container.style.width = Math.min(parseInt(this.container.style.width), window.innerWidth - this.scrollbarWidth) + \"px\";\n sizeModificated = true;\n } else {\n this.container.style.width = \"580px\";\n sizeModificated = true;\n }\n\n if (parseInt(this.container.style.height) > 338) {\n this.container.style.height = Math.min(parseInt(this.container.style.height), window.innerHeight) + \"px\";\n sizeModificated = true;\n } else {\n this.container.style.height = \"338px\";\n sizeModificated = true;\n }\n\n if (sizeModificated) {\n this.recalculateSize();\n }\n }\n /**\r\n * Recalculating width of browser scroll bar.\r\n */\n\n }, {\n key: \"recalculateScrollBar\",\n value: function recalculateScrollBar() {\n this.hasScrollBar = window.innerWidth > document.documentElement.clientWidth;\n\n if (this.hasScrollBar) {\n this.scrollbarWidth = this.getScrollBarWidth();\n } else {\n this.scrollbarWidth = 0;\n }\n }\n /**\r\n * Hide soft keyboards on iOS devices.\r\n */\n\n }, {\n key: \"hideKeyboard\",\n value: function hideKeyboard() {\n document.activeElement.blur();\n }\n /**\r\n * Focus to contentManager object.\r\n */\n\n }, {\n key: \"focus\",\n value: function focus() {\n if (this.contentManager != null && typeof this.contentManager.onFocus !== 'undefined') {\n this.contentManager.onFocus();\n }\n }\n /**\r\n * Returns true when the device is on portrait mode.\r\n */\n\n }, {\n key: \"portraitMode\",\n value: function portraitMode() {\n return window.innerHeight > window.innerWidth;\n }\n /**\r\n * Change container sizes when the keyboard is opened on iOS.\r\n */\n\n }, {\n key: \"openedIosSoftkeyboard\",\n value: function openedIosSoftkeyboard() {\n if (!this.iosSoftkeyboardOpened && this.iosDivHeight != null && this.iosDivHeight == \"100\" + this.iosMeasureUnit) {\n if (this.portraitMode()) {\n this.setContainerHeight(\"63\" + this.iosMeasureUnit);\n } else {\n this.setContainerHeight(\"40\" + this.iosMeasureUnit);\n }\n }\n\n this.iosSoftkeyboardOpened = true;\n }\n /**\r\n * Change container sizes when the keyboard is closed on iOS.\r\n */\n\n }, {\n key: \"closedIosSoftkeyboard\",\n value: function closedIosSoftkeyboard() {\n this.iosSoftkeyboardOpened = false;\n this.setContainerHeight(\"100\" + this.iosMeasureUnit);\n }\n /**\r\n * Change container sizes when orientation is changed on iOS.\r\n */\n\n }, {\n key: \"orientationChangeIosSoftkeyboard\",\n value: function orientationChangeIosSoftkeyboard() {\n if (this.iosSoftkeyboardOpened) {\n if (this.portraitMode()) {\n this.setContainerHeight(\"63\" + this.iosMeasureUnit);\n } else {\n this.setContainerHeight(\"40\" + this.iosMeasureUnit);\n }\n } else {\n this.setContainerHeight(\"100\" + this.iosMeasureUnit);\n }\n }\n /**\r\n * Change container sizes when orientation is changed on Android.\r\n */\n\n }, {\n key: \"orientationChangeAndroidSoftkeyboard\",\n value: function orientationChangeAndroidSoftkeyboard() {\n this.setContainerHeight(\"100%\");\n }\n /**\r\n * Set iframe container height.\r\n * @param {number} height - new height.\r\n */\n\n }, {\n key: \"setContainerHeight\",\n value: function setContainerHeight(height) {\n this.iosDivHeight = height;\n this.wrapper.style.height = height;\n }\n /**\r\n * Check content of editor before close action.\r\n */\n\n }, {\n key: \"showPopUpMessage\",\n value: function showPopUpMessage() {\n if (this.properties.state == 'minimized') {\n this.stack();\n }\n\n this.popup.show();\n }\n /**\r\n * Sets the tithle of the modal dialog.\r\n * @param {string} title - modal dialog title.\r\n */\n\n }, {\n key: \"setTitle\",\n value: function setTitle(title) {\n this.title.innerHTML = title;\n }\n /**\r\n * Returns the id of an element, adding the instance number to\r\n * the element class name:\r\n * className --> className[idNumber]\r\n * @param {string} className - the element class name.\r\n * @returns {string} a string appending the instance id to the className.\r\n */\n\n }, {\n key: \"getElementId\",\n value: function getElementId(className) {\n return className + \"[\" + this.instanceId + \"]\";\n }\n }]);\n\n return ModalDialog;\n}();\n\n\n\n//# sourceURL=webpack:///./core/src/modal.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"default\", function() { return ModalDialog; });\n/* harmony import */ var _popupmessage_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./popupmessage.js */ \"./core/src/popupmessage.js\");\n/* harmony import */ var _core_src_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./core.src.js */ \"./core/src/core.src.js\");\n/* harmony import */ var _util_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./util.js */ \"./core/src/util.js\");\n/* harmony import */ var _configuration_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./configuration.js */ \"./core/src/configuration.js\");\n/* harmony import */ var _listeners__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./listeners */ \"./core/src/listeners.js\");\n/* harmony import */ var _contentmanager_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./contentmanager.js */ \"./core/src/contentmanager.js\");\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\n\n\n\n\n\n\n/**\r\n * This class represents a modal dialog. The modal dialog admits a ContentManager instance in order\r\n * to manage the content of the dialog.\r\n */\n\nvar ModalDialog =\n/*#__PURE__*/\nfunction () {\n /**\r\n * Modal dialog constructor\r\n * @param {Object} modalDialogAttributes - An object containing all modal dialog attributes.\r\n */\n function ModalDialog(modalDialogAttributes) {\n _classCallCheck(this, ModalDialog);\n\n this.attributes = modalDialogAttributes; // Metrics\n\n var ua = navigator.userAgent.toLowerCase();\n var isAndroid = ua.indexOf(\"android\") > -1;\n var isIOS = ua.indexOf(\"ipad\") > -1 || ua.indexOf(\"iphone\") > -1;\n this.iosSoftkeyboardOpened = false;\n this.iosMeasureUnit = ua.indexOf(\"crios\") == -1 ? \"%\" : \"vh\";\n this.iosDivHeight = \"100\" + this.iosMeasureUnit;\n var deviceWidth = window.outerWidth;\n var deviceHeight = window.outerHeight;\n var landscape = deviceWidth > deviceHeight;\n var portrait = deviceWidth < deviceHeight; // TODO: Detect isMobile without using editor metrics.\n\n var isMobile = landscape && this.attributes.height > deviceHeight || portrait && this.attributes.width > deviceWidth ? true : false; // Obtain number of current instance\n\n this.instanceId = document.getElementsByClassName(\"wrs_modal_dialogContainer\").length; // Device object properties.\n\n this.deviceProperties = {\n orientation: landscape ? 'landscape' : 'portait',\n isAndroid: isAndroid ? true : false,\n isIOS: isIOS ? true : false,\n isMobile: isMobile,\n isDesktop: !isMobile && !isIOS && !isAndroid\n };\n this.properties = {\n created: false,\n state: '',\n previousState: '',\n position: {\n bottom: 0,\n right: 10\n },\n size: {\n height: 338,\n width: 580\n }\n };\n var attributes = {};\n attributes.class = 'wrs_modal_overlay';\n attributes.id = this.getElementId(attributes.class);\n this.overlay = _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].createElement('div', attributes);\n attributes = {};\n attributes.class = 'wrs_modal_title_bar';\n attributes.id = this.getElementId(attributes.class);\n this.titleBar = _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].createElement('div', attributes);\n attributes = {};\n attributes.class = 'wrs_modal_title';\n attributes.id = this.getElementId(attributes.class);\n this.title = _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].createElement('div', attributes);\n this.title.innerHTML = '';\n attributes = {};\n attributes.class = 'wrs_modal_close_button';\n attributes.id = this.getElementId(attributes.class);\n attributes.title = _core_src_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].getStringManager().getString('close');\n this.closeDiv = _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].createElement('a', attributes);\n ;\n this.closeDiv.setAttribute('role', 'button');\n attributes = {};\n attributes.class = 'wrs_modal_stack_button';\n attributes.id = this.getElementId(attributes.class);\n attributes.title = \"Exit full-screen\";\n this.stackDiv = _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].createElement('a', attributes);\n this.stackDiv.setAttribute('role', 'button');\n attributes = {};\n attributes.class = 'wrs_modal_maximize_button';\n attributes.id = this.getElementId(attributes.class);\n attributes.title = _core_src_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].getStringManager().getString('fullscreen');\n this.maximizeDiv = _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].createElement('a', attributes);\n this.maximizeDiv.setAttribute('role', 'button');\n attributes = {};\n attributes.class = 'wrs_modal_minimize_button';\n attributes.id = this.getElementId(attributes.class);\n attributes.title = _core_src_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].getStringManager().getString('minimise');\n this.minimizeDiv = _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].createElement('a', attributes);\n this.minimizeDiv.setAttribute('role', 'button');\n attributes = {};\n attributes.class = 'wrs_modal_dialogContainer';\n attributes.id = this.getElementId(attributes.class);\n this.container = _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].createElement('div', attributes);\n attributes = {};\n attributes.class = 'wrs_modal_wrapper';\n attributes.id = this.getElementId(attributes.class);\n this.wrapper = _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].createElement('div', attributes);\n attributes = {};\n attributes.class = 'wrs_content_container';\n attributes.id = this.getElementId(attributes.class);\n this.contentContainer = _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].createElement('div', attributes);\n attributes = {};\n attributes.class = 'wrs_modal_controls';\n attributes.id = this.getElementId(attributes.class);\n this.controls = _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].createElement('div', attributes);\n attributes = {};\n attributes.class = 'wrs_modal_buttons_container';\n attributes.id = this.getElementId(attributes.class);\n this.buttonContainer = _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].createElement('div', attributes); // Buttons: all button must be created using createSubmitButton method.\n\n this.submitButton = this.createSubmitButton({\n id: this.getElementId('wrs_modal_button_accept'),\n class: 'wrs_modal_button_accept',\n innerHTML: _core_src_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].getStringManager().getString('accept')\n }, this.submitAction.bind(this));\n this.cancelButton = this.createSubmitButton({\n id: this.getElementId('wrs_modal_button_cancel'),\n class: 'wrs_modal_button_cancel',\n innerHTML: _core_src_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].getStringManager().getString('cancel')\n }, this.cancelAction.bind(this));\n this.contentManager = null; // Overlay popup.\n\n var popupStrings = {\n 'cancelString': _core_src_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].getStringManager().getString('cancel'),\n 'submitString': _core_src_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].getStringManager().getString('close'),\n 'message': _core_src_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].getStringManager().getString('close_modal_warning')\n };\n var callbacks = {\n 'closeCallback': function () {\n this.close();\n }.bind(this),\n 'cancelCallback': function () {\n this.focus();\n }.bind(this)\n };\n var popupupProperties = {\n 'overlayElement': this.container,\n 'callbacks': callbacks,\n 'strings': popupStrings\n };\n this.popup = new _popupmessage_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"](popupupProperties);\n /**\r\n * Indicates if directionality of the modal dialog is RTL. false by default.\r\n * @type {boolean}\r\n */\n\n this.rtl = false;\n\n if ('rtl' in this.attributes) {\n this.rtl = this.attributes.rtl;\n } // Event handlers need modal instance context.\n\n\n this.handleOpenedIosSoftkeyboard = this.handleOpenedIosSoftkeyboard.bind(this);\n this.handleClosedIosSoftkeyboard = this.handleClosedIosSoftkeyboard.bind(this);\n }\n /**\r\n * This method sets an ContentManager instance to ModalDialog. ContentManager\r\n * manages the logic of ModalDialog content: submit, update, close and changes.\r\n * @param {ContentManager} contentManager - ContentManager instance.\r\n */\n\n\n _createClass(ModalDialog, [{\n key: \"setContentManager\",\n value: function setContentManager(contentManager) {\n this.contentManager = contentManager;\n }\n /**\r\n * Returns the modal contentElement object.\r\n * @returns {ContentManager} the instance of the ContentManager class.\r\n */\n\n }, {\n key: \"getContentManager\",\n value: function getContentManager() {\n return this.contentManager;\n }\n /**\r\n * This method is called when the modal object has been submitted. Calls\r\n * contentElement submitAction method - if exists - and closes the modal\r\n * object. No logic about the content should be placed here,\r\n * contentElement.submitAction is the responsible of the content logic.\r\n */\n\n }, {\n key: \"submitAction\",\n value: function submitAction() {\n if (typeof this.contentManager.submitAction !== 'undefined') {\n this.contentManager.submitAction();\n }\n\n this.close();\n }\n /**\r\n * This method is called when the modal object has been cancelled. If\r\n * contentElement has implemented hasChanges method, a confirm popup\r\n * will be shown if hasChanges returns true.\r\n */\n\n }, {\n key: \"cancelAction\",\n value: function cancelAction() {\n if (typeof this.contentManager.hasChanges === 'undefined') {\n this.close();\n } else if (!this.contentManager.hasChanges()) {\n this.close();\n } else {\n this.showPopUpMessage();\n }\n }\n /**\r\n * Returns a button element.\r\n * @param {Object} properties - input button properties.\r\n * @param {string} properties.class - input button class.\r\n * @param {string} properties.innerHTML - input button innerHTML.\r\n * @param {Object} callback - callback function associated to click event.\r\n * @returns {HTMLButtonElement} the button element.\r\n *\r\n */\n\n }, {\n key: \"createSubmitButton\",\n value: function createSubmitButton(properties, callback) {\n function SubmitButton(properties, callback) {\n this.element = document.createElement('button');\n this.element.id = properties.id;\n this.element.className = properties.class;\n this.element.innerHTML = properties.innerHTML;\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addEvent(this.element, 'click', callback);\n }\n\n SubmitButton.prototype.getElement = function () {\n return this.element;\n };\n\n return new SubmitButton(properties, callback).getElement();\n }\n /**\r\n * Creates the modal window object inserting a contentElement object.\r\n */\n\n }, {\n key: \"create\",\n value: function create() {\n /*Modal Window Structure\r\n _____________________________________________________________________________________\r\n |wrs_modal_dialog_Container |\r\n | _________________________________________________________________________________ |\r\n | |title_bar minimize_button stack_button close_button | |\r\n | |_______________________________________________________________________________| |\r\n | |wrapper | |\r\n | | _____________________________________________________________________________ | |\r\n | | |content | | |\r\n | | | | | |\r\n | | | | | |\r\n | | |___________________________________________________________________________| | |\r\n | | _____________________________________________________________________________ | |\r\n | | |controls | | |\r\n | | | ___________________________________ | | |\r\n | | | |buttonContainer | | | |\r\n | | | | _______________________________ | | | |\r\n | | | | |button_accept | button_cancel| | | | |\r\n | | | |_|_____________ |______________|_| | | |\r\n | | |___________________________________________________________________________| | |\r\n | |_______________________________________________________________________________| |\r\n |___________________________________________________________________________________|*/\n this.titleBar.appendChild(this.closeDiv);\n this.titleBar.appendChild(this.stackDiv);\n this.titleBar.appendChild(this.maximizeDiv);\n this.titleBar.appendChild(this.minimizeDiv);\n this.titleBar.appendChild(this.title);\n\n if (this.deviceProperties['isDesktop']) {\n this.container.appendChild(this.titleBar);\n }\n\n this.wrapper.appendChild(this.contentContainer);\n this.wrapper.appendChild(this.controls);\n this.controls.appendChild(this.buttonContainer);\n this.buttonContainer.appendChild(this.submitButton);\n this.buttonContainer.appendChild(this.cancelButton);\n this.container.appendChild(this.wrapper); // Check if browser has scrollBar before modal has modified.\n\n this.recalculateScrollBar();\n document.body.appendChild(this.container);\n document.body.appendChild(this.overlay);\n\n if (this.deviceProperties['isDesktop']) {\n // Desktop.\n this.createModalWindowDesktop();\n this.createResizeButtons();\n this.addListeners(); // Maximize window only when the configuration is set and the device is not iOS or Android.\n\n if (_configuration_js__WEBPACK_IMPORTED_MODULE_3__[\"default\"].get('modalWindowFullScreen')) {\n this.maximize();\n }\n } else if (this.deviceProperties['isAndroid']) {\n this.createModalWindowAndroid();\n } else if (this.deviceProperties['isIOS'] && !this.deviceProperties['isMobile']) {\n this.createModalWindowIos();\n }\n\n if (this.contentManager != null) {\n this.contentManager.insert(this);\n }\n\n this.properties.open = true;\n this.properties.created = true; // Checks language directionality.\n\n if (this.isRTL()) {\n this.container.style.right = window.innerWidth - this.scrollbarWidth - this.container.offsetWidth + 'px';\n this.container.className += ' wrs_modal_rtl';\n }\n }\n /**\r\n * Creates a button in the modal object to resize it.\r\n */\n\n }, {\n key: \"createResizeButtons\",\n value: function createResizeButtons() {\n // This is a definition of Resize Button Bottom-Right\n this.resizerBR = document.createElement('div');\n this.resizerBR.className = 'wrs_bottom_right_resizer';\n this.resizerBR.innerHTML = '◢'; // This is a definition of Resize Button Top-Left\n\n this.resizerTL = document.createElement('div');\n this.resizerTL.className = 'wrs_bottom_left_resizer'; // Append resize buttons to modal\n\n this.container.appendChild(this.resizerBR);\n this.titleBar.appendChild(this.resizerTL); // Add events to resize on click and drag\n\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addEvent(this.resizerBR, 'mousedown', this.activateResizeStateBR.bind(this));\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addEvent(this.resizerTL, 'mousedown', this.activateResizeStateTL.bind(this));\n }\n /**\r\n * Initialize variables for Bottom-Right resize button\r\n * @param {MouseEvent} mouseEvent - mouse event.\r\n */\n\n }, {\n key: \"activateResizeStateBR\",\n value: function activateResizeStateBR(mouseEvent) {\n this.initializeResizeProperties(mouseEvent, false);\n }\n /**\r\n * Initialize variables for Top-Left resize button\r\n * @param {MouseEvent} mouseEvent - mouse event.\r\n */\n\n }, {\n key: \"activateResizeStateTL\",\n value: function activateResizeStateTL(mouseEvent) {\n this.initializeResizeProperties(mouseEvent, true);\n }\n /**\r\n * Common method to initialize variables at resize\r\n * @param {MouseEvent} mouseEvent - mouse event.\r\n */\n\n }, {\n key: \"initializeResizeProperties\",\n value: function initializeResizeProperties(mouseEvent, leftOption) {\n // Apply class for disable involuntary select text when drag.\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addClass(document.body, 'wrs_noselect');\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addClass(this.overlay, 'wrs_overlay_active');\n this.resizeDataObject = {\n x: this.eventClient(mouseEvent).X,\n y: this.eventClient(mouseEvent).Y\n }; // Save Initial state of modal to compare on drag and obtain the difference.\n\n this.initialWidth = parseInt(this.container.style.width);\n this.initialHeight = parseInt(this.container.style.height);\n\n if (!leftOption) {\n this.initialRight = parseInt(this.container.style.right);\n this.initialBottom = parseInt(this.container.style.bottom);\n } else {\n this.leftScale = true;\n }\n\n if (!this.initialRight) {\n this.initialRight = 0;\n }\n\n if (!this.initialBottom) {\n this.initialBottom = 0;\n } // Disable mouse events on editor when we start to drag modal.\n\n\n document.body.style['user-select'] = 'none';\n }\n /**\r\n * This method opens the modal window, restoring the previous state, position and metrics,\r\n * if exists. By default the modal object opens in stack mode.\r\n */\n\n }, {\n key: \"open\",\n value: function open() {\n //Removing close class.\n this.removeClass('wrs_closed'); // Hiding keyboard for mobile devices.\n\n if (this.deviceProperties['isIOS'] || this.deviceProperties['isAndroid'] || this.deviceProperties['isMobile']) {\n // Restore scale to 1\n this.restoreWebsiteScale();\n this.blockWebsiteScroll(); // Due to editor wait we need to wait until editor focus.\n\n setTimeout(function () {\n this.hideKeyboard();\n }.bind(this), 400);\n } // New modal window. He need to create the whole object.\n\n\n if (!this.properties.created) {\n this.create();\n } else {\n // Previous state closed. Open method can be called even the previous state is open,\n // for example updating the content of the modal object.\n if (!this.properties.open) {\n this.properties.open = true; // Restoring the previous open state: if the modal object has been closed\n // re-open it should preserve the state and the metrics.\n\n if (!this.deviceProperties.isAndroid && !this.deviceProperties.isIOS) {\n this.restoreState();\n }\n } // Maximize window only when the configuration is set and the device is not iOs or Android.\n\n\n if (this.deviceProperties['isDesktop'] && _configuration_js__WEBPACK_IMPORTED_MODULE_3__[\"default\"].get('modalWindowFullScreen')) {\n this.maximize();\n } // In iOS we need to recalculate the size of the modal object because\n // iOS keyboard is a float div which can overlay the modal object.\n\n\n if (this.deviceProperties['isIOS']) {\n this.iosSoftkeyboardOpened = false;\n this.setContainerHeight(\"100\" + this.iosMeasureUnit);\n }\n }\n\n if (this.contentManager.isEditorLoaded === false) {\n var listener = _listeners__WEBPACK_IMPORTED_MODULE_4__[\"default\"].newListener('onLoad', function () {\n this.contentManager.onOpen(this);\n }.bind(this));\n this.contentManager.addListener(listener);\n } else {\n this.contentManager.onOpen(this);\n }\n }\n /**\r\n * Closes modal window and restores viewport header.\r\n */\n\n }, {\n key: \"close\",\n value: function close() {\n this.removeClass('wrs_maximized');\n this.removeClass('wrs_minimized');\n this.removeClass('wrs_stack');\n this.addClass('wrs_closed');\n this.saveModalProperties();\n this.unblockWebsiteScroll();\n this.properties.open = false;\n }\n /**\r\n * Sets the website scale to one.\r\n */\n\n }, {\n key: \"restoreWebsiteScale\",\n value: function restoreWebsiteScale() {\n var viewportmeta = document.querySelector('meta[name=viewport]'); // Let the equal symbols in order to search and make meta's final content.\n\n var contentAttrsToUpdate = ['initial-scale=', 'minimum-scale=', 'maximum-scale='];\n var contentAttrsValuesToUpdate = ['1.0', '1.0', '1.0'];\n\n var setMetaAttrFunc = function setMetaAttrFunc(viewportelement, contentAttrsToUpdate) {\n var contentAttr = viewportelement.getAttribute('content'); // If it exists, we need to maintain old values and put our values.\n\n if (contentAttr) {\n var attrArray = contentAttr.split(',');\n var finalContentMeta = \"\";\n var oldAttrs = [];\n\n for (var i = 0; i < attrArray.length; i++) {\n var isAttrToUpdate = false;\n var j = 0;\n\n while (!isAttrToUpdate && j < contentAttrsToUpdate.length) {\n if (attrArray[i].indexOf(contentAttrsToUpdate[j])) {\n isAttrToUpdate = true;\n }\n\n j++;\n }\n\n if (!isAttrToUpdate) {\n oldAttrs.push(attrArray[i]);\n }\n }\n\n for (var _i = 0; _i < contentAttrsToUpdate.length; _i++) {\n var attr = contentAttrsToUpdate[_i] + contentAttrsValuesToUpdate[_i];\n finalContentMeta += _i == 0 ? attr : ',' + attr;\n }\n\n for (var _i2 = 0; _i2 < oldAttrs.length; _i2++) {\n finalContentMeta += ',' + oldAttrs[_i2];\n }\n\n viewportelement.setAttribute('content', finalContentMeta);\n viewportelement.setAttribute('content', contentAttr);\n } else {\n viewportelement.setAttribute('content', 'initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0');\n viewportelement.removeAttribute('content');\n }\n };\n\n if (!viewportmeta) {\n viewportmeta = document.createElement('meta');\n document.getElementsByTagName('head')[0].appendChild(viewportmeta);\n setMetaAttrFunc(viewportmeta, contentAttrsToUpdate, contentAttrsValuesToUpdate);\n viewportmeta.remove();\n } else {\n setMetaAttrFunc(viewportmeta, contentAttrsToUpdate, contentAttrsValuesToUpdate);\n }\n }\n /**\r\n * Adds an event to avoid touch scrolling.\r\n */\n\n }, {\n key: \"blockWebsiteScroll\",\n value: function blockWebsiteScroll() {\n document.body.addEventListener('touchmove', this.disableTouchMove, {\n passive: false\n });\n }\n /**\r\n * Removes the event to avoid touch scrolling.\r\n */\n\n }, {\n key: \"unblockWebsiteScroll\",\n value: function unblockWebsiteScroll() {\n document.body.removeEventListener('touchmove', this.disableTouchMove, {\n passive: false\n });\n }\n /**\r\n * Prevents the default event behavior to a MouseEvent.\r\n * @param {MouseEvent} mouseEvent - mouse event.\r\n */\n\n }, {\n key: \"disableTouchMove\",\n value: function disableTouchMove(mouseEvent) {\n mouseEvent.preventDefault();\n }\n /**\r\n * Util function to known if browser is IE11.\r\n * @returns {boolean} true if the browser is IE11. false otherwise.\r\n */\n\n }, {\n key: \"isIE11\",\n value: function isIE11() {\n if (navigator.userAgent.search(\"Msie/\") >= 0 || navigator.userAgent.search(\"Trident/\") >= 0 || navigator.userAgent.search(\"Edge/\") >= 0) {\n return true;\n }\n\n return false;\n }\n /**\r\n * Returns if the current language type is RTL.\r\n * @return {boolean} true if current language is RTL. false otherwise.\r\n */\n\n }, {\n key: \"isRTL\",\n value: function isRTL() {\n if (this.attributes.language == 'ar' || this.attributes.language == 'he') {\n return true;\n } else {\n return this.rtl;\n }\n\n ;\n }\n /**\r\n * Adds a class to all modal ModalDialog DOM elements.\r\n * @param {string} className - class name.\r\n */\n\n }, {\n key: \"addClass\",\n value: function addClass(className) {\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addClass(this.overlay, className);\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addClass(this.titleBar, className);\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addClass(this.overlay, className);\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addClass(this.container, className);\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addClass(this.contentContainer, className);\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addClass(this.stackDiv, className);\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addClass(this.minimizeDiv, className);\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addClass(this.maximizeDiv, className);\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addClass(this.wrapper, className);\n }\n /**\r\n * Remove a class from all modal DOM elements.\r\n * @param {string} className - class name.\r\n */\n\n }, {\n key: \"removeClass\",\n value: function removeClass(className) {\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].removeClass(this.overlay, className);\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].removeClass(this.titleBar, className);\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].removeClass(this.overlay, className);\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].removeClass(this.container, className);\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].removeClass(this.contentContainer, className);\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].removeClass(this.stackDiv, className);\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].removeClass(this.minimizeDiv, className);\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].removeClass(this.maximizeDiv, className);\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].removeClass(this.wrapper, className);\n }\n /**\r\n * Create modal dialog for desktop.\r\n */\n\n }, {\n key: \"createModalWindowDesktop\",\n value: function createModalWindowDesktop() {\n this.addClass('wrs_modal_desktop');\n this.stack();\n }\n /**\r\n * Create modal dialog for non android devices.\r\n */\n\n }, {\n key: \"createModalWindowAndroid\",\n value: function createModalWindowAndroid() {\n this.addClass('wrs_modal_android');\n window.addEventListener('resize', this.orientationChangeAndroidSoftkeyboard.bind(this));\n }\n /**\r\n * Create modal dialog for iOS devices.\r\n */\n\n }, {\n key: \"createModalWindowIos\",\n value: function createModalWindowIos() {\n this.addClass('wrs_modal_ios'); // Refresh the size when the orientation is changed\n\n window.addEventListener('resize', this.orientationChangeIosSoftkeyboard.bind(this));\n }\n /**\r\n * Restore previous state, position and size of previous stacked modal dialog.\r\n */\n\n }, {\n key: \"restoreState\",\n value: function restoreState() {\n if (this.properties.state == 'maximized') {\n // Reset states for prevent return to stack state.\n this.maximize();\n } else if (this.properties.state == 'minimized') {\n // Reset states for prevent return to stack state.\n this.properties.state = this.properties.previousState;\n this.properties.previousState = '';\n this.minimize();\n } else {\n this.stack();\n }\n }\n /**\r\n * Stacks the modal object.\r\n */\n\n }, {\n key: \"stack\",\n value: function stack() {\n this.properties.previousState = this.properties.state;\n this.properties.state = 'stack';\n this.removeClass('wrs_maximized');\n this.minimizeDiv.title = \"Minimise\";\n this.removeClass('wrs_minimized');\n this.addClass('wrs_stack');\n this.restoreModalProperties();\n\n if (typeof this.resizerBR !== 'undefined' && typeof this.resizerTL !== 'undefined') {\n this.setResizeButtonsVisibility();\n } // Need recalculate position of actual modal because window can was changed in fullscreenmode\n\n\n this.recalculateScrollBar();\n this.recalculatePosition();\n this.recalculateScale();\n this.focus();\n }\n /**\r\n * Minimizes the modal object\r\n */\n\n }, {\n key: \"minimize\",\n value: function minimize() {\n // Saving width, height, top and bottom parameters to restore when open\n this.saveModalProperties();\n\n if (this.properties.state == 'minimized' && this.properties.previousState == 'stack') {\n this.stack();\n } else if (this.properties.state == 'minimized' && this.properties.previousState == 'maximized') {\n this.maximize();\n } else {\n // Setting css to prevent important tag into css style\n this.container.style.height = \"30px\";\n this.container.style.width = \"250px\";\n this.container.style.bottom = \"0px\";\n this.container.style.right = \"10px\";\n this.removeListeners();\n this.properties.previousState = this.properties.state;\n this.properties.state = \"minimized\";\n this.setResizeButtonsVisibility();\n this.minimizeDiv.title = \"Maximise\";\n\n if (_util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].containsClass(this.overlay, 'wrs_stack')) {\n this.removeClass('wrs_stack');\n } else {\n this.removeClass('wrs_maximized');\n }\n\n this.addClass('wrs_minimized');\n }\n }\n /**\r\n * Maximizes the modal object.\r\n */\n\n }, {\n key: \"maximize\",\n value: function maximize() {\n // Saving width, height, top and bottom parameters to restore when open\n this.saveModalProperties();\n\n if (this.properties.state != 'maximized') {\n this.properties.previousState = this.properties.state;\n this.properties.state = 'maximized';\n } // Don't permit resize on maximize mode.\n\n\n this.setResizeButtonsVisibility();\n\n if (_util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].containsClass(this.overlay, 'wrs_minimized')) {\n this.minimizeDiv.title = \"Minimise\";\n this.removeClass('wrs_minimized');\n } else if (_util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].containsClass(this.overlay, 'wrs_stack')) {\n this.container.style.left = null;\n this.container.style.top = null;\n this.removeClass('wrs_stack');\n }\n\n this.addClass('wrs_maximized'); // Set size to 80% screen with a max size.\n\n this.setSize(parseInt(window.innerHeight * 0.8), parseInt(window.innerWidth * 0.8));\n var sizeModificated = false;\n\n if (this.container.clientHeight > 700) {\n this.container.style.height = '700px';\n sizeModificated = true;\n }\n\n if (this.container.clientWidth > 1200) {\n this.container.style.width = '1200px';\n sizeModificated = true;\n } // Setting modal position in center on screen.\n\n\n this.setPosition(window.innerHeight / 2 - this.container.offsetHeight / 2, window.innerWidth / 2 - this.container.offsetWidth / 2);\n this.recalculateScale();\n this.recalculatePosition();\n this.recalculateSize();\n this.focus();\n }\n /**\r\n * Sets modal size.\r\n * @param {number} height - height of the ModalDialog\r\n * @param {number} width - width of the ModalDialog.\r\n */\n\n }, {\n key: \"setSize\",\n value: function setSize(height, width) {\n this.container.style.height = height + 'px';\n this.container.style.width = width + 'px';\n this.recalculateSize();\n }\n /**\r\n * Sets modal position using bottom and right style attributes.\r\n * @param {number} bottom - bottom attribute.\r\n * @param {number} right - right attribute.\r\n */\n\n }, {\n key: \"setPosition\",\n value: function setPosition(bottom, right) {\n this.container.style.bottom = bottom + 'px';\n this.container.style.right = right + 'px';\n }\n /**\r\n * Saves position and size parameters of and open ModalDialog. This attributes\r\n * are needed to restore it on re-open.\r\n */\n\n }, {\n key: \"saveModalProperties\",\n value: function saveModalProperties() {\n // Saving values of modal only when modal is in stack state.\n if (this.properties.state == 'stack') {\n this.properties.position.bottom = parseInt(this.container.style.bottom);\n this.properties.position.right = parseInt(this.container.style.right);\n this.properties.size.width = parseInt(this.container.style.width);\n this.properties.size.height = parseInt(this.container.style.height);\n }\n }\n /**\r\n * Restore ModalDialog position and size parameters.\r\n */\n\n }, {\n key: \"restoreModalProperties\",\n value: function restoreModalProperties() {\n if (this.properties.state == 'stack') {\n // Restoring Bottom and Right values from last modal\n this.setPosition(this.properties.position.bottom, this.properties.position.right); // Restoring Height and Left values from last modal\n\n this.setSize(this.properties.size.height, this.properties.size.width);\n }\n }\n /**\r\n * Sets the modal dialog initial size.\r\n */\n\n }, {\n key: \"recalculateSize\",\n value: function recalculateSize() {\n this.wrapper.style.width = this.container.clientWidth - 12 + 'px';\n this.wrapper.style.height = this.container.clientHeight - 38 + 'px';\n this.contentContainer.style.height = parseInt(this.wrapper.offsetHeight - 50) + 'px';\n }\n /**\r\n * Enable or disable visibility of resize buttons in modal window depend on state.\r\n */\n\n }, {\n key: \"setResizeButtonsVisibility\",\n value: function setResizeButtonsVisibility() {\n if (this.properties.state == 'stack') {\n this.resizerTL.style.visibility = 'visible';\n this.resizerBR.style.visibility = 'visible';\n } else {\n this.resizerTL.style.visibility = 'hidden';\n this.resizerBR.style.visibility = 'hidden';\n }\n }\n /**\r\n * Makes an object draggable adding mouse and touch events.\r\n */\n\n }, {\n key: \"addListeners\",\n value: function addListeners() {\n // Button events (maximize, minimize, stack and close).\n this.maximizeDiv.addEventListener('click', this.maximize.bind(this), true);\n this.stackDiv.addEventListener('click', this.stack.bind(this), true);\n this.minimizeDiv.addEventListener('click', this.minimize.bind(this), true);\n this.closeDiv.addEventListener('click', this.cancelAction.bind(this)); // Mouse events.\n\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addEvent(window, 'mousedown', this.startDrag.bind(this));\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addEvent(window, 'mouseup', this.stopDrag.bind(this));\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addEvent(window, 'mousemove', this.drag.bind(this));\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addEvent(window, 'resize', this.onWindowResize.bind(this)); // Key events.\n\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addEvent(window, 'keydown', this.onKeyDown.bind(this));\n }\n /**\r\n * Removes draggable events from an object.\r\n */\n\n }, {\n key: \"removeListeners\",\n value: function removeListeners() {\n // Mouse events.\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].removeEvent(window, 'mousedown', this.startDrag);\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].removeEvent(window, 'mouseup', this.stopDrag);\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].removeEvent(window, 'mousemove', this.drag);\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].removeEvent(window, 'resize', this.onWindowResize); // Key events\n\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].removeEvent(window, 'keydown', this.onKeyDown);\n }\n /**\r\n * Returns mouse or touch coordinates (on touch events ev.ClientX doesn't exists)\r\n * @param {MouseEvent} mouseEvent - mouse event.\r\n * @return {Object} with the X and Y coordinates.\r\n */\n\n }, {\n key: \"eventClient\",\n value: function eventClient(mouseEvent) {\n if (typeof mouseEvent.clientX == 'undefined' && mouseEvent.changedTouches) {\n var client = {\n X: mouseEvent.changedTouches[0].clientX,\n Y: mouseEvent.changedTouches[0].clientY\n };\n return client;\n } else {\n client = {\n X: mouseEvent.clientX,\n Y: mouseEvent.clientY\n };\n return client;\n }\n }\n /**\r\n * Start drag function: set the object dragDataObject with the draggable object offsets coordinates.\r\n * when drag starts (on touchstart or mousedown events).\r\n * @param {MouseEvent} mouseEvent - touchstart or mousedown event.\r\n */\n\n }, {\n key: \"startDrag\",\n value: function startDrag(mouseEvent) {\n if (this.properties.state == 'minimized') {\n return;\n }\n\n if (mouseEvent.target === this.title) {\n if (typeof this.dragDataObject === 'undefined' || this.dragDataObject === null) {\n mouseEvent = mouseEvent || event; // Save first click mouse point on screen\n\n this.dragDataObject = {\n x: this.eventClient(mouseEvent).X,\n y: this.eventClient(mouseEvent).Y\n }; // Reset last drag position when start drag\n\n this.lastDrag = {\n x: \"0px\",\n y: \"0px\"\n }; // Init right and bottom values for window modal if it isn't exist.\n\n if (this.container.style.right == '') {\n this.container.style.right = \"0px\";\n }\n\n if (this.container.style.bottom == '') {\n this.container.style.bottom = \"0px\";\n } // Needed for IE11 for apply disabled mouse events on editor because iexplorer need a dinamic object to apply this property.\n\n\n if (this.isIE11()) {} // this.iframe.style['position'] = 'relative';\n // Apply class for disable involuntary select text when drag.\n\n\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addClass(document.body, 'wrs_noselect');\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].addClass(this.overlay, 'wrs_overlay_active'); // Obtain screen limits for prevent overflow.\n\n this.limitWindow = this.getLimitWindow();\n }\n }\n }\n /**\r\n * Updates dragDataObject with the draggable object coordinates when the draggable object is being moved.\r\n * @param {MouseEvent} mouseEvent - the mouse event.\r\n */\n\n }, {\n key: \"drag\",\n value: function drag(mouseEvent) {\n if (this.dragDataObject) {\n mouseEvent.preventDefault();\n mouseEvent = mouseEvent || event; // Calculate max and min between actual mouse position and limit of screeen. It restric the movement of modal into window.\n\n var limitY = Math.min(this.eventClient(mouseEvent).Y, this.limitWindow.minPointer.y);\n limitY = Math.max(this.limitWindow.maxPointer.y, limitY);\n var limitX = Math.min(this.eventClient(mouseEvent).X, this.limitWindow.minPointer.x);\n limitX = Math.max(this.limitWindow.maxPointer.x, limitX); // Substract limit with first position to obtain relative pixels increment to the anchor point.\n\n var dragX = limitX - this.dragDataObject.x + \"px\";\n var dragY = limitY - this.dragDataObject.y + \"px\"; // Save last valid position of modal before window overflow.\n\n this.lastDrag = {\n x: dragX,\n y: dragY\n }; // This move modal with hadware acceleration.\n\n this.container.style.transform = \"translate3d(\" + dragX + \",\" + dragY + \",0)\";\n }\n\n if (this.resizeDataObject) {\n var limitX = Math.min(this.eventClient(mouseEvent).X, window.innerWidth - this.scrollbarWidth - 7);\n var limitY = Math.min(this.eventClient(mouseEvent).Y, window.innerHeight - 7);\n\n if (limitX < 0) {\n limitX = 0;\n }\n\n if (limitY < 0) {\n limitY = 0;\n }\n\n var scaleMultiplier;\n\n if (this.leftScale) {\n scaleMultiplier = -1;\n } else {\n scaleMultiplier = 1;\n }\n\n this.container.style.width = this.initialWidth + scaleMultiplier * (limitX - this.resizeDataObject.x) + 'px';\n this.container.style.height = this.initialHeight + scaleMultiplier * (limitY - this.resizeDataObject.y) + 'px';\n\n if (!this.leftScale) {\n if (this.resizeDataObject.x - limitX - this.initialWidth < -580) {\n this.container.style.right = this.initialRight - (limitX - this.resizeDataObject.x) + 'px';\n } else {\n this.container.style.right = this.initialRight + this.initialWidth - 580 + \"px\";\n this.container.style.width = \"580px\";\n }\n\n if (this.resizeDataObject.y - limitY < this.initialHeight - 338) {\n this.container.style.bottom = this.initialBottom - (limitY - this.resizeDataObject.y) + 'px';\n } else {\n this.container.style.bottom = this.initialBottom + this.initialHeight - 338 + \"px\";\n this.container.style.height = \"338px\";\n }\n }\n\n this.recalculateScale();\n this.recalculatePosition();\n }\n }\n /**\r\n * Returns the boundaries of actual window to limit modal movement.\r\n * @return {Object} Object containing mouseX and mouseY coordinates of actual mouse on screen.\r\n */\n\n }, {\n key: \"getLimitWindow\",\n value: function getLimitWindow() {\n // Obtain dimensions of window page.\n var maxWidth = window.innerWidth;\n var maxHeight = window.innerHeight; // Calculate relative position of mouse point into window.\n\n var offSetToolbarY = this.container.offsetHeight + parseInt(this.container.style.bottom) - (maxHeight - (this.dragDataObject.y - window.pageXOffset));\n var offSetToolbarX = maxWidth - this.scrollbarWidth - (this.dragDataObject.x - window.pageXOffset) - parseInt(this.container.style.right); // Calculate limits with sizes of window, modal and mouse position.\n\n var minPointerY = maxHeight - this.container.offsetHeight + offSetToolbarY;\n var maxPointerY = this.title.offsetHeight - (this.title.offsetHeight - offSetToolbarY);\n var minPointerX = maxWidth - offSetToolbarX - this.scrollbarWidth;\n var maxPointerX = this.container.offsetWidth - offSetToolbarX;\n var minPointer = {\n x: minPointerX,\n y: minPointerY\n };\n var maxPointer = {\n x: maxPointerX,\n y: maxPointerY\n };\n return {\n minPointer: minPointer,\n maxPointer: maxPointer\n };\n }\n /**\r\n * Returns the scrollbar width size of browser\r\n * @returns {number} the scrollbar width.\r\n */\n\n }, {\n key: \"getScrollBarWidth\",\n value: function getScrollBarWidth() {\n // Create a paragraph with full width of page.\n var inner = document.createElement('p');\n inner.style.width = \"100%\";\n inner.style.height = \"200px\"; // Create a hidden div to compare sizes.\n\n var outer = document.createElement('div');\n outer.style.position = \"absolute\";\n outer.style.top = \"0px\";\n outer.style.left = \"0px\";\n outer.style.visibility = \"hidden\";\n outer.style.width = \"200px\";\n outer.style.height = \"150px\";\n outer.style.overflow = \"hidden\";\n outer.appendChild(inner);\n document.body.appendChild(outer);\n var widthOuter = inner.offsetWidth; // Change type overflow of paragraph for measure scrollbar.\n\n outer.style.overflow = 'scroll';\n var widthInner = inner.offsetWidth; // If measure is the same, we compare with internal div.\n\n if (widthOuter == widthInner) {\n widthInner = outer.clientWidth;\n }\n\n document.body.removeChild(outer);\n return widthOuter - widthInner;\n }\n /**\r\n * Set the dragDataObject to null.\r\n */\n\n }, {\n key: \"stopDrag\",\n value: function stopDrag() {\n // Due to we have multiple events that call this function, we need only to execute the next modifiers one time,\n // when the user stops to drag and dragDataObject is not null (the object to drag is attached).\n if (this.dragDataObject || this.resizeDataObject) {\n // If modal doesn't change, it's not necessary to set position with interpolation\n this.container.style.transform = '';\n\n if (this.dragDataObject) {\n this.container.style.right = parseInt(this.container.style.right) - parseInt(this.lastDrag.x) + \"px\";\n this.container.style.bottom = parseInt(this.container.style.bottom) - parseInt(this.lastDrag.y) + \"px\";\n } // We make focus on editor after drag modal windows to prevent lose focus.\n\n\n this.focus(); // Restore mouse events on iframe\n // this.iframe.style['pointer-events'] = 'auto';\n\n document.body.style['user-select'] = ''; // Restore static state of iframe if we use Internet Explorer.\n\n if (this.isIE11()) {} // this.iframe.style['position'] = null;\n // Active text select event\n\n\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].removeClass(document.body, 'wrs_noselect');\n _util_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].removeClass(this.overlay, 'wrs_overlay_active');\n }\n\n this.dragDataObject = null;\n this.resizeDataObject = null;\n this.initialWidth = null;\n this.leftScale = null;\n }\n /**\r\n * Recalculates scale for modal when resize browser window.\r\n */\n\n }, {\n key: \"onWindowResize\",\n value: function onWindowResize() {\n this.recalculateScrollBar();\n this.recalculatePosition();\n this.recalculateScale();\n }\n /**\r\n * Triggers keyboard events:\r\n * - Tab key tab to go to submit button.\r\n * - Esc key to close the modal dialog.\r\n * @param {KeyboardEvent} keyboardEvent - the keyboard event.\r\n */\n\n }, {\n key: \"onKeyDown\",\n value: function onKeyDown(keyboardEvent) {\n if (keyboardEvent.key !== undefined && keyboardEvent.repeat === false) {\n // Code for detect Esc event\n if (keyboardEvent.key === \"Escape\" || keyboardEvent.key === 'Esc') {\n if (this.properties.open) {\n this.cancelAction();\n }\n } // Code for detect Tab event\n\n\n if (keyboardEvent.key === \"Tab\") {\n this.submitButton.focus();\n keyboardEvent.preventDefault();\n }\n }\n }\n /**\r\n * Recalculating position for modal dialog when the browser is resized.\r\n */\n\n }, {\n key: \"recalculatePosition\",\n value: function recalculatePosition() {\n this.container.style.right = Math.min(parseInt(this.container.style.right), window.innerWidth - this.scrollbarWidth - this.container.offsetWidth) + \"px\";\n\n if (parseInt(this.container.style.right) < 0) {\n this.container.style.right = \"0px\";\n }\n\n this.container.style.bottom = Math.min(parseInt(this.container.style.bottom), window.innerHeight - this.container.offsetHeight) + \"px\";\n\n if (parseInt(this.container.style.bottom) < 0) {\n this.container.style.bottom = \"0px\";\n }\n }\n /**\r\n * Recalculating scale for modal when the browser is resized.\r\n */\n\n }, {\n key: \"recalculateScale\",\n value: function recalculateScale() {\n var sizeModificated = false;\n\n if (parseInt(this.container.style.width) > 580) {\n this.container.style.width = Math.min(parseInt(this.container.style.width), window.innerWidth - this.scrollbarWidth) + \"px\";\n sizeModificated = true;\n } else {\n this.container.style.width = \"580px\";\n sizeModificated = true;\n }\n\n if (parseInt(this.container.style.height) > 338) {\n this.container.style.height = Math.min(parseInt(this.container.style.height), window.innerHeight) + \"px\";\n sizeModificated = true;\n } else {\n this.container.style.height = \"338px\";\n sizeModificated = true;\n }\n\n if (sizeModificated) {\n this.recalculateSize();\n }\n }\n /**\r\n * Recalculating width of browser scroll bar.\r\n */\n\n }, {\n key: \"recalculateScrollBar\",\n value: function recalculateScrollBar() {\n this.hasScrollBar = window.innerWidth > document.documentElement.clientWidth;\n\n if (this.hasScrollBar) {\n this.scrollbarWidth = this.getScrollBarWidth();\n } else {\n this.scrollbarWidth = 0;\n }\n }\n /**\r\n * Hide soft keyboards on iOS devices.\r\n */\n\n }, {\n key: \"hideKeyboard\",\n value: function hideKeyboard() {\n document.activeElement.blur();\n }\n /**\r\n * Focus to contentManager object.\r\n */\n\n }, {\n key: \"focus\",\n value: function focus() {\n if (this.contentManager != null && typeof this.contentManager.onFocus !== 'undefined') {\n this.contentManager.onFocus();\n }\n }\n /**\r\n * Returns true when the device is on portrait mode.\r\n */\n\n }, {\n key: \"portraitMode\",\n value: function portraitMode() {\n return window.innerHeight > window.innerWidth;\n }\n /**\r\n * Event handler that change container size when IOS softkeyboard is opened.\r\n */\n\n }, {\n key: \"handleOpenedIosSoftkeyboard\",\n value: function handleOpenedIosSoftkeyboard() {\n if (!this.iosSoftkeyboardOpened && this.iosDivHeight != null && this.iosDivHeight == \"100\" + this.iosMeasureUnit) {\n if (this.portraitMode()) {\n this.setContainerHeight(\"63\" + this.iosMeasureUnit);\n } else {\n this.setContainerHeight(\"40\" + this.iosMeasureUnit);\n }\n }\n\n this.iosSoftkeyboardOpened = true;\n }\n /**\r\n * Event handler that change container size when IOS softkeyboard is closed.\r\n */\n\n }, {\n key: \"handleClosedIosSoftkeyboard\",\n value: function handleClosedIosSoftkeyboard() {\n this.iosSoftkeyboardOpened = false;\n this.setContainerHeight(\"100\" + this.iosMeasureUnit);\n }\n /**\r\n * Change container sizes when orientation is changed on iOS.\r\n */\n\n }, {\n key: \"orientationChangeIosSoftkeyboard\",\n value: function orientationChangeIosSoftkeyboard() {\n if (this.iosSoftkeyboardOpened) {\n if (this.portraitMode()) {\n this.setContainerHeight(\"63\" + this.iosMeasureUnit);\n } else {\n this.setContainerHeight(\"40\" + this.iosMeasureUnit);\n }\n } else {\n this.setContainerHeight(\"100\" + this.iosMeasureUnit);\n }\n }\n /**\r\n * Change container sizes when orientation is changed on Android.\r\n */\n\n }, {\n key: \"orientationChangeAndroidSoftkeyboard\",\n value: function orientationChangeAndroidSoftkeyboard() {\n this.setContainerHeight(\"100%\");\n }\n /**\r\n * Set iframe container height.\r\n * @param {number} height - new height.\r\n */\n\n }, {\n key: \"setContainerHeight\",\n value: function setContainerHeight(height) {\n this.iosDivHeight = height;\n this.wrapper.style.height = height;\n }\n /**\r\n * Check content of editor before close action.\r\n */\n\n }, {\n key: \"showPopUpMessage\",\n value: function showPopUpMessage() {\n if (this.properties.state == 'minimized') {\n this.stack();\n }\n\n this.popup.show();\n }\n /**\r\n * Sets the tithle of the modal dialog.\r\n * @param {string} title - modal dialog title.\r\n */\n\n }, {\n key: \"setTitle\",\n value: function setTitle(title) {\n this.title.innerHTML = title;\n }\n /**\r\n * Returns the id of an element, adding the instance number to\r\n * the element class name:\r\n * className --> className[idNumber]\r\n * @param {string} className - the element class name.\r\n * @returns {string} a string appending the instance id to the className.\r\n */\n\n }, {\n key: \"getElementId\",\n value: function getElementId(className) {\n return className + \"[\" + this.instanceId + \"]\";\n }\n }]);\n\n return ModalDialog;\n}();\n\n\n\n//# sourceURL=webpack:///./core/src/modal.js?"); /***/ }), @@ -310,7 +310,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) * /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"default\", function() { return Parser; });\n/* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./util */ \"./core/src/util.js\");\n/* harmony import */ var _core_src__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./core.src */ \"./core/src/core.src.js\");\n/* harmony import */ var _latex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./latex */ \"./core/src/latex.js\");\n/* harmony import */ var _mathml__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./mathml */ \"./core/src/mathml.js\");\n/* harmony import */ var _image__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./image */ \"./core/src/image.js\");\n/* harmony import */ var _accessibility__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./accessibility */ \"./core/src/accessibility.js\");\n/* harmony import */ var _serviceprovider__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./serviceprovider */ \"./core/src/serviceprovider.js\");\n/* harmony import */ var _configuration__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./configuration */ \"./core/src/configuration.js\");\n/* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./constants */ \"./core/src/constants.js\");\n/* harmony import */ var _md5__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./md5 */ \"./core/src/md5.js\");\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\n\n\n\n\n\n\n\n\n\n\n/**\r\n * This class represent a MahML parser. Converts MathML into formulas depending on the\r\n * image format (SVG, PNG, base64) and the save mode (XML, safeXML, Image) configured in the backend.\r\n */\n\nvar Parser =\n/*#__PURE__*/\nfunction () {\n function Parser() {\n _classCallCheck(this, Parser);\n }\n\n _createClass(Parser, null, [{\n key: \"mathmlToImgObject\",\n\n /**\r\n * Converts a MathML string to an img element.\r\n * @param {Document} creator - Document object to call createElement method.\r\n * @param {string} mathml - MathML code\r\n * @param {Object[]} wirisProperties - object containing WIRIS custom properties\r\n * @param {language} language - custom language for accessibility.\r\n * @returns {HTMLImageElement} the formula image corresponding to initial MathML string.\r\n * @static\r\n */\n value: function mathmlToImgObject(creator, mathml, wirisProperties, language) {\n var width;\n var height;\n var baseline;\n var imgObject = creator.createElement('img');\n imgObject.align = 'middle';\n imgObject.style.maxWidth = 'none';\n var data = wirisProperties ? wirisProperties : {};\n data['mml'] = mathml;\n data['lang'] = language; // Request metrics of the generated image.\n\n data['metrics'] = 'true';\n data['centerbaseline'] = 'false'; // Full base64 method (edit & save).\n\n if (_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('saveMode') == 'base64' && _configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('editMode') == 'default') {\n data['base64'] = true;\n } // Render js params: _wrs_int_wirisProperties contains some js render params. Since mathml can support render params, js params should be send only to editor, not to render.\n\n\n imgObject.className = _configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('imageClassName');\n\n if (mathml.indexOf('class=\"') != -1) {\n // We check here if the MathML has been created from a customEditor (such chemistry)\n // to add data-custom-editor attribute to img object (if necessary).\n var mathmlSubstring = mathml.substring(mathml.indexOf('class=\"') + 'class=\"'.length, mathml.length);\n mathmlSubstring = mathmlSubstring.substring(0, mathmlSubstring.indexOf('\"'));\n mathmlSubstring = mathmlSubstring.substring(4, mathmlSubstring.length);\n imgObject.setAttribute('data-custom-editor', mathmlSubstring);\n } // Performance enabled.\n\n\n if (_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('wirisPluginPerformance') && (_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('saveMode') == 'xml' || _configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('saveMode') == 'safeXml')) {\n var result = JSON.parse(Parser.createShowImageSrc(data, language));\n\n if (result[\"status\"] == 'warning') {\n // POST call.\n // if the mathml is malformed, this function will throw an exception.\n try {\n result = JSON.parse(_serviceprovider__WEBPACK_IMPORTED_MODULE_6__[\"default\"].getService('showimage', data));\n } catch (e) {\n return;\n }\n }\n\n result = result.result;\n\n if (result['format'] == 'png') {\n imgObject.src = 'data:image/png;base64,' + result['content'];\n } else {\n imgObject.src = 'data:image/svg+xml;charset=utf8,' + _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].urlEncode(result['content']);\n }\n\n imgObject.setAttribute(_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('imageMathmlAttribute'), _mathml__WEBPACK_IMPORTED_MODULE_3__[\"default\"].safeXmlEncode(mathml));\n _image__WEBPACK_IMPORTED_MODULE_4__[\"default\"].setImgSize(imgObject, result['content'], true);\n\n if (_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('enableAccessibility')) {\n if (typeof result.alt == 'undefined') {\n imgObject.alt = _accessibility__WEBPACK_IMPORTED_MODULE_5__[\"default\"].mathMLToAccessible(mathml, language, data);\n } else {\n imgObject.alt = result.alt;\n }\n }\n } else {\n var result = Parser.createImageSrc(mathml, data);\n imgObject.setAttribute(_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('imageMathmlAttribute'), _mathml__WEBPACK_IMPORTED_MODULE_3__[\"default\"].safeXmlEncode(mathml));\n imgObject.src = result;\n _image__WEBPACK_IMPORTED_MODULE_4__[\"default\"].setImgSize(imgObject, result, _configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('saveMode') == 'base64' && _configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('editMode') == 'default' ? true : false);\n\n if (_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('enableAccessibility')) {\n imgObject.alt = _accessibility__WEBPACK_IMPORTED_MODULE_5__[\"default\"].mathMLToAccessible(mathml, language, data);\n }\n }\n\n if (typeof Parser.observer != 'undefined') {\n Parser.observer.observe(imgObject);\n } // Role math https://www.w3.org/TR/wai-aria/roles#math.\n\n\n imgObject.setAttribute('role', 'math');\n return imgObject;\n }\n /**\r\n * Returns the source to showimage service by calling createimage service. The\r\n * output of the createimage service is a URL path pointing to showimage service.\r\n * This method is called when performance is disabled.\r\n * @param {string} mathml - MathML code.\r\n * @param {Object[]} data - data object containing service parameters.\r\n * @returns {string} the showimage path.\r\n */\n\n }, {\n key: \"createImageSrc\",\n value: function createImageSrc(mathml, data) {\n // Full base64 method (edit & save).\n if (_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('saveMode') == 'base64' && _configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('editMode') == 'default') {\n data['base64'] = true;\n }\n\n var result = _serviceprovider__WEBPACK_IMPORTED_MODULE_6__[\"default\"].getService('createimage', data);\n\n if (result.indexOf('@BASE@') != -1) {\n // Replacing '@BASE@' with the base URL of createimage.\n var baseParts = _core_src__WEBPACK_IMPORTED_MODULE_1__[\"default\"].getServiceProvider().getServicePath('createimage').split('/');\n baseParts.pop();\n result = result.split('@BASE@').join(baseParts.join('/'));\n }\n\n return result;\n }\n /**\r\n * Parses initial HTML code. If the HTML contains data generated by WIRIS, this data would be converted as following:\r\n *
\r\n     * MathML code: Image containing the corresponding MathML formulas.\r\n     * MathML code with LaTeX annotation : LaTeX string.\r\n     * 
\r\n * @param {string} code - HTML code containing MathML data.\r\n * @param {string} language - language to create image alt text.\r\n * @returns {string} HTML code with the original MathML converted into LaTeX and images.\r\n */\n\n }, {\n key: \"initParse\",\n value: function initParse(code, language) {\n /* Note: The code inside this function has been inverted.\r\n If you invert again the code then you cannot use correctly LaTeX\r\n in Moodle.\r\n */\n code = Parser.initParseSaveMode(code, language);\n return Parser.initParseEditMode(code);\n }\n /**\r\n * Parses initial HTML code depending on the save mode. Transforms all MathML\r\n * occurrences for it's correspondent image or LaTeX.\r\n * @param {string} code - HTML code to be parsed\r\n * @param {string} language - language to create image alt text.\r\n * @returns {string} HTML code parsed.\r\n */\n\n }, {\n key: \"initParseSaveMode\",\n value: function initParseSaveMode(code, language) {\n if (_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('saveMode')) {\n // Converting XML to tags.\n code = _latex__WEBPACK_IMPORTED_MODULE_2__[\"default\"].parseMathmlToLatex(code, _constants__WEBPACK_IMPORTED_MODULE_8__[\"default\"].safeXmlCharacters);\n code = _latex__WEBPACK_IMPORTED_MODULE_2__[\"default\"].parseMathmlToLatex(code, _constants__WEBPACK_IMPORTED_MODULE_8__[\"default\"].xmlCharacters); // Safe XML and XML must be parsed regardeless of save mode.\n // Order is important here, safeXml must be parsed first in order to avoid conflicts with data-mathml img attribute.\n\n code = Parser.parseSafeAppletsToObjects(code);\n code = Parser.parseMathmlToImg(code, _constants__WEBPACK_IMPORTED_MODULE_8__[\"default\"].safeXmlCharacters, language);\n code = Parser.parseMathmlToImg(code, _constants__WEBPACK_IMPORTED_MODULE_8__[\"default\"].xmlCharacters, language);\n\n if (_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('saveMode') == 'base64' && _configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('editMode') == 'image') {\n code = Parser.codeImgTransform(code, 'base642showimage');\n }\n }\n\n var appletList = _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].getElementsByNameFromString(code, 'applet', false);\n var carry = 0; // While replacing applets with images, the indexes of the found applets changes respecting the original code, so this carry is needed.\n\n for (var i = 0; i < appletList.length; ++i) {\n var appletCode = code.substring(appletList[i].start + carry, appletList[i].end + carry); // The second control in the if is used to find WIRIS applet which don't have Wiriscas class (as it was in old CAS applets).\n\n if (appletCode.indexOf(' class=\"' + _configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('CASClassName') + '\"') != -1 || appletCode.toUpperCase().indexOf('WIRIS') != -1) {\n if (appletCode.indexOf(' src=\"') != -1) {\n var srcStart = appletCode.indexOf(' src=\"') + ' src=\"'.length;\n var srcEnd = appletCode.indexOf('\"', srcStart);\n var src = appletCode.substring(srcStart, srcEnd);\n } else {\n // This should happen only with old CAS imported from Moodle 1 to Moodle 2.\n if (typeof _wrs_conf_pluginBasePath != 'undefined') {\n var src = _wrs_conf_pluginBasePath + '/integration/showcasimage.php?formula=noimage';\n } else {\n var src = '';\n }\n\n if (appletCode.indexOf(' class=\"' + _configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('CASClassName') + '\"') == -1) {\n var closeSymbol = appletCode.indexOf('>');\n var appletTag = appletCode.substring(0, closeSymbol);\n var newAppletTag = appletTag.split(' width=').join(' class=\"Wiriscas\" width=');\n appletCode = appletCode.split(appletTag).join(newAppletTag);\n appletCode = appletCode.split('\\'').join('\"');\n }\n } // Double click to edit has been removed here.\n\n\n var imgCode = '';\n code = code.substring(0, appletList[i].start + carry) + imgCode + code.substring(appletList[i].end + carry);\n carry += imgCode.length - (appletList[i].end - appletList[i].start);\n }\n }\n\n return code;\n }\n /**\r\n * Parses initial HTML code depending on the edit mode.\r\n * If 'latex' parseMode is enabled all MathML containing an annotation with encoding='LaTeX' will\r\n * be converted into a LaTeX string instead of an image.\r\n * @param {string} code - HTML code containing MathML.\r\n * @returns {string} parsed HTML code.\r\n */\n\n }, {\n key: \"initParseEditMode\",\n value: function initParseEditMode(code) {\n if (_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('parseModes').indexOf('latex') != -1) {\n var imgList = _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].getElementsByNameFromString(code, 'img', true);\n var token = 'encoding=\"LaTeX\">';\n var carry = 0;\n 4; // While replacing images with latex, the indexes of the found images changes respecting the original code, so this carry is needed.\n\n for (var i = 0; i < imgList.length; ++i) {\n var imgCode = code.substring(imgList[i].start + carry, imgList[i].end + carry);\n\n if (imgCode.indexOf(' class=\"' + _configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('imageClassName') + '\"') != -1) {\n var mathmlStartToken = ' ' + _configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('imageMathmlAttribute') + '=\"';\n var mathmlStart = imgCode.indexOf(mathmlStartToken);\n\n if (mathmlStart == -1) {\n mathmlStartToken = ' alt=\"';\n mathmlStart = imgCode.indexOf(mathmlStartToken);\n }\n\n if (mathmlStart != -1) {\n mathmlStart += mathmlStartToken.length;\n var mathmlEnd = imgCode.indexOf('\"', mathmlStart);\n var mathml = _mathml__WEBPACK_IMPORTED_MODULE_3__[\"default\"].safeXmlDecode(imgCode.substring(mathmlStart, mathmlEnd));\n var latexStartPosition = mathml.indexOf(token);\n\n if (latexStartPosition != -1) {\n latexStartPosition += token.length;\n var latexEndPosition = mathml.indexOf('', latexStartPosition);\n var latex = mathml.substring(latexStartPosition, latexEndPosition);\n var replaceText = '$$' + _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].htmlEntitiesDecode(latex) + '$$';\n code = code.substring(0, imgList[i].start + carry) + replaceText + code.substring(imgList[i].end + carry);\n carry += replaceText.length - (imgList[i].end - imgList[i].start);\n }\n }\n }\n }\n }\n\n return code;\n }\n /**\r\n * Parses end HTML code. The end HTML code is HTML code with embedded images or LaTeX formulas created with MathType.
\r\n * By default this method converts the formula images and LaTeX strings in MathML.
\r\n * If image mode is enabled the images will not be converted into MathML. For further information see {@link http://www.wiris.com/plugins/docs/full-mathml-mode}.\r\n * @param {string} code - HTML to be parsed\r\n * @returns {string} the HTML code parsed.\r\n */\n\n }, {\n key: \"endParse\",\n value: function endParse(code) {\n code = Parser.endParseEditMode(code);\n return Parser.endParseSaveMode(code);\n }\n /**\r\n * Parses end HTML code depending on the edit mode.\r\n * - LaTeX is an enabled parse mode, all LaTeX occurrences will be converted into MathML.\r\n * @param {string} code - HTML code to be parsed.\r\n * @returns {string} HTML code parsed.\r\n */\n\n }, {\n key: \"endParseEditMode\",\n value: function endParseEditMode(code) {\n // Converting LaTeX to images.\n if (_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('parseModes').indexOf('latex') != -1) {\n var output = '';\n var endPosition = 0;\n var startPosition = code.indexOf('$$');\n\n while (startPosition != -1) {\n output += code.substring(endPosition, startPosition);\n endPosition = code.indexOf('$$', startPosition + 2);\n\n if (endPosition != -1) {\n // Before, it was a condition here to execute the next codelines 'latex.indexOf('<') == -1'.\n // We don't know why it was used, but seems to have a conflict with latex formulas that contains '<'.\n var latex = code.substring(startPosition + 2, endPosition);\n latex = _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].htmlEntitiesDecode(latex);\n var mathml = _latex__WEBPACK_IMPORTED_MODULE_2__[\"default\"].getMathMLFromLatex(latex, true);\n output += mathml;\n endPosition += 2;\n } else {\n output += '$$';\n endPosition = startPosition + 2;\n }\n\n startPosition = code.indexOf('$$', endPosition);\n }\n\n output += code.substring(endPosition, code.length);\n code = output;\n }\n\n return code;\n }\n /**\r\n * Parses end HTML code depending on the save mode. Converts all\r\n * images into the element determined by the save mode:\r\n * - xml: Parses images formulas into MathML.\r\n * - safeXml: Parses images formulas into safeMAthML\r\n * - base64: Parses images into base64 images.\r\n * - image: Parse images into images (no parsing)\r\n * @param {string} code - HTML code to be parsed\r\n * @returns {string} HTML code parsed.\r\n */\n\n }, {\n key: \"endParseSaveMode\",\n value: function endParseSaveMode(code) {\n if (_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('saveMode')) {\n if (_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('saveMode') == 'safeXml') {\n code = Parser.codeImgTransform(code, 'img2mathml');\n } else if (_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('saveMode') == 'xml') {\n code = Parser.codeImgTransform(code, 'img2mathml');\n } else if (_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('saveMode') == 'base64' && _configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('editMode') == 'image') {\n code = Parser.codeImgTransform(code, 'img264');\n }\n }\n\n return code;\n }\n /**\r\n * Returns the result to call showimage service with the formula md5 as parameter.\r\n * The result could be:\r\n * - {'status' : warning'} : The image associated to the MathML md5 is not in cache.\r\n * - {'status' : 'ok' ...} : The image associated to the MathML md5 is in cache.\r\n * @param {Object[]} data - object containing showimage service parameters.\r\n * @param {string} language - string containing the language of the formula.\r\n * @returns {Object} JSON object containing showimage response.\r\n */\n\n }, {\n key: \"createShowImageSrc\",\n value: function createShowImageSrc(data, language) {\n var dataMd5 = [];\n var renderParams = 'mml,color,centerbaseline,zoom,dpi,fontSize,fontFamily,defaultStretchy,backgroundColor,format';\n var renderParamsArray = renderParams.split(',');\n\n for (var key in renderParamsArray) {\n var param = renderParamsArray[key];\n\n if (typeof data[param] != 'undefined') {\n dataMd5[param] = data[param];\n }\n } // Data variables to get.\n\n\n var dataObject = {};\n\n for (var key in data) {\n // We don't need mathml in this request we try to get cached so we only need the formula md5 calculated before.\n if (key != 'mml') {\n dataObject[key] = data[key];\n }\n }\n\n dataObject.formula = com.wiris.js.JsPluginTools.md5encode(_util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].propertiesToString(dataMd5));\n dataObject.lang = typeof language == 'undefined' ? 'en' : language;\n dataObject.version = _configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('version');\n var result = _serviceprovider__WEBPACK_IMPORTED_MODULE_6__[\"default\"].getService('showimage', _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].httpBuildQuery(dataObject), true);\n return result;\n }\n /**\r\n * Transform html img tags inside a html code to mathml, base64 img tags (i.e with base64 on src) or showimage img tags (i.e with showimage.php on src)\r\n * @param {string} code - HTML code\r\n * @param {string} mode - base642showimage or img2mathml or img264 transform.\r\n * @returns {string} html - code transformed.\r\n */\n\n }, {\n key: \"codeImgTransform\",\n value: function codeImgTransform(code, mode) {\n var output = '';\n var endPosition = 0;\n var pattern = /') {\n endPosition = i + 1;\n }\n\n ++i;\n }\n\n if (endPosition < startPosition) {\n // The img tag is stripped.\n output += code.substring(startPosition, code.length);\n return output;\n }\n\n var imgCode = code.substring(startPosition, endPosition);\n var imgObject = _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].createObject(imgCode);\n var xmlCode = imgObject.getAttribute(_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('imageMathmlAttribute'));\n var convertToXml;\n var convertToSafeXml;\n\n if (mode == 'base642showimage') {\n if (xmlCode == null) {\n xmlCode = imgObject.getAttribute('alt');\n }\n\n xmlCode = _mathml__WEBPACK_IMPORTED_MODULE_3__[\"default\"].safeXmlDecode(xmlCode);\n imgCode = Parser.mathmlToImgObject(document, xmlCode, null, null);\n output += _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].createObjectCode(imgCode);\n } else if (mode == 'img2mathml') {\n if (_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('saveMode')) {\n if (_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('saveMode') == 'safeXml') {\n convertToXml = true;\n convertToSafeXml = true;\n } else if (_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('saveMode') == 'xml') {\n convertToXml = true;\n convertToSafeXml = false;\n }\n }\n\n output += _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].getWIRISImageOutput(imgCode, convertToXml, convertToSafeXml);\n } else if (mode == 'img264') {\n if (xmlCode == null) {\n xmlCode = imgObject.getAttribute('alt');\n }\n\n xmlCode = _mathml__WEBPACK_IMPORTED_MODULE_3__[\"default\"].safeXmlDecode(xmlCode);\n var properties = {};\n properties['base64'] = 'true';\n imgCode = Parser.mathmlToImgObject(document, xmlCode, properties, null); // Metrics.\n\n _image__WEBPACK_IMPORTED_MODULE_4__[\"default\"].setImgSize(imgCode, imgCode.src, true);\n output += _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].createObjectCode(imgCode);\n }\n }\n\n output += code.substring(endPosition, code.length);\n return output;\n }\n /**\r\n * Converts all occurrences of safe applet code to the corresponding code.\r\n * @param {string} content - String containing valid applet code ...\r\n * @returns {string} content with all the applet code converted to safe tags.\r\n */\n\n }, {\n key: \"parseSafeAppletsToObjects\",\n value: function parseSafeAppletsToObjects(content) {\n var output = '';\n var appletTagBegin = _constants__WEBPACK_IMPORTED_MODULE_8__[\"default\"].safeXmlCharacters.tagOpener + 'APPLET';\n var appletTagEnd = _constants__WEBPACK_IMPORTED_MODULE_8__[\"default\"].safeXmlCharacters.tagOpener + '/APPLET' + _constants__WEBPACK_IMPORTED_MODULE_8__[\"default\"].safeXmlCharacters.tagCloser;\n var upperCaseContent = content.toUpperCase();\n var start = upperCaseContent.indexOf(appletTagBegin);\n var end = 0;\n var applet;\n\n while (start != -1) {\n output += content.substring(end, start);\n end = upperCaseContent.indexOf(appletTagEnd, start);\n\n if (end == -1) {\n end = content.length - 1;\n } else {\n end += appletTagEnd.length;\n }\n\n applet = _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].convertOldXmlinitialtextAttribute(content.substring(start, end));\n output += _mathml__WEBPACK_IMPORTED_MODULE_3__[\"default\"].safeXmlDecode(applet);\n start = upperCaseContent.indexOf(appletTagBegin, end);\n }\n\n output += content.substring(end, content.length);\n return output;\n }\n /**\r\n * Converts all occurrences of MathML to the corresponding image.\r\n * @param {string} content - string with valid MathML code. The MathML code doesn't contain semantics.\r\n * @param {Constants} characters - Constant object containing xmlCharacters or safeXmlCharacters relation.\r\n * @param {string} language - a valid language code in order to generate formula accessibility.\r\n * @returns {string} The input string with all the MathML occurrences replaced by the corresponding image.\r\n */\n\n }, {\n key: \"parseMathmlToImg\",\n value: function parseMathmlToImg(content, characters, language) {\n var output = '';\n var mathTagBegin = characters.tagOpener + 'math';\n var mathTagEnd = characters.tagOpener + '/math' + characters.tagCloser;\n var start = content.indexOf(mathTagBegin);\n var end = 0;\n\n while (start != -1) {\n output += content.substring(end, start); // Avoid WIRIS images to be parsed.\n\n var imageMathmlAtrribute = content.indexOf(_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('imageMathmlAttribute'));\n end = content.indexOf(mathTagEnd, start);\n\n if (end == -1) {\n end = content.length - 1;\n } else if (imageMathmlAtrribute != -1) {\n // First close tag of img attribute\n // If a mathmlAttribute exists should be inside a img tag.\n end += content.indexOf(\"/>\", start);\n } else {\n end += mathTagEnd.length;\n }\n\n if (!_mathml__WEBPACK_IMPORTED_MODULE_3__[\"default\"].isMathmlInAttribute(content, start) && imageMathmlAtrribute == -1) {\n var mathml = content.substring(start, end);\n mathml = characters == _constants__WEBPACK_IMPORTED_MODULE_8__[\"default\"].safeXmlCharacters ? _mathml__WEBPACK_IMPORTED_MODULE_3__[\"default\"].safeXmlDecode(mathml) : _mathml__WEBPACK_IMPORTED_MODULE_3__[\"default\"].mathMLEntities(mathml);\n output += _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].createObjectCode(Parser.mathmlToImgObject(document, mathml, null, language));\n } else {\n output += content.substring(start, end);\n }\n\n start = content.indexOf(mathTagBegin, end);\n }\n\n output += content.substring(end, content.length);\n return output;\n }\n }]);\n\n return Parser;\n}(); // Mutation observers to avoid wiris image formulas class be removed.\n\n\n\n\nif (typeof MutationObserver !== 'undefined') {\n var mutationObserver = new MutationObserver(function (mutations) {\n mutations.forEach(function (mutation) {\n if (mutation.oldValue === _configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('imageClassName') && mutation.attributeName === 'class' && mutation.target.className.indexOf(_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('imageClassName')) == -1) {\n mutation.target.className = _configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('imageClassName');\n }\n });\n });\n Parser.observer = Object.create(mutationObserver);\n Parser.observer.Config = {\n attributes: true,\n attributeOldValue: true\n }; // We use own default config.\n\n Parser.observer.observe = function name(target) {\n this.__proto__.observe(target, this.Config);\n };\n}\n\n//# sourceURL=webpack:///./core/src/parser.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"default\", function() { return Parser; });\n/* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./util */ \"./core/src/util.js\");\n/* harmony import */ var _core_src__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./core.src */ \"./core/src/core.src.js\");\n/* harmony import */ var _latex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./latex */ \"./core/src/latex.js\");\n/* harmony import */ var _mathml__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./mathml */ \"./core/src/mathml.js\");\n/* harmony import */ var _image__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./image */ \"./core/src/image.js\");\n/* harmony import */ var _accessibility__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./accessibility */ \"./core/src/accessibility.js\");\n/* harmony import */ var _serviceprovider__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./serviceprovider */ \"./core/src/serviceprovider.js\");\n/* harmony import */ var _configuration__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./configuration */ \"./core/src/configuration.js\");\n/* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./constants */ \"./core/src/constants.js\");\n/* harmony import */ var _md5__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./md5 */ \"./core/src/md5.js\");\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\n\n\n\n\n\n\n\n\n\n\n/**\r\n * This class represent a MahML parser. Converts MathML into formulas depending on the\r\n * image format (SVG, PNG, base64) and the save mode (XML, safeXML, Image) configured in the backend.\r\n */\n\nvar Parser =\n/*#__PURE__*/\nfunction () {\n function Parser() {\n _classCallCheck(this, Parser);\n }\n\n _createClass(Parser, null, [{\n key: \"mathmlToImgObject\",\n\n /**\r\n * Converts a MathML string to an img element.\r\n * @param {Document} creator - Document object to call createElement method.\r\n * @param {string} mathml - MathML code\r\n * @param {Object[]} wirisProperties - object containing WIRIS custom properties\r\n * @param {language} language - custom language for accessibility.\r\n * @returns {HTMLImageElement} the formula image corresponding to initial MathML string.\r\n * @static\r\n */\n value: function mathmlToImgObject(creator, mathml, wirisProperties, language) {\n var width;\n var height;\n var baseline;\n var imgObject = creator.createElement('img');\n imgObject.align = 'middle';\n imgObject.style.maxWidth = 'none';\n var data = wirisProperties ? wirisProperties : {};\n data['mml'] = mathml;\n data['lang'] = language; // Request metrics of the generated image.\n\n data['metrics'] = 'true';\n data['centerbaseline'] = 'false'; // Full base64 method (edit & save).\n\n if (_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('saveMode') == 'base64' && _configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('editMode') == 'default') {\n data['base64'] = true;\n } // Render js params: _wrs_int_wirisProperties contains some js render params. Since mathml can support render params, js params should be send only to editor, not to render.\n\n\n imgObject.className = _configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('imageClassName');\n\n if (mathml.indexOf('class=\"') != -1) {\n // We check here if the MathML has been created from a customEditor (such chemistry)\n // to add data-custom-editor attribute to img object (if necessary).\n var mathmlSubstring = mathml.substring(mathml.indexOf('class=\"') + 'class=\"'.length, mathml.length);\n mathmlSubstring = mathmlSubstring.substring(0, mathmlSubstring.indexOf('\"'));\n mathmlSubstring = mathmlSubstring.substring(4, mathmlSubstring.length);\n imgObject.setAttribute('data-custom-editor', mathmlSubstring);\n } // Performance enabled.\n\n\n if (_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('wirisPluginPerformance') && (_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('saveMode') == 'xml' || _configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('saveMode') == 'safeXml')) {\n var result = JSON.parse(Parser.createShowImageSrc(data, language));\n\n if (result[\"status\"] == 'warning') {\n // POST call.\n // if the mathml is malformed, this function will throw an exception.\n try {\n result = JSON.parse(_serviceprovider__WEBPACK_IMPORTED_MODULE_6__[\"default\"].getService('showimage', data));\n } catch (e) {\n return;\n }\n }\n\n result = result.result;\n\n if (result['format'] == 'png') {\n imgObject.src = 'data:image/png;base64,' + result['content'];\n } else {\n imgObject.src = 'data:image/svg+xml;charset=utf8,' + _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].urlEncode(result['content']);\n }\n\n imgObject.setAttribute(_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('imageMathmlAttribute'), _mathml__WEBPACK_IMPORTED_MODULE_3__[\"default\"].safeXmlEncode(mathml));\n _image__WEBPACK_IMPORTED_MODULE_4__[\"default\"].setImgSize(imgObject, result['content'], true);\n\n if (_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('enableAccessibility')) {\n if (typeof result.alt == 'undefined') {\n imgObject.alt = _accessibility__WEBPACK_IMPORTED_MODULE_5__[\"default\"].mathMLToAccessible(mathml, language, data);\n } else {\n imgObject.alt = result.alt;\n }\n }\n } else {\n var result = Parser.createImageSrc(mathml, data);\n imgObject.setAttribute(_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('imageMathmlAttribute'), _mathml__WEBPACK_IMPORTED_MODULE_3__[\"default\"].safeXmlEncode(mathml));\n imgObject.src = result;\n _image__WEBPACK_IMPORTED_MODULE_4__[\"default\"].setImgSize(imgObject, result, _configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('saveMode') == 'base64' && _configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('editMode') == 'default' ? true : false);\n\n if (_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('enableAccessibility')) {\n imgObject.alt = _accessibility__WEBPACK_IMPORTED_MODULE_5__[\"default\"].mathMLToAccessible(mathml, language, data);\n }\n }\n\n if (typeof Parser.observer != 'undefined') {\n Parser.observer.observe(imgObject);\n } // Role math https://www.w3.org/TR/wai-aria/roles#math.\n\n\n imgObject.setAttribute('role', 'math');\n return imgObject;\n }\n /**\r\n * Returns the source to showimage service by calling createimage service. The\r\n * output of the createimage service is a URL path pointing to showimage service.\r\n * This method is called when performance is disabled.\r\n * @param {string} mathml - MathML code.\r\n * @param {Object[]} data - data object containing service parameters.\r\n * @returns {string} the showimage path.\r\n */\n\n }, {\n key: \"createImageSrc\",\n value: function createImageSrc(mathml, data) {\n // Full base64 method (edit & save).\n if (_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('saveMode') == 'base64' && _configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('editMode') == 'default') {\n data['base64'] = true;\n }\n\n var result = _serviceprovider__WEBPACK_IMPORTED_MODULE_6__[\"default\"].getService('createimage', data);\n\n if (result.indexOf('@BASE@') != -1) {\n // Replacing '@BASE@' with the base URL of createimage.\n var baseParts = _core_src__WEBPACK_IMPORTED_MODULE_1__[\"default\"].getServiceProvider().getServicePath('createimage').split('/');\n baseParts.pop();\n result = result.split('@BASE@').join(baseParts.join('/'));\n }\n\n return result;\n }\n /**\r\n * Parses initial HTML code. If the HTML contains data generated by WIRIS, this data would be converted as following:\r\n *
\r\n     * MathML code: Image containing the corresponding MathML formulas.\r\n     * MathML code with LaTeX annotation : LaTeX string.\r\n     * 
\r\n * @param {string} code - HTML code containing MathML data.\r\n * @param {string} language - language to create image alt text.\r\n * @returns {string} HTML code with the original MathML converted into LaTeX and images.\r\n */\n\n }, {\n key: \"initParse\",\n value: function initParse(code, language) {\n /* Note: The code inside this function has been inverted.\r\n If you invert again the code then you cannot use correctly LaTeX\r\n in Moodle.\r\n */\n code = Parser.initParseSaveMode(code, language);\n return Parser.initParseEditMode(code);\n }\n /**\r\n * Parses initial HTML code depending on the save mode. Transforms all MathML\r\n * occurrences for it's correspondent image or LaTeX.\r\n * @param {string} code - HTML code to be parsed\r\n * @param {string} language - language to create image alt text.\r\n * @returns {string} HTML code parsed.\r\n */\n\n }, {\n key: \"initParseSaveMode\",\n value: function initParseSaveMode(code, language) {\n if (_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('saveMode')) {\n // Converting XML to tags.\n code = _latex__WEBPACK_IMPORTED_MODULE_2__[\"default\"].parseMathmlToLatex(code, _constants__WEBPACK_IMPORTED_MODULE_8__[\"default\"].safeXmlCharacters);\n code = _latex__WEBPACK_IMPORTED_MODULE_2__[\"default\"].parseMathmlToLatex(code, _constants__WEBPACK_IMPORTED_MODULE_8__[\"default\"].xmlCharacters); // Safe XML and XML must be parsed regardeless of save mode.\n // Order is important here, safeXml must be parsed first in order to avoid conflicts with data-mathml img attribute.\n\n code = Parser.parseSafeAppletsToObjects(code);\n code = Parser.parseMathmlToImg(code, _constants__WEBPACK_IMPORTED_MODULE_8__[\"default\"].safeXmlCharacters, language);\n code = Parser.parseMathmlToImg(code, _constants__WEBPACK_IMPORTED_MODULE_8__[\"default\"].xmlCharacters, language);\n\n if (_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('saveMode') == 'base64' && _configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('editMode') == 'image') {\n code = Parser.codeImgTransform(code, 'base642showimage');\n }\n }\n\n var appletList = _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].getElementsByNameFromString(code, 'applet', false);\n var carry = 0; // While replacing applets with images, the indexes of the found applets changes respecting the original code, so this carry is needed.\n\n for (var i = 0; i < appletList.length; ++i) {\n var appletCode = code.substring(appletList[i].start + carry, appletList[i].end + carry); // The second control in the if is used to find WIRIS applet which don't have Wiriscas class (as it was in old CAS applets).\n\n if (appletCode.indexOf(' class=\"' + _configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('CASClassName') + '\"') != -1 || appletCode.toUpperCase().indexOf('WIRIS') != -1) {\n if (appletCode.indexOf(' src=\"') != -1) {\n var srcStart = appletCode.indexOf(' src=\"') + ' src=\"'.length;\n var srcEnd = appletCode.indexOf('\"', srcStart);\n var src = appletCode.substring(srcStart, srcEnd);\n } else {\n // This should happen only with old CAS imported from Moodle 1 to Moodle 2.\n if (typeof _wrs_conf_pluginBasePath != 'undefined') {\n var src = _wrs_conf_pluginBasePath + '/integration/showcasimage.php?formula=noimage';\n } else {\n var src = '';\n }\n\n if (appletCode.indexOf(' class=\"' + _configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('CASClassName') + '\"') == -1) {\n var closeSymbol = appletCode.indexOf('>');\n var appletTag = appletCode.substring(0, closeSymbol);\n var newAppletTag = appletTag.split(' width=').join(' class=\"Wiriscas\" width=');\n appletCode = appletCode.split(appletTag).join(newAppletTag);\n appletCode = appletCode.split('\\'').join('\"');\n }\n } // Double click to edit has been removed here.\n\n\n var imgCode = '';\n code = code.substring(0, appletList[i].start + carry) + imgCode + code.substring(appletList[i].end + carry);\n carry += imgCode.length - (appletList[i].end - appletList[i].start);\n }\n }\n\n return code;\n }\n /**\r\n * Parses initial HTML code depending on the edit mode.\r\n * If 'latex' parseMode is enabled all MathML containing an annotation with encoding='LaTeX' will\r\n * be converted into a LaTeX string instead of an image.\r\n * @param {string} code - HTML code containing MathML.\r\n * @returns {string} parsed HTML code.\r\n */\n\n }, {\n key: \"initParseEditMode\",\n value: function initParseEditMode(code) {\n if (_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('parseModes').indexOf('latex') != -1) {\n var imgList = _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].getElementsByNameFromString(code, 'img', true);\n var token = 'encoding=\"LaTeX\">';\n var carry = 0;\n 4; // While replacing images with latex, the indexes of the found images changes respecting the original code, so this carry is needed.\n\n for (var i = 0; i < imgList.length; ++i) {\n var imgCode = code.substring(imgList[i].start + carry, imgList[i].end + carry);\n\n if (imgCode.indexOf(' class=\"' + _configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('imageClassName') + '\"') != -1) {\n var mathmlStartToken = ' ' + _configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('imageMathmlAttribute') + '=\"';\n var mathmlStart = imgCode.indexOf(mathmlStartToken);\n\n if (mathmlStart == -1) {\n mathmlStartToken = ' alt=\"';\n mathmlStart = imgCode.indexOf(mathmlStartToken);\n }\n\n if (mathmlStart != -1) {\n mathmlStart += mathmlStartToken.length;\n var mathmlEnd = imgCode.indexOf('\"', mathmlStart);\n var mathml = _mathml__WEBPACK_IMPORTED_MODULE_3__[\"default\"].safeXmlDecode(imgCode.substring(mathmlStart, mathmlEnd));\n var latexStartPosition = mathml.indexOf(token);\n\n if (latexStartPosition != -1) {\n latexStartPosition += token.length;\n var latexEndPosition = mathml.indexOf('', latexStartPosition);\n var latex = mathml.substring(latexStartPosition, latexEndPosition);\n var replaceText = '$$' + _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].htmlEntitiesDecode(latex) + '$$';\n code = code.substring(0, imgList[i].start + carry) + replaceText + code.substring(imgList[i].end + carry);\n carry += replaceText.length - (imgList[i].end - imgList[i].start);\n }\n }\n }\n }\n }\n\n return code;\n }\n /**\r\n * Parses end HTML code. The end HTML code is HTML code with embedded images or LaTeX formulas created with MathType.
\r\n * By default this method converts the formula images and LaTeX strings in MathML.
\r\n * If image mode is enabled the images will not be converted into MathML. For further information see {@link http://www.wiris.com/plugins/docs/full-mathml-mode}.\r\n * @param {string} code - HTML to be parsed\r\n * @returns {string} the HTML code parsed.\r\n */\n\n }, {\n key: \"endParse\",\n value: function endParse(code) {\n // Transform LaTeX ocurrences to MathML elements.\n var codeEndParsedEditMode = Parser.endParseEditMode(code); // Transform img elements to MathML elements.\n\n var codeEndParseSaveMode = Parser.endParseSaveMode(codeEndParsedEditMode);\n return codeEndParseSaveMode;\n }\n /**\r\n * Parses end HTML code depending on the edit mode.\r\n * - LaTeX is an enabled parse mode, all LaTeX occurrences will be converted into MathML.\r\n * @param {string} code - HTML code to be parsed.\r\n * @returns {string} HTML code parsed.\r\n */\n\n }, {\n key: \"endParseEditMode\",\n value: function endParseEditMode(code) {\n // Converting LaTeX to images.\n if (_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('parseModes').indexOf('latex') != -1) {\n var output = '';\n var endPosition = 0;\n var startPosition = code.indexOf('$$');\n\n while (startPosition != -1) {\n output += code.substring(endPosition, startPosition);\n endPosition = code.indexOf('$$', startPosition + 2);\n\n if (endPosition != -1) {\n // Before, it was a condition here to execute the next codelines 'latex.indexOf('<') == -1'.\n // We don't know why it was used, but seems to have a conflict with latex formulas that contains '<'.\n var latex = code.substring(startPosition + 2, endPosition);\n latex = _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].htmlEntitiesDecode(latex);\n var mathml = _latex__WEBPACK_IMPORTED_MODULE_2__[\"default\"].getMathMLFromLatex(latex, true);\n output += mathml;\n endPosition += 2;\n } else {\n output += '$$';\n endPosition = startPosition + 2;\n }\n\n startPosition = code.indexOf('$$', endPosition);\n }\n\n output += code.substring(endPosition, code.length);\n code = output;\n }\n\n return code;\n }\n /**\r\n * Parses end HTML code depending on the save mode. Converts all\r\n * images into the element determined by the save mode:\r\n * - xml: Parses images formulas into MathML.\r\n * - safeXml: Parses images formulas into safeMAthML\r\n * - base64: Parses images into base64 images.\r\n * - image: Parse images into images (no parsing)\r\n * @param {string} code - HTML code to be parsed\r\n * @returns {string} HTML code parsed.\r\n */\n\n }, {\n key: \"endParseSaveMode\",\n value: function endParseSaveMode(code) {\n if (_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('saveMode')) {\n if (_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('saveMode') == 'safeXml') {\n code = Parser.codeImgTransform(code, 'img2mathml');\n } else if (_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('saveMode') == 'xml') {\n code = Parser.codeImgTransform(code, 'img2mathml');\n } else if (_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('saveMode') == 'base64' && _configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('editMode') == 'image') {\n code = Parser.codeImgTransform(code, 'img264');\n }\n }\n\n return code;\n }\n /**\r\n * Returns the result to call showimage service with the formula md5 as parameter.\r\n * The result could be:\r\n * - {'status' : warning'} : The image associated to the MathML md5 is not in cache.\r\n * - {'status' : 'ok' ...} : The image associated to the MathML md5 is in cache.\r\n * @param {Object[]} data - object containing showimage service parameters.\r\n * @param {string} language - string containing the language of the formula.\r\n * @returns {Object} JSON object containing showimage response.\r\n */\n\n }, {\n key: \"createShowImageSrc\",\n value: function createShowImageSrc(data, language) {\n var dataMd5 = [];\n var renderParams = 'mml,color,centerbaseline,zoom,dpi,fontSize,fontFamily,defaultStretchy,backgroundColor,format';\n var renderParamsArray = renderParams.split(',');\n\n for (var key in renderParamsArray) {\n var param = renderParamsArray[key];\n\n if (typeof data[param] != 'undefined') {\n dataMd5[param] = data[param];\n }\n } // Data variables to get.\n\n\n var dataObject = {};\n\n for (var key in data) {\n // We don't need mathml in this request we try to get cached so we only need the formula md5 calculated before.\n if (key != 'mml') {\n dataObject[key] = data[key];\n }\n }\n\n dataObject.formula = com.wiris.js.JsPluginTools.md5encode(_util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].propertiesToString(dataMd5));\n dataObject.lang = typeof language == 'undefined' ? 'en' : language;\n dataObject.version = _configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('version');\n var result = _serviceprovider__WEBPACK_IMPORTED_MODULE_6__[\"default\"].getService('showimage', _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].httpBuildQuery(dataObject), true);\n return result;\n }\n /**\r\n * Transform html img tags inside a html code to mathml, base64 img tags (i.e with base64 on src) or showimage img tags (i.e with showimage.php on src)\r\n * @param {string} code - HTML code\r\n * @param {string} mode - base642showimage or img2mathml or img264 transform.\r\n * @returns {string} html - code transformed.\r\n */\n\n }, {\n key: \"codeImgTransform\",\n value: function codeImgTransform(code, mode) {\n var output = '';\n var endPosition = 0;\n var pattern = /') {\n endPosition = i + 1;\n }\n\n ++i;\n }\n\n if (endPosition < startPosition) {\n // The img tag is stripped.\n output += code.substring(startPosition, code.length);\n return output;\n }\n\n var imgCode = code.substring(startPosition, endPosition);\n var imgObject = _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].createObject(imgCode);\n var xmlCode = imgObject.getAttribute(_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('imageMathmlAttribute'));\n var convertToXml;\n var convertToSafeXml;\n\n if (mode == 'base642showimage') {\n if (xmlCode == null) {\n xmlCode = imgObject.getAttribute('alt');\n }\n\n xmlCode = _mathml__WEBPACK_IMPORTED_MODULE_3__[\"default\"].safeXmlDecode(xmlCode);\n imgCode = Parser.mathmlToImgObject(document, xmlCode, null, null);\n output += _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].createObjectCode(imgCode);\n } else if (mode == 'img2mathml') {\n if (_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('saveMode')) {\n if (_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('saveMode') == 'safeXml') {\n convertToXml = true;\n convertToSafeXml = true;\n } else if (_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('saveMode') == 'xml') {\n convertToXml = true;\n convertToSafeXml = false;\n }\n }\n\n output += _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].getWIRISImageOutput(imgCode, convertToXml, convertToSafeXml);\n } else if (mode == 'img264') {\n if (xmlCode == null) {\n xmlCode = imgObject.getAttribute('alt');\n }\n\n xmlCode = _mathml__WEBPACK_IMPORTED_MODULE_3__[\"default\"].safeXmlDecode(xmlCode);\n var properties = {};\n properties['base64'] = 'true';\n imgCode = Parser.mathmlToImgObject(document, xmlCode, properties, null); // Metrics.\n\n _image__WEBPACK_IMPORTED_MODULE_4__[\"default\"].setImgSize(imgCode, imgCode.src, true);\n output += _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].createObjectCode(imgCode);\n }\n }\n\n output += code.substring(endPosition, code.length);\n return output;\n }\n /**\r\n * Converts all occurrences of safe applet code to the corresponding code.\r\n * @param {string} content - String containing valid applet code ...\r\n * @returns {string} content with all the applet code converted to safe tags.\r\n */\n\n }, {\n key: \"parseSafeAppletsToObjects\",\n value: function parseSafeAppletsToObjects(content) {\n var output = '';\n var appletTagBegin = _constants__WEBPACK_IMPORTED_MODULE_8__[\"default\"].safeXmlCharacters.tagOpener + 'APPLET';\n var appletTagEnd = _constants__WEBPACK_IMPORTED_MODULE_8__[\"default\"].safeXmlCharacters.tagOpener + '/APPLET' + _constants__WEBPACK_IMPORTED_MODULE_8__[\"default\"].safeXmlCharacters.tagCloser;\n var upperCaseContent = content.toUpperCase();\n var start = upperCaseContent.indexOf(appletTagBegin);\n var end = 0;\n var applet;\n\n while (start != -1) {\n output += content.substring(end, start);\n end = upperCaseContent.indexOf(appletTagEnd, start);\n\n if (end == -1) {\n end = content.length - 1;\n } else {\n end += appletTagEnd.length;\n }\n\n applet = _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].convertOldXmlinitialtextAttribute(content.substring(start, end));\n output += _mathml__WEBPACK_IMPORTED_MODULE_3__[\"default\"].safeXmlDecode(applet);\n start = upperCaseContent.indexOf(appletTagBegin, end);\n }\n\n output += content.substring(end, content.length);\n return output;\n }\n /**\r\n * Converts all occurrences of MathML to the corresponding image.\r\n * @param {string} content - string with valid MathML code. The MathML code doesn't contain semantics.\r\n * @param {Constants} characters - Constant object containing xmlCharacters or safeXmlCharacters relation.\r\n * @param {string} language - a valid language code in order to generate formula accessibility.\r\n * @returns {string} The input string with all the MathML occurrences replaced by the corresponding image.\r\n */\n\n }, {\n key: \"parseMathmlToImg\",\n value: function parseMathmlToImg(content, characters, language) {\n var output = '';\n var mathTagBegin = characters.tagOpener + 'math';\n var mathTagEnd = characters.tagOpener + '/math' + characters.tagCloser;\n var start = content.indexOf(mathTagBegin);\n var end = 0;\n\n while (start != -1) {\n output += content.substring(end, start); // Avoid WIRIS images to be parsed.\n\n var imageMathmlAtrribute = content.indexOf(_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('imageMathmlAttribute'));\n end = content.indexOf(mathTagEnd, start);\n\n if (end == -1) {\n end = content.length - 1;\n } else if (imageMathmlAtrribute != -1) {\n // First close tag of img attribute\n // If a mathmlAttribute exists should be inside a img tag.\n end += content.indexOf(\"/>\", start);\n } else {\n end += mathTagEnd.length;\n }\n\n if (!_mathml__WEBPACK_IMPORTED_MODULE_3__[\"default\"].isMathmlInAttribute(content, start) && imageMathmlAtrribute == -1) {\n var mathml = content.substring(start, end);\n mathml = characters == _constants__WEBPACK_IMPORTED_MODULE_8__[\"default\"].safeXmlCharacters ? _mathml__WEBPACK_IMPORTED_MODULE_3__[\"default\"].safeXmlDecode(mathml) : _mathml__WEBPACK_IMPORTED_MODULE_3__[\"default\"].mathMLEntities(mathml);\n output += _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].createObjectCode(Parser.mathmlToImgObject(document, mathml, null, language));\n } else {\n output += content.substring(start, end);\n }\n\n start = content.indexOf(mathTagBegin, end);\n }\n\n output += content.substring(end, content.length);\n return output;\n }\n }]);\n\n return Parser;\n}(); // Mutation observers to avoid wiris image formulas class be removed.\n\n\n\n\nif (typeof MutationObserver !== 'undefined') {\n var mutationObserver = new MutationObserver(function (mutations) {\n mutations.forEach(function (mutation) {\n if (mutation.oldValue === _configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('imageClassName') && mutation.attributeName === 'class' && mutation.target.className.indexOf(_configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('imageClassName')) == -1) {\n mutation.target.className = _configuration__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get('imageClassName');\n }\n });\n });\n Parser.observer = Object.create(mutationObserver);\n Parser.observer.Config = {\n attributes: true,\n attributeOldValue: true\n }; // We use own default config.\n\n Parser.observer.observe = function name(target) {\n this.__proto__.observe(target, this.Config);\n };\n}\n\n//# sourceURL=webpack:///./core/src/parser.js?"); /***/ }), @@ -370,7 +370,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) * /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"default\", function() { return Util; });\n/* harmony import */ var _mathml__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./mathml */ \"./core/src/mathml.js\");\n/* harmony import */ var _configuration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./configuration */ \"./core/src/configuration.js\");\n/* harmony import */ var _latex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./latex */ \"./core/src/latex.js\");\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\n\n\n\n/**\r\n * This class represents an utility class.\r\n */\n\nvar Util =\n/*#__PURE__*/\nfunction () {\n function Util() {\n _classCallCheck(this, Util);\n }\n\n _createClass(Util, null, [{\n key: \"fireEvent\",\n\n /**\r\n * Fires an event in a target.\r\n * @param {EventTarget} eventTarget - target where event should be fired.\r\n * @param {string} eventName event to fire.\r\n * @static\r\n */\n value: function fireEvent(eventTarget, eventName) {\n if (document.createEvent) {\n var eventObject = document.createEvent('HTMLEvents');\n eventObject.initEvent(eventName, true, true);\n return !eventTarget.dispatchEvent(eventObject);\n }\n\n var eventObject = document.createEventObject();\n return eventTarget.fireEvent('on' + eventName, eventObject);\n }\n /**\r\n * Cross-browser addEventListener/attachEvent function.\r\n * @param {EventTarget} eventTarget - target to add the event.\r\n * @param {string} eventName - specifies the type of event.\r\n * @param {Function} callBackFunction - callback function.\r\n * @static\r\n */\n\n }, {\n key: \"addEvent\",\n value: function addEvent(eventTarget, eventName, callBackFunction) {\n if (eventTarget.addEventListener) {\n eventTarget.addEventListener(eventName, callBackFunction, true);\n } else if (eventTarget.attachEvent) {\n // Backwards compatibility.\n eventTarget.attachEvent('on' + eventName, callBackFunction);\n }\n }\n /**\r\n * Cross-browser removeEventListener/detachEvent function.\r\n * @param {EventTarget} eventTarget - target to add the event.\r\n * @param {string} eventName - specifies the type of event.\r\n * @param {Function} callBackFunction - function to remove from the event target.\r\n * @static\r\n */\n\n }, {\n key: \"removeEvent\",\n value: function removeEvent(eventTarget, eventName, callBackFunction) {\n if (eventTarget.removeEventListener) {\n eventTarget.removeEventListener(eventName, callBackFunction, true);\n } else if (eventTarget.detachEvent) {\n eventTarget.detachEvent('on' + eventName, callBackFunction);\n }\n }\n /**\r\n * Adds the a callback function, for a certain event target, to the following event types:\r\n * - dblclick\r\n * - mousedown\r\n * - mouseup\r\n * @param {EventTarget} eventTarget - event target.\r\n * @param {Function} doubleClickHandler - function to run when on dblclick event.\r\n * @param {Function} mousedownHandler - function to run when on mousedown event.\r\n * @param {Function} mouseupHandler - function to run when on mouseup event.\r\n * @static\r\n */\n\n }, {\n key: \"addElementEvents\",\n value: function addElementEvents(eventTarget, doubleClickHandler, mousedownHandler, mouseupHandler) {\n if (doubleClickHandler) {\n Util.addEvent(eventTarget, 'dblclick', function (event) {\n var realEvent = event ? event : window.event;\n var element = realEvent.srcElement ? realEvent.srcElement : realEvent.target;\n doubleClickHandler(element, realEvent);\n });\n }\n\n if (mousedownHandler) {\n Util.addEvent(eventTarget, 'mousedown', function (event) {\n var realEvent = event ? event : window.event;\n var element = realEvent.srcElement ? realEvent.srcElement : realEvent.target;\n mousedownHandler(element, realEvent);\n });\n }\n\n if (mouseupHandler) {\n Util.addEvent(eventTarget, 'mouseup', function (event) {\n var realEvent = event ? event : window.event;\n var element = realEvent.srcElement ? realEvent.srcElement : realEvent.target;\n mouseupHandler(element, realEvent);\n });\n }\n }\n /**\r\n * Adds a class name to a HTMLElement.\r\n * @param {HTMLElement} element - the HTML element.\r\n * @param {string} className - the class name.\r\n * @static\r\n */\n\n }, {\n key: \"addClass\",\n value: function addClass(element, className) {\n if (!Util.containsClass(element, className)) {\n element.className += \" \" + className;\n }\n }\n /**\r\n * Checks if a HTMLElement contains a certain class.\r\n * @param {HTMLElement} element - the HTML element.\r\n * @param {string} className - the className.\r\n * @returns {boolean} true if the HTMLElement contains the class name. false otherwise.\r\n * @static\r\n */\n\n }, {\n key: \"containsClass\",\n value: function containsClass(element, className) {\n if (element == null || !('className' in element)) {\n return false;\n }\n\n var currentClasses = element.className.split(' ');\n\n for (var i = currentClasses.length - 1; i >= 0; --i) {\n if (currentClasses[i] == className) {\n return true;\n }\n }\n\n return false;\n }\n /**\r\n * Remove a certain class for a HTMLElement.\r\n * @param {HTMLElement} element - the HTML element.\r\n * @param {string} className - the class name.\r\n * @static\r\n */\n\n }, {\n key: \"removeClass\",\n value: function removeClass(element, className) {\n var newClassName = '';\n var classes = element.className.split(\" \");\n\n for (var i = 0; i < classes.length; i++) {\n if (classes[i] != className) {\n newClassName += classes[i] + \" \";\n }\n }\n\n element.className = newClassName.trim();\n }\n /**\r\n * Converts old xml initial text attribute (with «») to the correct one(with §lt;§gt;). It's\r\n * used to parse old applets.\r\n * @param {string} text - string containing safeXml characters\r\n * @returns {string} a string with safeXml characters parsed.\r\n * @static\r\n */\n\n }, {\n key: \"convertOldXmlinitialtextAttribute\",\n value: function convertOldXmlinitialtextAttribute(text) {\n // Used to fix a bug with Cas imported from Moodle 1.9 to Moodle 2.x.\n // This could be removed in future.\n var val = 'value=';\n var xitpos = text.indexOf('xmlinitialtext');\n var valpos = text.indexOf(val, xitpos);\n var quote = text.charAt(valpos + val.length);\n var startquote = valpos + val.length + 1;\n var endquote = text.indexOf(quote, startquote);\n var value = text.substring(startquote, endquote);\n var newvalue = value.split('«').join('§lt;');\n newvalue = newvalue.split('»').join('§gt;');\n newvalue = newvalue.split('&').join('§');\n newvalue = newvalue.split('¨').join('§quot;');\n text = text.split(value).join(newvalue);\n return text;\n }\n /**\r\n * Cross-browser solution for creating new elements.\r\n * @param {string} tagName - tag name of the wished element.\r\n * @param {Object} attributes - an object where each key is a wished attribute name and each value is its value.\r\n * @param {Object} [creator] - if supplied, this function will use the \"createElement\" method from this param. Otherwise\r\n * document will be used as creator.\r\n * @returns {Element} The DOM element with the specified attributes assigned.\r\n * @static\r\n */\n\n }, {\n key: \"createElement\",\n value: function createElement(tagName, attributes, creator) {\n if (attributes === undefined) {\n attributes = {};\n }\n\n if (creator === undefined) {\n creator = document;\n }\n\n var element;\n /*\r\n * Internet Explorer fix:\r\n * If you create a new object dynamically, you can't set a non-standard attribute.\r\n * For example, you can't set the \"src\" attribute on an \"applet\" object.\r\n * Other browsers will throw an exception and will run the standard code.\r\n */\n\n try {\n var html = '<' + tagName;\n\n for (var attributeName in attributes) {\n html += ' ' + attributeName + '=\"' + Util.htmlEntities(attributes[attributeName]) + '\"';\n }\n\n html += '>';\n element = creator.createElement(html);\n } catch (e) {\n element = creator.createElement(tagName);\n\n for (var attributeName in attributes) {\n element.setAttribute(attributeName, attributes[attributeName]);\n }\n }\n\n return element;\n }\n /**\r\n * Creates new HTML from it's HTML code as string.\r\n * @param {string} objectCode - html code\r\n * @returns {Element} the HTML element.\r\n * @static\r\n */\n\n }, {\n key: \"createObject\",\n value: function createObject(objectCode, creator) {\n if (creator === undefined) {\n creator = document;\n } // Internet Explorer can't include \"param\" tag when is setting an innerHTML property.\n\n\n objectCode = objectCode.split('').join('').split('').join('');\n objectCode = objectCode.split('').join('
').split('').join('
');\n var container = Util.createElement('div', {}, creator);\n container.innerHTML = objectCode;\n\n function recursiveParamsFix(object) {\n if (object.getAttribute && object.getAttribute('wirisObject') == 'WirisParam') {\n var attributesParsed = {};\n\n for (var i = 0; i < object.attributes.length; ++i) {\n if (object.attributes[i].nodeValue !== null) {\n attributesParsed[object.attributes[i].nodeName] = object.attributes[i].nodeValue;\n }\n }\n\n var param = Util.createElement('param', attributesParsed, creator); // IE fix.\n\n if (param.NAME) {\n param.name = param.NAME;\n param.value = param.VALUE;\n }\n\n param.removeAttribute('wirisObject');\n object.parentNode.replaceChild(param, object);\n } else if (object.getAttribute && object.getAttribute('wirisObject') == 'WirisApplet') {\n var attributesParsed = {};\n\n for (var i = 0; i < object.attributes.length; ++i) {\n if (object.attributes[i].nodeValue !== null) {\n attributesParsed[object.attributes[i].nodeName] = object.attributes[i].nodeValue;\n }\n }\n\n var applet = Util.createElement('applet', attributesParsed, creator);\n applet.removeAttribute('wirisObject');\n\n for (var i = 0; i < object.childNodes.length; ++i) {\n recursiveParamsFix(object.childNodes[i]);\n\n if (object.childNodes[i].nodeName.toLowerCase() == 'param') {\n applet.appendChild(object.childNodes[i]);\n --i; // When we insert the object child into the applet, object loses one child.\n }\n }\n\n object.parentNode.replaceChild(applet, object);\n } else {\n for (var i = 0; i < object.childNodes.length; ++i) {\n recursiveParamsFix(object.childNodes[i]);\n }\n }\n }\n\n recursiveParamsFix(container);\n return container.firstChild;\n }\n /**\r\n * Converts an Element to its HTML code.\r\n * @param {Element} element - entry element.\r\n * @return {string} the HTML code of the input element.\r\n * @static\r\n */\n\n }, {\n key: \"createObjectCode\",\n value: function createObjectCode(element) {\n // In case that the image was not created, the object can be null or undefined.\n if (typeof element == 'undefined' || element == null) {\n return;\n }\n\n if (element.nodeType == 1) {\n // ELEMENT_NODE.\n var output = '<' + element.tagName;\n\n for (var i = 0; i < element.attributes.length; ++i) {\n if (element.attributes[i].specified) {\n output += ' ' + element.attributes[i].name + '=\"' + Util.htmlEntities(element.attributes[i].value) + '\"';\n }\n }\n\n if (element.childNodes.length > 0) {\n output += '>';\n\n for (var i = 0; i < element.childNodes.length; ++i) {\n output += Util.createObject(element.childNodes[i]);\n }\n\n output += '';\n } else if (element.nodeName == 'DIV' || element.nodeName == 'SCRIPT') {\n output += '>';\n } else {\n output += '/>';\n }\n\n return output;\n }\n\n if (element.nodeType == 3) {\n // TEXT_NODE.\n return Util.htmlEntities(element.nodeValue);\n }\n\n return '';\n }\n /**\r\n * Concatenates two URL paths.\r\n * @param {string} path1 - first URL path\r\n * @param {string} path2 - second URL path\r\n * @returns {string} new URL.\r\n */\n\n }, {\n key: \"concatenateUrl\",\n value: function concatenateUrl(path1, path2) {\n var separator = \"\";\n\n if (path1.indexOf(\"/\") != path1.length && path2.indexOf(\"/\") != 0) {\n separator = \"/\";\n }\n\n return (path1 + separator + path2).replace(/([^:]\\/)\\/+/g, \"$1\");\n }\n /**\r\n * Parses a text and replaces all HTML special characters by their correspondent entities.\r\n * @param {string} input - text to be parsed.\r\n * @returns {string} the input text with all their special characters replaced by their entities.\r\n * @static\r\n */\n\n }, {\n key: \"htmlEntities\",\n value: function htmlEntities(input) {\n return input.split('&').join('&').split('<').join('<').split('>').join('>').split('\"').join('"');\n }\n /**\r\n * Parses a text and replaces all the HTML entities by their characters.\r\n * @param {string} input - text to be parsed\r\n * @returns {string} the input text with all their entities replaced by characters.\r\n * @static\r\n */\n\n }, {\n key: \"htmlEntitiesDecode\",\n value: function htmlEntitiesDecode(input) {\n return input.split('"').join('\"').split('>').join('>').split('<').join('<').split('&').join('&');\n }\n /**\r\n * Returns a cross-browser http request.\r\n * @return {object} httpRequest request object.\r\n * @returns {XMLHttpRequest|ActiveXObject} the proper request object.\r\n */\n\n }, {\n key: \"createHttpRequest\",\n value: function createHttpRequest() {\n var currentPath = window.location.toString().substr(0, window.location.toString().lastIndexOf('/') + 1);\n\n if (currentPath.substr(0, 7) == 'file://') {\n throw Core.getStringManager().getString('exception_cross_site');\n }\n\n if (typeof XMLHttpRequest != 'undefined') {\n return new XMLHttpRequest();\n }\n\n try {\n return new ActiveXObject('Msxml2.XMLHTTP');\n } catch (e) {\n try {\n return new ActiveXObject('Microsoft.XMLHTTP');\n } catch (oc) {}\n }\n\n return false;\n }\n /**\r\n * Converts a hash to a HTTP query.\r\n * @param {Object[]} properties - a key/value object.\r\n * @returns {string} a HTTP query containing all the key value pairs with all the special characters replaced by their entities.\r\n * @static\r\n */\n\n }, {\n key: \"httpBuildQuery\",\n value: function httpBuildQuery(properties) {\n var result = '';\n\n for (var i in properties) {\n if (properties[i] != null) {\n result += Util.urlEncode(i) + '=' + Util.urlEncode(properties[i]) + '&';\n }\n } // Deleting last '&' empty character.\n\n\n if (result.substring(result.length - 1) == '&') {\n result = result.substring(0, result.length - 1);\n }\n\n return result;\n }\n /**\r\n * Convert a hash to string sorting keys to get a deterministic output\r\n * @param {Object[]} hash - a key/value object.\r\n * @returns {string} a string with the form key1=value1...keyn=valuen\r\n * @static\r\n */\n\n }, {\n key: \"propertiesToString\",\n value: function propertiesToString(hash) {\n // 1. Sort keys. We sort the keys because we want a deterministic output.\n var keys = [];\n\n for (var key in hash) {\n if (hash.hasOwnProperty(key)) {\n keys.push(key);\n }\n }\n\n var n = keys.length;\n\n for (var i = 0; i < n; i++) {\n for (var j = i + 1; j < n; j++) {\n var s1 = keys[i];\n var s2 = keys[j];\n\n if (Util.compareStrings(s1, s2) > 0) {\n // Swap.\n keys[i] = s2;\n keys[j] = s1;\n }\n }\n } // 2. Generate output.\n\n\n var output = '';\n\n for (var i = 0; i < n; i++) {\n var key = keys[i];\n output += key;\n output += \"=\";\n var value = hash[key];\n value = value.replace(\"\\\\\", \"\\\\\\\\\");\n value = value.replace(\"\\n\", \"\\\\n\");\n value = value.replace(\"\\r\", \"\\\\r\");\n value = value.replace(\"\\t\", \"\\\\t\");\n output += value;\n output += \"\\n\";\n }\n\n return output;\n }\n /**\r\n * Compare two strings using charCodeAt method\r\n * @param {string} a - first string to compare.\r\n * @param {string} b - second string to compare.\r\n * @returns {number} the difference between a and b\r\n * @static\r\n */\n\n }, {\n key: \"compareStrings\",\n value: function compareStrings(a, b) {\n var i;\n var an = a.length;\n var bn = b.length;\n var n = an > bn ? bn : an;\n\n for (i = 0; i < n; i++) {\n var c = Util.fixedCharCodeAt(a, i) - Util.fixedCharCodeAt(b, i);\n\n if (c != 0) {\n return c;\n }\n }\n\n return a.length - b.length;\n }\n /**\r\n * Fix charCodeAt() JavaScript function to handle non-Basic-Multilingual-Plane characters.\r\n * @param {string} string - input string\r\n * @param {number} idx - an integer greater than or equal to 0 and less than the length of the string\r\n * @returns {number} an integer representing the UTF-16 code of the string at the given index.\r\n * @static\r\n */\n\n }, {\n key: \"fixedCharCodeAt\",\n value: function fixedCharCodeAt(string, idx) {\n idx = idx || 0;\n var code = string.charCodeAt(idx);\n var hi, low;\n /* High surrogate (could change last hex to 0xDB7F to treat high\r\n private surrogates as single characters) */\n\n if (0xD800 <= code && code <= 0xDBFF) {\n hi = code;\n low = string.charCodeAt(idx + 1);\n\n if (isNaN(low)) {\n throw Core.getStringManager().getString('exception_high_surrogate');\n }\n\n return (hi - 0xD800) * 0x400 + (low - 0xDC00) + 0x10000;\n }\n\n if (0xDC00 <= code && code <= 0xDFFF) {\n // Low surrogate.\n\n /* We return false to allow loops to skip this iteration since should have\r\n already handled high surrogate above in the previous iteration. */\n return false;\n }\n\n return code;\n }\n /**\r\n * Returns an URL with it's query params converted into array.\r\n * @param {string} url - input URL.\r\n * @returns {Object[]} an array containing all URL query params.\r\n * @static\r\n */\n\n }, {\n key: \"urlToAssArray\",\n value: function urlToAssArray(url) {\n var i;\n i = url.indexOf(\"?\");\n\n if (i > 0) {\n var query = url.substring(i + 1);\n var ss = query.split(\"&\");\n var h = new Object();\n\n for (i = 0; i < ss.length; i++) {\n var s = ss[i];\n var kv = s.split(\"=\");\n\n if (kv.length > 1) {\n h[kv[0]] = decodeURIComponent(kv[1].replace(/\\+/g, ' '));\n }\n }\n\n return h;\n } else {\n return new Object();\n }\n }\n /**\r\n * Returns an encoded URL by replacing each instance of certain characters by\r\n * one, two, three or four escape sequences using encodeURIComponent method.\r\n * !'()* . will not be encoded.\r\n *\r\n * @param {string} clearString - URL string to be encoded\r\n * @returns {string} URL with it's special characters replaced.\r\n * @static\r\n */\n\n }, {\n key: \"urlEncode\",\n value: function urlEncode(clearString) {\n var output = ''; // Method encodeURIComponent doesn't encode !'()*~ .\n\n output = encodeURIComponent(clearString);\n return output;\n } // TODO: To parser?\n\n /**\r\n * Converts the HTML of a image into the output code that WIRIS must return.\r\n * By default returns the MathML stored on data-mahml attribute (if imgCode is a formula)\r\n * or the Wiriscas attribute of a WIRIS applet.\r\n * @param {string} imgCode - the html code from a formula or a CAS image.\r\n * @param {boolean} convertToXml - true if the image should be converted to XML.\r\n * @param {boolean} convertToSafeXml - true if the image should be converted to safeXML.\r\n * @returns {string} the XML or safeXML of a WIRIS image.\r\n * @static\r\n */\n\n }, {\n key: \"getWIRISImageOutput\",\n value: function getWIRISImageOutput(imgCode, convertToXml, convertToSafeXml) {\n var imgObject = Util.createObject(imgCode);\n\n if (imgObject) {\n if (imgObject.className == _configuration__WEBPACK_IMPORTED_MODULE_1__[\"default\"].get('imageClassName') || imgObject.getAttribute(_configuration__WEBPACK_IMPORTED_MODULE_1__[\"default\"].get('imageMathmlAttribute'))) {\n if (!convertToXml) {\n return imgCode;\n }\n\n var xmlCode = imgObject.getAttribute(_configuration__WEBPACK_IMPORTED_MODULE_1__[\"default\"].get('imageMathmlAttribute'));\n\n if (xmlCode == null) {\n xmlCode = imgObject.getAttribute('alt');\n }\n\n if (!convertToSafeXml) {\n xmlCode = _mathml__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlDecode(xmlCode);\n }\n\n return xmlCode;\n } else if (imgObject.className == _configuration__WEBPACK_IMPORTED_MODULE_1__[\"default\"].get('CASClassName')) {\n var appletCode = imgObject.getAttribute(_configuration__WEBPACK_IMPORTED_MODULE_1__[\"default\"].get('CASMathmlAttribute'));\n appletCode = _mathml__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlDecode(appletCode);\n var appletObject = Util.createObject(appletCode);\n appletObject.setAttribute('src', imgObject.src);\n var object = appletObject;\n var appletCodeToBeInserted = Util.createObjectCode(appletObject);\n\n if (convertToSafeXml) {\n appletCodeToBeInserted = _mathml__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlEncode(appletCodeToBeInserted);\n }\n\n return appletCodeToBeInserted;\n }\n }\n\n return imgCode;\n }\n /**\r\n * Gets the node length in characters.\r\n * @param {Node} node - HTML node.\r\n * @returns {number} node length.\r\n * @static\r\n */\n\n }, {\n key: \"getNodeLength\",\n value: function (_getNodeLength) {\n function getNodeLength(_x) {\n return _getNodeLength.apply(this, arguments);\n }\n\n getNodeLength.toString = function () {\n return _getNodeLength.toString();\n };\n\n return getNodeLength;\n }(function (node) {\n var staticNodeLengths = {\n 'IMG': 1,\n 'BR': 1\n };\n\n if (node.nodeType == 3) {\n // TEXT_NODE.\n return node.nodeValue.length;\n }\n\n if (node.nodeType == 1) {\n // ELEMENT_NODE.\n var length = staticNodeLengths[node.nodeName.toUpperCase()];\n\n if (length === undefined) {\n length = 0;\n }\n\n for (var i = 0; i < node.childNodes.length; ++i) {\n length += getNodeLength(node.childNodes[i]);\n }\n\n return length;\n }\n\n return 0;\n })\n /**\r\n * Gets a selected node or text from an editable HTMLElement.\r\n * If the caret is on a text node, concatenates it with all the previous and next text nodes.\r\n * @param {HTMLElement} target - the editable HTMLElement.\r\n * @param {boolean} isIframe - specifies if the target is an iframe or not\r\n * @param {boolean} forceGetSelection - if true, ignores IE system to get the current selection and uses window.getSelection()\r\n * @returns {object} an object with the 'node' key set if the item is an element or the keys 'node' and 'caretPosition' if the element is text.\r\n * @static\r\n */\n\n }, {\n key: \"getSelectedItem\",\n value: function getSelectedItem(target, isIframe, forceGetSelection) {\n var windowTarget;\n\n if (isIframe) {\n windowTarget = target.contentWindow;\n windowTarget.focus();\n } else {\n windowTarget = window;\n target.focus();\n }\n\n if (document.selection && !forceGetSelection) {\n var range = windowTarget.document.selection.createRange();\n\n if (range.parentElement) {\n if (range.htmlText.length > 0) {\n if (range.text.length == 0) {\n return Util.getSelectedItem(target, isIframe, true);\n }\n\n return null;\n }\n\n windowTarget.document.execCommand('InsertImage', false, '#');\n var temporalObject = range.parentElement();\n\n if (temporalObject.nodeName.toUpperCase() != 'IMG') {\n // IE9 fix: parentElement() does not return the IMG node, returns the parent DIV node. In IE < 9, pasteHTML does not work well.\n range.pasteHTML('');\n temporalObject = windowTarget.document.getElementById('wrs_openEditorWindow_temporalObject');\n }\n\n var node;\n var caretPosition;\n\n if (temporalObject.nextSibling && temporalObject.nextSibling.nodeType == 3) {\n // TEXT_NODE.\n node = temporalObject.nextSibling;\n caretPosition = 0;\n } else if (temporalObject.previousSibling && temporalObject.previousSibling.nodeType == 3) {\n // TEXT_NODE.\n node = temporalObject.previousSibling;\n caretPosition = node.nodeValue.length;\n } else {\n node = windowTarget.document.createTextNode('');\n temporalObject.parentNode.insertBefore(node, temporalObject);\n caretPosition = 0;\n }\n\n temporalObject.parentNode.removeChild(temporalObject);\n return {\n 'node': node,\n 'caretPosition': caretPosition\n };\n }\n\n if (range.length > 1) {\n return null;\n }\n\n return {\n 'node': range.item(0)\n };\n }\n\n if (windowTarget.getSelection) {\n var selection = windowTarget.getSelection();\n\n try {\n var range = selection.getRangeAt(0);\n } catch (e) {\n var range = windowTarget.document.createRange();\n }\n\n var node = range.startContainer;\n\n if (node.nodeType == 3) {\n // TEXT_NODE.\n return {\n 'node': node,\n 'caretPosition': range.startOffset\n };\n }\n\n if (node != range.endContainer) {\n return null;\n }\n\n if (node.nodeType == 1) {\n // ELEMENT_NODE.\n var position = range.startOffset;\n\n if (node.childNodes[position]) {\n return {\n 'node': node.childNodes[position]\n };\n }\n }\n }\n\n return null;\n }\n /**\r\n * Returns null if there isn't any item or if it is malformed.\r\n * Otherwise returns an object containing the node with the MathML image\r\n * and the cursor position inside the textarea.\r\n * @param {HTMLTextAreaElement} textarea - textarea element.\r\n * @returns {Object} An object containing the node, the index of the\r\n * beginning of the selected text, caret position and the start and end position of the\r\n * text node.\r\n * @static\r\n */\n\n }, {\n key: \"getSelectedItemOnTextarea\",\n value: function getSelectedItemOnTextarea(textarea) {\n var textNode = document.createTextNode(textarea.value);\n var textNodeValues = _latex__WEBPACK_IMPORTED_MODULE_2__[\"default\"].getLatexFromTextNode(textNode, textarea.selectionStart);\n\n if (textNodeValues === null) {\n return null;\n }\n\n ;\n return {\n 'node': textNode,\n 'caretPosition': textarea.selectionStart,\n 'startPosition': textNodeValues.startPosition,\n 'endPosition': textNodeValues.endPosition\n };\n }\n /**\r\n * Looks for elements that match the given name in a HTML code string.\r\n * Important: this function is very concrete for WIRIS code. It takes as preconditions lots of behaviors that are not the general case.\r\n * @param {string} code - HTML code.\r\n * @param {string} name - element name.\r\n * @param {boolean} autoClosed - true if the elements are autoClosed.\r\n * @return {Object[]} an object containing all HTML elements of code matching the name argument.\r\n * @static\r\n */\n\n }, {\n key: \"getElementsByNameFromString\",\n value: function getElementsByNameFromString(code, name, autoClosed) {\n var elements = [];\n var code = code.toLowerCase();\n name = name.toLowerCase();\n var start = code.indexOf('<' + name + ' ');\n\n while (start != -1) {\n // Look for nodes.\n var endString;\n\n if (autoClosed) {\n endString = '>';\n } else {\n endString = '';\n }\n\n var end = code.indexOf(endString, start);\n\n if (end != -1) {\n end += endString.length;\n elements.push({\n 'start': start,\n 'end': end\n });\n } else {\n end = start + 1;\n }\n\n start = code.indexOf('<' + name + ' ', end);\n }\n\n return elements;\n }\n /**\r\n * Returns the numeric value of a base64 character.\r\n * @param {string} character - base64 character.\r\n * @returns {number} base64 character numeric value.\r\n * @static\r\n */\n\n }, {\n key: \"decode64\",\n value: function decode64(character) {\n var PLUS = '+'.charCodeAt(0);\n var SLASH = '/'.charCodeAt(0);\n var NUMBER = '0'.charCodeAt(0);\n var LOWER = 'a'.charCodeAt(0);\n var UPPER = 'A'.charCodeAt(0);\n var PLUS_URL_SAFE = '-'.charCodeAt(0);\n var SLASH_URL_SAFE = '_'.charCodeAt(0);\n var code = character.charCodeAt(0);\n\n if (code === PLUS || code === PLUS_URL_SAFE) {\n return 62; // Char '+'.\n }\n\n if (code === SLASH || code === SLASH_URL_SAFE) {\n return 63; // Char '/'.\n }\n\n if (code < NUMBER) {\n return -1; // No match.\n }\n\n if (code < NUMBER + 10) {\n return code - NUMBER + 26 + 26;\n }\n\n if (code < UPPER + 26) {\n return code - UPPER;\n }\n\n if (code < LOWER + 26) {\n return code - LOWER + 26;\n }\n }\n /**\r\n * Converts a base64 string to a array of bytes.\r\n * @param {string} b64String - base64 string.\r\n * @param {number} length - dimension of byte array (by default whole string).\r\n * @return {Object[]} the resultant byte array.\r\n * @static\r\n */\n\n }, {\n key: \"b64ToByteArray\",\n value: function b64ToByteArray(b64String, length) {\n var tmp;\n\n if (b64String.length % 4 > 0) {\n throw new Error('Invalid string. Length must be a multiple of 4'); // Tipped base64. Length is fixed.\n }\n\n var arr = new Array();\n\n if (!length) {\n // All b64String string.\n var placeHolders = b64String.charAt(b64String.length - 2) === '=' ? 2 : b64String.charAt(b64String.length - 1) === '=' ? 1 : 0;\n var l = placeHolders > 0 ? b64String.length - 4 : b64String.length;\n } else {\n var l = length;\n }\n\n for (var i = 0; i < l; i += 4) {\n // Ignoring code checker standards (bitewise operators).\n // See https://tracker.moodle.org/browse/CONTRIB-5862 for further information.\n // @codingStandardsIgnoreStart\n tmp = Util.decode64(b64String.charAt(i)) << 18 | Util.decode64(b64String.charAt(i + 1)) << 12 | Util.decode64(b64String.charAt(i + 2)) << 6 | Util.decode64(b64String.charAt(i + 3));\n arr.push(tmp >> 16 & 0xFF);\n arr.push(tmp >> 8 & 0xFF);\n arr.push(tmp & 0xFF); // @codingStandardsIgnoreEnd\n }\n\n if (placeHolders) {\n if (placeHolders === 2) {\n // Ignoring code checker standards (bitewise operators).\n // @codingStandardsIgnoreStart\n tmp = Util.decode64(b64String.charAt(i)) << 2 | Util.decode64(b64String.charAt(i + 1)) >> 4;\n arr.push(tmp & 0xFF);\n } else if (placeHolders === 1) {\n tmp = Util.decode64(b64String.charAt(i)) << 10 | Util.decode64(b64String.charAt(i + 1)) << 4 | Util.decode64(b64String.charAt(i + 2)) >> 2;\n arr.push(tmp >> 8 & 0xFF);\n arr.push(tmp & 0xFF); // @codingStandardsIgnoreEnd\n }\n }\n\n return arr;\n }\n /**\r\n * Returns the first 32-bit signed integer from a byte array.\r\n * @param {Object[]} bytes - array of bytes.\r\n * @returns {number} the 32-bit signed integer.\r\n * @static\r\n */\n\n }, {\n key: \"readInt32\",\n value: function readInt32(bytes) {\n if (bytes.length < 4) {\n return false;\n }\n\n var int32 = bytes.splice(0, 4); // @codingStandardsIgnoreStart\n\n return int32[0] << 24 | int32[1] << 16 | int32[2] << 8 | int32[3] << 0; // @codingStandardsIgnoreEnd\n }\n /**\r\n * Read the first byte from a byte array.\r\n * @param {Object} bytes - input byte array.\r\n * @returns {number} first byte of the byte array.\r\n * @static\r\n */\n\n }, {\n key: \"readByte\",\n value: function readByte(bytes) {\n // @codingStandardsIgnoreStart\n return bytes.shift() << 0; // @codingStandardsIgnoreEnd\n }\n /**\r\n * Read an arbitrary number of bytes, from a fixed position on a byte array.\r\n * @param {Object[]} bytes - byte array.\r\n * @param {number} pos - start position.\r\n * @param {number} len - number of bytes to read.\r\n * @returns {Object[]} the byte array.\r\n * @static\r\n */\n\n }, {\n key: \"readBytes\",\n value: function readBytes(bytes, pos, len) {\n return bytes.splice(pos, len);\n }\n /**\r\n * Inserts or modifies formulas or CAS on a textarea.\r\n * @param {HTMLTextAreaElement} textarea - textarea target.\r\n * @param {string} text - text to add in the textarea. For example, to add the link to the image,\r\n * call this function as (textarea, Parser.createImageSrc(mathml));\r\n * @static\r\n */\n\n }, {\n key: \"updateTextArea\",\n value: function updateTextArea(textarea, text) {\n if (textarea && text) {\n textarea.focus();\n\n if (textarea.selectionStart != null) {\n var selectionEnd = textarea.selectionEnd;\n textarea.value = textarea.value.substring(0, textarea.selectionStart) + text + textarea.value.substring(textarea.selectionEnd, textarea.value.length);\n textarea.selectionEnd = selectionEnd + text.length;\n } else {\n var selection = document.selection.createRange();\n selection.text = text;\n }\n }\n }\n /**\r\n * Modifies existing formula on a textarea.\r\n * @param {HTMLTextAreaElement} textarea - text area target.\r\n * @param {string} text - text to add in the textarea. For example, if you want to add the link to the image, you can call this function as Util.updateTextarea(textarea, Parser.createImageSrc(mathml));\r\n * @param {number} start - beginning index from textarea where it needs to be replaced by text.\r\n * @param {number} end - ending index from textarea where it needs to be replaced by text\r\n * @static\r\n */\n\n }, {\n key: \"updateExistingTextOnTextarea\",\n value: function updateExistingTextOnTextarea(textarea, text, start, end) {\n textarea.focus();\n textarea.value = textarea.value.substring(0, start) + text + textarea.value.substring(end, textarea.value.length);\n textarea.selectionEnd = start + text.length;\n }\n /**\r\n * Add a parameter with it's correspondent value to an URL (GET).\r\n * @param {string} path - URL path\r\n * @param {string} parameter - parameter\r\n * @param {string} value - value\r\n * @static\r\n */\n\n }, {\n key: \"addArgument\",\n value: function addArgument(path, parameter, value) {\n var sep;\n\n if (path.indexOf(\"?\") > 0) {\n sep = \"&\";\n } else {\n sep = \"?\";\n }\n\n return path + sep + parameter + \"=\" + value;\n }\n }]);\n\n return Util;\n}();\n\n\n\n//# sourceURL=webpack:///./core/src/util.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"default\", function() { return Util; });\n/* harmony import */ var _mathml__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./mathml */ \"./core/src/mathml.js\");\n/* harmony import */ var _configuration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./configuration */ \"./core/src/configuration.js\");\n/* harmony import */ var _latex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./latex */ \"./core/src/latex.js\");\n/* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./constants */ \"./core/src/constants.js\");\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\n\n\n\n\n/**\r\n * This class represents an utility class.\r\n */\n\nvar Util =\n/*#__PURE__*/\nfunction () {\n function Util() {\n _classCallCheck(this, Util);\n }\n\n _createClass(Util, null, [{\n key: \"fireEvent\",\n\n /**\r\n * Fires an event in a target.\r\n * @param {EventTarget} eventTarget - target where event should be fired.\r\n * @param {string} eventName event to fire.\r\n * @static\r\n */\n value: function fireEvent(eventTarget, eventName) {\n if (document.createEvent) {\n var eventObject = document.createEvent('HTMLEvents');\n eventObject.initEvent(eventName, true, true);\n return !eventTarget.dispatchEvent(eventObject);\n }\n\n var eventObject = document.createEventObject();\n return eventTarget.fireEvent('on' + eventName, eventObject);\n }\n /**\r\n * Cross-browser addEventListener/attachEvent function.\r\n * @param {EventTarget} eventTarget - target to add the event.\r\n * @param {string} eventName - specifies the type of event.\r\n * @param {Function} callBackFunction - callback function.\r\n * @static\r\n */\n\n }, {\n key: \"addEvent\",\n value: function addEvent(eventTarget, eventName, callBackFunction) {\n if (eventTarget.addEventListener) {\n eventTarget.addEventListener(eventName, callBackFunction, true);\n } else if (eventTarget.attachEvent) {\n // Backwards compatibility.\n eventTarget.attachEvent('on' + eventName, callBackFunction);\n }\n }\n /**\r\n * Cross-browser removeEventListener/detachEvent function.\r\n * @param {EventTarget} eventTarget - target to add the event.\r\n * @param {string} eventName - specifies the type of event.\r\n * @param {Function} callBackFunction - function to remove from the event target.\r\n * @static\r\n */\n\n }, {\n key: \"removeEvent\",\n value: function removeEvent(eventTarget, eventName, callBackFunction) {\n if (eventTarget.removeEventListener) {\n eventTarget.removeEventListener(eventName, callBackFunction, true);\n } else if (eventTarget.detachEvent) {\n eventTarget.detachEvent('on' + eventName, callBackFunction);\n }\n }\n /**\r\n * Adds the a callback function, for a certain event target, to the following event types:\r\n * - dblclick\r\n * - mousedown\r\n * - mouseup\r\n * @param {EventTarget} eventTarget - event target.\r\n * @param {Function} doubleClickHandler - function to run when on dblclick event.\r\n * @param {Function} mousedownHandler - function to run when on mousedown event.\r\n * @param {Function} mouseupHandler - function to run when on mouseup event.\r\n * @static\r\n */\n\n }, {\n key: \"addElementEvents\",\n value: function addElementEvents(eventTarget, doubleClickHandler, mousedownHandler, mouseupHandler) {\n if (doubleClickHandler) {\n Util.addEvent(eventTarget, 'dblclick', function (event) {\n var realEvent = event ? event : window.event;\n var element = realEvent.srcElement ? realEvent.srcElement : realEvent.target;\n doubleClickHandler(element, realEvent);\n });\n }\n\n if (mousedownHandler) {\n Util.addEvent(eventTarget, 'mousedown', function (event) {\n var realEvent = event ? event : window.event;\n var element = realEvent.srcElement ? realEvent.srcElement : realEvent.target;\n mousedownHandler(element, realEvent);\n });\n }\n\n if (mouseupHandler) {\n Util.addEvent(eventTarget, 'mouseup', function (event) {\n var realEvent = event ? event : window.event;\n var element = realEvent.srcElement ? realEvent.srcElement : realEvent.target;\n mouseupHandler(element, realEvent);\n });\n }\n }\n /**\r\n * Adds a class name to a HTMLElement.\r\n * @param {HTMLElement} element - the HTML element.\r\n * @param {string} className - the class name.\r\n * @static\r\n */\n\n }, {\n key: \"addClass\",\n value: function addClass(element, className) {\n if (!Util.containsClass(element, className)) {\n element.className += \" \" + className;\n }\n }\n /**\r\n * Checks if a HTMLElement contains a certain class.\r\n * @param {HTMLElement} element - the HTML element.\r\n * @param {string} className - the className.\r\n * @returns {boolean} true if the HTMLElement contains the class name. false otherwise.\r\n * @static\r\n */\n\n }, {\n key: \"containsClass\",\n value: function containsClass(element, className) {\n if (element == null || !('className' in element)) {\n return false;\n }\n\n var currentClasses = element.className.split(' ');\n\n for (var i = currentClasses.length - 1; i >= 0; --i) {\n if (currentClasses[i] == className) {\n return true;\n }\n }\n\n return false;\n }\n /**\r\n * Remove a certain class for a HTMLElement.\r\n * @param {HTMLElement} element - the HTML element.\r\n * @param {string} className - the class name.\r\n * @static\r\n */\n\n }, {\n key: \"removeClass\",\n value: function removeClass(element, className) {\n var newClassName = '';\n var classes = element.className.split(\" \");\n\n for (var i = 0; i < classes.length; i++) {\n if (classes[i] != className) {\n newClassName += classes[i] + \" \";\n }\n }\n\n element.className = newClassName.trim();\n }\n /**\r\n * Converts old xml initial text attribute (with «») to the correct one(with §lt;§gt;). It's\r\n * used to parse old applets.\r\n * @param {string} text - string containing safeXml characters\r\n * @returns {string} a string with safeXml characters parsed.\r\n * @static\r\n */\n\n }, {\n key: \"convertOldXmlinitialtextAttribute\",\n value: function convertOldXmlinitialtextAttribute(text) {\n // Used to fix a bug with Cas imported from Moodle 1.9 to Moodle 2.x.\n // This could be removed in future.\n var val = 'value=';\n var xitpos = text.indexOf('xmlinitialtext');\n var valpos = text.indexOf(val, xitpos);\n var quote = text.charAt(valpos + val.length);\n var startquote = valpos + val.length + 1;\n var endquote = text.indexOf(quote, startquote);\n var value = text.substring(startquote, endquote);\n var newvalue = value.split('«').join('§lt;');\n newvalue = newvalue.split('»').join('§gt;');\n newvalue = newvalue.split('&').join('§');\n newvalue = newvalue.split('¨').join('§quot;');\n text = text.split(value).join(newvalue);\n return text;\n }\n /**\r\n * Cross-browser solution for creating new elements.\r\n * @param {string} tagName - tag name of the wished element.\r\n * @param {Object} attributes - an object where each key is a wished attribute name and each value is its value.\r\n * @param {Object} [creator] - if supplied, this function will use the \"createElement\" method from this param. Otherwise\r\n * document will be used as creator.\r\n * @returns {Element} The DOM element with the specified attributes assigned.\r\n * @static\r\n */\n\n }, {\n key: \"createElement\",\n value: function createElement(tagName, attributes, creator) {\n if (attributes === undefined) {\n attributes = {};\n }\n\n if (creator === undefined) {\n creator = document;\n }\n\n var element;\n /*\r\n * Internet Explorer fix:\r\n * If you create a new object dynamically, you can't set a non-standard attribute.\r\n * For example, you can't set the \"src\" attribute on an \"applet\" object.\r\n * Other browsers will throw an exception and will run the standard code.\r\n */\n\n try {\n var html = '<' + tagName;\n\n for (var attributeName in attributes) {\n html += ' ' + attributeName + '=\"' + Util.htmlEntities(attributes[attributeName]) + '\"';\n }\n\n html += '>';\n element = creator.createElement(html);\n } catch (e) {\n element = creator.createElement(tagName);\n\n for (var attributeName in attributes) {\n element.setAttribute(attributeName, attributes[attributeName]);\n }\n }\n\n return element;\n }\n /**\r\n * Creates new HTML from it's HTML code as string.\r\n * @param {string} objectCode - html code\r\n * @returns {Element} the HTML element.\r\n * @static\r\n */\n\n }, {\n key: \"createObject\",\n value: function createObject(objectCode, creator) {\n if (creator === undefined) {\n creator = document;\n } // Internet Explorer can't include \"param\" tag when is setting an innerHTML property.\n\n\n objectCode = objectCode.split('').join('').split('').join('');\n objectCode = objectCode.split('').join('
').split('').join('
');\n var container = Util.createElement('div', {}, creator);\n container.innerHTML = objectCode;\n\n function recursiveParamsFix(object) {\n if (object.getAttribute && object.getAttribute('wirisObject') == 'WirisParam') {\n var attributesParsed = {};\n\n for (var i = 0; i < object.attributes.length; ++i) {\n if (object.attributes[i].nodeValue !== null) {\n attributesParsed[object.attributes[i].nodeName] = object.attributes[i].nodeValue;\n }\n }\n\n var param = Util.createElement('param', attributesParsed, creator); // IE fix.\n\n if (param.NAME) {\n param.name = param.NAME;\n param.value = param.VALUE;\n }\n\n param.removeAttribute('wirisObject');\n object.parentNode.replaceChild(param, object);\n } else if (object.getAttribute && object.getAttribute('wirisObject') == 'WirisApplet') {\n var attributesParsed = {};\n\n for (var i = 0; i < object.attributes.length; ++i) {\n if (object.attributes[i].nodeValue !== null) {\n attributesParsed[object.attributes[i].nodeName] = object.attributes[i].nodeValue;\n }\n }\n\n var applet = Util.createElement('applet', attributesParsed, creator);\n applet.removeAttribute('wirisObject');\n\n for (var i = 0; i < object.childNodes.length; ++i) {\n recursiveParamsFix(object.childNodes[i]);\n\n if (object.childNodes[i].nodeName.toLowerCase() == 'param') {\n applet.appendChild(object.childNodes[i]);\n --i; // When we insert the object child into the applet, object loses one child.\n }\n }\n\n object.parentNode.replaceChild(applet, object);\n } else {\n for (var i = 0; i < object.childNodes.length; ++i) {\n recursiveParamsFix(object.childNodes[i]);\n }\n }\n }\n\n recursiveParamsFix(container);\n return container.firstChild;\n }\n /**\r\n * Converts an Element to its HTML code.\r\n * @param {Element} element - entry element.\r\n * @return {string} the HTML code of the input element.\r\n * @static\r\n */\n\n }, {\n key: \"createObjectCode\",\n value: function createObjectCode(element) {\n // In case that the image was not created, the object can be null or undefined.\n if (typeof element == 'undefined' || element == null) {\n return;\n }\n\n if (element.nodeType == 1) {\n // ELEMENT_NODE.\n var output = '<' + element.tagName;\n\n for (var i = 0; i < element.attributes.length; ++i) {\n if (element.attributes[i].specified) {\n output += ' ' + element.attributes[i].name + '=\"' + Util.htmlEntities(element.attributes[i].value) + '\"';\n }\n }\n\n if (element.childNodes.length > 0) {\n output += '>';\n\n for (var i = 0; i < element.childNodes.length; ++i) {\n output += Util.createObject(element.childNodes[i]);\n }\n\n output += '';\n } else if (element.nodeName == 'DIV' || element.nodeName == 'SCRIPT') {\n output += '>';\n } else {\n output += '/>';\n }\n\n return output;\n }\n\n if (element.nodeType == 3) {\n // TEXT_NODE.\n return Util.htmlEntities(element.nodeValue);\n }\n\n return '';\n }\n /**\r\n * Concatenates two URL paths.\r\n * @param {string} path1 - first URL path\r\n * @param {string} path2 - second URL path\r\n * @returns {string} new URL.\r\n */\n\n }, {\n key: \"concatenateUrl\",\n value: function concatenateUrl(path1, path2) {\n var separator = \"\";\n\n if (path1.indexOf(\"/\") != path1.length && path2.indexOf(\"/\") != 0) {\n separator = \"/\";\n }\n\n return (path1 + separator + path2).replace(/([^:]\\/)\\/+/g, \"$1\");\n }\n /**\r\n * Parses a text and replaces all HTML special characters by their correspondent entities.\r\n * @param {string} input - text to be parsed.\r\n * @returns {string} the input text with all their special characters replaced by their entities.\r\n * @static\r\n */\n\n }, {\n key: \"htmlEntities\",\n value: function htmlEntities(input) {\n return input.split('&').join('&').split('<').join('<').split('>').join('>').split('\"').join('"');\n }\n /**\r\n * Parses a text and replaces all the HTML entities by their characters.\r\n * @param {string} input - text to be parsed\r\n * @returns {string} the input text with all their entities replaced by characters.\r\n * @static\r\n */\n\n }, {\n key: \"htmlEntitiesDecode\",\n value: function htmlEntitiesDecode(input) {\n return input.split('"').join('\"').split('>').join('>').split('<').join('<').split('&').join('&');\n }\n /**\r\n * Returns a cross-browser http request.\r\n * @return {object} httpRequest request object.\r\n * @returns {XMLHttpRequest|ActiveXObject} the proper request object.\r\n */\n\n }, {\n key: \"createHttpRequest\",\n value: function createHttpRequest() {\n var currentPath = window.location.toString().substr(0, window.location.toString().lastIndexOf('/') + 1);\n\n if (currentPath.substr(0, 7) == 'file://') {\n throw Core.getStringManager().getString('exception_cross_site');\n }\n\n if (typeof XMLHttpRequest != 'undefined') {\n return new XMLHttpRequest();\n }\n\n try {\n return new ActiveXObject('Msxml2.XMLHTTP');\n } catch (e) {\n try {\n return new ActiveXObject('Microsoft.XMLHTTP');\n } catch (oc) {}\n }\n\n return false;\n }\n /**\r\n * Converts a hash to a HTTP query.\r\n * @param {Object[]} properties - a key/value object.\r\n * @returns {string} a HTTP query containing all the key value pairs with all the special characters replaced by their entities.\r\n * @static\r\n */\n\n }, {\n key: \"httpBuildQuery\",\n value: function httpBuildQuery(properties) {\n var result = '';\n\n for (var i in properties) {\n if (properties[i] != null) {\n result += Util.urlEncode(i) + '=' + Util.urlEncode(properties[i]) + '&';\n }\n } // Deleting last '&' empty character.\n\n\n if (result.substring(result.length - 1) == '&') {\n result = result.substring(0, result.length - 1);\n }\n\n return result;\n }\n /**\r\n * Convert a hash to string sorting keys to get a deterministic output\r\n * @param {Object[]} hash - a key/value object.\r\n * @returns {string} a string with the form key1=value1...keyn=valuen\r\n * @static\r\n */\n\n }, {\n key: \"propertiesToString\",\n value: function propertiesToString(hash) {\n // 1. Sort keys. We sort the keys because we want a deterministic output.\n var keys = [];\n\n for (var key in hash) {\n if (hash.hasOwnProperty(key)) {\n keys.push(key);\n }\n }\n\n var n = keys.length;\n\n for (var i = 0; i < n; i++) {\n for (var j = i + 1; j < n; j++) {\n var s1 = keys[i];\n var s2 = keys[j];\n\n if (Util.compareStrings(s1, s2) > 0) {\n // Swap.\n keys[i] = s2;\n keys[j] = s1;\n }\n }\n } // 2. Generate output.\n\n\n var output = '';\n\n for (var i = 0; i < n; i++) {\n var key = keys[i];\n output += key;\n output += \"=\";\n var value = hash[key];\n value = value.replace(\"\\\\\", \"\\\\\\\\\");\n value = value.replace(\"\\n\", \"\\\\n\");\n value = value.replace(\"\\r\", \"\\\\r\");\n value = value.replace(\"\\t\", \"\\\\t\");\n output += value;\n output += \"\\n\";\n }\n\n return output;\n }\n /**\r\n * Compare two strings using charCodeAt method\r\n * @param {string} a - first string to compare.\r\n * @param {string} b - second string to compare.\r\n * @returns {number} the difference between a and b\r\n * @static\r\n */\n\n }, {\n key: \"compareStrings\",\n value: function compareStrings(a, b) {\n var i;\n var an = a.length;\n var bn = b.length;\n var n = an > bn ? bn : an;\n\n for (i = 0; i < n; i++) {\n var c = Util.fixedCharCodeAt(a, i) - Util.fixedCharCodeAt(b, i);\n\n if (c != 0) {\n return c;\n }\n }\n\n return a.length - b.length;\n }\n /**\r\n * Fix charCodeAt() JavaScript function to handle non-Basic-Multilingual-Plane characters.\r\n * @param {string} string - input string\r\n * @param {number} idx - an integer greater than or equal to 0 and less than the length of the string\r\n * @returns {number} an integer representing the UTF-16 code of the string at the given index.\r\n * @static\r\n */\n\n }, {\n key: \"fixedCharCodeAt\",\n value: function fixedCharCodeAt(string, idx) {\n idx = idx || 0;\n var code = string.charCodeAt(idx);\n var hi, low;\n /* High surrogate (could change last hex to 0xDB7F to treat high\r\n private surrogates as single characters) */\n\n if (0xD800 <= code && code <= 0xDBFF) {\n hi = code;\n low = string.charCodeAt(idx + 1);\n\n if (isNaN(low)) {\n throw Core.getStringManager().getString('exception_high_surrogate');\n }\n\n return (hi - 0xD800) * 0x400 + (low - 0xDC00) + 0x10000;\n }\n\n if (0xDC00 <= code && code <= 0xDFFF) {\n // Low surrogate.\n\n /* We return false to allow loops to skip this iteration since should have\r\n already handled high surrogate above in the previous iteration. */\n return false;\n }\n\n return code;\n }\n /**\r\n * Returns an URL with it's query params converted into array.\r\n * @param {string} url - input URL.\r\n * @returns {Object[]} an array containing all URL query params.\r\n * @static\r\n */\n\n }, {\n key: \"urlToAssArray\",\n value: function urlToAssArray(url) {\n var i;\n i = url.indexOf(\"?\");\n\n if (i > 0) {\n var query = url.substring(i + 1);\n var ss = query.split(\"&\");\n var h = new Object();\n\n for (i = 0; i < ss.length; i++) {\n var s = ss[i];\n var kv = s.split(\"=\");\n\n if (kv.length > 1) {\n h[kv[0]] = decodeURIComponent(kv[1].replace(/\\+/g, ' '));\n }\n }\n\n return h;\n } else {\n return new Object();\n }\n }\n /**\r\n * Returns an encoded URL by replacing each instance of certain characters by\r\n * one, two, three or four escape sequences using encodeURIComponent method.\r\n * !'()* . will not be encoded.\r\n *\r\n * @param {string} clearString - URL string to be encoded\r\n * @returns {string} URL with it's special characters replaced.\r\n * @static\r\n */\n\n }, {\n key: \"urlEncode\",\n value: function urlEncode(clearString) {\n var output = ''; // Method encodeURIComponent doesn't encode !'()*~ .\n\n output = encodeURIComponent(clearString);\n return output;\n } // TODO: To parser?\n\n /**\r\n * Converts the HTML of a image into the output code that WIRIS must return.\r\n * By default returns the MathML stored on data-mahml attribute (if imgCode is a formula)\r\n * or the Wiriscas attribute of a WIRIS applet.\r\n * @param {string} imgCode - the html code from a formula or a CAS image.\r\n * @param {boolean} convertToXml - true if the image should be converted to XML.\r\n * @param {boolean} convertToSafeXml - true if the image should be converted to safeXML.\r\n * @returns {string} the XML or safeXML of a WIRIS image.\r\n * @static\r\n */\n\n }, {\n key: \"getWIRISImageOutput\",\n value: function getWIRISImageOutput(imgCode, convertToXml, convertToSafeXml) {\n var imgObject = Util.createObject(imgCode);\n\n if (imgObject) {\n if (imgObject.className == _configuration__WEBPACK_IMPORTED_MODULE_1__[\"default\"].get('imageClassName') || imgObject.getAttribute(_configuration__WEBPACK_IMPORTED_MODULE_1__[\"default\"].get('imageMathmlAttribute'))) {\n if (!convertToXml) {\n return imgCode;\n }\n\n var xmlCode = imgObject.getAttribute(_configuration__WEBPACK_IMPORTED_MODULE_1__[\"default\"].get('imageMathmlAttribute'));\n\n if (!_configuration__WEBPACK_IMPORTED_MODULE_1__[\"default\"].get('saveHandTraces')) {\n xmlCode = _mathml__WEBPACK_IMPORTED_MODULE_0__[\"default\"].removeSemanticsOcurrences(xmlCode, _constants__WEBPACK_IMPORTED_MODULE_3__[\"default\"].safeXmlCharacters);\n }\n\n if (xmlCode == null) {\n xmlCode = imgObject.getAttribute('alt');\n }\n\n if (!convertToSafeXml) {\n xmlCode = _mathml__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlDecode(xmlCode);\n }\n\n return xmlCode;\n } else if (imgObject.className == _configuration__WEBPACK_IMPORTED_MODULE_1__[\"default\"].get('CASClassName')) {\n var appletCode = imgObject.getAttribute(_configuration__WEBPACK_IMPORTED_MODULE_1__[\"default\"].get('CASMathmlAttribute'));\n appletCode = _mathml__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlDecode(appletCode);\n var appletObject = Util.createObject(appletCode);\n appletObject.setAttribute('src', imgObject.src);\n var object = appletObject;\n var appletCodeToBeInserted = Util.createObjectCode(appletObject);\n\n if (convertToSafeXml) {\n appletCodeToBeInserted = _mathml__WEBPACK_IMPORTED_MODULE_0__[\"default\"].safeXmlEncode(appletCodeToBeInserted);\n }\n\n return appletCodeToBeInserted;\n }\n }\n\n return imgCode;\n }\n /**\r\n * Gets the node length in characters.\r\n * @param {Node} node - HTML node.\r\n * @returns {number} node length.\r\n * @static\r\n */\n\n }, {\n key: \"getNodeLength\",\n value: function (_getNodeLength) {\n function getNodeLength(_x) {\n return _getNodeLength.apply(this, arguments);\n }\n\n getNodeLength.toString = function () {\n return _getNodeLength.toString();\n };\n\n return getNodeLength;\n }(function (node) {\n var staticNodeLengths = {\n 'IMG': 1,\n 'BR': 1\n };\n\n if (node.nodeType == 3) {\n // TEXT_NODE.\n return node.nodeValue.length;\n }\n\n if (node.nodeType == 1) {\n // ELEMENT_NODE.\n var length = staticNodeLengths[node.nodeName.toUpperCase()];\n\n if (length === undefined) {\n length = 0;\n }\n\n for (var i = 0; i < node.childNodes.length; ++i) {\n length += getNodeLength(node.childNodes[i]);\n }\n\n return length;\n }\n\n return 0;\n })\n /**\r\n * Gets a selected node or text from an editable HTMLElement.\r\n * If the caret is on a text node, concatenates it with all the previous and next text nodes.\r\n * @param {HTMLElement} target - the editable HTMLElement.\r\n * @param {boolean} isIframe - specifies if the target is an iframe or not\r\n * @param {boolean} forceGetSelection - if true, ignores IE system to get the current selection and uses window.getSelection()\r\n * @returns {object} an object with the 'node' key set if the item is an element or the keys 'node' and 'caretPosition' if the element is text.\r\n * @static\r\n */\n\n }, {\n key: \"getSelectedItem\",\n value: function getSelectedItem(target, isIframe, forceGetSelection) {\n var windowTarget;\n\n if (isIframe) {\n windowTarget = target.contentWindow;\n windowTarget.focus();\n } else {\n windowTarget = window;\n target.focus();\n }\n\n if (document.selection && !forceGetSelection) {\n var range = windowTarget.document.selection.createRange();\n\n if (range.parentElement) {\n if (range.htmlText.length > 0) {\n if (range.text.length == 0) {\n return Util.getSelectedItem(target, isIframe, true);\n }\n\n return null;\n }\n\n windowTarget.document.execCommand('InsertImage', false, '#');\n var temporalObject = range.parentElement();\n\n if (temporalObject.nodeName.toUpperCase() != 'IMG') {\n // IE9 fix: parentElement() does not return the IMG node, returns the parent DIV node. In IE < 9, pasteHTML does not work well.\n range.pasteHTML('');\n temporalObject = windowTarget.document.getElementById('wrs_openEditorWindow_temporalObject');\n }\n\n var node;\n var caretPosition;\n\n if (temporalObject.nextSibling && temporalObject.nextSibling.nodeType == 3) {\n // TEXT_NODE.\n node = temporalObject.nextSibling;\n caretPosition = 0;\n } else if (temporalObject.previousSibling && temporalObject.previousSibling.nodeType == 3) {\n // TEXT_NODE.\n node = temporalObject.previousSibling;\n caretPosition = node.nodeValue.length;\n } else {\n node = windowTarget.document.createTextNode('');\n temporalObject.parentNode.insertBefore(node, temporalObject);\n caretPosition = 0;\n }\n\n temporalObject.parentNode.removeChild(temporalObject);\n return {\n 'node': node,\n 'caretPosition': caretPosition\n };\n }\n\n if (range.length > 1) {\n return null;\n }\n\n return {\n 'node': range.item(0)\n };\n }\n\n if (windowTarget.getSelection) {\n var selection = windowTarget.getSelection();\n\n try {\n var range = selection.getRangeAt(0);\n } catch (e) {\n var range = windowTarget.document.createRange();\n }\n\n var node = range.startContainer;\n\n if (node.nodeType == 3) {\n // TEXT_NODE.\n return {\n 'node': node,\n 'caretPosition': range.startOffset\n };\n }\n\n if (node != range.endContainer) {\n return null;\n }\n\n if (node.nodeType == 1) {\n // ELEMENT_NODE.\n var position = range.startOffset;\n\n if (node.childNodes[position]) {\n return {\n 'node': node.childNodes[position]\n };\n }\n }\n }\n\n return null;\n }\n /**\r\n * Returns null if there isn't any item or if it is malformed.\r\n * Otherwise returns an object containing the node with the MathML image\r\n * and the cursor position inside the textarea.\r\n * @param {HTMLTextAreaElement} textarea - textarea element.\r\n * @returns {Object} An object containing the node, the index of the\r\n * beginning of the selected text, caret position and the start and end position of the\r\n * text node.\r\n * @static\r\n */\n\n }, {\n key: \"getSelectedItemOnTextarea\",\n value: function getSelectedItemOnTextarea(textarea) {\n var textNode = document.createTextNode(textarea.value);\n var textNodeValues = _latex__WEBPACK_IMPORTED_MODULE_2__[\"default\"].getLatexFromTextNode(textNode, textarea.selectionStart);\n\n if (textNodeValues === null) {\n return null;\n }\n\n ;\n return {\n 'node': textNode,\n 'caretPosition': textarea.selectionStart,\n 'startPosition': textNodeValues.startPosition,\n 'endPosition': textNodeValues.endPosition\n };\n }\n /**\r\n * Looks for elements that match the given name in a HTML code string.\r\n * Important: this function is very concrete for WIRIS code. It takes as preconditions lots of behaviors that are not the general case.\r\n * @param {string} code - HTML code.\r\n * @param {string} name - element name.\r\n * @param {boolean} autoClosed - true if the elements are autoClosed.\r\n * @return {Object[]} an object containing all HTML elements of code matching the name argument.\r\n * @static\r\n */\n\n }, {\n key: \"getElementsByNameFromString\",\n value: function getElementsByNameFromString(code, name, autoClosed) {\n var elements = [];\n var code = code.toLowerCase();\n name = name.toLowerCase();\n var start = code.indexOf('<' + name + ' ');\n\n while (start != -1) {\n // Look for nodes.\n var endString;\n\n if (autoClosed) {\n endString = '>';\n } else {\n endString = '';\n }\n\n var end = code.indexOf(endString, start);\n\n if (end != -1) {\n end += endString.length;\n elements.push({\n 'start': start,\n 'end': end\n });\n } else {\n end = start + 1;\n }\n\n start = code.indexOf('<' + name + ' ', end);\n }\n\n return elements;\n }\n /**\r\n * Returns the numeric value of a base64 character.\r\n * @param {string} character - base64 character.\r\n * @returns {number} base64 character numeric value.\r\n * @static\r\n */\n\n }, {\n key: \"decode64\",\n value: function decode64(character) {\n var PLUS = '+'.charCodeAt(0);\n var SLASH = '/'.charCodeAt(0);\n var NUMBER = '0'.charCodeAt(0);\n var LOWER = 'a'.charCodeAt(0);\n var UPPER = 'A'.charCodeAt(0);\n var PLUS_URL_SAFE = '-'.charCodeAt(0);\n var SLASH_URL_SAFE = '_'.charCodeAt(0);\n var code = character.charCodeAt(0);\n\n if (code === PLUS || code === PLUS_URL_SAFE) {\n return 62; // Char '+'.\n }\n\n if (code === SLASH || code === SLASH_URL_SAFE) {\n return 63; // Char '/'.\n }\n\n if (code < NUMBER) {\n return -1; // No match.\n }\n\n if (code < NUMBER + 10) {\n return code - NUMBER + 26 + 26;\n }\n\n if (code < UPPER + 26) {\n return code - UPPER;\n }\n\n if (code < LOWER + 26) {\n return code - LOWER + 26;\n }\n }\n /**\r\n * Converts a base64 string to a array of bytes.\r\n * @param {string} b64String - base64 string.\r\n * @param {number} length - dimension of byte array (by default whole string).\r\n * @return {Object[]} the resultant byte array.\r\n * @static\r\n */\n\n }, {\n key: \"b64ToByteArray\",\n value: function b64ToByteArray(b64String, length) {\n var tmp;\n\n if (b64String.length % 4 > 0) {\n throw new Error('Invalid string. Length must be a multiple of 4'); // Tipped base64. Length is fixed.\n }\n\n var arr = new Array();\n\n if (!length) {\n // All b64String string.\n var placeHolders = b64String.charAt(b64String.length - 2) === '=' ? 2 : b64String.charAt(b64String.length - 1) === '=' ? 1 : 0;\n var l = placeHolders > 0 ? b64String.length - 4 : b64String.length;\n } else {\n var l = length;\n }\n\n for (var i = 0; i < l; i += 4) {\n // Ignoring code checker standards (bitewise operators).\n // See https://tracker.moodle.org/browse/CONTRIB-5862 for further information.\n // @codingStandardsIgnoreStart\n tmp = Util.decode64(b64String.charAt(i)) << 18 | Util.decode64(b64String.charAt(i + 1)) << 12 | Util.decode64(b64String.charAt(i + 2)) << 6 | Util.decode64(b64String.charAt(i + 3));\n arr.push(tmp >> 16 & 0xFF);\n arr.push(tmp >> 8 & 0xFF);\n arr.push(tmp & 0xFF); // @codingStandardsIgnoreEnd\n }\n\n if (placeHolders) {\n if (placeHolders === 2) {\n // Ignoring code checker standards (bitewise operators).\n // @codingStandardsIgnoreStart\n tmp = Util.decode64(b64String.charAt(i)) << 2 | Util.decode64(b64String.charAt(i + 1)) >> 4;\n arr.push(tmp & 0xFF);\n } else if (placeHolders === 1) {\n tmp = Util.decode64(b64String.charAt(i)) << 10 | Util.decode64(b64String.charAt(i + 1)) << 4 | Util.decode64(b64String.charAt(i + 2)) >> 2;\n arr.push(tmp >> 8 & 0xFF);\n arr.push(tmp & 0xFF); // @codingStandardsIgnoreEnd\n }\n }\n\n return arr;\n }\n /**\r\n * Returns the first 32-bit signed integer from a byte array.\r\n * @param {Object[]} bytes - array of bytes.\r\n * @returns {number} the 32-bit signed integer.\r\n * @static\r\n */\n\n }, {\n key: \"readInt32\",\n value: function readInt32(bytes) {\n if (bytes.length < 4) {\n return false;\n }\n\n var int32 = bytes.splice(0, 4); // @codingStandardsIgnoreStart\n\n return int32[0] << 24 | int32[1] << 16 | int32[2] << 8 | int32[3] << 0; // @codingStandardsIgnoreEnd\n }\n /**\r\n * Read the first byte from a byte array.\r\n * @param {Object} bytes - input byte array.\r\n * @returns {number} first byte of the byte array.\r\n * @static\r\n */\n\n }, {\n key: \"readByte\",\n value: function readByte(bytes) {\n // @codingStandardsIgnoreStart\n return bytes.shift() << 0; // @codingStandardsIgnoreEnd\n }\n /**\r\n * Read an arbitrary number of bytes, from a fixed position on a byte array.\r\n * @param {Object[]} bytes - byte array.\r\n * @param {number} pos - start position.\r\n * @param {number} len - number of bytes to read.\r\n * @returns {Object[]} the byte array.\r\n * @static\r\n */\n\n }, {\n key: \"readBytes\",\n value: function readBytes(bytes, pos, len) {\n return bytes.splice(pos, len);\n }\n /**\r\n * Inserts or modifies formulas or CAS on a textarea.\r\n * @param {HTMLTextAreaElement} textarea - textarea target.\r\n * @param {string} text - text to add in the textarea. For example, to add the link to the image,\r\n * call this function as (textarea, Parser.createImageSrc(mathml));\r\n * @static\r\n */\n\n }, {\n key: \"updateTextArea\",\n value: function updateTextArea(textarea, text) {\n if (textarea && text) {\n textarea.focus();\n\n if (textarea.selectionStart != null) {\n var selectionEnd = textarea.selectionEnd;\n textarea.value = textarea.value.substring(0, textarea.selectionStart) + text + textarea.value.substring(textarea.selectionEnd, textarea.value.length);\n textarea.selectionEnd = selectionEnd + text.length;\n } else {\n var selection = document.selection.createRange();\n selection.text = text;\n }\n }\n }\n /**\r\n * Modifies existing formula on a textarea.\r\n * @param {HTMLTextAreaElement} textarea - text area target.\r\n * @param {string} text - text to add in the textarea. For example, if you want to add the link to the image, you can call this function as Util.updateTextarea(textarea, Parser.createImageSrc(mathml));\r\n * @param {number} start - beginning index from textarea where it needs to be replaced by text.\r\n * @param {number} end - ending index from textarea where it needs to be replaced by text\r\n * @static\r\n */\n\n }, {\n key: \"updateExistingTextOnTextarea\",\n value: function updateExistingTextOnTextarea(textarea, text, start, end) {\n textarea.focus();\n textarea.value = textarea.value.substring(0, start) + text + textarea.value.substring(end, textarea.value.length);\n textarea.selectionEnd = start + text.length;\n }\n /**\r\n * Add a parameter with it's correspondent value to an URL (GET).\r\n * @param {string} path - URL path\r\n * @param {string} parameter - parameter\r\n * @param {string} value - value\r\n * @static\r\n */\n\n }, {\n key: \"addArgument\",\n value: function addArgument(path, parameter, value) {\n var sep;\n\n if (path.indexOf(\"?\") > 0) {\n sep = \"&\";\n } else {\n sep = \"?\";\n }\n\n return path + sep + parameter + \"=\" + value;\n }\n }]);\n\n return Util;\n}();\n\n\n\n//# sourceURL=webpack:///./core/src/util.js?"); /***/ }), @@ -393,7 +393,7 @@ eval("\nvar content = __webpack_require__(/*! !../node_modules/mini-css-extract- /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"TinyMceIntegration\", function() { return TinyMceIntegration; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"instances\", function() { return instances; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"currentInstance\", function() { return currentInstance; });\n/* harmony import */ var _core_src_integrationmodel_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./core/src/integrationmodel.js */ \"./core/src/integrationmodel.js\");\n/* harmony import */ var _core_src_configuration_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./core/src/configuration.js */ \"./core/src/configuration.js\");\n/* harmony import */ var _core_src_parser_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./core/src/parser.js */ \"./core/src/parser.js\");\n/* harmony import */ var _core_src_util__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./core/src/util */ \"./core/src/util.js\");\n/* harmony import */ var _core_src_listeners__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./core/src/listeners */ \"./core/src/listeners.js\");\nfunction _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) { return call; } return _assertThisInitialized(self); }\n\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\n\nfunction _get(target, property, receiver) { if (typeof Reflect !== \"undefined\" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(receiver); } return desc.value; }; } return _get(target, property, receiver || target); }\n\nfunction _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }\n\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function\"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }\n\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\n\n\n\n\n\n\n/**\n * TinyMCE integration class. This class extends IntegrationModel class.\n */\n\nvar TinyMceIntegration =\n/*#__PURE__*/\nfunction (_IntegrationModel) {\n _inherits(TinyMceIntegration, _IntegrationModel);\n\n function TinyMceIntegration(integrationModelProperties) {\n var _this;\n\n _classCallCheck(this, TinyMceIntegration);\n\n _this = _possibleConstructorReturn(this, _getPrototypeOf(TinyMceIntegration).call(this, integrationModelProperties));\n /**\n * Indicates if the content of the TinyMCe editor has\n * been parsed.\n * @type {boolean}\n */\n\n _this.initParsed = integrationModelProperties.initParsed;\n /**\n * Indicates if the TinyMCE is integrated in Moodle.\n * @type {boolean}\n */\n\n _this.isMoodle = integrationModelProperties.isMoodle;\n /**\n * Indicates if the plugin is loaded as an external plugin by TinyMCE.\n * @type {boolean}\n */\n\n _this.isExternal = integrationModelProperties.isExternal;\n return _this;\n }\n /**\n * Returns the absolute path of the integration script. Depends on\n * TinyMCE integration (Moodle or standard).\n * @returns {boolean} - Absolute path for the integration script.\n */\n\n\n _createClass(TinyMceIntegration, [{\n key: \"getPath\",\n value: function getPath() {\n if (this.isMoodle) {\n var search = 'lib/editor/tinymce';\n var pos = tinymce.baseURL.indexOf(search);\n var baseURL = tinymce.baseURL.substr(0, pos + search.length);\n return baseURL + '/plugins/tiny_mce_wiris/tinymce/';\n } else if (this.isExternal) {\n var externalUrl = this.editorObject.getParam('external_plugins')['tiny_mce_wiris'];\n return externalUrl.substring(0, externalUrl.lastIndexOf('/') + 1);\n } else {\n return tinymce.baseURL + '/plugins/tiny_mce_wiris/';\n }\n }\n /**\n * Returns the absolute path of plugin icons. A set of different\n * icons is needed for TinyMCE and Moodle 2.5-\n * @returns {string} - Absolute path of the icons folder.\n */\n\n }, {\n key: \"getIconsPath\",\n value: function getIconsPath() {\n if (this.isMoodle && _core_src_configuration_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].get('versionPlatform') < 2013111800) {\n return this.getPath() + 'icons/tinymce3/';\n } else {\n return this.getPath() + 'icons/';\n }\n }\n /**\n * Returns the integration language. TinyMCE language is inherited.\n * @returns {string} - Integration language.\n */\n\n }, {\n key: \"getLanguage\",\n value: function getLanguage() {\n if (this.editorObject.settings['wirisformulaeditorlang']) {\n return editor.settings['wirisformulaeditorlang'];\n }\n\n return this.editorObject.getParam('language');\n }\n /**\n * Callback function called before 'onTargetLoad' is fired. All the logic here is to\n * avoid TinyMCE change MathType formulas.\n */\n\n }, {\n key: \"callbackFunction\",\n value: function callbackFunction() {\n var dataImgFiltered = [];\n\n _get(_getPrototypeOf(TinyMceIntegration.prototype), \"callbackFunction\", this).call(this); // Avoid to change class of image formulas.\n\n\n var imageClassName = _core_src_configuration_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].get('imageClassName');\n\n if (this.isIframe) {\n // Attaching observers to wiris images.\n if (typeof _core_src_parser_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].observer != 'undefined') {\n Array.prototype.forEach.call(this.target.contentDocument.getElementsByClassName(imageClassName), function (wirisImages) {\n _core_src_parser_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].observer.observe(wirisImages);\n });\n }\n } else {\n // Inline.\n // Attaching observers to wiris images.\n Array.prototype.forEach.call(document.getElementsByClassName(imageClassName), function (wirisImages) {\n _core_src_parser_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].observer.observe(wirisImages);\n });\n } // When a formula is updated TinyMCE 'Change' event must be fired.\n // See https://www.tiny.cloud/docs/advanced/events/#change for further information.\n\n\n var listener = _core_src_listeners__WEBPACK_IMPORTED_MODULE_4__[\"default\"].newListener('onAfterFormulaInsertion', function () {\n if (typeof this.editorObject.fire != 'undefined') {\n this.editorObject.fire('Change');\n }\n }.bind(this));\n this.getCore().addListener(listener); // Avoid filter formulas with performance enabled.\n\n dataImgFiltered[this.editorObject.id] = this.editorObject.settings.images_dataimg_filter;\n\n this.editorObject.settings.images_dataimg_filter = function (img) {\n if (img.hasAttribute('class') && img.getAttribute('class').indexOf(_core_src_configuration_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].get(imageClassName)) != -1) {\n return img.hasAttribute('internal-blob');\n } else {\n // If the client put an image data filter, run. Otherwise default behaviour (put blob).\n if (typeof dataImgFiltered[this.editorObject.id] != 'undefined') {\n return dataImgFiltered[this.editorObject.id](img);\n }\n\n return true;\n }\n };\n }\n }]);\n\n return TinyMceIntegration;\n}(_core_src_integrationmodel_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"]);\n/**\n * Object containing all TinyMCE integration instances. One for each TinyMCE editor.\n * @type {Object}\n */\n\nvar instances = {};\n/**\n * TinyMCE integration current instance. The current instance\n * is the instance related with the focused editor.\n * @type {TinyMceIntegration}\n */\n\nvar currentInstance = null;\n/* Plugin integration */\n\n(function () {\n tinymce.create('tinymce.plugins.tiny_mce_wiris', {\n init: function init(editor, url) {\n // Array with MathML valid alements.\n var validMathML = ['math[*]', 'maction[*]]', 'malignmark[*]', 'maligngroup[*]', 'menclose[*]', 'merror[*]', 'mfenced[*]', 'mfrac[*]', 'mglyph[*]', 'mi[*]', 'mlabeledtr[*]', 'mlongdiv[*]', 'mmultiscripts[*]', 'mn[*]', 'mo[*]', 'mover[*]', 'mpadded[*]', 'mphantom[*]', 'mprescripts[*]', 'mroot[*]', 'mrow[*]', 'ms[*]', 'mscarries[*]', 'mscarry[*]', 'msgroup[*]', 'msline[*]', 'mspace[*]', 'msqrt[*]', 'msrow[*]', 'mstack[*]', 'mstyle[*]', 'msub[*]', 'msubsup[*]', 'msup[*]', 'mtable[*]', 'mtd[*]', 'mtext[*]', 'mtr[*]', 'munder[*]', 'munderover[*]', 'semantics[*]', 'annotation[*]'];\n editor.settings.extended_valid_elements += ',' + validMathML.join();\n var callbackMethodArguments = {};\n /**\n * Integration model properties\n * @type {object}\n * @property {object} target - Integration DOM target.\n * @property {string} configurationService - Configuration integration service.\n * @property {string} version - Plugin version.\n * @property {string} scriptName - Integration script name.\n * @property {object} environment - Integration environment properties.\n * @property {string} editor - Editor name.\n */\n\n var integrationModelProperties = {};\n integrationModelProperties.configurationService = '' + M.cfg.wwwroot + '/filter/wiris/integration/configurationjs.php';\n integrationModelProperties.version = '7.6.1.1393';\n integrationModelProperties.isMoodle = true;\n\n if (typeof editor.getParam('wiriscontextpath') !== 'undefined') {\n integrationModelProperties.configurationService = _core_src_util__WEBPACK_IMPORTED_MODULE_3__[\"default\"].concatenateUrl(editor.getParam('wiriscontextpath'), integrationModelProperties.configurationService);\n editor.getParam('wiriscontextpath') + '/' + integrationModelProperties.configurationService;\n }\n\n integrationModelProperties.version = '7.5.0.1414';\n integrationModelProperties.scriptName = \"plugin.min.js\";\n integrationModelProperties.environment = {};\n integrationModelProperties.environment.editor = \"TinyMCE 4.x\";\n integrationModelProperties.callbackMethodArguments = callbackMethodArguments;\n integrationModelProperties.editorObject = editor;\n integrationModelProperties.initParsed = false; // We need to create the instance before TinyMce initialization in order to register commands.\n // However, as TinyMCE is not initialized at this point the HTML target is not created.\n // Here we create the target as null and onInit object the target is updated.\n\n integrationModelProperties.target = null;\n var isExternalPlugin = typeof editor.getParam('external_plugins') !== 'undefined' && 'tiny_mce_wiris' in editor.getParam('external_plugins');\n integrationModelProperties.isExternal = isExternalPlugin;\n integrationModelProperties.rtl = editor.getParam('directionality') === 'rtl'; // GenericIntegration instance.\n\n var tinyMceIntegrationInstance = new TinyMceIntegration(integrationModelProperties);\n tinyMceIntegrationInstance.init();\n WirisPlugin.instances[tinyMceIntegrationInstance.editorObject.id] = tinyMceIntegrationInstance;\n WirisPlugin.currentInstance = tinyMceIntegrationInstance;\n\n var onInit = function onInit(editor) {\n var integrationInstance = WirisPlugin.instances[tinyMceIntegrationInstance.editorObject.id];\n\n if (!editor.inline) {\n integrationInstance.setTarget(editor.getContentAreaContainer().firstChild);\n } else {\n integrationInstance.setTarget(editor.getElement());\n }\n\n integrationInstance.setEditorObject(editor);\n integrationInstance.listeners.fire('onTargetReady', {});\n\n if ('wiriseditorparameters' in editor.settings) {\n _core_src_configuration_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].update('_wrs_conf_editorParameters', editor.settings.wiriseditorparameters);\n }\n\n var content = editor.getContent(); // Bug fix: In Moodle2.x when TinyMCE is set to full screen\n // the content doesn't need to be filtered.\n\n if (!editor.getParam('fullscreen_is_enabled') && content !== \"\") {\n // We set content in html because other tiny plugins need data-mce\n // and this is not posibil with raw format.\n editor.setContent(_core_src_parser_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].initParse(content, editor.getParam('language')), {\n format: \"html\"\n }); // This clean undoQueue for prevent onChange and Dirty state.\n\n editor.undoManager.clear();\n } // Init parsing OK. If a setContent method is called\n // wrs_initParse is called again.\n // Now if source code is edited the returned code is parsed.\n // PLUGINS-1070: We set this variable out of condition to parse content after.\n\n\n WirisPlugin.instances[editor.id].initParsed = true;\n };\n\n if ('onInit' in editor) {\n editor.onInit.add(onInit);\n } else {\n editor.on('init', function () {\n onInit(editor);\n });\n }\n\n if ('onActivate' in editor) {\n editor.onActivate.add(function (editor) {\n WirisPlugin.currentInstance = WirisPlugin.instances[tinymce.activeEditor.id];\n });\n } else {\n editor.on('focus', function (event) {\n WirisPlugin.currentInstance = WirisPlugin.instances[tinymce.activeEditor.id];\n });\n }\n\n var onSave = function onSave(editor, params) {\n params.content = _core_src_parser_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].endParse(params.content, editor.getParam('language'));\n };\n\n if ('onSaveContent' in editor) {\n editor.onSaveContent.add(onSave);\n } else {\n editor.on('saveContent', function (params) {\n onSave(editor, params);\n });\n }\n\n if ('onGetContent' in editor) {\n editor.onGetContent.add(onSave);\n } else {\n editor.on('getContent', function (params) {\n onSave(editor, params);\n });\n }\n\n if ('onBeforeSetContent' in editor) {\n editor.onBeforeSetContent.add(function (e, params) {\n if (WirisPlugin.instances[editor.id].initParsed) {\n params.content = Parse.initParse(params.content, editor.getParam('language'));\n }\n });\n } else {\n editor.on('beforeSetContent', function (params) {\n if (WirisPlugin.instances[editor.id].initParsed) {\n params.content = _core_src_parser_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].initParse(params.content, editor.getParam('language'));\n }\n });\n } // We use a mutation to observe iframe of tiny and filter to remove data-mce.\n\n\n var observerConfig = {\n attributes: true,\n childList: true,\n characterData: true,\n subtree: true\n };\n\n function onMutations(mutations) {\n Array.prototype.forEach.call(mutations, function (mutation) {\n Array.prototype.forEach.call(mutation.addedNodes, function (node) {\n // We search only in element nodes.\n if (node.nodeType == 1) {\n Array.prototype.forEach.call(node.getElementsByClassName(WirisPlugin.Configuration.get('imageMathmlAttribute')), function (image) {\n image.removeAttribute('data-mce-src');\n image.removeAttribute('data-mce-style');\n });\n }\n });\n });\n }\n\n var mutationInstance = new MutationObserver(onMutations); // We wait for iframe definition for observe this.\n\n function waitForIframeBody() {\n if (typeof editor.contentDocument != 'undefined') {\n mutationInstance.observe(editor.getBody(), observerConfig);\n } else {\n setTimeout(waitForIframeBody, 50);\n }\n }\n\n waitForIframeBody(); // MathType button.\n\n editor.addCommand('tiny_mce_wiris_openFormulaEditor', function () {\n WirisPlugin.instances[editor.id].openNewFormulaEditor();\n });\n editor.addButton('tiny_mce_wiris_formulaEditor', {\n title: 'Insert a math equation - MathType',\n cmd: 'tiny_mce_wiris_openFormulaEditor',\n image: WirisPlugin.instances[editor.id].getIconsPath() + 'formula.png'\n }); // }\n // Dynamic customEditors buttons.\n\n var customEditors = WirisPlugin.instances[tinyMCE.activeEditor.id].getCore().getCustomEditors();\n\n for (var customEditor in customEditors.editors) {\n if (customEditors.editors[customEditor].confVariable) {\n var cmd = 'tiny_mce_wiris_openFormulaEditor' + customEditors.editors[customEditor].name;\n editor.addCommand(cmd, function () {\n customEditors.enable(customEditor);\n WirisPlugin.instances[editor.id].openNewFormulaEditor();\n });\n editor.addButton('tiny_mce_wiris_formulaEditor' + customEditors.editors[customEditor].name, {\n title: customEditors.editors[customEditor].tooltip,\n cmd: cmd,\n image: WirisPlugin.instances[editor.id].getIconsPath() + customEditors.editors[customEditor].icon\n });\n }\n }\n },\n // All versions.\n getInfo: function getInfo() {\n return {\n longname: 'tiny_mce_wiris',\n author: 'Maths for More',\n authorurl: 'http://www.wiris.com',\n infourl: 'http://www.wiris.com',\n version: '7.6.1.1393'\n };\n }\n });\n tinymce.PluginManager.add('tiny_mce_wiris', tinymce.plugins.tiny_mce_wiris);\n})();\n\n//# sourceURL=webpack:///./editor_plugin.src.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"TinyMceIntegration\", function() { return TinyMceIntegration; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"instances\", function() { return instances; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"currentInstance\", function() { return currentInstance; });\n/* harmony import */ var _core_src_integrationmodel_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./core/src/integrationmodel.js */ \"./core/src/integrationmodel.js\");\n/* harmony import */ var _core_src_configuration_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./core/src/configuration.js */ \"./core/src/configuration.js\");\n/* harmony import */ var _core_src_parser_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./core/src/parser.js */ \"./core/src/parser.js\");\n/* harmony import */ var _core_src_util__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./core/src/util */ \"./core/src/util.js\");\n/* harmony import */ var _core_src_listeners__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./core/src/listeners */ \"./core/src/listeners.js\");\nfunction _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) { return call; } return _assertThisInitialized(self); }\n\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\n\nfunction _get(target, property, receiver) { if (typeof Reflect !== \"undefined\" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(receiver); } return desc.value; }; } return _get(target, property, receiver || target); }\n\nfunction _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }\n\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function\"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }\n\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\n\n\n\n\n\n\n/**\n * TinyMCE integration class. This class extends IntegrationModel class.\n */\n\nvar TinyMceIntegration =\n/*#__PURE__*/\nfunction (_IntegrationModel) {\n _inherits(TinyMceIntegration, _IntegrationModel);\n\n function TinyMceIntegration(integrationModelProperties) {\n var _this;\n\n _classCallCheck(this, TinyMceIntegration);\n\n _this = _possibleConstructorReturn(this, _getPrototypeOf(TinyMceIntegration).call(this, integrationModelProperties));\n /**\n * Indicates if the content of the TinyMCe editor has\n * been parsed.\n * @type {boolean}\n */\n\n _this.initParsed = integrationModelProperties.initParsed;\n /**\n * Indicates if the TinyMCE is integrated in Moodle.\n * @type {boolean}\n */\n\n _this.isMoodle = integrationModelProperties.isMoodle;\n /**\n * Indicates if the plugin is loaded as an external plugin by TinyMCE.\n * @type {boolean}\n */\n\n _this.isExternal = integrationModelProperties.isExternal;\n return _this;\n }\n /**\n * Returns the absolute path of the integration script. Depends on\n * TinyMCE integration (Moodle or standard).\n * @returns {boolean} - Absolute path for the integration script.\n */\n\n\n _createClass(TinyMceIntegration, [{\n key: \"getPath\",\n value: function getPath() {\n if (this.isMoodle) {\n var search = 'lib/editor/tinymce';\n var pos = tinymce.baseURL.indexOf(search);\n var baseURL = tinymce.baseURL.substr(0, pos + search.length);\n return baseURL + '/plugins/tiny_mce_wiris/tinymce/';\n } else if (this.isExternal) {\n var externalUrl = this.editorObject.getParam('external_plugins')['tiny_mce_wiris'];\n return externalUrl.substring(0, externalUrl.lastIndexOf('/') + 1);\n } else {\n return tinymce.baseURL + '/plugins/tiny_mce_wiris/';\n }\n }\n /**\n * Returns the absolute path of plugin icons. A set of different\n * icons is needed for TinyMCE and Moodle 2.5-\n * @returns {string} - Absolute path of the icons folder.\n */\n\n }, {\n key: \"getIconsPath\",\n value: function getIconsPath() {\n if (this.isMoodle && _core_src_configuration_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].get('versionPlatform') < 2013111800) {\n return this.getPath() + 'icons/tinymce3/';\n } else {\n return this.getPath() + 'icons/';\n }\n }\n /**\n * Returns the integration language. TinyMCE language is inherited.\n * @returns {string} - Integration language.\n */\n\n }, {\n key: \"getLanguage\",\n value: function getLanguage() {\n if (this.editorObject.settings['wirisformulaeditorlang']) {\n return editor.settings['wirisformulaeditorlang'];\n }\n\n return this.editorObject.getParam('language');\n }\n /**\n * Callback function called before 'onTargetLoad' is fired. All the logic here is to\n * avoid TinyMCE change MathType formulas.\n */\n\n }, {\n key: \"callbackFunction\",\n value: function callbackFunction() {\n var dataImgFiltered = [];\n\n _get(_getPrototypeOf(TinyMceIntegration.prototype), \"callbackFunction\", this).call(this); // Avoid to change class of image formulas.\n\n\n var imageClassName = _core_src_configuration_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].get('imageClassName');\n\n if (this.isIframe) {\n // Attaching observers to wiris images.\n if (typeof _core_src_parser_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].observer != 'undefined') {\n Array.prototype.forEach.call(this.target.contentDocument.getElementsByClassName(imageClassName), function (wirisImages) {\n _core_src_parser_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].observer.observe(wirisImages);\n });\n }\n } else {\n // Inline.\n // Attaching observers to wiris images.\n Array.prototype.forEach.call(document.getElementsByClassName(imageClassName), function (wirisImages) {\n _core_src_parser_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].observer.observe(wirisImages);\n });\n } // When a formula is updated TinyMCE 'Change' event must be fired.\n // See https://www.tiny.cloud/docs/advanced/events/#change for further information.\n\n\n var listener = _core_src_listeners__WEBPACK_IMPORTED_MODULE_4__[\"default\"].newListener('onAfterFormulaInsertion', function () {\n if (typeof this.editorObject.fire != 'undefined') {\n this.editorObject.fire('Change');\n }\n }.bind(this));\n this.getCore().addListener(listener); // Avoid filter formulas with performance enabled.\n\n dataImgFiltered[this.editorObject.id] = this.editorObject.settings.images_dataimg_filter;\n\n this.editorObject.settings.images_dataimg_filter = function (img) {\n if (img.hasAttribute('class') && img.getAttribute('class').indexOf(_core_src_configuration_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].get(imageClassName)) != -1) {\n return img.hasAttribute('internal-blob');\n } else {\n // If the client put an image data filter, run. Otherwise default behaviour (put blob).\n if (typeof dataImgFiltered[this.editorObject.id] != 'undefined') {\n return dataImgFiltered[this.editorObject.id](img);\n }\n\n return true;\n }\n };\n }\n }]);\n\n return TinyMceIntegration;\n}(_core_src_integrationmodel_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"]);\n/**\n * Object containing all TinyMCE integration instances. One for each TinyMCE editor.\n * @type {Object}\n */\n\nvar instances = {};\n/**\n * TinyMCE integration current instance. The current instance\n * is the instance related with the focused editor.\n * @type {TinyMceIntegration}\n */\n\nvar currentInstance = null;\n/* Plugin integration */\n\n(function () {\n tinymce.create('tinymce.plugins.tiny_mce_wiris', {\n init: function init(editor, url) {\n // Array with MathML valid alements.\n var validMathML = ['math[*]', 'maction[*]]', 'malignmark[*]', 'maligngroup[*]', 'menclose[*]', 'merror[*]', 'mfenced[*]', 'mfrac[*]', 'mglyph[*]', 'mi[*]', 'mlabeledtr[*]', 'mlongdiv[*]', 'mmultiscripts[*]', 'mn[*]', 'mo[*]', 'mover[*]', 'mpadded[*]', 'mphantom[*]', 'mprescripts[*]', 'mroot[*]', 'mrow[*]', 'ms[*]', 'mscarries[*]', 'mscarry[*]', 'msgroup[*]', 'msline[*]', 'mspace[*]', 'msqrt[*]', 'msrow[*]', 'mstack[*]', 'mstyle[*]', 'msub[*]', 'msubsup[*]', 'msup[*]', 'mtable[*]', 'mtd[*]', 'mtext[*]', 'mtr[*]', 'munder[*]', 'munderover[*]', 'semantics[*]', 'annotation[*]'];\n editor.settings.extended_valid_elements += ',' + validMathML.join();\n var callbackMethodArguments = {};\n /**\n * Integration model properties\n * @type {object}\n * @property {object} target - Integration DOM target.\n * @property {string} configurationService - Configuration integration service.\n * @property {string} version - Plugin version.\n * @property {string} scriptName - Integration script name.\n * @property {object} environment - Integration environment properties.\n * @property {string} editor - Editor name.\n */\n\n var integrationModelProperties = {};\n integrationModelProperties.configurationService = '' + M.cfg.wwwroot + '/filter/wiris/integration/configurationjs.php';\n integrationModelProperties.version = '7.7.0.1394';\n integrationModelProperties.isMoodle = true;\n\n if (typeof editor.getParam('wiriscontextpath') !== 'undefined') {\n integrationModelProperties.configurationService = _core_src_util__WEBPACK_IMPORTED_MODULE_3__[\"default\"].concatenateUrl(editor.getParam('wiriscontextpath'), integrationModelProperties.configurationService);\n editor.getParam('wiriscontextpath') + '/' + integrationModelProperties.configurationService;\n }\n\n integrationModelProperties.version = '7.5.0.1414';\n integrationModelProperties.scriptName = \"plugin.min.js\";\n integrationModelProperties.environment = {};\n integrationModelProperties.environment.editor = \"TinyMCE 4.x\";\n integrationModelProperties.callbackMethodArguments = callbackMethodArguments;\n integrationModelProperties.editorObject = editor;\n integrationModelProperties.initParsed = false; // We need to create the instance before TinyMce initialization in order to register commands.\n // However, as TinyMCE is not initialized at this point the HTML target is not created.\n // Here we create the target as null and onInit object the target is updated.\n\n integrationModelProperties.target = null;\n var isExternalPlugin = typeof editor.getParam('external_plugins') !== 'undefined' && 'tiny_mce_wiris' in editor.getParam('external_plugins');\n integrationModelProperties.isExternal = isExternalPlugin;\n integrationModelProperties.rtl = editor.getParam('directionality') === 'rtl'; // GenericIntegration instance.\n\n var tinyMceIntegrationInstance = new TinyMceIntegration(integrationModelProperties);\n tinyMceIntegrationInstance.init();\n WirisPlugin.instances[tinyMceIntegrationInstance.editorObject.id] = tinyMceIntegrationInstance;\n WirisPlugin.currentInstance = tinyMceIntegrationInstance;\n\n var onInit = function onInit(editor) {\n var integrationInstance = WirisPlugin.instances[tinyMceIntegrationInstance.editorObject.id];\n\n if (!editor.inline) {\n integrationInstance.setTarget(editor.getContentAreaContainer().firstChild);\n } else {\n integrationInstance.setTarget(editor.getElement());\n }\n\n integrationInstance.setEditorObject(editor);\n integrationInstance.listeners.fire('onTargetReady', {});\n\n if ('wiriseditorparameters' in editor.settings) {\n _core_src_configuration_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].update('_wrs_conf_editorParameters', editor.settings.wiriseditorparameters);\n }\n\n var content = editor.getContent(); // Bug fix: In Moodle2.x when TinyMCE is set to full screen\n // the content doesn't need to be filtered.\n\n if (!editor.getParam('fullscreen_is_enabled') && content !== \"\") {\n // We set content in html because other tiny plugins need data-mce\n // and this is not posibil with raw format.\n editor.setContent(_core_src_parser_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].initParse(content, editor.getParam('language')), {\n format: \"html\"\n }); // This clean undoQueue for prevent onChange and Dirty state.\n\n editor.undoManager.clear();\n } // Init parsing OK. If a setContent method is called\n // wrs_initParse is called again.\n // Now if source code is edited the returned code is parsed.\n // PLUGINS-1070: We set this variable out of condition to parse content after.\n\n\n WirisPlugin.instances[editor.id].initParsed = true;\n };\n\n if ('onInit' in editor) {\n editor.onInit.add(onInit);\n } else {\n editor.on('init', function () {\n onInit(editor);\n });\n }\n\n if ('onActivate' in editor) {\n editor.onActivate.add(function (editor) {\n WirisPlugin.currentInstance = WirisPlugin.instances[tinymce.activeEditor.id];\n });\n } else {\n editor.on('focus', function (event) {\n WirisPlugin.currentInstance = WirisPlugin.instances[tinymce.activeEditor.id];\n });\n }\n\n var onSave = function onSave(editor, params) {\n params.content = _core_src_parser_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].endParse(params.content, editor.getParam('language'));\n };\n\n if ('onSaveContent' in editor) {\n editor.onSaveContent.add(onSave);\n } else {\n editor.on('saveContent', function (params) {\n onSave(editor, params);\n });\n }\n\n if ('onGetContent' in editor) {\n editor.onGetContent.add(onSave);\n } else {\n editor.on('getContent', function (params) {\n onSave(editor, params);\n });\n }\n\n if ('onBeforeSetContent' in editor) {\n editor.onBeforeSetContent.add(function (e, params) {\n if (WirisPlugin.instances[editor.id].initParsed) {\n params.content = Parse.initParse(params.content, editor.getParam('language'));\n }\n });\n } else {\n editor.on('beforeSetContent', function (params) {\n if (WirisPlugin.instances[editor.id].initParsed) {\n params.content = _core_src_parser_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].initParse(params.content, editor.getParam('language'));\n }\n });\n } // We use a mutation to observe iframe of tiny and filter to remove data-mce.\n\n\n var observerConfig = {\n attributes: true,\n childList: true,\n characterData: true,\n subtree: true\n };\n\n function onMutations(mutations) {\n Array.prototype.forEach.call(mutations, function (mutation) {\n Array.prototype.forEach.call(mutation.addedNodes, function (node) {\n // We search only in element nodes.\n if (node.nodeType == 1) {\n Array.prototype.forEach.call(node.getElementsByClassName(WirisPlugin.Configuration.get('imageMathmlAttribute')), function (image) {\n image.removeAttribute('data-mce-src');\n image.removeAttribute('data-mce-style');\n });\n }\n });\n });\n }\n\n var mutationInstance = new MutationObserver(onMutations); // We wait for iframe definition for observe this.\n\n function waitForIframeBody() {\n if (typeof editor.contentDocument != 'undefined') {\n mutationInstance.observe(editor.getBody(), observerConfig);\n } else {\n setTimeout(waitForIframeBody, 50);\n }\n }\n\n waitForIframeBody(); // MathType button.\n\n editor.addCommand('tiny_mce_wiris_openFormulaEditor', function () {\n WirisPlugin.instances[editor.id].openNewFormulaEditor();\n });\n editor.addButton('tiny_mce_wiris_formulaEditor', {\n title: 'Insert a math equation - MathType',\n cmd: 'tiny_mce_wiris_openFormulaEditor',\n image: WirisPlugin.instances[editor.id].getIconsPath() + 'formula.png'\n }); // }\n // Dynamic customEditors buttons.\n\n var customEditors = WirisPlugin.instances[tinyMCE.activeEditor.id].getCore().getCustomEditors();\n\n for (var customEditor in customEditors.editors) {\n if (customEditors.editors[customEditor].confVariable) {\n var cmd = 'tiny_mce_wiris_openFormulaEditor' + customEditors.editors[customEditor].name;\n editor.addCommand(cmd, function () {\n customEditors.enable(customEditor);\n WirisPlugin.instances[editor.id].openNewFormulaEditor();\n });\n editor.addButton('tiny_mce_wiris_formulaEditor' + customEditors.editors[customEditor].name, {\n title: customEditors.editors[customEditor].tooltip,\n cmd: cmd,\n image: WirisPlugin.instances[editor.id].getIconsPath() + customEditors.editors[customEditor].icon\n });\n }\n }\n },\n // All versions.\n getInfo: function getInfo() {\n return {\n longname: 'tiny_mce_wiris',\n author: 'Maths for More',\n authorurl: 'http://www.wiris.com',\n infourl: 'http://www.wiris.com',\n version: '7.7.0.1394'\n };\n }\n });\n tinymce.PluginManager.add('tiny_mce_wiris', tinymce.plugins.tiny_mce_wiris);\n})();\n\n//# sourceURL=webpack:///./editor_plugin.src.js?"); /***/ }), diff --git a/tinymce/plugin.min.js b/tinymce/plugin.min.js index 42b37dc..bbd0f29 100644 --- a/tinymce/plugin.min.js +++ b/tinymce/plugin.min.js @@ -1,3 +1,3 @@ -!function(e){var t={};function i(n){if(t[n])return t[n].exports;var r=t[n]={i:n,l:!1,exports:{}};return e[n].call(r.exports,r,r.exports,i),r.l=!0,r.exports}i.m=e,i.c=t,i.d=function(e,t,n){i.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},i.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.t=function(e,t){if(1&t&&(e=i(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)i.d(n,r,function(t){return e[t]}.bind(null,r));return n},i.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(t,"a",t),t},i.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},i.p="",i(i.s=6)}([function(module,__webpack_exports__,__webpack_require__){"use strict";function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var md5,_unused_webpack_default_export=md5;!function(){var HxOverrides=function(){};HxOverrides.__name__=!0,HxOverrides.dateStr=function(e){var t=e.getMonth()+1,i=e.getDate(),n=e.getHours(),r=e.getMinutes(),s=e.getSeconds();return e.getFullYear()+"-"+(t<10?"0"+t:""+t)+"-"+(i<10?"0"+i:""+i)+" "+(n<10?"0"+n:""+n)+":"+(r<10?"0"+r:""+r)+":"+(s<10?"0"+s:""+s)},HxOverrides.strDate=function(e){switch(e.length){case 8:var t=e.split(":"),i=new Date;return i.setTime(0),i.setUTCHours(t[0]),i.setUTCMinutes(t[1]),i.setUTCSeconds(t[2]),i;case 10:t=e.split("-");return new Date(t[0],t[1]-1,t[2],0,0,0);case 19:var n=(t=e.split(" "))[0].split("-"),r=t[1].split(":");return new Date(n[0],n[1]-1,n[2],r[0],r[1],r[2]);default:throw"Invalid date format : "+e}},HxOverrides.cca=function(e,t){var i=e.charCodeAt(t);if(i==i)return i},HxOverrides.substr=function(e,t,i){return null!=t&&0!=t&&null!=i&&i<0?"":(null==i&&(i=e.length),t<0?(t=e.length+t)<0&&(t=0):i<0&&(i=e.length+i-t),e.substr(t,i))},HxOverrides.remove=function(e,t){for(var i=0,n=e.length;i>>32-t},str2blks:function(e){for(var t=1+(e.length+8>>6),i=new Array,n=0,r=16*t;n>2]|=HxOverrides.cca(e,s)<<(8*e.length+s)%4*8,s++;i[s>>2]|=128<<(8*e.length+s)%4*8;var o=8*e.length,a=16*t-2;return i[a]=255&o,i[a]|=(o>>>8&255)<<8,i[a]|=(o>>>16&255)<<16,i[a]|=(o>>>24&255)<<24,i},rhex:function(e){for(var t="",i=0;i<4;){var n=i++;t+="0123456789abcdef".charAt(e>>8*n+4&15)+"0123456789abcdef".charAt(e>>8*n&15)}return t},addme:function(e,t){var i=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(i>>16)<<16|65535&i},bitAND:function(e,t){return(e>>>1&t>>>1)<<1|1&e&t},bitXOR:function(e,t){return(e>>>1^t>>>1)<<1|1&e^1&t},bitOR:function(e,t){return(e>>>1|t>>>1)<<1|(1&e|1&t)},__class__:haxe.Md5},haxe.Timer=function(e){var t=this;this.id=window.setInterval(function(){t.run()},e)},haxe.Timer.__name__=!0,haxe.Timer.delay=function(e,t){var i=new haxe.Timer(t);return i.run=function(){i.stop(),e()},i},haxe.Timer.measure=function(e,t){var i=haxe.Timer.stamp(),n=e();return haxe.Log.trace(haxe.Timer.stamp()-i+"s",t),n},haxe.Timer.stamp=function(){return(new Date).getTime()/1e3},haxe.Timer.prototype={run:function(){},stop:function(){null!=this.id&&(window.clearInterval(this.id),this.id=null)},__class__:haxe.Timer};var js=js||{},$_;function $bind(e,t){var i=function e(){return e.method.apply(e.scope,arguments)};return i.scope=e,i.method=t,i}js.Boot=function(){},js.Boot.__name__=!0,js.Boot.__unhtml=function(e){return e.split("&").join("&").split("<").join("<").split(">").join(">")},js.Boot.__trace=function(e,t){var i,n=null!=t?t.fileName+":"+t.lineNumber+": ":"";n+=js.Boot.__string_rec(e,""),"undefined"!=typeof document&&null!=(i=document.getElementById("haxe:trace"))?i.innerHTML+=js.Boot.__unhtml(n)+"
":"undefined"!=typeof console&&null!=console.log&&console.log(n)},js.Boot.__clear_trace=function(){var e=document.getElementById("haxe:trace");null!=e&&(e.innerHTML="")},js.Boot.isClass=function(e){return e.__name__},js.Boot.isEnum=function(e){return e.__ename__},js.Boot.getClass=function(e){return e.__class__},js.Boot.__string_rec=function(e,t){if(null==e)return"null";if(t.length>=5)return"<...>";var i=_typeof(e);switch("function"==i&&(e.__name__||e.__ename__)&&(i="object"),i){case"object":if(e instanceof Array){if(e.__enum__){if(2==e.length)return e[0];var n=e[0]+"(";t+="\t";for(var r=2,s=e.length;r0?",":"")+js.Boot.__string_rec(e[l],t)}return n+="]"}var c;try{c=e.toString}catch(e){return"???"}if(null!=c&&c!=Object.toString){var u=e.toString();if("[object Object]"!=u)return u}var h=null;n="{\n";t+="\t";var d=null!=e.hasOwnProperty;for(var h in e)d&&!e.hasOwnProperty(h)||"prototype"!=h&&"__class__"!=h&&"__super__"!=h&&"__interfaces__"!=h&&"__properties__"!=h&&(2!=n.length&&(n+=", \n"),n+=t+h+" : "+js.Boot.__string_rec(e[h],t));return n+="\n"+(t=t.substring(1))+"}";case"function":return"";case"string":return e;default:return String(e)}},js.Boot.__interfLoop=function(e,t){if(null==e)return!1;if(e==t)return!0;var i=e.__interfaces__;if(null!=i)for(var n=0,r=i.length;n>>32-t},str2blks:function(e){for(var t=1+(e.length+8>>6),i=new Array,n=0,r=16*t;n>2]|=HxOverrides.cca(e,s)<<(8*e.length+s)%4*8,s++;i[s>>2]|=128<<(8*e.length+s)%4*8;var o=8*e.length,a=16*t-2;return i[a]=255&o,i[a]|=(o>>>8&255)<<8,i[a]|=(o>>>16&255)<<16,i[a]|=(o>>>24&255)<<24,i},rhex:function(e){for(var t="",i=0;i<4;){var n=i++;t+="0123456789abcdef".charAt(e>>8*n+4&15)+"0123456789abcdef".charAt(e>>8*n&15)}return t},addme:function(e,t){var i=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(i>>16)<<16|65535&i},bitAND:function(e,t){return(e>>>1&t>>>1)<<1|1&e&t},bitXOR:function(e,t){return(e>>>1^t>>>1)<<1|1&e^1&t},bitOR:function(e,t){return(e>>>1|t>>>1)<<1|(1&e|1&t)},__class__:haxe.Md5},haxe.Timer=function(e){var t=this;this.id=window.setInterval(function(){t.run()},e)},haxe.Timer.__name__=!0,haxe.Timer.delay=function(e,t){var i=new haxe.Timer(t);return i.run=function(){i.stop(),e()},i},haxe.Timer.measure=function(e,t){var i=haxe.Timer.stamp(),n=e();return haxe.Log.trace(haxe.Timer.stamp()-i+"s",t),n},haxe.Timer.stamp=function(){return(new Date).getTime()/1e3},haxe.Timer.prototype={run:function(){},stop:function(){null!=this.id&&(window.clearInterval(this.id),this.id=null)},__class__:haxe.Timer};var js=js||{},$_;function $bind(e,t){var i=function e(){return e.method.apply(e.scope,arguments)};return i.scope=e,i.method=t,i}js.Boot=function(){},js.Boot.__name__=!0,js.Boot.__unhtml=function(e){return e.split("&").join("&").split("<").join("<").split(">").join(">")},js.Boot.__trace=function(e,t){var i,n=null!=t?t.fileName+":"+t.lineNumber+": ":"";n+=js.Boot.__string_rec(e,""),"undefined"!=typeof document&&null!=(i=document.getElementById("haxe:trace"))?i.innerHTML+=js.Boot.__unhtml(n)+"
":"undefined"!=typeof console&&null!=console.log&&console.log(n)},js.Boot.__clear_trace=function(){var e=document.getElementById("haxe:trace");null!=e&&(e.innerHTML="")},js.Boot.isClass=function(e){return e.__name__},js.Boot.isEnum=function(e){return e.__ename__},js.Boot.getClass=function(e){return e.__class__},js.Boot.__string_rec=function(e,t){if(null==e)return"null";if(t.length>=5)return"<...>";var i=_typeof(e);switch("function"==i&&(e.__name__||e.__ename__)&&(i="object"),i){case"object":if(e instanceof Array){if(e.__enum__){if(2==e.length)return e[0];var n=e[0]+"(";t+="\t";for(var r=2,s=e.length;r0?",":"")+js.Boot.__string_rec(e[l],t)}return n+="]"}var c;try{c=e.toString}catch(e){return"???"}if(null!=c&&c!=Object.toString){var u=e.toString();if("[object Object]"!=u)return u}var h=null;n="{\n";t+="\t";var d=null!=e.hasOwnProperty;for(var h in e)d&&!e.hasOwnProperty(h)||"prototype"!=h&&"__class__"!=h&&"__super__"!=h&&"__interfaces__"!=h&&"__properties__"!=h&&(2!=n.length&&(n+=", \n"),n+=t+h+" : "+js.Boot.__string_rec(e[h],t));return n+="\n"+(t=t.substring(1))+"}";case"function":return"";case"string":return e;default:return String(e)}},js.Boot.__interfLoop=function(e,t){if(null==e)return!1;if(e==t)return!0;var i=e.__interfaces__;if(null!=i)for(var n=0,r=i.length;n=0&&l.splice(t,1)}function m(e){var t=document.createElement("style");if(void 0===e.attrs.type&&(e.attrs.type="text/css"),void 0===e.attrs.nonce){var n=function(){0;return i.nc}();n&&(e.attrs.nonce=n)}return g(t,e.attrs),d(e,t),t}function g(e,t){Object.keys(t).forEach(function(i){e.setAttribute(i,t[i])})}function p(e,t){var i,n,r,s;if(t.transform&&e.css){if(!(s=t.transform(e.css)))return function(){};e.css=s}if(t.singleton){var l=a++;i=o||(o=m(t)),n=b.bind(null,i,l,!1),r=b.bind(null,i,l,!0)}else e.sourceMap&&"function"==typeof URL&&"function"==typeof URL.createObjectURL&&"function"==typeof URL.revokeObjectURL&&"function"==typeof Blob&&"function"==typeof btoa?(i=function(e){var t=document.createElement("link");return void 0===e.attrs.type&&(e.attrs.type="text/css"),e.attrs.rel="stylesheet",g(t,e.attrs),d(e,t),t}(t),n=function(e,t,i){var n=i.css,r=i.sourceMap,s=void 0===t.convertToAbsoluteUrls&&r;(t.convertToAbsoluteUrls||s)&&(n=c(n));r&&(n+="\n/*# sourceMappingURL=data:application/json;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(r))))+" */");var o=new Blob([n],{type:"text/css"}),a=e.href;e.href=URL.createObjectURL(o),a&&URL.revokeObjectURL(a)}.bind(null,i,t),r=function(){f(i),i.href&&URL.revokeObjectURL(i.href)}):(i=m(t),n=function(e,t){var i=t.css,n=t.media;n&&e.setAttribute("media",n);if(e.styleSheet)e.styleSheet.cssText=i;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(i))}}.bind(null,i),r=function(){f(i)});return n(e),function(t){if(t){if(t.css===e.css&&t.media===e.media&&t.sourceMap===e.sourceMap)return;n(e=t)}else r()}}e.exports=function(e,t){if("undefined"!=typeof DEBUG&&DEBUG&&"object"!=typeof document)throw new Error("The style-loader cannot be used in a non-browser environment");(t=t||{}).attrs="object"==typeof t.attrs?t.attrs:{},t.singleton||"boolean"==typeof t.singleton||(t.singleton=r()),t.insertInto||(t.insertInto="head"),t.insertAt||(t.insertAt="bottom");var i=h(e,t);return u(i,t),function(e){for(var r=[],s=0;s«/mo»",ampElement:"«mo»&«/mo»"}}},{key:"safeGoodBlackboardCharacters",get:function(){return{ltElement:"«mo»§lt;«/mo»",gtElement:"«mo»§gt;«/mo»",ampElement:"«mo»§amp;«/mo»"}}}]),e}();function s(e,t){for(var i=0;i",doubleQuote:'"',ampersand:"&",quote:"'"},r.safeXmlCharacters={tagOpener:"«",tagCloser:"»",doubleQuote:"¨",ampersand:"§",quote:"`",realDoubleQuote:"¨"};var o=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}return function(e,t,i){t&&s(e.prototype,t),i&&s(e,i)}(e,null,[{key:"isMathmlInAttribute",value:function(e,t){var i=new RegExp("^['\"][\\s]*=[\\s]*[\\w-]+([\\s]*(\"[^\"]*\"|'[^']*')[\\s]*=[\\s]*[\\w-]+[\\s]*)*[\\s]+gmi<"),n=e.substring(0,t).split("").reverse().join("");return i.test(n)}},{key:"safeXmlDecode",value:function(e){e=(e=(e=(e=e.split(r.safeXmlCharactersEntities.tagOpener).join(r.safeXmlCharacters.tagOpener)).split(r.safeXmlCharactersEntities.tagCloser).join(r.safeXmlCharacters.tagCloser)).split(r.safeXmlCharactersEntities.doubleQuote).join(r.safeXmlCharacters.doubleQuote)).split(r.safeXmlCharactersEntities.realDoubleQuote).join(r.safeXmlCharacters.realDoubleQuote),"_wrs_blackboard"in window&&window._wrs_blackboard&&(e=(e=(e=e.split(r.safeBadBlackboardCharacters.ltElement).join(r.safeGoodBlackboardCharacters.ltElement)).split(r.safeBadBlackboardCharacters.gtElement).join(r.safeGoodBlackboardCharacters.gtElement)).split(r.safeBadBlackboardCharacters.ampElement).join(r.safeGoodBlackboardCharacters.ampElement)),e=(e=(e=(e=(e=e.split(r.safeXmlCharacters.tagOpener).join(r.xmlCharacters.tagOpener)).split(r.safeXmlCharacters.tagCloser).join(r.xmlCharacters.tagCloser)).split(r.safeXmlCharacters.doubleQuote).join(r.xmlCharacters.doubleQuote)).split(r.safeXmlCharacters.ampersand).join(r.xmlCharacters.ampersand)).split(r.safeXmlCharacters.quote).join(r.xmlCharacters.quote);for(var t="",i=null,n=0;n128)t+="&#"+e.codePointAt(i)+";",e.codePointAt(i)>65535&&i++;else if("&"==n){var r=e.indexOf(";",i+1);if(r>=0){var s=document.createElement("span");s.innerHTML=e.substring(i,r+1),t+="&#"+v.fixedCharCodeAt(s.innerText||s.textContent,0)+";",i=r}else t+=n}else t+=n}return t}},{key:"addCustomEditorClassAttribute",value:function(e,t){var i="",n=e.indexOf("");if(-1==e.indexOf("class"))return i=e.substr(n,r)+' class="wrs_'+t+'">',i+=e.substr(r+1,e.length)}return e}},{key:"removeCustomEditorClassAttribute",value:function(e,t){return-1==e.indexOf("class")||e.indexOf("wrs_"+t)?e:-1!==e.indexOf('class="wrs_'+t+'"')?e.replace('class="wrs_'+t+'"',""):e.replace("wrs_"+t,"")}},{key:"insertSemanticsMathml",value:function(e,t,i){if(""==t)return e;var n='',r=e.indexOf(">"),s=e.indexOf(""),o=e.substring(e.indexOf("<"),e.indexOf(">")).indexOf("math");if(-1!=r&&-1!=s&&o){var a=e.substring(r+1,s);if(0!=a.indexOf(""))var l=""+a+""+n+t+"";else l=""+a+n+t+"";return e.replace(a,l)}return e}},{key:"removeSemanticsMathml",value:function(e,t){var i='',n=e,r=e.indexOf("");if(-1!=r){var s=e.indexOf(i,r+"".length);-1!=s&&(n=e.substring(0,r)+e.substring(r+"".length,s)+"")}return n}},{key:"containClass",value:function(e,t){var i=e.indexOf("class");if(-1==i)return!1;var n=e.indexOf(">",i);return-1!=e.substring(i,n).indexOf(t)}}]),e}();function a(e,t){for(var i=0;i=0;--n)if(i[n]==t)return!0;return!1}},{key:"removeClass",value:function(e,t){for(var i="",n=e.className.split(" "),r=0;r").join("").split("").join("")).split("").join("
").split("").join("
");var n=e.createElement("div",{},i);return n.innerHTML=t,function t(n){if(n.getAttribute&&"WirisParam"==n.getAttribute("wirisObject")){for(var r={},s=0;s0){i+=">";for(n=0;n"}else"DIV"==t.nodeName||"SCRIPT"==t.nodeName?i+=">":i+="/>";return i}return 3==t.nodeType?e.htmlEntities(t.nodeValue):""}}},{key:"concatenateUrl",value:function(e,t){var i="";return e.indexOf("/")!=e.length&&0!=t.indexOf("/")&&(i="/"),(e+i+t).replace(/([^:]\/)\/+/g,"$1")}},{key:"htmlEntities",value:function(e){return e.split("&").join("&").split("<").join("<").split(">").join(">").split('"').join(""")}},{key:"htmlEntitiesDecode",value:function(e){return e.split(""").join('"').split(">").join(">").split("<").join("<").split("&").join("&")}},{key:"createHttpRequest",value:function(){if("file://"==window.location.toString().substr(0,window.location.toString().lastIndexOf("/")+1).substr(0,7))throw Core.getStringManager().getString("exception_cross_site");if("undefined"!=typeof XMLHttpRequest)return new XMLHttpRequest;try{return new ActiveXObject("Msxml2.XMLHTTP")}catch(e){try{return new ActiveXObject("Microsoft.XMLHTTP")}catch(e){}}return!1}},{key:"httpBuildQuery",value:function(t){var i="";for(var n in t)null!=t[n]&&(i+=e.urlEncode(n)+"="+e.urlEncode(t[n])+"&");return"&"==i.substring(i.length-1)&&(i=i.substring(0,i.length-1)),i}},{key:"propertiesToString",value:function(t){var i=[];for(var n in t)t.hasOwnProperty(n)&&i.push(n);for(var r=i.length,s=0;s0&&(i[s]=l,i[o]=a)}var c="";for(s=0;ss?s:r;for(n=0;n0){var i=e.substring(t+1).split("&"),n=new Object;for(t=0;t1&&(n[r[0]]=decodeURIComponent(r[1].replace(/\+/g," ")))}return n}return new Object}},{key:"urlEncode",value:function(e){return encodeURIComponent(e)}},{key:"getWIRISImageOutput",value:function(t,i,n){var r=e.createObject(t);if(r){if(r.className==l.get("imageClassName")||r.getAttribute(l.get("imageMathmlAttribute"))){if(!i)return t;var s=r.getAttribute(l.get("imageMathmlAttribute"));return null==s&&(s=r.getAttribute("alt")),n||(s=o.safeXmlDecode(s)),s}if(r.className==l.get("CASClassName")){var a=r.getAttribute(l.get("CASMathmlAttribute"));a=o.safeXmlDecode(a);var c=e.createObject(a);c.setAttribute("src",r.src);var u=e.createObjectCode(c);return n&&(u=o.safeXmlEncode(u)),u}}return t}},{key:"getNodeLength",value:function(e){function t(t){return e.apply(this,arguments)}return t.toString=function(){return e.toString()},t}(function(e){if(3==e.nodeType)return e.nodeValue.length;if(1==e.nodeType){var t={IMG:1,BR:1}[e.nodeName.toUpperCase()];void 0===t&&(t=0);for(var i=0;i0)return 0==c.text.length?e.getSelectedItem(t,i,!0):null;r.document.execCommand("InsertImage",!1,"#");var s,o=c.parentElement();return"IMG"!=o.nodeName.toUpperCase()&&(c.pasteHTML(''),o=r.document.getElementById("wrs_openEditorWindow_temporalObject")),o.nextSibling&&3==o.nextSibling.nodeType?(a=o.nextSibling,s=0):o.previousSibling&&3==o.previousSibling.nodeType?s=(a=o.previousSibling).nodeValue.length:(a=r.document.createTextNode(""),o.parentNode.insertBefore(a,o),s=0),o.parentNode.removeChild(o),{node:a,caretPosition:s}}return c.length>1?null:{node:c.item(0)}}if(r.getSelection){var a,l=r.getSelection();try{var c=l.getRangeAt(0)}catch(e){c=r.document.createRange()}if(3==(a=c.startContainer).nodeType)return{node:a,caretPosition:c.startOffset};if(a!=c.endContainer)return null;if(1==a.nodeType){var u=c.startOffset;if(a.childNodes[u])return{node:a.childNodes[u]}}}return null}},{key:"getSelectedItemOnTextarea",value:function(e){var t=document.createTextNode(e.value),i=g.getLatexFromTextNode(t,e.selectionStart);return null===i?null:{node:t,caretPosition:e.selectionStart,startPosition:i.startPosition,endPosition:i.endPosition}}},{key:"getElementsByNameFromString",value:function(e,t,i){var n=[];e=e.toLowerCase();t=t.toLowerCase();for(var r=e.indexOf("<"+t+" ");-1!=r;){var s;s=i?">":"";var o=e.indexOf(s,r);-1!=o?(o+=s.length,n.push({start:r,end:o})):o=r+1,r=e.indexOf("<"+t+" ",o)}return n}},{key:"decode64",value:function(e){var t="+".charCodeAt(0),i="/".charCodeAt(0),n="0".charCodeAt(0),r="a".charCodeAt(0),s="A".charCodeAt(0),o="-".charCodeAt(0),a="_".charCodeAt(0),l=e.charCodeAt(0);return l===t||l===o?62:l===i||l===a?63:l0)throw new Error("Invalid string. Length must be a multiple of 4");var r=new Array;if(i)o=i;else var s="="===t.charAt(t.length-2)?2:"="===t.charAt(t.length-1)?1:0,o=s>0?t.length-4:t.length;for(var a=0;a>16&255),r.push(n>>8&255),r.push(255&n);return s&&(2===s?(n=e.decode64(t.charAt(a))<<2|e.decode64(t.charAt(a+1))>>4,r.push(255&n)):1===s&&(n=e.decode64(t.charAt(a))<<10|e.decode64(t.charAt(a+1))<<4|e.decode64(t.charAt(a+2))>>2,r.push(n>>8&255),r.push(255&n))),r}},{key:"readInt32",value:function(e){if(e.length<4)return!1;var t=e.splice(0,4);return t[0]<<24|t[1]<<16|t[2]<<8|t[3]<<0}},{key:"readByte",value:function(e){return e.shift()<<0}},{key:"readBytes",value:function(e,t,i){return e.splice(t,i)}},{key:"updateTextArea",value:function(e,t){if(e&&t)if(e.focus(),null!=e.selectionStart){var i=e.selectionEnd;e.value=e.value.substring(0,e.selectionStart)+t+e.value.substring(e.selectionEnd,e.value.length),e.selectionEnd=i+t.length}else{document.selection.createRange().text=t}}},{key:"updateExistingTextOnTextarea",value:function(e,t,i,n){e.focus(),e.value=e.value.substring(0,i)+t+e.value.substring(n,e.value.length),e.selectionEnd=i+t.length}},{key:"addArgument",value:function(e,t,i){return e+(e.indexOf("?")>0?"&":"?")+t+"="+i}}]),e}();function b(e,t){for(var i=0;i-1,this.deviceProperties.isIOS=this.ua.indexOf("ipad")>-1||this.ua.indexOf("iphone")>-1,this.toolbar=null,this.modalDialogInstance=null,this.listeners=new y,this.mathML=null,this.isNewElement=!0,this.integrationModel=null,this.isEditorLoaded=!1}return function(e,t,i){t&&E(e.prototype,t),i&&E(e,i)}(e,[{key:"addListener",value:function(e){this.listeners.add(e)}},{key:"setIntegrationModel",value:function(e){this.integrationModel=e}},{key:"setModalDialogInstance",value:function(e){this.modalDialogInstance=e}},{key:"insert",value:function(){this.updateTitle(this.modalDialogInstance),this.insertEditor(this.modalDialogInstance)}},{key:"insertEditor",value:function(){if("com"in window&&"wiris"in window.com&&"jsEditor"in window.com.wiris){if(this.editor=com.wiris.jsEditor.JsEditor.newInstance(this.editorAttributes),this.editor.insertInto(this.modalDialogInstance.contentContainer),this.editor.focus(),this.modalDialogInstance.rtl&&this.editor.action("rtl"),this.editor.getEditorModel().isRTL()&&(this.editor.element.style.direction="rtl"),this.editor.getEditorModel().addEditorListener(this.editorListener),this.modalDialogInstance.deviceProperties.isIOS){setTimeout(function(){this.modalDialogInstance.hideKeyboard()},400);var t=document.getElementsByClassName("wrs_formulaDisplay")[0];v.addEvent(t,"focus",this.modalDialogInstance.openedIosSoftkeyboard.bind()),v.addEvent(t,"blur",this.modalDialogInstance.closedIosSoftkeyboard.bind())}this.listeners.fire("onLoad",{}),this.isEditorLoaded=!0}else setTimeout(e.prototype.insertEditor.bind(this,this.modalDialogInstance),100)}},{key:"init",value:function(){for(var e=window.location.search.substring(1).split("&"),t=0;t=0&&(version=e[t].substring(2))}var i=document.createElement("script");i.type="text/javascript";var n=l.get("editorUrl"),r=document.createElement("a");r.href=n,0==window.location.href.indexOf("https://")&&"http:"==r.protocol&&(r.protocol="https:"),n="80"==r.port||"443"==r.port?r.protocol+"//"+r.hostname+"/"+r.pathname:r.protocol+"//"+r.hostname+":"+r.port+"/"+r.pathname;var s={};"editor"in this.environment?s.editor=this.environment.editor:s.editor="unknown","mode"in this.environment?s.mode=this.environment.mode:s.mode=l.get("saveMode"),"version"in this.environment?s.version=this.environment.version:s.version=l.get("version"),i.src=n+"?lang="+this.language+"&stats-editor="+s.editor+"&stats-mode="+s.mode+"&stats-version="+s.version,document.getElementsByTagName("head")[0].appendChild(i)}},{key:"setInitialContent",value:function(){this.isNewElement||this.setMathML(this.mathML)}},{key:"setMathML",value:function(e,t){void 0===t&&(t=!1),this.editor.setMathMLWithCallback(e,function(){this.editorListener.setWaitingForChanges(!0)}.bind(this)),setTimeout(function(){this.editorListener.setIsContentChanged(!1)}.bind(this),500),t||this.onFocus()}},{key:"onFocus",value:function(){void 0!==this.editor&&null!=this.editor&&this.editor.focus()}},{key:"submitAction",value:function(){var e=this.editor.getMathML();if(null!=this.customEditors.getActiveEditor())e=o.addCustomEditorClassAttribute(e,this.customEditors.getActiveEditor().toolbar);else for(var t in this.customEditors.editors)e=o.removeCustomEditorClassAttribute(e,t);var i=o.mathMLEntities(e);this.integrationModel.updateFormula(i),this.customEditors.disable(),this.integrationModel.notifyWindowClosed(),this.setEmptyMathML(),this.customEditors.disable(),setTimeout(function(){"undefined"!=typeof _wrs_currentEditor&&_wrs_currentEditor&&_wrs_currentEditor.focus()},100)}},{key:"setEmptyMathML",value:function(){this.deviceProperties.isAndroid||this.deviceProperties.isIOS?this.editor.getEditorModel().isRTL()?this.setMathML('[]"',!0):this.setMathML('[]"',!0):this.editor.getEditorModel().isRTL()?this.setMathML('',!0):this.setMathML("",!0)}},{key:"onOpen",value:function(){this.isNewElement?this.setEmptyMathML():this.setMathML(this.mathML),this.updateToolbar(),this.onFocus()}},{key:"updateToolbar",value:function(){var e;if(this.updateTitle(this.modalDialogInstance),e=this.customEditors.getActiveEditor()){var t=e.toolbar?e.toolbar:_wrs_int_wirisProperties.toolbar;null!=this.toolbar&&this.toolbar==t||this.setToolbar(t)}else{t=this.getToolbar();null!=this.toolbar&&this.toolbar==t||(this.setToolbar(t),this.customEditors.disable())}}},{key:"updateTitle",value:function(){var e;(e=this.customEditors.getActiveEditor())?this.modalDialogInstance.setTitle(e.title):this.modalDialogInstance.setTitle("MathType")}},{key:"getToolbar",value:function(){var e;return"general"==(e="toolbar"in this.editorAttributes?this.editorAttributes.toolbar:"general")&&(e="undefined"==typeof _wrs_int_wirisProperties||void 0===_wrs_int_wirisProperties.toolbar?"general":_wrs_int_wirisProperties.toolbar),e}},{key:"setToolbar",value:function(e){this.toolbar=e,this.editor.setParams({toolbar:this.toolbar})}},{key:"hasChanges",value:function(){return!this.editor.isFormulaEmpty()&&this.editorListener.getIsContentChanged()}}]),e}();function k(e,t){for(var i=0;i-1,r=i.indexOf("ipad")>-1||i.indexOf("iphone")>-1;this.iosSoftkeyboardOpened=!1,this.iosMeasureUnit=-1==i.indexOf("crios")?"%":"vh",this.iosDivHeight="100"+this.iosMeasureUnit;var s=window.outerWidth,o=window.outerHeight,a=s>o,l=so||l&&this.attributes.width>s);this.instanceId=document.getElementsByClassName("wrs_modal_dialogContainer").length,this.deviceProperties={orientation:a?"landscape":"portait",isAndroid:!!n,isIOS:!!r,isMobile:c,isDesktop:!c&&!r&&!n},this.properties={created:!1,state:"",previousState:"",position:{bottom:0,right:10},size:{height:338,width:580}};var u={class:"wrs_modal_overlay"};u.id=this.getElementId(u.class),this.overlay=v.createElement("div",u),(u={}).class="wrs_modal_title_bar",u.id=this.getElementId(u.class),this.titleBar=v.createElement("div",u),(u={}).class="wrs_modal_title",u.id=this.getElementId(u.class),this.title=v.createElement("div",u),this.title.innerHTML="",(u={}).class="wrs_modal_close_button",u.id=this.getElementId(u.class),u.title=$.getStringManager().getString("close"),this.closeDiv=v.createElement("a",u),this.closeDiv.setAttribute("role","button"),(u={}).class="wrs_modal_stack_button",u.id=this.getElementId(u.class),u.title="Exit full-screen",this.stackDiv=v.createElement("a",u),this.stackDiv.setAttribute("role","button"),(u={}).class="wrs_modal_maximize_button",u.id=this.getElementId(u.class),u.title=$.getStringManager().getString("fullscreen"),this.maximizeDiv=v.createElement("a",u),this.maximizeDiv.setAttribute("role","button"),(u={}).class="wrs_modal_minimize_button",u.id=this.getElementId(u.class),u.title=$.getStringManager().getString("minimise"),this.minimizeDiv=v.createElement("a",u),this.minimizeDiv.setAttribute("role","button"),(u={}).class="wrs_modal_dialogContainer",u.id=this.getElementId(u.class),this.container=v.createElement("div",u),(u={}).class="wrs_modal_wrapper",u.id=this.getElementId(u.class),this.wrapper=v.createElement("div",u),(u={}).class="wrs_content_container",u.id=this.getElementId(u.class),this.contentContainer=v.createElement("div",u),(u={}).class="wrs_modal_controls",u.id=this.getElementId(u.class),this.controls=v.createElement("div",u),(u={}).class="wrs_modal_buttons_container",u.id=this.getElementId(u.class),this.buttonContainer=v.createElement("div",u),this.submitButton=this.createSubmitButton({id:this.getElementId("wrs_modal_button_accept"),class:"wrs_modal_button_accept",innerHTML:$.getStringManager().getString("accept")},this.submitAction.bind(this)),this.cancelButton=this.createSubmitButton({id:this.getElementId("wrs_modal_button_cancel"),class:"wrs_modal_button_cancel",innerHTML:$.getStringManager().getString("cancel")},this.cancelAction.bind(this)),this.contentManager=null;var h={cancelString:$.getStringManager().getString("cancel"),submitString:$.getStringManager().getString("close"),message:$.getStringManager().getString("close_modal_warning")},d={closeCallback:function(){this.close()}.bind(this),cancelCallback:function(){this.focus()}.bind(this)},f={overlayElement:this.container,callbacks:d,strings:h};this.popup=new S(f),this.rtl=!1,"rtl"in this.attributes&&(this.rtl=this.attributes.rtl)}return function(e,t,i){t&&j(e.prototype,t),i&&j(e,i)}(e,[{key:"setContentManager",value:function(e){this.contentManager=e}},{key:"getContentManager",value:function(){return this.contentManager}},{key:"submitAction",value:function(){void 0!==this.contentManager.submitAction&&this.contentManager.submitAction(),this.close()}},{key:"cancelAction",value:function(){void 0===this.contentManager.hasChanges?this.close():this.contentManager.hasChanges()?this.showPopUpMessage():this.close()}},{key:"createSubmitButton",value:function(e,t){function i(e,t){this.element=document.createElement("button"),this.element.id=e.id,this.element.className=e.class,this.element.innerHTML=e.innerHTML,v.addEvent(this.element,"click",t)}return i.prototype.getElement=function(){return this.element},new i(e,t).getElement()}},{key:"create",value:function(){this.titleBar.appendChild(this.closeDiv),this.titleBar.appendChild(this.stackDiv),this.titleBar.appendChild(this.maximizeDiv),this.titleBar.appendChild(this.minimizeDiv),this.titleBar.appendChild(this.title),this.deviceProperties.isDesktop&&this.container.appendChild(this.titleBar),this.wrapper.appendChild(this.contentContainer),this.wrapper.appendChild(this.controls),this.controls.appendChild(this.buttonContainer),this.buttonContainer.appendChild(this.submitButton),this.buttonContainer.appendChild(this.cancelButton),this.container.appendChild(this.wrapper),this.recalculateScrollBar(),document.body.appendChild(this.container),document.body.appendChild(this.overlay),this.deviceProperties.isDesktop?(this.createModalWindowDesktop(),this.createResizeButtons(),this.addListeners(),l.get("modalWindowFullScreen")&&this.maximize()):this.deviceProperties.isAndroid?this.createModalWindowAndroid():this.deviceProperties.isIOS&&!this.deviceProperties.isMobile&&this.createModalWindowIos(),null!=this.contentManager&&this.contentManager.insert(this),this.properties.open=!0,this.properties.created=!0,this.isRTL()&&(this.container.style.right=window.innerWidth-this.scrollbarWidth-this.container.offsetWidth+"px",this.container.className+=" wrs_modal_rtl")}},{key:"createResizeButtons",value:function(){this.resizerBR=document.createElement("div"),this.resizerBR.className="wrs_bottom_right_resizer",this.resizerBR.innerHTML="◢",this.resizerTL=document.createElement("div"),this.resizerTL.className="wrs_bottom_left_resizer",this.container.appendChild(this.resizerBR),this.titleBar.appendChild(this.resizerTL),v.addEvent(this.resizerBR,"mousedown",this.activateResizeStateBR.bind(this)),v.addEvent(this.resizerTL,"mousedown",this.activateResizeStateTL.bind(this))}},{key:"activateResizeStateBR",value:function(e){this.initializeResizeProperties(e,!1)}},{key:"activateResizeStateTL",value:function(e){this.initializeResizeProperties(e,!0)}},{key:"initializeResizeProperties",value:function(e,t){v.addClass(document.body,"wrs_noselect"),v.addClass(this.overlay,"wrs_overlay_active"),this.resizeDataObject={x:this.eventClient(e).X,y:this.eventClient(e).Y},this.initialWidth=parseInt(this.container.style.width),this.initialHeight=parseInt(this.container.style.height),t?this.leftScale=!0:(this.initialRight=parseInt(this.container.style.right),this.initialBottom=parseInt(this.container.style.bottom)),this.initialRight||(this.initialRight=0),this.initialBottom||(this.initialBottom=0),document.body.style["user-select"]="none"}},{key:"open",value:function(){if(this.removeClass("wrs_closed"),(this.deviceProperties.isIOS||this.deviceProperties.isAndroid||this.deviceProperties.isMobile)&&(this.restoreWebsiteScale(),this.blockWebsiteScroll(),setTimeout(function(){this.hideKeyboard()}.bind(this),400)),this.properties.created?(this.properties.open||(this.properties.open=!0,this.deviceProperties.isAndroid||this.deviceProperties.isIOS||this.restoreState()),this.deviceProperties.isDesktop&&l.get("modalWindowFullScreen")&&this.maximize(),this.deviceProperties.isIOS&&(this.iosSoftkeyboardOpened=!1,this.setContainerHeight("100"+this.iosMeasureUnit))):this.create(),!1===this.contentManager.isEditorLoaded){var e=y.newListener("onLoad",function(){this.contentManager.onOpen(this)}.bind(this));this.contentManager.addListener(e)}else this.contentManager.onOpen(this)}},{key:"close",value:function(){this.removeClass("wrs_maximized"),this.removeClass("wrs_minimized"),this.removeClass("wrs_stack"),this.addClass("wrs_closed"),this.saveModalProperties(),this.unblockWebsiteScroll(),this.properties.open=!1}},{key:"restoreWebsiteScale",value:function(){var e=document.querySelector("meta[name=viewport]"),t=["initial-scale=","minimum-scale=","maximum-scale="],i=["1.0","1.0","1.0"],n=function(e,t){var n=e.getAttribute("content");if(n){for(var r=n.split(","),s="",o=[],a=0;a=0||navigator.userAgent.search("Trident/")>=0||navigator.userAgent.search("Edge/")>=0}},{key:"isRTL",value:function(){return"ar"==this.attributes.language||"he"==this.attributes.language||this.rtl}},{key:"addClass",value:function(e){v.addClass(this.overlay,e),v.addClass(this.titleBar,e),v.addClass(this.overlay,e),v.addClass(this.container,e),v.addClass(this.contentContainer,e),v.addClass(this.stackDiv,e),v.addClass(this.minimizeDiv,e),v.addClass(this.maximizeDiv,e),v.addClass(this.wrapper,e)}},{key:"removeClass",value:function(e){v.removeClass(this.overlay,e),v.removeClass(this.titleBar,e),v.removeClass(this.overlay,e),v.removeClass(this.container,e),v.removeClass(this.contentContainer,e),v.removeClass(this.stackDiv,e),v.removeClass(this.minimizeDiv,e),v.removeClass(this.maximizeDiv,e),v.removeClass(this.wrapper,e)}},{key:"createModalWindowDesktop",value:function(){this.addClass("wrs_modal_desktop"),this.stack()}},{key:"createModalWindowAndroid",value:function(){this.addClass("wrs_modal_android"),window.addEventListener("resize",this.orientationChangeAndroidSoftkeyboard.bind(this))}},{key:"createModalWindowIos",value:function(){this.addClass("wrs_modal_ios"),window.addEventListener("resize",this.orientationChangeIosSoftkeyboard.bind(this))}},{key:"restoreState",value:function(){"maximized"==this.properties.state?this.maximize():"minimized"==this.properties.state?(this.properties.state=this.properties.previousState,this.properties.previousState="",this.minimize()):this.stack()}},{key:"stack",value:function(){this.properties.previousState=this.properties.state,this.properties.state="stack",this.removeClass("wrs_maximized"),this.minimizeDiv.title="Minimise",this.removeClass("wrs_minimized"),this.addClass("wrs_stack"),this.restoreModalProperties(),void 0!==this.resizerBR&&void 0!==this.resizerTL&&this.setResizeButtonsVisibility(),this.recalculateScrollBar(),this.recalculatePosition(),this.recalculateScale(),this.focus()}},{key:"minimize",value:function(){this.saveModalProperties(),"minimized"==this.properties.state&&"stack"==this.properties.previousState?this.stack():"minimized"==this.properties.state&&"maximized"==this.properties.previousState?this.maximize():(this.container.style.height="30px",this.container.style.width="250px",this.container.style.bottom="0px",this.container.style.right="10px",this.removeListeners(),this.properties.previousState=this.properties.state,this.properties.state="minimized",this.setResizeButtonsVisibility(),this.minimizeDiv.title="Maximise",v.containsClass(this.overlay,"wrs_stack")?this.removeClass("wrs_stack"):this.removeClass("wrs_maximized"),this.addClass("wrs_minimized"))}},{key:"maximize",value:function(){this.saveModalProperties(),"maximized"!=this.properties.state&&(this.properties.previousState=this.properties.state,this.properties.state="maximized"),this.setResizeButtonsVisibility(),v.containsClass(this.overlay,"wrs_minimized")?(this.minimizeDiv.title="Minimise",this.removeClass("wrs_minimized")):v.containsClass(this.overlay,"wrs_stack")&&(this.container.style.left=null,this.container.style.top=null,this.removeClass("wrs_stack")),this.addClass("wrs_maximized"),this.setSize(parseInt(.8*window.innerHeight),parseInt(.8*window.innerWidth));this.container.clientHeight>700&&(this.container.style.height="700px"),this.container.clientWidth>1200&&(this.container.style.width="1200px"),this.setPosition(window.innerHeight/2-this.container.offsetHeight/2,window.innerWidth/2-this.container.offsetWidth/2),this.recalculateScale(),this.recalculatePosition(),this.recalculateSize(),this.focus()}},{key:"setSize",value:function(e,t){this.container.style.height=e+"px",this.container.style.width=t+"px",this.recalculateSize()}},{key:"setPosition",value:function(e,t){this.container.style.bottom=e+"px",this.container.style.right=t+"px"}},{key:"saveModalProperties",value:function(){"stack"==this.properties.state&&(this.properties.position.bottom=parseInt(this.container.style.bottom),this.properties.position.right=parseInt(this.container.style.right),this.properties.size.width=parseInt(this.container.style.width),this.properties.size.height=parseInt(this.container.style.height))}},{key:"restoreModalProperties",value:function(){"stack"==this.properties.state&&(this.setPosition(this.properties.position.bottom,this.properties.position.right),this.setSize(this.properties.size.height,this.properties.size.width))}},{key:"recalculateSize",value:function(){this.wrapper.style.width=this.container.clientWidth-12+"px",this.wrapper.style.height=this.container.clientHeight-38+"px",this.contentContainer.style.height=parseInt(this.wrapper.offsetHeight-50)+"px"}},{key:"setResizeButtonsVisibility",value:function(){"stack"==this.properties.state?(this.resizerTL.style.visibility="visible",this.resizerBR.style.visibility="visible"):(this.resizerTL.style.visibility="hidden",this.resizerBR.style.visibility="hidden")}},{key:"addListeners",value:function(){this.maximizeDiv.addEventListener("click",this.maximize.bind(this),!0),this.stackDiv.addEventListener("click",this.stack.bind(this),!0),this.minimizeDiv.addEventListener("click",this.minimize.bind(this),!0),this.closeDiv.addEventListener("click",this.cancelAction.bind(this)),v.addEvent(window,"mousedown",this.startDrag.bind(this)),v.addEvent(window,"mouseup",this.stopDrag.bind(this)),v.addEvent(window,"mousemove",this.drag.bind(this)),v.addEvent(window,"resize",this.onWindowResize.bind(this)),v.addEvent(window,"keydown",this.onKeyDown.bind(this))}},{key:"removeListeners",value:function(){v.removeEvent(window,"mousedown",this.startDrag),v.removeEvent(window,"mouseup",this.stopDrag),v.removeEvent(window,"mousemove",this.drag),v.removeEvent(window,"resize",this.onWindowResize),v.removeEvent(window,"keydown",this.onKeyDown)}},{key:"eventClient",value:function(e){if(void 0===e.clientX&&e.changedTouches){var t={X:e.changedTouches[0].clientX,Y:e.changedTouches[0].clientY};return t}return t={X:e.clientX,Y:e.clientY}}},{key:"startDrag",value:function(e){"minimized"!=this.properties.state&&e.target===this.title&&(void 0!==this.dragDataObject&&null!==this.dragDataObject||(e=e||event,this.dragDataObject={x:this.eventClient(e).X,y:this.eventClient(e).Y},this.lastDrag={x:"0px",y:"0px"},""==this.container.style.right&&(this.container.style.right="0px"),""==this.container.style.bottom&&(this.container.style.bottom="0px"),this.isIE11(),v.addClass(document.body,"wrs_noselect"),v.addClass(this.overlay,"wrs_overlay_active"),this.limitWindow=this.getLimitWindow()))}},{key:"drag",value:function(e){if(this.dragDataObject){e.preventDefault(),e=e||event;var t=Math.min(this.eventClient(e).Y,this.limitWindow.minPointer.y);t=Math.max(this.limitWindow.maxPointer.y,t);var i=Math.min(this.eventClient(e).X,this.limitWindow.minPointer.x),n=(i=Math.max(this.limitWindow.maxPointer.x,i))-this.dragDataObject.x+"px",r=t-this.dragDataObject.y+"px";this.lastDrag={x:n,y:r},this.container.style.transform="translate3d("+n+","+r+",0)"}if(this.resizeDataObject){var s;i=Math.min(this.eventClient(e).X,window.innerWidth-this.scrollbarWidth-7),t=Math.min(this.eventClient(e).Y,window.innerHeight-7);i<0&&(i=0),t<0&&(t=0),s=this.leftScale?-1:1,this.container.style.width=this.initialWidth+s*(i-this.resizeDataObject.x)+"px",this.container.style.height=this.initialHeight+s*(t-this.resizeDataObject.y)+"px",this.leftScale||(this.resizeDataObject.x-i-this.initialWidth<-580?this.container.style.right=this.initialRight-(i-this.resizeDataObject.x)+"px":(this.container.style.right=this.initialRight+this.initialWidth-580+"px",this.container.style.width="580px"),this.resizeDataObject.y-t580?(this.container.style.width=Math.min(parseInt(this.container.style.width),window.innerWidth-this.scrollbarWidth)+"px",e=!0):(this.container.style.width="580px",e=!0),parseInt(this.container.style.height)>338?(this.container.style.height=Math.min(parseInt(this.container.style.height),window.innerHeight)+"px",e=!0):(this.container.style.height="338px",e=!0),e&&this.recalculateSize()}},{key:"recalculateScrollBar",value:function(){this.hasScrollBar=window.innerWidth>document.documentElement.clientWidth,this.hasScrollBar?this.scrollbarWidth=this.getScrollBarWidth():this.scrollbarWidth=0}},{key:"hideKeyboard",value:function(){document.activeElement.blur()}},{key:"focus",value:function(){null!=this.contentManager&&void 0!==this.contentManager.onFocus&&this.contentManager.onFocus()}},{key:"portraitMode",value:function(){return window.innerHeight>window.innerWidth}},{key:"openedIosSoftkeyboard",value:function(){this.iosSoftkeyboardOpened||null==this.iosDivHeight||this.iosDivHeight!="100"+this.iosMeasureUnit||(this.portraitMode()?this.setContainerHeight("63"+this.iosMeasureUnit):this.setContainerHeight("40"+this.iosMeasureUnit)),this.iosSoftkeyboardOpened=!0}},{key:"closedIosSoftkeyboard",value:function(){this.iosSoftkeyboardOpened=!1,this.setContainerHeight("100"+this.iosMeasureUnit)}},{key:"orientationChangeIosSoftkeyboard",value:function(){this.iosSoftkeyboardOpened?this.portraitMode()?this.setContainerHeight("63"+this.iosMeasureUnit):this.setContainerHeight("40"+this.iosMeasureUnit):this.setContainerHeight("100"+this.iosMeasureUnit)}},{key:"orientationChangeAndroidSoftkeyboard",value:function(){this.setContainerHeight("100%")}},{key:"setContainerHeight",value:function(e){this.iosDivHeight=e,this.wrapper.style.height=e}},{key:"showPopUpMessage",value:function(){"minimized"==this.properties.state&&this.stack(),this.popup.show()}},{key:"setTitle",value:function(e){this.title.innerHTML=e}},{key:"getElementId",value:function(e){return e+"["+this.instanceId+"]"}}]),e}();function I(e){return(I="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function A(e,t){for(var i=0;i=4;){v.readInt32(e);var t=v.readInt32(e);if(1229472850==t){var i=v.readInt32(e),n=v.readInt32(e);v.readInt32(e),v.readByte(e)}else if(1650545477==t)var r=v.readInt32(e);else if(1883789683==t){var s=v.readInt32(e);s=Math.round(s/39.37),v.readInt32(e),v.readByte(e)}v.readInt32(e)}if(void 0!==i){var o=new Array;return o.cw=i,o.ch=n,o.dpi=s,r&&(o.cb=r),o}}}]),e}();function L(e,t){for(var i=0;i"),m=c.substring(0,f),p=m.split(" width=").join(' class="Wiriscas" width=');c=(c=c.split(m).join(p)).split("'").join('"')}}var b='';t=t.substring(0,n[a].start+s)+b+t.substring(n[a].end+s),s+=b.length-(n[a].end-n[a].start)}}return t}},{key:"initParseEditMode",value:function(e){if(-1!=l.get("parseModes").indexOf("latex"))for(var t=v.getElementsByNameFromString(e,"img",!0),i='encoding="LaTeX">',n=0,r=0;r",d),m=h.substring(d,f),g="$$"+v.htmlEntitiesDecode(m)+"$$";e=e.substring(0,t[r].start+n)+g+e.substring(t[r].end+n),n+=g.length-(t[r].end-t[r].start)}}}}return e}},{key:"endParse",value:function(t){return t=e.endParseEditMode(t),e.endParseSaveMode(t)}},{key:"endParseEditMode",value:function(e){if(-1!=l.get("parseModes").indexOf("latex")){for(var t="",i=0,n=e.indexOf("$$");-1!=n;){if(t+=e.substring(i,n),-1!=(i=e.indexOf("$$",n+2))){var r=e.substring(n+2,i);r=v.htmlEntitiesDecode(r),t+=g.getMathMLFromLatex(r,!0),i+=2}else t+="$$",i=n+2;n=e.indexOf("$$",i)}e=t+=e.substring(i,e.length)}return e}},{key:"endParseSaveMode",value:function(t){return l.get("saveMode")&&("safeXml"==l.get("saveMode")?t=e.codeImgTransform(t,"img2mathml"):"xml"==l.get("saveMode")?t=e.codeImgTransform(t,"img2mathml"):"base64"==l.get("saveMode")&&"image"==l.get("editMode")&&(t=e.codeImgTransform(t,"img264"))),t}},{key:"createShowImageSrc",value:function(e,t){var i=[],n="mml,color,centerbaseline,zoom,dpi,fontSize,fontFamily,defaultStretchy,backgroundColor,format".split(",");for(var r in n){var s=n[r];void 0!==e[s]&&(i[s]=e[s])}var o={};for(var r in e)"mml"!=r&&(o[r]=e[r]);return o.formula=com.wiris.js.JsPluginTools.md5encode(v.propertiesToString(i)),o.lang=void 0===t?"en":t,o.version=l.get("version"),f.getService("showimage",v.httpBuildQuery(o),!0)}},{key:"codeImgTransform",value:function(t,i){for(var n="",r=0,s=/"==h&&(r=u+1);++u}if(r",u):c.length,o.isMathmlInAttribute(t,u)||-1!=d)s+=t.substring(u,h);else{var f=t.substring(u,h);f=i==r.safeXmlCharacters?o.safeXmlDecode(f):o.mathMLEntities(f),s+=v.createObjectCode(e.mathmlToImgObject(document,f,null,n))}u=t.indexOf(a,h)}return s+=t.substring(h,t.length)}}]),e}();if("undefined"!=typeof MutationObserver){var R=new MutationObserver(function(e){e.forEach(function(e){e.oldValue===l.get("imageClassName")&&"class"===e.attributeName&&-1==e.target.className.indexOf(l.get("imageClassName"))&&(e.target.className=l.get("imageClassName"))})});D.observer=Object.create(R),D.observer.Config={attributes:!0,attributeOldValue:!0},D.observer.observe=function(e){this.__proto__.observe(e,this.Config)}}function z(e,t){for(var i=0;i=0&&(t=e[i].src.substr(0,n-1))}return t}},{key:"setLanguage",value:function(e){this.language=e}},{key:"setCore",value:function(e){this.core=e,e.setIntegrationModel(this)}},{key:"getCore",value:function(){return this.core}},{key:"setTarget",value:function(e){this.target=e,this.isIframe="IFRAME"===this.target.tagName.toUpperCase()}},{key:"setEditorObject",value:function(e){this.editorObject=e}},{key:"openNewFormulaEditor",value:function(){this.core.editionProperties.isNewElement=!0,this.core.openModalDialog(this.target,this.isIframe)}},{key:"openExistingFormulaEditor",value:function(){this.core.editionProperties.isNewElement=!1,this.core.openModalDialog(this.target,this.isIframe)}},{key:"updateFormula",value:function(e){this.isIframe?this.core.updateFormula(this.target.contentWindow,this.target.contentWindow,e,null):this.core.updateFormula(this.target,window,e,null)}},{key:"getSelection",value:function(){return this.isIframe?(this.target.contentWindow.focus(),this.target.contentWindow.getSelection()):(this.target.focus(),window.getSelection())}},{key:"addEvents",value:function(){var e=this.isIframe?this.target.contentWindow.document:this.target;v.addElementEvents(e,function(e,t){this.doubleClickHandler(e,t)}.bind(this),function(e,t){this.mousedownHandler(e,t)}.bind(this),function(e,t){this.mouseupHandler(e,t)}.bind(this))}},{key:"doubleClickHandler",value:function(e){if("img"==e.nodeName.toLowerCase()){if(this.core.getCustomEditors().disable(),e.hasAttribute("data-custom-editor")){var t=e.getAttribute("data-custom-editor");this.core.getCustomEditors().enable(t)}v.containsClass(e,l.get("imageClassName"))&&(this.core.editionProperties.temporalImage=e,this.core.editionProperties.isNewElement=!0,this.openExistingFormulaEditor())}}},{key:"mouseupHandler",value:function(){this.temporalImageResizing&&setTimeout(function(){T.fixAfterResize(this.temporalImageResizing)}.bind(this),10)}},{key:"mousedownHandler",value:function(e){"img"==e.nodeName.toLowerCase()&&v.containsClass(e,l.get("imageClassName"))&&(this.temporalImageResizing=e)}},{key:"getLanguage",value:function(){return this.getBrowserLanguage()}},{key:"getBrowserLanguage",value:function(){return navigator.userLanguage?navigator.userLanguage.substring(0,2):navigator.language?navigator.language.substring(0,2):"en"}},{key:"callbackFunction",value:function(){var e=y.newListener("onTargetReady",function(){this.addEvents(this.target)}.bind(this));this.listeners.add(e)}},{key:"notifyWindowClosed",value:function(){}},{key:"getMathmlFromTextNode",value:function(e,t){}},{key:"fillNonLatexNode",value:function(e,t,i){}},{key:"getSelectedItem",value:function(e,t){}}]),e}();function V(e,t){for(var i=0;i=0?"EDGE":e.search("Chrome/")>=0?"CHROME":e.search("Trident/")>=0?"IE":e.search("Firefox/")>=0?"FIREFOX":e.search("Safari/")>=0?"SAFARI":void 0}(),this.listeners=new y}return function(e,t,i){t&&V(e.prototype,t),i&&V(e,i)}(e,[{key:"init",value:function(e){this.load(e)}},{key:"setIntegrationModel",value:function(e){this.integrationModel=e}},{key:"setEnvironment",value:function(e){"editor"in e&&(this.environment.editor=e.editor),"mode"in e&&(this.environment.mode=e.mode),"version"in e&&(this.environment.version=e.version)}},{key:"getModalDialog",value:function(){return this.modalDialog}},{key:"load",value:function(t){var i="undefined"!=typeof XMLHttpRequest?new XMLHttpRequest:new ActiveXObject("Microsoft.XMLHTTP");this.integrationPath=0==t.indexOf("/")||0==t.indexOf("http")?t:v.concatenateUrl(this.integrationModel.getPath(),t),i.open("GET",this.integrationPath,!1),i.onload=function(t){var n=this;if(4===i.readyState){var r=JSON.parse(i.responseText);Object.keys(r);if(l.addConfiguration(r),l.addConfiguration(H),this.loadServicePaths(),this.loadLangFile(),this.loadCSS(),null===e.stringManager){var s=y.newListener("onLoad",function(){n.listeners.fire("onLoad",{})});e.stringManager.addListener(s)}else this.listeners.fire("onLoad",{})}}.bind(this),i.send(null)}},{key:"loadServicePaths",value:function(){var e=this.integrationPath.replace("configurationjs","createimage"),t=this.integrationPath.replace("configurationjs","showimage"),i=(e=this.integrationPath.replace("configurationjs","createimage"),this.integrationPath.replace("configurationjs","getmathml")),n=this.integrationPath.replace("configurationjs","service");if(0==this.integrationPath.indexOf("/")){var r=this.getServerPath();t=r+t,e=r+e,i=r+i,n=r+n}f.setServicePath("showimage",t),f.setServicePath("createimage",e),f.setServicePath("service",n),f.setServicePath("getmathml",i)}},{key:"getServerPath",value:function(){var e=this.integrationModel.getPath(),t=e.indexOf("/",e.indexOf("/")+2);return e.substr(0,t)}},{key:"loadLangFile",value:function(){var t="ar,ca,cs,da,de,en,es,et,eu,fi,fr,gl,he,hr,hu,it,ja,ko,nl,no,pl,pt,pt_br,ru,sv,tr,zh,el".split(","),i=this.language;-1==t.indexOf(i)&&(i=i.substr(0,2)),-1==t.indexOf(i)&&(i="en");var n=document.createElement("script");n.type="text/javascript",n.src=this.integrationModel.getPath()+"/"+this.integrationModel.langFolderName+"/"+i+"/strings.js",n.onload=function(){e.getStringManager().loadStrings(wrs_strings)},document.getElementsByTagName("head")[0].appendChild(n)}},{key:"loadCSS",value:function(){var e=document.createElement("link");e.setAttribute("rel","stylesheet"),e.setAttribute("type","text/css"),e.setAttribute("href",v.concatenateUrl(this.integrationModel.getPath(),"/core/styles.css")),document.getElementsByTagName("head")[0].appendChild(e)}},{key:"addListener",value:function(e){this.listeners.add(e)}},{key:"updateFormula",value:function(t,i,n,r){var s=new X;for(var o in s.mathml=n,s.wirisProperties={},r)s.wirisProperties[o]=r[o];if(s.language=this.language,s.editMode=this.editMode,!this.listeners.fire("onBeforeFormulaInsertion",s)&&!e.globalListeners.fire("onBeforeFormulaInsertion",s)){n=s.mathml,r=s.wirisProperties;var a=new X;if(a.editMode=this.editMode,a.windowTarget=i,a.focusElement=t,0==n.length)this.insertElementOnSelection(null,t,i);else if("latex"==this.editMode)a.latex=g.getLatexFromMathML(n),this.integrationModel.fillNonLatexNode&&void 0===a.latex?this.integrationModel.fillNonLatexNode(a,i,n):a.node=i.document.createTextNode("$$"+a.latex+"$$"),this.insertElementOnSelection(a.node,t,i);else if("iframes"==this.editMode){var l=wrs_mathmlToIframeObject(i,n);this.insertElementOnSelection(l,t,i)}else a.node=D.mathmlToImgObject(i.document,n,r,this.language),this.insertElementOnSelection(a.node,t,i);this.listeners.fire("onAfterFormulaInsertion",a)||e.globalListeners.fire("onAfterFormulaInsertion",a)}}},{key:"placeCaretAfterNode",value:function(e){this.integrationModel.getSelection();var t=e.ownerDocument;if(void 0!==t.getSelection){var i=t.createRange();i.setStartAfter(e),i.collapse(!0);var n=t.getSelection();n.removeAllRanges(),n.addRange(i),t.body.focus()}}},{key:"insertElementOnSelection",value:function(e,t,i){if(this.editionProperties.isNewElement)if("textarea"==t.type)v.updateTextArea(t,e.textContent);else if(document.selection&&0==document.getSelection){var n=i.document.selection.createRange();if(i.document.execCommand("InsertImage",!1,e.src),"parentElement"in n||(i.document.execCommand("delete",!1),n=i.document.selection.createRange(),i.document.execCommand("InsertImage",!1,e.src)),"parentElement"in n){var r=n.parentElement();"IMG"==r.nodeName.toUpperCase()?r.parentNode.replaceChild(e,r):n.pasteHTML(v.createObjectCode(e))}}else{var s,o=this.integrationModel.getSelection();this.editionProperties.range?(s=this.editionProperties.range,this.editionProperties.range=null):s=o.getRangeAt(0),s.deleteContents();var a=s.startContainer,l=s.startOffset;3==a.nodeType?(a=a.splitText(l)).parentNode.insertBefore(e,a):1==a.nodeType&&a.insertBefore(e,a.childNodes[l]),this.placeCaretAfterNode(e)}else if(this.editionProperties.latexRange)if(document.selection&&0==document.getSelection)this.editionProperties.isNewElement=!0,this.editionProperties.latexRange.select(),this.insertElementOnSelection(e,t,i);else{this.editionProperties.latexRange.startContainer;this.editionProperties.latexRange.deleteContents(),this.editionProperties.latexRange.insertNode(e),this.placeCaretAfterNode(e)}else if("textarea"==t.type){var c;c=void 0!==this.integrationModel.getSelectedItem?this.integrationModel.getSelectedItem(t,!1):v.getSelectedItemOnTextarea(t),v.updateExistingTextOnTextarea(t,e.textContent,c.startPosition,c.endPosition)}else e||this.editionProperties.temporalImage.parentNode.removeChild(this.editionProperties.temporalImage),this.editionProperties.temporalImage.parentNode.replaceChild(e,this.editionProperties.temporalImage),this.placeCaretAfterNode(e)}},{key:"openModalDialog",value:function(e,t){this.editMode="images";try{if(t){e.contentWindow.focus();var i=e.contentWindow.getSelection();this.editionProperties.range=i.getRangeAt(0)}else{e.focus();var n=getSelection();this.editionProperties.range=n.getRangeAt(0)}}catch(e){this.editionProperties.range=null}var r;if(void 0===t&&(t=!0),this.editionProperties.latexRange=null,e)if(r=void 0!==this.integrationModel.getSelectedItem?this.integrationModel.getSelectedItem(e,t):v.getSelectedItem(e,t)){if(!r.caretPosition&&v.containsClass(r.node,l.get("imageClassName")))this.editionProperties.temporalImage=r.node,this.editionProperties.isNewElement=!1;else if(3===r.node.nodeType)if(this.integrationModel.getMathmlFromTextNode){var s=this.integrationModel.getMathmlFromTextNode(r.node,r.caretPosition);s&&(this.editMode="latex",this.editionProperties.isNewElement=!1,this.editionProperties.temporalImage=document.createElement("img"),this.editionProperties.temporalImage.setAttribute(l.get("imageMathmlAttribute"),o.safeXmlEncode(s)))}else{var a=g.getLatexFromTextNode(r.node,r.caretPosition);if(a){var c=g.getMathMLFromLatex(a.latex);this.editMode="latex",this.editionProperties.isNewElement=!1,this.editionProperties.temporalImage=document.createElement("img"),this.editionProperties.temporalImage.setAttribute(l.get("imageMathmlAttribute"),o.safeXmlEncode(c));var u=t?e.contentWindow:window;if("textarea"!==e.tagName.toLowerCase())if(document.selection){for(var h=0,d=a.startNode.previousSibling;d;)h+=v.getNodeLength(d),d=d.previousSibling;this.editionProperties.latexRange=u.document.selection.createRange(),this.editionProperties.latexRange.moveToElementText(a.startNode.parentNode),this.editionProperties.latexRange.move("character",h+a.startPosition),this.editionProperties.latexRange.moveEnd("character",a.latex.length+4)}else this.editionProperties.latexRange=u.document.createRange(),this.editionProperties.latexRange.setStart(a.startNode,a.startPosition),this.editionProperties.latexRange.setEnd(a.endNode,a.endPosition)}}}else"textarea"===e.tagName.toLowerCase()&&(this.editMode="latex");for(var f=l.get("editorAttributes").split(", "),m={},p=0,b=f.length;p>>32-t},str2blks:function(e){for(var t=1+(e.length+8>>6),i=new Array,n=0,r=16*t;n>2]|=HxOverrides.cca(e,s)<<(8*e.length+s)%4*8,s++;i[s>>2]|=128<<(8*e.length+s)%4*8;var o=8*e.length,a=16*t-2;return i[a]=255&o,i[a]|=(o>>>8&255)<<8,i[a]|=(o>>>16&255)<<16,i[a]|=(o>>>24&255)<<24,i},rhex:function(e){for(var t="",i=0;i<4;){var n=i++;t+="0123456789abcdef".charAt(e>>8*n+4&15)+"0123456789abcdef".charAt(e>>8*n&15)}return t},addme:function(e,t){var i=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(i>>16)<<16|65535&i},bitAND:function(e,t){return(e>>>1&t>>>1)<<1|1&e&t},bitXOR:function(e,t){return(e>>>1^t>>>1)<<1|1&e^1&t},bitOR:function(e,t){return(e>>>1|t>>>1)<<1|(1&e|1&t)},__class__:haxe.Md5},haxe.Timer=function(e){var t=this;this.id=window.setInterval(function(){t.run()},e)},haxe.Timer.__name__=!0,haxe.Timer.delay=function(e,t){var i=new haxe.Timer(t);return i.run=function(){i.stop(),e()},i},haxe.Timer.measure=function(e,t){var i=haxe.Timer.stamp(),n=e();return haxe.Log.trace(haxe.Timer.stamp()-i+"s",t),n},haxe.Timer.stamp=function(){return(new Date).getTime()/1e3},haxe.Timer.prototype={run:function(){},stop:function(){null!=this.id&&(window.clearInterval(this.id),this.id=null)},__class__:haxe.Timer};var js=js||{},$_;function $bind(e,t){var i=function e(){return e.method.apply(e.scope,arguments)};return i.scope=e,i.method=t,i}js.Boot=function(){},js.Boot.__name__=!0,js.Boot.__unhtml=function(e){return e.split("&").join("&").split("<").join("<").split(">").join(">")},js.Boot.__trace=function(e,t){var i,n=null!=t?t.fileName+":"+t.lineNumber+": ":"";n+=js.Boot.__string_rec(e,""),"undefined"!=typeof document&&null!=(i=document.getElementById("haxe:trace"))?i.innerHTML+=js.Boot.__unhtml(n)+"
":"undefined"!=typeof console&&null!=console.log&&console.log(n)},js.Boot.__clear_trace=function(){var e=document.getElementById("haxe:trace");null!=e&&(e.innerHTML="")},js.Boot.isClass=function(e){return e.__name__},js.Boot.isEnum=function(e){return e.__ename__},js.Boot.getClass=function(e){return e.__class__},js.Boot.__string_rec=function(e,t){if(null==e)return"null";if(t.length>=5)return"<...>";var i=_typeof(e);switch("function"==i&&(e.__name__||e.__ename__)&&(i="object"),i){case"object":if(e instanceof Array){if(e.__enum__){if(2==e.length)return e[0];var n=e[0]+"(";t+="\t";for(var r=2,s=e.length;r0?",":"")+js.Boot.__string_rec(e[l],t)}return n+="]"}var c;try{c=e.toString}catch(e){return"???"}if(null!=c&&c!=Object.toString){var u=e.toString();if("[object Object]"!=u)return u}var h=null;n="{\n";t+="\t";var d=null!=e.hasOwnProperty;for(var h in e)d&&!e.hasOwnProperty(h)||"prototype"!=h&&"__class__"!=h&&"__super__"!=h&&"__interfaces__"!=h&&"__properties__"!=h&&(2!=n.length&&(n+=", \n"),n+=t+h+" : "+js.Boot.__string_rec(e[h],t));return n+="\n"+(t=t.substring(1))+"}";case"function":return"";case"string":return e;default:return String(e)}},js.Boot.__interfLoop=function(e,t){if(null==e)return!1;if(e==t)return!0;var i=e.__interfaces__;if(null!=i)for(var n=0,r=i.length;n>>32-t},str2blks:function(e){for(var t=1+(e.length+8>>6),i=new Array,n=0,r=16*t;n>2]|=HxOverrides.cca(e,s)<<(8*e.length+s)%4*8,s++;i[s>>2]|=128<<(8*e.length+s)%4*8;var o=8*e.length,a=16*t-2;return i[a]=255&o,i[a]|=(o>>>8&255)<<8,i[a]|=(o>>>16&255)<<16,i[a]|=(o>>>24&255)<<24,i},rhex:function(e){for(var t="",i=0;i<4;){var n=i++;t+="0123456789abcdef".charAt(e>>8*n+4&15)+"0123456789abcdef".charAt(e>>8*n&15)}return t},addme:function(e,t){var i=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(i>>16)<<16|65535&i},bitAND:function(e,t){return(e>>>1&t>>>1)<<1|1&e&t},bitXOR:function(e,t){return(e>>>1^t>>>1)<<1|1&e^1&t},bitOR:function(e,t){return(e>>>1|t>>>1)<<1|(1&e|1&t)},__class__:haxe.Md5},haxe.Timer=function(e){var t=this;this.id=window.setInterval(function(){t.run()},e)},haxe.Timer.__name__=!0,haxe.Timer.delay=function(e,t){var i=new haxe.Timer(t);return i.run=function(){i.stop(),e()},i},haxe.Timer.measure=function(e,t){var i=haxe.Timer.stamp(),n=e();return haxe.Log.trace(haxe.Timer.stamp()-i+"s",t),n},haxe.Timer.stamp=function(){return(new Date).getTime()/1e3},haxe.Timer.prototype={run:function(){},stop:function(){null!=this.id&&(window.clearInterval(this.id),this.id=null)},__class__:haxe.Timer};var js=js||{},$_;function $bind(e,t){var i=function e(){return e.method.apply(e.scope,arguments)};return i.scope=e,i.method=t,i}js.Boot=function(){},js.Boot.__name__=!0,js.Boot.__unhtml=function(e){return e.split("&").join("&").split("<").join("<").split(">").join(">")},js.Boot.__trace=function(e,t){var i,n=null!=t?t.fileName+":"+t.lineNumber+": ":"";n+=js.Boot.__string_rec(e,""),"undefined"!=typeof document&&null!=(i=document.getElementById("haxe:trace"))?i.innerHTML+=js.Boot.__unhtml(n)+"
":"undefined"!=typeof console&&null!=console.log&&console.log(n)},js.Boot.__clear_trace=function(){var e=document.getElementById("haxe:trace");null!=e&&(e.innerHTML="")},js.Boot.isClass=function(e){return e.__name__},js.Boot.isEnum=function(e){return e.__ename__},js.Boot.getClass=function(e){return e.__class__},js.Boot.__string_rec=function(e,t){if(null==e)return"null";if(t.length>=5)return"<...>";var i=_typeof(e);switch("function"==i&&(e.__name__||e.__ename__)&&(i="object"),i){case"object":if(e instanceof Array){if(e.__enum__){if(2==e.length)return e[0];var n=e[0]+"(";t+="\t";for(var r=2,s=e.length;r0?",":"")+js.Boot.__string_rec(e[l],t)}return n+="]"}var c;try{c=e.toString}catch(e){return"???"}if(null!=c&&c!=Object.toString){var u=e.toString();if("[object Object]"!=u)return u}var h=null;n="{\n";t+="\t";var d=null!=e.hasOwnProperty;for(var h in e)d&&!e.hasOwnProperty(h)||"prototype"!=h&&"__class__"!=h&&"__super__"!=h&&"__interfaces__"!=h&&"__properties__"!=h&&(2!=n.length&&(n+=", \n"),n+=t+h+" : "+js.Boot.__string_rec(e[h],t));return n+="\n"+(t=t.substring(1))+"}";case"function":return"";case"string":return e;default:return String(e)}},js.Boot.__interfLoop=function(e,t){if(null==e)return!1;if(e==t)return!0;var i=e.__interfaces__;if(null!=i)for(var n=0,r=i.length;n=0&&l.splice(t,1)}function m(e){var t=document.createElement("style");if(void 0===e.attrs.type&&(e.attrs.type="text/css"),void 0===e.attrs.nonce){var n=function(){0;return i.nc}();n&&(e.attrs.nonce=n)}return g(t,e.attrs),d(e,t),t}function g(e,t){Object.keys(t).forEach(function(i){e.setAttribute(i,t[i])})}function p(e,t){var i,n,r,s;if(t.transform&&e.css){if(!(s=t.transform(e.css)))return function(){};e.css=s}if(t.singleton){var l=a++;i=o||(o=m(t)),n=b.bind(null,i,l,!1),r=b.bind(null,i,l,!0)}else e.sourceMap&&"function"==typeof URL&&"function"==typeof URL.createObjectURL&&"function"==typeof URL.revokeObjectURL&&"function"==typeof Blob&&"function"==typeof btoa?(i=function(e){var t=document.createElement("link");return void 0===e.attrs.type&&(e.attrs.type="text/css"),e.attrs.rel="stylesheet",g(t,e.attrs),d(e,t),t}(t),n=function(e,t,i){var n=i.css,r=i.sourceMap,s=void 0===t.convertToAbsoluteUrls&&r;(t.convertToAbsoluteUrls||s)&&(n=c(n));r&&(n+="\n/*# sourceMappingURL=data:application/json;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(r))))+" */");var o=new Blob([n],{type:"text/css"}),a=e.href;e.href=URL.createObjectURL(o),a&&URL.revokeObjectURL(a)}.bind(null,i,t),r=function(){f(i),i.href&&URL.revokeObjectURL(i.href)}):(i=m(t),n=function(e,t){var i=t.css,n=t.media;n&&e.setAttribute("media",n);if(e.styleSheet)e.styleSheet.cssText=i;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(i))}}.bind(null,i),r=function(){f(i)});return n(e),function(t){if(t){if(t.css===e.css&&t.media===e.media&&t.sourceMap===e.sourceMap)return;n(e=t)}else r()}}e.exports=function(e,t){if("undefined"!=typeof DEBUG&&DEBUG&&"object"!=typeof document)throw new Error("The style-loader cannot be used in a non-browser environment");(t=t||{}).attrs="object"==typeof t.attrs?t.attrs:{},t.singleton||"boolean"==typeof t.singleton||(t.singleton=r()),t.insertInto||(t.insertInto="head"),t.insertAt||(t.insertAt="bottom");var i=h(e,t);return u(i,t),function(e){for(var r=[],s=0;s«/mo»",ampElement:"«mo»&«/mo»"}}},{key:"safeGoodBlackboardCharacters",get:function(){return{ltElement:"«mo»§lt;«/mo»",gtElement:"«mo»§gt;«/mo»",ampElement:"«mo»§amp;«/mo»"}}}]),e}();function s(e,t){for(var i=0;i",doubleQuote:'"',ampersand:"&",quote:"'"},r.safeXmlCharacters={tagOpener:"«",tagCloser:"»",doubleQuote:"¨",ampersand:"§",quote:"`",realDoubleQuote:"¨"};var o=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}return function(e,t,i){t&&s(e.prototype,t),i&&s(e,i)}(e,null,[{key:"isMathmlInAttribute",value:function(e,t){var i=new RegExp("^['\"][\\s]*=[\\s]*[\\w-]+([\\s]*(\"[^\"]*\"|'[^']*')[\\s]*=[\\s]*[\\w-]+[\\s]*)*[\\s]+gmi<"),n=e.substring(0,t).split("").reverse().join("");return i.test(n)}},{key:"safeXmlDecode",value:function(e){e=(e=(e=(e=e.split(r.safeXmlCharactersEntities.tagOpener).join(r.safeXmlCharacters.tagOpener)).split(r.safeXmlCharactersEntities.tagCloser).join(r.safeXmlCharacters.tagCloser)).split(r.safeXmlCharactersEntities.doubleQuote).join(r.safeXmlCharacters.doubleQuote)).split(r.safeXmlCharactersEntities.realDoubleQuote).join(r.safeXmlCharacters.realDoubleQuote),"_wrs_blackboard"in window&&window._wrs_blackboard&&(e=(e=(e=e.split(r.safeBadBlackboardCharacters.ltElement).join(r.safeGoodBlackboardCharacters.ltElement)).split(r.safeBadBlackboardCharacters.gtElement).join(r.safeGoodBlackboardCharacters.gtElement)).split(r.safeBadBlackboardCharacters.ampElement).join(r.safeGoodBlackboardCharacters.ampElement)),e=(e=(e=(e=(e=e.split(r.safeXmlCharacters.tagOpener).join(r.xmlCharacters.tagOpener)).split(r.safeXmlCharacters.tagCloser).join(r.xmlCharacters.tagCloser)).split(r.safeXmlCharacters.doubleQuote).join(r.xmlCharacters.doubleQuote)).split(r.safeXmlCharacters.ampersand).join(r.xmlCharacters.ampersand)).split(r.safeXmlCharacters.quote).join(r.xmlCharacters.quote);for(var t="",i=null,n=0;n128)t+="&#"+e.codePointAt(i)+";",e.codePointAt(i)>65535&&i++;else if("&"==n){var r=e.indexOf(";",i+1);if(r>=0){var s=document.createElement("span");s.innerHTML=e.substring(i,r+1),t+="&#"+v.fixedCharCodeAt(s.innerText||s.textContent,0)+";",i=r}else t+=n}else t+=n}return t}},{key:"addCustomEditorClassAttribute",value:function(e,t){var i="",n=e.indexOf("");if(-1==e.indexOf("class"))return i=e.substr(n,r)+' class="wrs_'+t+'">',i+=e.substr(r+1,e.length)}return e}},{key:"removeCustomEditorClassAttribute",value:function(e,t){return-1===e.indexOf("class")||-1===e.indexOf("wrs_"+t)?e:-1!==e.indexOf('class="wrs_'+t+'"')?e.replace('class="wrs_'+t+'"',""):e.replace("wrs_"+t,"")}},{key:"insertSemanticsMathml",value:function(e,t,i){if(""==t)return e;var n='',r=e.indexOf(">"),s=e.indexOf(""),o=e.substring(e.indexOf("<"),e.indexOf(">")).indexOf("math");if(-1!=r&&-1!=s&&o){var a=e.substring(r+1,s);if(0!=a.indexOf(""))var l=""+a+""+n+t+"
";else l=""+a+n+t+"
";return e.replace(a,l)}return e}},{key:"removeSemantics",value:function(e,t){var i='',n=e,r=e.indexOf("");if(-1!=r){var s=e.indexOf(i,r+"".length);-1!=s&&(n=e.substring(0,r)+e.substring(r+"".length,s)+"")}return n}},{key:"removeSemanticsOcurrences",value:function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:r.xmlCharacters,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"application/json",n=t.tagOpener+"math",s=t.tagOpener+"/math"+t.tagCloser,o="/"+t.tagCloser,a=t.tagCloser,l=t.tagOpener+"semantics"+t.tagCloser,c=t.tagOpener+"annotation encoding="+t.doubleQuote+i+t.doubleQuote+t.tagCloser,u="",h=e.indexOf(n),d=0;-1!==h;){u+=e.substring(d,h);var f=e.indexOf(s,h),m=e.indexOf(o,h),g=e.indexOf(a,h);-1!==f?d=f:m===g-1&&(d=m);var p=e.indexOf(l,h);if(-1!==p){var v=e.substring(h,p),b=e.indexOf(c,h);if(-1!==b)u+=v+e.substring(p+l.length,b)+s,h=e.indexOf(n,h+n.length),d+=s.length;else d=h,h=e.indexOf(n,h+n.length)}else d=h,h=e.indexOf(n,h+n.length)}return u+=e.substring(d,e.length)}},{key:"containClass",value:function(e,t){var i=e.indexOf("class");if(-1==i)return!1;var n=e.indexOf(">",i);return-1!=e.substring(i,n).indexOf(t)}}]),e}();function a(e,t){for(var i=0;i=0;--n)if(i[n]==t)return!0;return!1}},{key:"removeClass",value:function(e,t){for(var i="",n=e.className.split(" "),r=0;r").join("").split("").join("")).split("").join("
").split("").join("
");var n=e.createElement("div",{},i);return n.innerHTML=t,function t(n){if(n.getAttribute&&"WirisParam"==n.getAttribute("wirisObject")){for(var r={},s=0;s0){i+=">";for(n=0;n"}else"DIV"==t.nodeName||"SCRIPT"==t.nodeName?i+=">":i+="/>";return i}return 3==t.nodeType?e.htmlEntities(t.nodeValue):""}}},{key:"concatenateUrl",value:function(e,t){var i="";return e.indexOf("/")!=e.length&&0!=t.indexOf("/")&&(i="/"),(e+i+t).replace(/([^:]\/)\/+/g,"$1")}},{key:"htmlEntities",value:function(e){return e.split("&").join("&").split("<").join("<").split(">").join(">").split('"').join(""")}},{key:"htmlEntitiesDecode",value:function(e){return e.split(""").join('"').split(">").join(">").split("<").join("<").split("&").join("&")}},{key:"createHttpRequest",value:function(){if("file://"==window.location.toString().substr(0,window.location.toString().lastIndexOf("/")+1).substr(0,7))throw Core.getStringManager().getString("exception_cross_site");if("undefined"!=typeof XMLHttpRequest)return new XMLHttpRequest;try{return new ActiveXObject("Msxml2.XMLHTTP")}catch(e){try{return new ActiveXObject("Microsoft.XMLHTTP")}catch(e){}}return!1}},{key:"httpBuildQuery",value:function(t){var i="";for(var n in t)null!=t[n]&&(i+=e.urlEncode(n)+"="+e.urlEncode(t[n])+"&");return"&"==i.substring(i.length-1)&&(i=i.substring(0,i.length-1)),i}},{key:"propertiesToString",value:function(t){var i=[];for(var n in t)t.hasOwnProperty(n)&&i.push(n);for(var r=i.length,s=0;s0&&(i[s]=l,i[o]=a)}var c="";for(s=0;ss?s:r;for(n=0;n0){var i=e.substring(t+1).split("&"),n=new Object;for(t=0;t1&&(n[r[0]]=decodeURIComponent(r[1].replace(/\+/g," ")))}return n}return new Object}},{key:"urlEncode",value:function(e){return encodeURIComponent(e)}},{key:"getWIRISImageOutput",value:function(t,i,n){var s=e.createObject(t);if(s){if(s.className==l.get("imageClassName")||s.getAttribute(l.get("imageMathmlAttribute"))){if(!i)return t;var a=s.getAttribute(l.get("imageMathmlAttribute"));return l.get("saveHandTraces")||(a=o.removeSemanticsOcurrences(a,r.safeXmlCharacters)),null==a&&(a=s.getAttribute("alt")),n||(a=o.safeXmlDecode(a)),a}if(s.className==l.get("CASClassName")){var c=s.getAttribute(l.get("CASMathmlAttribute"));c=o.safeXmlDecode(c);var u=e.createObject(c);u.setAttribute("src",s.src);var h=e.createObjectCode(u);return n&&(h=o.safeXmlEncode(h)),h}}return t}},{key:"getNodeLength",value:function(e){function t(t){return e.apply(this,arguments)}return t.toString=function(){return e.toString()},t}(function(e){if(3==e.nodeType)return e.nodeValue.length;if(1==e.nodeType){var t={IMG:1,BR:1}[e.nodeName.toUpperCase()];void 0===t&&(t=0);for(var i=0;i0)return 0==c.text.length?e.getSelectedItem(t,i,!0):null;r.document.execCommand("InsertImage",!1,"#");var s,o=c.parentElement();return"IMG"!=o.nodeName.toUpperCase()&&(c.pasteHTML(''),o=r.document.getElementById("wrs_openEditorWindow_temporalObject")),o.nextSibling&&3==o.nextSibling.nodeType?(a=o.nextSibling,s=0):o.previousSibling&&3==o.previousSibling.nodeType?s=(a=o.previousSibling).nodeValue.length:(a=r.document.createTextNode(""),o.parentNode.insertBefore(a,o),s=0),o.parentNode.removeChild(o),{node:a,caretPosition:s}}return c.length>1?null:{node:c.item(0)}}if(r.getSelection){var a,l=r.getSelection();try{var c=l.getRangeAt(0)}catch(e){c=r.document.createRange()}if(3==(a=c.startContainer).nodeType)return{node:a,caretPosition:c.startOffset};if(a!=c.endContainer)return null;if(1==a.nodeType){var u=c.startOffset;if(a.childNodes[u])return{node:a.childNodes[u]}}}return null}},{key:"getSelectedItemOnTextarea",value:function(e){var t=document.createTextNode(e.value),i=g.getLatexFromTextNode(t,e.selectionStart);return null===i?null:{node:t,caretPosition:e.selectionStart,startPosition:i.startPosition,endPosition:i.endPosition}}},{key:"getElementsByNameFromString",value:function(e,t,i){var n=[];e=e.toLowerCase();t=t.toLowerCase();for(var r=e.indexOf("<"+t+" ");-1!=r;){var s;s=i?">":"";var o=e.indexOf(s,r);-1!=o?(o+=s.length,n.push({start:r,end:o})):o=r+1,r=e.indexOf("<"+t+" ",o)}return n}},{key:"decode64",value:function(e){var t="+".charCodeAt(0),i="/".charCodeAt(0),n="0".charCodeAt(0),r="a".charCodeAt(0),s="A".charCodeAt(0),o="-".charCodeAt(0),a="_".charCodeAt(0),l=e.charCodeAt(0);return l===t||l===o?62:l===i||l===a?63:l0)throw new Error("Invalid string. Length must be a multiple of 4");var r=new Array;if(i)o=i;else var s="="===t.charAt(t.length-2)?2:"="===t.charAt(t.length-1)?1:0,o=s>0?t.length-4:t.length;for(var a=0;a>16&255),r.push(n>>8&255),r.push(255&n);return s&&(2===s?(n=e.decode64(t.charAt(a))<<2|e.decode64(t.charAt(a+1))>>4,r.push(255&n)):1===s&&(n=e.decode64(t.charAt(a))<<10|e.decode64(t.charAt(a+1))<<4|e.decode64(t.charAt(a+2))>>2,r.push(n>>8&255),r.push(255&n))),r}},{key:"readInt32",value:function(e){if(e.length<4)return!1;var t=e.splice(0,4);return t[0]<<24|t[1]<<16|t[2]<<8|t[3]<<0}},{key:"readByte",value:function(e){return e.shift()<<0}},{key:"readBytes",value:function(e,t,i){return e.splice(t,i)}},{key:"updateTextArea",value:function(e,t){if(e&&t)if(e.focus(),null!=e.selectionStart){var i=e.selectionEnd;e.value=e.value.substring(0,e.selectionStart)+t+e.value.substring(e.selectionEnd,e.value.length),e.selectionEnd=i+t.length}else{document.selection.createRange().text=t}}},{key:"updateExistingTextOnTextarea",value:function(e,t,i,n){e.focus(),e.value=e.value.substring(0,i)+t+e.value.substring(n,e.value.length),e.selectionEnd=i+t.length}},{key:"addArgument",value:function(e,t,i){return e+(e.indexOf("?")>0?"&":"?")+t+"="+i}}]),e}();function b(e,t){for(var i=0;i-1,this.deviceProperties.isIOS=this.ua.indexOf("ipad")>-1||this.ua.indexOf("iphone")>-1,this.toolbar=null,this.modalDialogInstance=null,this.listeners=new y,this.mathML=null,this.isNewElement=!0,this.integrationModel=null,this.isEditorLoaded=!1}return function(e,t,i){t&&E(e.prototype,t),i&&E(e,i)}(e,[{key:"addListener",value:function(e){this.listeners.add(e)}},{key:"setIntegrationModel",value:function(e){this.integrationModel=e}},{key:"setModalDialogInstance",value:function(e){this.modalDialogInstance=e}},{key:"insert",value:function(){this.updateTitle(this.modalDialogInstance),this.insertEditor(this.modalDialogInstance)}},{key:"insertEditor",value:function(){if("com"in window&&"wiris"in window.com&&"jsEditor"in window.com.wiris){if(this.editor=com.wiris.jsEditor.JsEditor.newInstance(this.editorAttributes),this.editor.insertInto(this.modalDialogInstance.contentContainer),this.editor.focus(),this.modalDialogInstance.rtl&&this.editor.action("rtl"),this.editor.getEditorModel().isRTL()&&(this.editor.element.style.direction="rtl"),this.editor.getEditorModel().addEditorListener(this.editorListener),this.modalDialogInstance.deviceProperties.isIOS){setTimeout(function(){this.modalDialogInstance.hideKeyboard()},400);var t=document.getElementsByClassName("wrs_formulaDisplay")[0];v.addEvent(t,"focus",this.modalDialogInstance.handleOpenedIosSoftkeyboard),v.addEvent(t,"blur",this.modalDialogInstance.handleClosedIosSoftkeyboard)}this.listeners.fire("onLoad",{}),this.isEditorLoaded=!0}else setTimeout(e.prototype.insertEditor.bind(this,this.modalDialogInstance),100)}},{key:"init",value:function(){for(var e=window.location.search.substring(1).split("&"),t=0;t=0&&(version=e[t].substring(2))}var i=document.createElement("script");i.type="text/javascript";var n=l.get("editorUrl"),r=document.createElement("a");r.href=n,0==window.location.href.indexOf("https://")&&"http:"==r.protocol&&(r.protocol="https:"),n="80"==r.port||"443"==r.port?r.protocol+"//"+r.hostname+"/"+r.pathname:r.protocol+"//"+r.hostname+":"+r.port+"/"+r.pathname;var s={};"editor"in this.environment?s.editor=this.environment.editor:s.editor="unknown","mode"in this.environment?s.mode=this.environment.mode:s.mode=l.get("saveMode"),"version"in this.environment?s.version=this.environment.version:s.version=l.get("version"),i.src=n+"?lang="+this.language+"&stats-editor="+s.editor+"&stats-mode="+s.mode+"&stats-version="+s.version,document.getElementsByTagName("head")[0].appendChild(i)}},{key:"setInitialContent",value:function(){this.isNewElement||this.setMathML(this.mathML)}},{key:"setMathML",value:function(e,t){void 0===t&&(t=!1),this.editor.setMathMLWithCallback(e,function(){this.editorListener.setWaitingForChanges(!0)}.bind(this)),setTimeout(function(){this.editorListener.setIsContentChanged(!1)}.bind(this),500),t||this.onFocus()}},{key:"onFocus",value:function(){void 0!==this.editor&&null!=this.editor&&this.editor.focus()}},{key:"submitAction",value:function(){if(this.editor.isFormulaEmpty())this.integrationModel.updateFormula(null);else{var e=this.editor.getMathMLWithSemantics();if(null!=this.customEditors.getActiveEditor())e=o.addCustomEditorClassAttribute(e,this.customEditors.getActiveEditor().toolbar);else for(var t in this.customEditors.editors)e=o.removeCustomEditorClassAttribute(e,t);var i=o.mathMLEntities(e);this.integrationModel.updateFormula(i)}this.customEditors.disable(),this.integrationModel.notifyWindowClosed(),this.setEmptyMathML(),this.customEditors.disable()}},{key:"setEmptyMathML",value:function(){this.deviceProperties.isAndroid||this.deviceProperties.isIOS?this.editor.getEditorModel().isRTL()?this.setMathML('[]"',!0):this.setMathML('[]"',!0):this.editor.getEditorModel().isRTL()?this.setMathML('',!0):this.setMathML("",!0)}},{key:"onOpen",value:function(){this.isNewElement?this.setEmptyMathML():this.setMathML(this.mathML),this.updateToolbar(),this.onFocus()}},{key:"updateToolbar",value:function(){var e;if(this.updateTitle(this.modalDialogInstance),e=this.customEditors.getActiveEditor()){var t=e.toolbar?e.toolbar:_wrs_int_wirisProperties.toolbar;null!=this.toolbar&&this.toolbar==t||this.setToolbar(t)}else{t=this.getToolbar();null!=this.toolbar&&this.toolbar==t||(this.setToolbar(t),this.customEditors.disable())}}},{key:"updateTitle",value:function(){var e;(e=this.customEditors.getActiveEditor())?this.modalDialogInstance.setTitle(e.title):this.modalDialogInstance.setTitle("MathType")}},{key:"getToolbar",value:function(){var e;return"general"==(e="toolbar"in this.editorAttributes?this.editorAttributes.toolbar:"general")&&(e="undefined"==typeof _wrs_int_wirisProperties||void 0===_wrs_int_wirisProperties.toolbar?"general":_wrs_int_wirisProperties.toolbar),e}},{key:"setToolbar",value:function(e){this.toolbar=e,this.editor.setParams({toolbar:this.toolbar})}},{key:"hasChanges",value:function(){return!this.editor.isFormulaEmpty()&&this.editorListener.getIsContentChanged()}}]),e}();function k(e,t){for(var i=0;i-1,r=i.indexOf("ipad")>-1||i.indexOf("iphone")>-1;this.iosSoftkeyboardOpened=!1,this.iosMeasureUnit=-1==i.indexOf("crios")?"%":"vh",this.iosDivHeight="100"+this.iosMeasureUnit;var s=window.outerWidth,o=window.outerHeight,a=s>o,l=so||l&&this.attributes.width>s);this.instanceId=document.getElementsByClassName("wrs_modal_dialogContainer").length,this.deviceProperties={orientation:a?"landscape":"portait",isAndroid:!!n,isIOS:!!r,isMobile:c,isDesktop:!c&&!r&&!n},this.properties={created:!1,state:"",previousState:"",position:{bottom:0,right:10},size:{height:338,width:580}};var u={class:"wrs_modal_overlay"};u.id=this.getElementId(u.class),this.overlay=v.createElement("div",u),(u={}).class="wrs_modal_title_bar",u.id=this.getElementId(u.class),this.titleBar=v.createElement("div",u),(u={}).class="wrs_modal_title",u.id=this.getElementId(u.class),this.title=v.createElement("div",u),this.title.innerHTML="",(u={}).class="wrs_modal_close_button",u.id=this.getElementId(u.class),u.title=$.getStringManager().getString("close"),this.closeDiv=v.createElement("a",u),this.closeDiv.setAttribute("role","button"),(u={}).class="wrs_modal_stack_button",u.id=this.getElementId(u.class),u.title="Exit full-screen",this.stackDiv=v.createElement("a",u),this.stackDiv.setAttribute("role","button"),(u={}).class="wrs_modal_maximize_button",u.id=this.getElementId(u.class),u.title=$.getStringManager().getString("fullscreen"),this.maximizeDiv=v.createElement("a",u),this.maximizeDiv.setAttribute("role","button"),(u={}).class="wrs_modal_minimize_button",u.id=this.getElementId(u.class),u.title=$.getStringManager().getString("minimise"),this.minimizeDiv=v.createElement("a",u),this.minimizeDiv.setAttribute("role","button"),(u={}).class="wrs_modal_dialogContainer",u.id=this.getElementId(u.class),this.container=v.createElement("div",u),(u={}).class="wrs_modal_wrapper",u.id=this.getElementId(u.class),this.wrapper=v.createElement("div",u),(u={}).class="wrs_content_container",u.id=this.getElementId(u.class),this.contentContainer=v.createElement("div",u),(u={}).class="wrs_modal_controls",u.id=this.getElementId(u.class),this.controls=v.createElement("div",u),(u={}).class="wrs_modal_buttons_container",u.id=this.getElementId(u.class),this.buttonContainer=v.createElement("div",u),this.submitButton=this.createSubmitButton({id:this.getElementId("wrs_modal_button_accept"),class:"wrs_modal_button_accept",innerHTML:$.getStringManager().getString("accept")},this.submitAction.bind(this)),this.cancelButton=this.createSubmitButton({id:this.getElementId("wrs_modal_button_cancel"),class:"wrs_modal_button_cancel",innerHTML:$.getStringManager().getString("cancel")},this.cancelAction.bind(this)),this.contentManager=null;var h={cancelString:$.getStringManager().getString("cancel"),submitString:$.getStringManager().getString("close"),message:$.getStringManager().getString("close_modal_warning")},d={closeCallback:function(){this.close()}.bind(this),cancelCallback:function(){this.focus()}.bind(this)},f={overlayElement:this.container,callbacks:d,strings:h};this.popup=new S(f),this.rtl=!1,"rtl"in this.attributes&&(this.rtl=this.attributes.rtl),this.handleOpenedIosSoftkeyboard=this.handleOpenedIosSoftkeyboard.bind(this),this.handleClosedIosSoftkeyboard=this.handleClosedIosSoftkeyboard.bind(this)}return function(e,t,i){t&&j(e.prototype,t),i&&j(e,i)}(e,[{key:"setContentManager",value:function(e){this.contentManager=e}},{key:"getContentManager",value:function(){return this.contentManager}},{key:"submitAction",value:function(){void 0!==this.contentManager.submitAction&&this.contentManager.submitAction(),this.close()}},{key:"cancelAction",value:function(){void 0===this.contentManager.hasChanges?this.close():this.contentManager.hasChanges()?this.showPopUpMessage():this.close()}},{key:"createSubmitButton",value:function(e,t){function i(e,t){this.element=document.createElement("button"),this.element.id=e.id,this.element.className=e.class,this.element.innerHTML=e.innerHTML,v.addEvent(this.element,"click",t)}return i.prototype.getElement=function(){return this.element},new i(e,t).getElement()}},{key:"create",value:function(){this.titleBar.appendChild(this.closeDiv),this.titleBar.appendChild(this.stackDiv),this.titleBar.appendChild(this.maximizeDiv),this.titleBar.appendChild(this.minimizeDiv),this.titleBar.appendChild(this.title),this.deviceProperties.isDesktop&&this.container.appendChild(this.titleBar),this.wrapper.appendChild(this.contentContainer),this.wrapper.appendChild(this.controls),this.controls.appendChild(this.buttonContainer),this.buttonContainer.appendChild(this.submitButton),this.buttonContainer.appendChild(this.cancelButton),this.container.appendChild(this.wrapper),this.recalculateScrollBar(),document.body.appendChild(this.container),document.body.appendChild(this.overlay),this.deviceProperties.isDesktop?(this.createModalWindowDesktop(),this.createResizeButtons(),this.addListeners(),l.get("modalWindowFullScreen")&&this.maximize()):this.deviceProperties.isAndroid?this.createModalWindowAndroid():this.deviceProperties.isIOS&&!this.deviceProperties.isMobile&&this.createModalWindowIos(),null!=this.contentManager&&this.contentManager.insert(this),this.properties.open=!0,this.properties.created=!0,this.isRTL()&&(this.container.style.right=window.innerWidth-this.scrollbarWidth-this.container.offsetWidth+"px",this.container.className+=" wrs_modal_rtl")}},{key:"createResizeButtons",value:function(){this.resizerBR=document.createElement("div"),this.resizerBR.className="wrs_bottom_right_resizer",this.resizerBR.innerHTML="◢",this.resizerTL=document.createElement("div"),this.resizerTL.className="wrs_bottom_left_resizer",this.container.appendChild(this.resizerBR),this.titleBar.appendChild(this.resizerTL),v.addEvent(this.resizerBR,"mousedown",this.activateResizeStateBR.bind(this)),v.addEvent(this.resizerTL,"mousedown",this.activateResizeStateTL.bind(this))}},{key:"activateResizeStateBR",value:function(e){this.initializeResizeProperties(e,!1)}},{key:"activateResizeStateTL",value:function(e){this.initializeResizeProperties(e,!0)}},{key:"initializeResizeProperties",value:function(e,t){v.addClass(document.body,"wrs_noselect"),v.addClass(this.overlay,"wrs_overlay_active"),this.resizeDataObject={x:this.eventClient(e).X,y:this.eventClient(e).Y},this.initialWidth=parseInt(this.container.style.width),this.initialHeight=parseInt(this.container.style.height),t?this.leftScale=!0:(this.initialRight=parseInt(this.container.style.right),this.initialBottom=parseInt(this.container.style.bottom)),this.initialRight||(this.initialRight=0),this.initialBottom||(this.initialBottom=0),document.body.style["user-select"]="none"}},{key:"open",value:function(){if(this.removeClass("wrs_closed"),(this.deviceProperties.isIOS||this.deviceProperties.isAndroid||this.deviceProperties.isMobile)&&(this.restoreWebsiteScale(),this.blockWebsiteScroll(),setTimeout(function(){this.hideKeyboard()}.bind(this),400)),this.properties.created?(this.properties.open||(this.properties.open=!0,this.deviceProperties.isAndroid||this.deviceProperties.isIOS||this.restoreState()),this.deviceProperties.isDesktop&&l.get("modalWindowFullScreen")&&this.maximize(),this.deviceProperties.isIOS&&(this.iosSoftkeyboardOpened=!1,this.setContainerHeight("100"+this.iosMeasureUnit))):this.create(),!1===this.contentManager.isEditorLoaded){var e=y.newListener("onLoad",function(){this.contentManager.onOpen(this)}.bind(this));this.contentManager.addListener(e)}else this.contentManager.onOpen(this)}},{key:"close",value:function(){this.removeClass("wrs_maximized"),this.removeClass("wrs_minimized"),this.removeClass("wrs_stack"),this.addClass("wrs_closed"),this.saveModalProperties(),this.unblockWebsiteScroll(),this.properties.open=!1}},{key:"restoreWebsiteScale",value:function(){var e=document.querySelector("meta[name=viewport]"),t=["initial-scale=","minimum-scale=","maximum-scale="],i=["1.0","1.0","1.0"],n=function(e,t){var n=e.getAttribute("content");if(n){for(var r=n.split(","),s="",o=[],a=0;a=0||navigator.userAgent.search("Trident/")>=0||navigator.userAgent.search("Edge/")>=0}},{key:"isRTL",value:function(){return"ar"==this.attributes.language||"he"==this.attributes.language||this.rtl}},{key:"addClass",value:function(e){v.addClass(this.overlay,e),v.addClass(this.titleBar,e),v.addClass(this.overlay,e),v.addClass(this.container,e),v.addClass(this.contentContainer,e),v.addClass(this.stackDiv,e),v.addClass(this.minimizeDiv,e),v.addClass(this.maximizeDiv,e),v.addClass(this.wrapper,e)}},{key:"removeClass",value:function(e){v.removeClass(this.overlay,e),v.removeClass(this.titleBar,e),v.removeClass(this.overlay,e),v.removeClass(this.container,e),v.removeClass(this.contentContainer,e),v.removeClass(this.stackDiv,e),v.removeClass(this.minimizeDiv,e),v.removeClass(this.maximizeDiv,e),v.removeClass(this.wrapper,e)}},{key:"createModalWindowDesktop",value:function(){this.addClass("wrs_modal_desktop"),this.stack()}},{key:"createModalWindowAndroid",value:function(){this.addClass("wrs_modal_android"),window.addEventListener("resize",this.orientationChangeAndroidSoftkeyboard.bind(this))}},{key:"createModalWindowIos",value:function(){this.addClass("wrs_modal_ios"),window.addEventListener("resize",this.orientationChangeIosSoftkeyboard.bind(this))}},{key:"restoreState",value:function(){"maximized"==this.properties.state?this.maximize():"minimized"==this.properties.state?(this.properties.state=this.properties.previousState,this.properties.previousState="",this.minimize()):this.stack()}},{key:"stack",value:function(){this.properties.previousState=this.properties.state,this.properties.state="stack",this.removeClass("wrs_maximized"),this.minimizeDiv.title="Minimise",this.removeClass("wrs_minimized"),this.addClass("wrs_stack"),this.restoreModalProperties(),void 0!==this.resizerBR&&void 0!==this.resizerTL&&this.setResizeButtonsVisibility(),this.recalculateScrollBar(),this.recalculatePosition(),this.recalculateScale(),this.focus()}},{key:"minimize",value:function(){this.saveModalProperties(),"minimized"==this.properties.state&&"stack"==this.properties.previousState?this.stack():"minimized"==this.properties.state&&"maximized"==this.properties.previousState?this.maximize():(this.container.style.height="30px",this.container.style.width="250px",this.container.style.bottom="0px",this.container.style.right="10px",this.removeListeners(),this.properties.previousState=this.properties.state,this.properties.state="minimized",this.setResizeButtonsVisibility(),this.minimizeDiv.title="Maximise",v.containsClass(this.overlay,"wrs_stack")?this.removeClass("wrs_stack"):this.removeClass("wrs_maximized"),this.addClass("wrs_minimized"))}},{key:"maximize",value:function(){this.saveModalProperties(),"maximized"!=this.properties.state&&(this.properties.previousState=this.properties.state,this.properties.state="maximized"),this.setResizeButtonsVisibility(),v.containsClass(this.overlay,"wrs_minimized")?(this.minimizeDiv.title="Minimise",this.removeClass("wrs_minimized")):v.containsClass(this.overlay,"wrs_stack")&&(this.container.style.left=null,this.container.style.top=null,this.removeClass("wrs_stack")),this.addClass("wrs_maximized"),this.setSize(parseInt(.8*window.innerHeight),parseInt(.8*window.innerWidth));this.container.clientHeight>700&&(this.container.style.height="700px"),this.container.clientWidth>1200&&(this.container.style.width="1200px"),this.setPosition(window.innerHeight/2-this.container.offsetHeight/2,window.innerWidth/2-this.container.offsetWidth/2),this.recalculateScale(),this.recalculatePosition(),this.recalculateSize(),this.focus()}},{key:"setSize",value:function(e,t){this.container.style.height=e+"px",this.container.style.width=t+"px",this.recalculateSize()}},{key:"setPosition",value:function(e,t){this.container.style.bottom=e+"px",this.container.style.right=t+"px"}},{key:"saveModalProperties",value:function(){"stack"==this.properties.state&&(this.properties.position.bottom=parseInt(this.container.style.bottom),this.properties.position.right=parseInt(this.container.style.right),this.properties.size.width=parseInt(this.container.style.width),this.properties.size.height=parseInt(this.container.style.height))}},{key:"restoreModalProperties",value:function(){"stack"==this.properties.state&&(this.setPosition(this.properties.position.bottom,this.properties.position.right),this.setSize(this.properties.size.height,this.properties.size.width))}},{key:"recalculateSize",value:function(){this.wrapper.style.width=this.container.clientWidth-12+"px",this.wrapper.style.height=this.container.clientHeight-38+"px",this.contentContainer.style.height=parseInt(this.wrapper.offsetHeight-50)+"px"}},{key:"setResizeButtonsVisibility",value:function(){"stack"==this.properties.state?(this.resizerTL.style.visibility="visible",this.resizerBR.style.visibility="visible"):(this.resizerTL.style.visibility="hidden",this.resizerBR.style.visibility="hidden")}},{key:"addListeners",value:function(){this.maximizeDiv.addEventListener("click",this.maximize.bind(this),!0),this.stackDiv.addEventListener("click",this.stack.bind(this),!0),this.minimizeDiv.addEventListener("click",this.minimize.bind(this),!0),this.closeDiv.addEventListener("click",this.cancelAction.bind(this)),v.addEvent(window,"mousedown",this.startDrag.bind(this)),v.addEvent(window,"mouseup",this.stopDrag.bind(this)),v.addEvent(window,"mousemove",this.drag.bind(this)),v.addEvent(window,"resize",this.onWindowResize.bind(this)),v.addEvent(window,"keydown",this.onKeyDown.bind(this))}},{key:"removeListeners",value:function(){v.removeEvent(window,"mousedown",this.startDrag),v.removeEvent(window,"mouseup",this.stopDrag),v.removeEvent(window,"mousemove",this.drag),v.removeEvent(window,"resize",this.onWindowResize),v.removeEvent(window,"keydown",this.onKeyDown)}},{key:"eventClient",value:function(e){if(void 0===e.clientX&&e.changedTouches){var t={X:e.changedTouches[0].clientX,Y:e.changedTouches[0].clientY};return t}return t={X:e.clientX,Y:e.clientY}}},{key:"startDrag",value:function(e){"minimized"!=this.properties.state&&e.target===this.title&&(void 0!==this.dragDataObject&&null!==this.dragDataObject||(e=e||event,this.dragDataObject={x:this.eventClient(e).X,y:this.eventClient(e).Y},this.lastDrag={x:"0px",y:"0px"},""==this.container.style.right&&(this.container.style.right="0px"),""==this.container.style.bottom&&(this.container.style.bottom="0px"),this.isIE11(),v.addClass(document.body,"wrs_noselect"),v.addClass(this.overlay,"wrs_overlay_active"),this.limitWindow=this.getLimitWindow()))}},{key:"drag",value:function(e){if(this.dragDataObject){e.preventDefault(),e=e||event;var t=Math.min(this.eventClient(e).Y,this.limitWindow.minPointer.y);t=Math.max(this.limitWindow.maxPointer.y,t);var i=Math.min(this.eventClient(e).X,this.limitWindow.minPointer.x),n=(i=Math.max(this.limitWindow.maxPointer.x,i))-this.dragDataObject.x+"px",r=t-this.dragDataObject.y+"px";this.lastDrag={x:n,y:r},this.container.style.transform="translate3d("+n+","+r+",0)"}if(this.resizeDataObject){var s;i=Math.min(this.eventClient(e).X,window.innerWidth-this.scrollbarWidth-7),t=Math.min(this.eventClient(e).Y,window.innerHeight-7);i<0&&(i=0),t<0&&(t=0),s=this.leftScale?-1:1,this.container.style.width=this.initialWidth+s*(i-this.resizeDataObject.x)+"px",this.container.style.height=this.initialHeight+s*(t-this.resizeDataObject.y)+"px",this.leftScale||(this.resizeDataObject.x-i-this.initialWidth<-580?this.container.style.right=this.initialRight-(i-this.resizeDataObject.x)+"px":(this.container.style.right=this.initialRight+this.initialWidth-580+"px",this.container.style.width="580px"),this.resizeDataObject.y-t580?(this.container.style.width=Math.min(parseInt(this.container.style.width),window.innerWidth-this.scrollbarWidth)+"px",e=!0):(this.container.style.width="580px",e=!0),parseInt(this.container.style.height)>338?(this.container.style.height=Math.min(parseInt(this.container.style.height),window.innerHeight)+"px",e=!0):(this.container.style.height="338px",e=!0),e&&this.recalculateSize()}},{key:"recalculateScrollBar",value:function(){this.hasScrollBar=window.innerWidth>document.documentElement.clientWidth,this.hasScrollBar?this.scrollbarWidth=this.getScrollBarWidth():this.scrollbarWidth=0}},{key:"hideKeyboard",value:function(){document.activeElement.blur()}},{key:"focus",value:function(){null!=this.contentManager&&void 0!==this.contentManager.onFocus&&this.contentManager.onFocus()}},{key:"portraitMode",value:function(){return window.innerHeight>window.innerWidth}},{key:"handleOpenedIosSoftkeyboard",value:function(){this.iosSoftkeyboardOpened||null==this.iosDivHeight||this.iosDivHeight!="100"+this.iosMeasureUnit||(this.portraitMode()?this.setContainerHeight("63"+this.iosMeasureUnit):this.setContainerHeight("40"+this.iosMeasureUnit)),this.iosSoftkeyboardOpened=!0}},{key:"handleClosedIosSoftkeyboard",value:function(){this.iosSoftkeyboardOpened=!1,this.setContainerHeight("100"+this.iosMeasureUnit)}},{key:"orientationChangeIosSoftkeyboard",value:function(){this.iosSoftkeyboardOpened?this.portraitMode()?this.setContainerHeight("63"+this.iosMeasureUnit):this.setContainerHeight("40"+this.iosMeasureUnit):this.setContainerHeight("100"+this.iosMeasureUnit)}},{key:"orientationChangeAndroidSoftkeyboard",value:function(){this.setContainerHeight("100%")}},{key:"setContainerHeight",value:function(e){this.iosDivHeight=e,this.wrapper.style.height=e}},{key:"showPopUpMessage",value:function(){"minimized"==this.properties.state&&this.stack(),this.popup.show()}},{key:"setTitle",value:function(e){this.title.innerHTML=e}},{key:"getElementId",value:function(e){return e+"["+this.instanceId+"]"}}]),e}();function I(e){return(I="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function A(e,t){for(var i=0;i=4;){v.readInt32(e);var t=v.readInt32(e);if(1229472850==t){var i=v.readInt32(e),n=v.readInt32(e);v.readInt32(e),v.readByte(e)}else if(1650545477==t)var r=v.readInt32(e);else if(1883789683==t){var s=v.readInt32(e);s=Math.round(s/39.37),v.readInt32(e),v.readByte(e)}v.readInt32(e)}if(void 0!==i){var o=new Array;return o.cw=i,o.ch=n,o.dpi=s,r&&(o.cb=r),o}}}]),e}();function L(e,t){for(var i=0;i"),m=c.substring(0,f),p=m.split(" width=").join(' class="Wiriscas" width=');c=(c=c.split(m).join(p)).split("'").join('"')}}var b='';t=t.substring(0,n[a].start+s)+b+t.substring(n[a].end+s),s+=b.length-(n[a].end-n[a].start)}}return t}},{key:"initParseEditMode",value:function(e){if(-1!=l.get("parseModes").indexOf("latex"))for(var t=v.getElementsByNameFromString(e,"img",!0),i='encoding="LaTeX">',n=0,r=0;r",d),m=h.substring(d,f),g="$$"+v.htmlEntitiesDecode(m)+"$$";e=e.substring(0,t[r].start+n)+g+e.substring(t[r].end+n),n+=g.length-(t[r].end-t[r].start)}}}}return e}},{key:"endParse",value:function(t){var i=e.endParseEditMode(t);return e.endParseSaveMode(i)}},{key:"endParseEditMode",value:function(e){if(-1!=l.get("parseModes").indexOf("latex")){for(var t="",i=0,n=e.indexOf("$$");-1!=n;){if(t+=e.substring(i,n),-1!=(i=e.indexOf("$$",n+2))){var r=e.substring(n+2,i);r=v.htmlEntitiesDecode(r),t+=g.getMathMLFromLatex(r,!0),i+=2}else t+="$$",i=n+2;n=e.indexOf("$$",i)}e=t+=e.substring(i,e.length)}return e}},{key:"endParseSaveMode",value:function(t){return l.get("saveMode")&&("safeXml"==l.get("saveMode")?t=e.codeImgTransform(t,"img2mathml"):"xml"==l.get("saveMode")?t=e.codeImgTransform(t,"img2mathml"):"base64"==l.get("saveMode")&&"image"==l.get("editMode")&&(t=e.codeImgTransform(t,"img264"))),t}},{key:"createShowImageSrc",value:function(e,t){var i=[],n="mml,color,centerbaseline,zoom,dpi,fontSize,fontFamily,defaultStretchy,backgroundColor,format".split(",");for(var r in n){var s=n[r];void 0!==e[s]&&(i[s]=e[s])}var o={};for(var r in e)"mml"!=r&&(o[r]=e[r]);return o.formula=com.wiris.js.JsPluginTools.md5encode(v.propertiesToString(i)),o.lang=void 0===t?"en":t,o.version=l.get("version"),f.getService("showimage",v.httpBuildQuery(o),!0)}},{key:"codeImgTransform",value:function(t,i){for(var n="",r=0,s=/"==h&&(r=u+1);++u}if(r",u):c.length,o.isMathmlInAttribute(t,u)||-1!=d)s+=t.substring(u,h);else{var f=t.substring(u,h);f=i==r.safeXmlCharacters?o.safeXmlDecode(f):o.mathMLEntities(f),s+=v.createObjectCode(e.mathmlToImgObject(document,f,null,n))}u=t.indexOf(a,h)}return s+=t.substring(h,t.length)}}]),e}();if("undefined"!=typeof MutationObserver){var R=new MutationObserver(function(e){e.forEach(function(e){e.oldValue===l.get("imageClassName")&&"class"===e.attributeName&&-1==e.target.className.indexOf(l.get("imageClassName"))&&(e.target.className=l.get("imageClassName"))})});D.observer=Object.create(R),D.observer.Config={attributes:!0,attributeOldValue:!0},D.observer.observe=function(e){this.__proto__.observe(e,this.Config)}}function z(e,t){for(var i=0;i=0&&(t=e[i].src.substr(0,n-1))}return t}},{key:"setLanguage",value:function(e){this.language=e}},{key:"setCore",value:function(e){this.core=e,e.setIntegrationModel(this)}},{key:"getCore",value:function(){return this.core}},{key:"setTarget",value:function(e){this.target=e,this.isIframe="IFRAME"===this.target.tagName.toUpperCase()}},{key:"setEditorObject",value:function(e){this.editorObject=e}},{key:"openNewFormulaEditor",value:function(){this.core.editionProperties.isNewElement=!0,this.core.openModalDialog(this.target,this.isIframe)}},{key:"openExistingFormulaEditor",value:function(){this.core.editionProperties.isNewElement=!1,this.core.openModalDialog(this.target,this.isIframe)}},{key:"updateFormula",value:function(e){this.isIframe?this.core.updateFormula(this.target.contentWindow,this.target.contentWindow,e,null):this.core.updateFormula(this.target,window,e,null)}},{key:"getSelection",value:function(){return this.isIframe?(this.target.contentWindow.focus(),this.target.contentWindow.getSelection()):(this.target.focus(),window.getSelection())}},{key:"addEvents",value:function(){var e=this.isIframe?this.target.contentWindow.document:this.target;v.addElementEvents(e,function(e,t){this.doubleClickHandler(e,t)}.bind(this),function(e,t){this.mousedownHandler(e,t)}.bind(this),function(e,t){this.mouseupHandler(e,t)}.bind(this))}},{key:"doubleClickHandler",value:function(e){if("img"==e.nodeName.toLowerCase()){if(this.core.getCustomEditors().disable(),e.hasAttribute("data-custom-editor")){var t=e.getAttribute("data-custom-editor");this.core.getCustomEditors().enable(t)}v.containsClass(e,l.get("imageClassName"))&&(this.core.editionProperties.temporalImage=e,this.core.editionProperties.isNewElement=!0,this.openExistingFormulaEditor())}}},{key:"mouseupHandler",value:function(){this.temporalImageResizing&&setTimeout(function(){T.fixAfterResize(this.temporalImageResizing)}.bind(this),10)}},{key:"mousedownHandler",value:function(e){"img"==e.nodeName.toLowerCase()&&v.containsClass(e,l.get("imageClassName"))&&(this.temporalImageResizing=e)}},{key:"getLanguage",value:function(){return this.getBrowserLanguage()}},{key:"getBrowserLanguage",value:function(){return navigator.userLanguage?navigator.userLanguage.substring(0,2):navigator.language?navigator.language.substring(0,2):"en"}},{key:"callbackFunction",value:function(){var e=y.newListener("onTargetReady",function(){this.addEvents(this.target)}.bind(this));this.listeners.add(e)}},{key:"notifyWindowClosed",value:function(){}},{key:"getMathmlFromTextNode",value:function(e,t){}},{key:"fillNonLatexNode",value:function(e,t,i){}},{key:"getSelectedItem",value:function(e,t){}}]),e}();function V(e,t){for(var i=0;i=0?"EDGE":e.search("Chrome/")>=0?"CHROME":e.search("Trident/")>=0?"IE":e.search("Firefox/")>=0?"FIREFOX":e.search("Safari/")>=0?"SAFARI":void 0}(),this.listeners=new y}return function(e,t,i){t&&V(e.prototype,t),i&&V(e,i)}(e,[{key:"init",value:function(e){this.load(e)}},{key:"setIntegrationModel",value:function(e){this.integrationModel=e}},{key:"setEnvironment",value:function(e){"editor"in e&&(this.environment.editor=e.editor),"mode"in e&&(this.environment.mode=e.mode),"version"in e&&(this.environment.version=e.version)}},{key:"getModalDialog",value:function(){return this.modalDialog}},{key:"load",value:function(t){var i="undefined"!=typeof XMLHttpRequest?new XMLHttpRequest:new ActiveXObject("Microsoft.XMLHTTP");this.integrationPath=0==t.indexOf("/")||0==t.indexOf("http")?t:v.concatenateUrl(this.integrationModel.getPath(),t),i.open("GET",this.integrationPath,!1),i.onload=function(t){var n=this;if(4===i.readyState){var r=JSON.parse(i.responseText);Object.keys(r);if(l.addConfiguration(r),l.addConfiguration(H),this.loadServicePaths(),this.loadLangFile(),this.loadCSS(),null===e.stringManager){var s=y.newListener("onLoad",function(){n.listeners.fire("onLoad",{})});e.stringManager.addListener(s)}else this.listeners.fire("onLoad",{})}}.bind(this),i.send(null)}},{key:"loadServicePaths",value:function(){var e=this.integrationPath.replace("configurationjs","createimage"),t=this.integrationPath.replace("configurationjs","showimage"),i=(e=this.integrationPath.replace("configurationjs","createimage"),this.integrationPath.replace("configurationjs","getmathml")),n=this.integrationPath.replace("configurationjs","service");if(0==this.integrationPath.indexOf("/")){var r=this.getServerPath();t=r+t,e=r+e,i=r+i,n=r+n}f.setServicePath("showimage",t),f.setServicePath("createimage",e),f.setServicePath("service",n),f.setServicePath("getmathml",i)}},{key:"getServerPath",value:function(){var e=this.integrationModel.getPath(),t=e.indexOf("/",e.indexOf("/")+2);return e.substr(0,t)}},{key:"loadLangFile",value:function(){var t="ar,ca,cs,da,de,en,es,et,eu,fi,fr,gl,he,hr,hu,it,ja,ko,nl,no,pl,pt,pt_br,ru,sv,tr,zh,el".split(","),i=this.language;-1==t.indexOf(i)&&(i=i.substr(0,2)),-1==t.indexOf(i)&&(i="en");var n=document.createElement("script");n.type="text/javascript",n.src=this.integrationModel.getPath()+"/"+this.integrationModel.langFolderName+"/"+i+"/strings.js",n.onload=function(){e.getStringManager().loadStrings(wrs_strings)},document.getElementsByTagName("head")[0].appendChild(n)}},{key:"loadCSS",value:function(){var e=document.createElement("link");e.setAttribute("rel","stylesheet"),e.setAttribute("type","text/css"),e.setAttribute("href",v.concatenateUrl(this.integrationModel.getPath(),"/core/styles.css")),document.getElementsByTagName("head")[0].appendChild(e)}},{key:"addListener",value:function(e){this.listeners.add(e)}},{key:"updateFormula",value:function(t,i,n,r){var s=new X;for(var o in s.mathml=n,s.wirisProperties={},r)s.wirisProperties[o]=r[o];if(s.language=this.language,s.editMode=this.editMode,!this.listeners.fire("onBeforeFormulaInsertion",s)&&!e.globalListeners.fire("onBeforeFormulaInsertion",s)){n=s.mathml,r=s.wirisProperties;var a=new X;if(a.editMode=this.editMode,a.windowTarget=i,a.focusElement=t,n)if("latex"==this.editMode)a.latex=g.getLatexFromMathML(n),this.integrationModel.fillNonLatexNode&&!a.latex?this.integrationModel.fillNonLatexNode(a,i,n):a.node=i.document.createTextNode("$$"+a.latex+"$$"),this.insertElementOnSelection(a.node,t,i);else if("iframes"==this.editMode){var l=wrs_mathmlToIframeObject(i,n);this.insertElementOnSelection(l,t,i)}else a.node=D.mathmlToImgObject(i.document,n,r,this.language),this.insertElementOnSelection(a.node,t,i);else this.insertElementOnSelection(null,t,i);this.listeners.fire("onAfterFormulaInsertion",a)||e.globalListeners.fire("onAfterFormulaInsertion",a)}}},{key:"placeCaretAfterNode",value:function(e){this.integrationModel.getSelection();var t=e.ownerDocument;if(void 0!==t.getSelection&&e.parentElement){var i=t.createRange();i.setStartAfter(e),i.collapse(!0);var n=t.getSelection();n.removeAllRanges(),n.addRange(i),t.body.focus()}}},{key:"insertElementOnSelection",value:function(e,t,i){if(this.editionProperties.isNewElement)if(e)if("textarea"==t.type)v.updateTextArea(t,e.textContent);else if(document.selection&&0==document.getSelection){var n=i.document.selection.createRange();if(i.document.execCommand("InsertImage",!1,e.src),"parentElement"in n||(i.document.execCommand("delete",!1),n=i.document.selection.createRange(),i.document.execCommand("InsertImage",!1,e.src)),"parentElement"in n){var r=n.parentElement();"IMG"==r.nodeName.toUpperCase()?r.parentNode.replaceChild(e,r):n.pasteHTML(v.createObjectCode(e))}}else{var s,o=this.integrationModel.getSelection();this.editionProperties.range?(s=this.editionProperties.range,this.editionProperties.range=null):s=o.getRangeAt(0),s.deleteContents();var a=s.startContainer,l=s.startOffset;3==a.nodeType?(a=a.splitText(l)).parentNode.insertBefore(e,a):1==a.nodeType&&a.insertBefore(e,a.childNodes[l]),this.placeCaretAfterNode(e)}else if("textarea"==t.type)t.focus();else{var c=this.integrationModel.getSelection();if(c.removeAllRanges(),this.editionProperties.range){var u=this.editionProperties.range;this.editionProperties.range=null,c.addRange(u)}}else if(this.editionProperties.latexRange)document.selection&&0==document.getSelection?(this.editionProperties.isNewElement=!0,this.editionProperties.latexRange.select(),this.insertElementOnSelection(e,t,i)):(this.editionProperties.latexRange.deleteContents(),this.editionProperties.latexRange.insertNode(e),this.placeCaretAfterNode(e));else if("textarea"==t.type){var h;h=void 0!==this.integrationModel.getSelectedItem?this.integrationModel.getSelectedItem(t,!1):v.getSelectedItemOnTextarea(t),v.updateExistingTextOnTextarea(t,e.textContent,h.startPosition,h.endPosition)}else e&&"img"===e.nodeName.toLowerCase()?T.clone(e,this.editionProperties.temporalImage):this.editionProperties.temporalImage.remove(),this.placeCaretAfterNode(this.editionProperties.temporalImage)}},{key:"openModalDialog",value:function(e,t){this.editMode="images";try{if(t){e.contentWindow.focus();var i=e.contentWindow.getSelection();this.editionProperties.range=i.getRangeAt(0)}else{e.focus();var n=getSelection();this.editionProperties.range=n.getRangeAt(0)}}catch(e){this.editionProperties.range=null}var r;if(void 0===t&&(t=!0),this.editionProperties.latexRange=null,e)if(r=void 0!==this.integrationModel.getSelectedItem?this.integrationModel.getSelectedItem(e,t):v.getSelectedItem(e,t)){if(!r.caretPosition&&v.containsClass(r.node,l.get("imageClassName")))this.editionProperties.temporalImage=r.node,this.editionProperties.isNewElement=!1;else if(3===r.node.nodeType)if(this.integrationModel.getMathmlFromTextNode){var s=this.integrationModel.getMathmlFromTextNode(r.node,r.caretPosition);s&&(this.editMode="latex",this.editionProperties.isNewElement=!1,this.editionProperties.temporalImage=document.createElement("img"),this.editionProperties.temporalImage.setAttribute(l.get("imageMathmlAttribute"),o.safeXmlEncode(s)))}else{var a=g.getLatexFromTextNode(r.node,r.caretPosition);if(a){var c=g.getMathMLFromLatex(a.latex);this.editMode="latex",this.editionProperties.isNewElement=!1,this.editionProperties.temporalImage=document.createElement("img"),this.editionProperties.temporalImage.setAttribute(l.get("imageMathmlAttribute"),o.safeXmlEncode(c));var u=t?e.contentWindow:window;if("textarea"!==e.tagName.toLowerCase())if(document.selection){for(var h=0,d=a.startNode.previousSibling;d;)h+=v.getNodeLength(d),d=d.previousSibling;this.editionProperties.latexRange=u.document.selection.createRange(),this.editionProperties.latexRange.moveToElementText(a.startNode.parentNode),this.editionProperties.latexRange.move("character",h+a.startPosition),this.editionProperties.latexRange.moveEnd("character",a.latex.length+4)}else this.editionProperties.latexRange=u.document.createRange(),this.editionProperties.latexRange.setStart(a.startNode,a.startPosition),this.editionProperties.latexRange.setEnd(a.endNode,a.endPosition)}}}else"textarea"===e.tagName.toLowerCase()&&(this.editMode="latex");for(var f=l.get("editorAttributes").split(", "),m={},p=0,b=f.length;p=i)){var r,s=t.charCodeAt(n);return s>=55296&&s<=56319&&i>n+1&&(r=t.charCodeAt(n+1))>=56320&&r<=57343?1024*(s-55296)+r-56320+65536:s}};Object.defineProperty?Object.defineProperty(String.prototype,"codePointAt",{value:e,configurable:!0,writable:!0}):String.prototype.codePointAt=e}(),"function"!=typeof Object.assign&&Object.defineProperty(Object,"assign",{value:function(e,t){if(null==e)throw new TypeError("Cannot convert undefined or null to object");for(var i=Object(e),n=1;n=i)){var r,s=t.charCodeAt(n);return s>=55296&&s<=56319&&i>n+1&&(r=t.charCodeAt(n+1))>=56320&&r<=57343?1024*(s-55296)+r-56320+65536:s}};Object.defineProperty?Object.defineProperty(String.prototype,"codePointAt",{value:e,configurable:!0,writable:!0}):String.prototype.codePointAt=e}(),"function"!=typeof Object.assign&&Object.defineProperty(Object,"assign",{value:function(e,t){if(null==e)throw new TypeError("Cannot convert undefined or null to object");for(var i=Object(e),n=1;nversion = 2018092500; -$plugin->release = '7.6.1.1393'; +$plugin->version = 2018100800; +$plugin->release = '7.7.0.1394'; $plugin->requires = 2012120300; $plugin->component = 'tinymce_tiny_mce_wiris'; -$plugin->dependencies = array ('filter_wiris' => 2018092500); +$plugin->dependencies = array ('filter_wiris' => 2018100800); $plugin->maturity = MATURITY_STABLE;