-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjste.min.js
2 lines (2 loc) · 24.7 KB
/
jste.min.js
1
2
function _extends(){return(_extends=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var s,o=arguments[t];for(s in o)Object.prototype.hasOwnProperty.call(o,s)&&(e[s]=o[s])}return e}).apply(this,arguments)}var jste=function(e){var v=this,t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},g=(2<arguments.length&&void 0!==arguments[2]?arguments[2]:document).querySelector(e),b=["0,0,0","68,68,68","102,102,102","153,153,153","204,204,204","238,238,238","243,243,243","255,255,255",null,"255,0,0","255,153,0","255,255,0","0,255,0","0,255,255","0,0,255","153,0,255","255,0,255",null,"244,204,204","252,229,205","255,242,204","217,234,211","208,224,227","207,226,243","217,210,233","234,209,220","234,153,153","249,203,156","255,229,153","182,215,168","162,196,201","159,197,232","180,167,214","213,166,189","224,102,102","246,178,107","255,217,102","147,196,125","118,165,175","111,168,220","142,124,195","194,123,160","204,0,0","230,145,56","241,194,50","106,168,79","69,129,142","61,133,198","103,78,167","166,77,121","153,0,0","180,95,6","191,144,0","56,118,29","19,79,92","11,83,148","53,28,117","116,27,71","102,0,0","120,63,4","127,96,0","39,78,19","12,52,61","7,55,99","32,18,77","76,17,48"],k=_extends({status:!0,css:"jste",title:!0,titletext:[{title:"Text Format"},{title:"Font Size"},{title:"Color"},{title:"Bold",hotkey:"B"},{title:"Italic",hotkey:"I"},{title:"Underline",hotkey:"U"},{title:"Ordered List",hotkey:"."},{title:"Unordered List",hotkey:","},{title:"Subscript",hotkey:"down arrow"},{title:"Superscript",hotkey:"up arrow"},{title:"Outdent",hotkey:"left arrow"},{title:"Indent",hotkey:"right arrow"},{title:"Justify Left"},{title:"Justify Center"},{title:"Justify Right"},{title:"Strike Through",hotkey:"K"},{title:"Add Link",hotkey:"L"},{title:"Remove Link"},{title:"Cleaner Style",hotkey:"Delete"},{title:"Horizontal Rule",hotkey:"H"},{title:"Source"}],button:"OK",format:!0,formats:[["p","Normal"],["h1","Header 1"],["h2","Header 2"],["h3","Header 3"],["h4","Header 4"],["h5","Header 5"],["h6","Header 6"],["pre","Preformatted"]],fsize:!0,fsizes:["10","12","16","18","20","24","28"],funit:"px",color:!0,linktypes:["Web Address","E-mail Address","Picture URL"],b:!0,i:!0,u:!0,ol:!0,ul:!0,sub:!0,sup:!0,outdent:!0,indent:!0,left:!0,center:!0,right:!0,strike:!0,link:!0,unlink:!0,remove:!0,rule:!0,source:!0,placeholder:!1,br:!0,p:!0,change:"",focus:"",blur:""},t),_=navigator.userAgent.toLowerCase(),S=(/msie [1-7]./.test(_)&&(k.title=!1),[]);function s(e,t,s,o,n){var r=S.length+1;S.push({name:e,cls:r,command:t,key:s,tag:o,emphasis:n})}function l(){return window.getSelection?window.getSelection():document.selection&&document.selection.createRange&&"None"!==document.selection.type?document.selection.createRange():void 0}function E(e,t){var s,o=l();window.getSelection?((s=o.anchorNode&&o.getRangeAt?o.getRangeAt(0):s)&&(o.removeAllRanges(),o.addRange(s)),_.match(/msie/)||document.execCommand("StyleWithCSS",!1,!1),document.execCommand(e,!1,t)):document.selection&&document.selection.createRange&&"None"!==document.selection.type&&(s=document.selection.createRange()).execCommand(e,!1,t),i(!1,!1)}function n(e,t,s){var o,n,r,a;editor.matches(":not(:focus)")&&editor.focus(),window.getSelection?(o=l()).anchorNode&&o.getRangeAt&&(n=o.getRangeAt(0),(r=document.createElement(e)).setAttribute(t,s),a=n.extractContents(),r.appendChild(a),n.insertNode(r),o.removeAllRanges(),i(r,"style"===t&&s)):document.selection&&document.selection.createRange&&"None"!==document.selection.type&&(a="<"+e+" "+t+'="'+s+'">'+document.selection.createRange().htmlText+"</"+e+">",document.selection.createRange().pasteHTML(a))}s("format","formats","","",!1),s("fsize","fSize","","",!1),s("color","colors","","",!1),s("b","Bold","B",["b","strong"],!0),s("i","Italic","I",["i","em"],!0),s("u","Underline","U",["u"],!0),s("ol","insertorderedlist","¾",["ol"],!0),s("ul","insertunorderedlist","¼",["ul"],!0),s("sub","subscript","(",["sub"],!0),s("sup","superscript","&",["sup"],!0),s("outdent","outdent","%",["blockquote"],!1),s("indent","indent","'",["blockquote"],!0),s("left","justifyLeft","","",!1),s("center","justifyCenter","","",!1),s("right","justifyRight","","",!1),s("strike","strikeThrough","K",["strike"],!0),s("link","linkcreator","L",["a"],!0),s("unlink","unlink","",["a"],!1),s("remove","removeformat",".","",!1),s("rule","inserthorizontalrule","H",["hr"],!1),s("source","displaysource","","",!1);var r=function(){var e,t;return!!(t=!(t=window.getSelection?(e=getSelection()).anchorNode:t)&&document.selection&&document.selection.createRange&&"None"!==document.selection.type?(e=(e=document.selection).getRangeAt?e.getRangeAt(0):e.createRange()).commonAncestorContainer||(e.parentElement?e.parentElement():e.item(0)):t)&&("#text"===t.nodeName?t.parentNode:t)};function i(e,t){var s,o=r();(o=o||e)&&!1===t?(o.parentNode.matches("[style]")&&o.setAttribute("style",o.parentNode.getAttribute("style")),o.matches("[style]")&&o.querySelectorAll("*").forEach(function(e){e.setAttribute("style",o.getAttribute("style"))})):e&&t&&e.matches("[style]")&&(s=(s=t.split(";"))[0].split(":"),e.matches('[style*="'+s[0]+'"]')&&e.querySelectorAll("*").forEach(function(e){e.style[s[0]]=s[1]}),a(e))}function a(e){var t,s;e&&(document.body.createTextRange?((t=document.body.createTextRange()).moveToElementText(e),t.select()):window.getSelection&&(t=window.getSelection(),s=document.createRange(),"undefined"!==e)&&null!=e&&(s.selectNodeContents(e),t.removeAllRanges(),t.addRange(s),e.matches(":empty"))&&(e.insertAdjacentHTML("beforeend"," "),a(e)))}function A(){var e,t;void 0===toolbar.dataset.sourceOpened||"false"===toolbar.dataset.sourceOpened?(e=r(),t="https://",T(!0),e?"a"===e.tagName.toLowerCase()&&e.matches("[href]")?(t=e.getAttribute("href"),e.setAttribute(setdatalink,"")):n("a",setdatalink,""):linkinput.value=t,linkinput.focus(),O(linktypeselect,"click",function(e){(e.target.classList.contains(k.css+"_linktypetext")||e.target.classList.contains(k.css+"_linktypearrow"))&&w(!0)}),linktypes.querySelectorAll("a").forEach(function(e){O(e,"click",function(){linktypes.dataset.linktype=this.getAttribute(k.css+"-linktype"),linktypeview.querySelector("."+k.css+"_linktypetext").innerHTML=linktypes.querySelectorAll("a")[linktypes.dataset.linktype].textContent,c(t),w()})}),c(t),linkinput.focus(),linkinput.value=t,["keypress","keyup"].forEach(function(e){O(linkinput,e,function(e){if(13===e.keyCode)return o(JSTEContainer.querySelector("["+setdatalink+"]")),!1})}),O(linkbutton,"click",function(){return o(JSTEContainer.querySelector("["+setdatalink+"]")),!1})):T(!1)}function L(e,t){e=e.nextElementSibling;return!t||e&&e.matches(t)?e:null}function o(e){linkinput.focus(),a(e),void 0!==e&&e&&e.removeAttribute(setdatalink),"2"!==linktypes.dataset.linktype?E("createlink",linkinput.value):(E("insertImage",linkinput.value),editor.querySelectorAll("img").forEach(function(e){t="a",s=(s=e).previousElementSibling;var t=!t||s&&s.matches(t)?s:null,s=L(e,"a");t&&""===t.innerHTML?t.remove():s&&""===s.innerHTML&&s.remove()})),T(),editor.dispatchEvent(new Event("change"))}function T(e){var t;t="["+setdatalink+"]:not([href])",JSTEContainer.querySelectorAll(t).forEach(function(e){e.insertAdjacentHTML("beforebegin",e.innerHTML),e.remove()}),JSTEContainer.querySelectorAll("["+setdatalink+"][href]").forEach(function(e){e.removeAttribute(setdatalink)}),e?(toolbar.dataset.linkOpened=!0,linkform.style.display=""):(toolbar.dataset.linkOpened=!1,linkform.style.display="none"),w()}function w(e){linktypes.style.display=e?"":"none"}function c(e){var t=linktypes.dataset.linktype;"1"!==t||"https://"!==linkinput.value&&!linkinput.matches('[value^="https://"]')&&linkinput.matches('[value^="mailto"]')?"1"===t||linkinput.matches('[value^="https://"]')?linkinput.value=e:linkinput.value="https://":linkinput.value="mailto:"}function x(o){void 0===toolbar.dataset.sourceOpened||"false"===toolbar.dataset.sourceOpened?("fSize"===o?styleField=fsizebar:"colors"===o&&(styleField=cpalette),q(styleField,!0),styleField.querySelectorAll("a").forEach(function(e){R(e,"click"),O(e,"click",function(){var e,t=this.getAttribute(k.css+"-styleval"),s=("fSize"===o?(e="font-size",t+=k.funit):"colors"===o&&(e="color",t="rgb("+t+")"),function(e){var t=r();{var s,o;return t&&t.matches("[style]")&&""!==t.style[e]?(s=t.style[e],t.style[e]="",o=t.getAttribute("style"),t.style[e]=s,o):""}}(e));n("span","style",e+":"+t+";"+s),q("",!1),document.querySelectorAll("."+k.css+"_title").forEach(function(e){e.remove()}),editor.dispatchEvent(new Event("change"))})})):q(styleField,!1),T(!1)}function q(e,t){var s="",o=[{d:"fsizeOpened",f:fsizebar},{d:"cpallOpened",f:cpalette}];if(""!==e)for(var n=0;n<o.length;n++)e===o[n].f&&(s=o[n]);if(t){toolbar.dataset[s.d]=!0,m(s.f,100);for(var r=0;r<o.length;r++)s.d!==o[r].d&&(toolbar.dataset[o[r].d]=!1,p(o[r].f,1e3))}else for(var a=0;a<o.length;a++)toolbar.dataset[o[a].d]=!1,p(o[a].f,100)}function C(e){(e&&void 0!==formatbar.dataset.status&&"true"===formatbar.dataset.status.toLowerCase()||!e?(formatbar.dataset.status="false",p):(formatbar.dataset.status="true",m))(formatbar,200)}function H(e){var t=formatbar.closest("."+k.css+"_tool").querySelector("."+k.css+"_tool_label").querySelector("."+k.css+"_tool_text");10<e.length&&(e=e.substr(0,7)+"..."),t.innerHTML=e}function d(e){var t=e.replace(/\n/gim,"").replace(/\r/gim,"").replace(/\t/gim,"").replace(/ /gim," ");n=[/\<span(|\s+.*?)><span(|\s+.*?)>(.*?)<\/span><\/span>/gim,/<(\w*[^p])\s*[^\/>]*>\s*<\/\1>/gim,/\<div(|\s+.*?)>(.*?)\<\/div>/gim,/\<strong(|\s+.*?)>(.*?)\<\/strong>/gim,/\<em(|\s+.*?)>(.*?)\<\/em>/gim],r=["<span$2>$3</span>","","<p$1>$2</p>","<b$1>$2</b>","<i$1>$2</i>"];for(var s=0;s<5;s++)for(var o=0;o<n.length;o++)t=t.replace(n[o],r[o]);if(k.p||(t=t.replace(/\<p(|\s+.*?)>(.*?)\<\/p>/gi,"<br/>$2")),!k.br)for(var n=[/\<br>(.*?)/gi,/\<br\/>(.*?)/gi],r=["<p>$1</p>","<p>$1</p>"],a=0;a<n.length;a++)t=t.replace(n[a],r[a]);return t=k.p||k.br?t:t.replace(/\<p>(.*?)\<\/p>/gi,"<div>$1</div>")}function M(){var e=""===editor.textContent&&editor.innerHTML.length<12?"":editor.innerHTML;thisElement.value=d(e)}function z(){editor.innerHTML=d(thisElement.value)}function u(e){var s=!1,o=r();return o&&(e.forEach(function(e,t){o.tagName.toLowerCase()===t?s=!0:function(e,t){void 0===t&&(t=document.querySelector("html"));for(var s=[],o=e.parentNode;o!==t;){var n=o;s.push(n),o=n.parentNode}return s.push(t),s}(o).forEach(function(e){e.tagName.toLowerCase()===t&&(s=!0)})}),s)}function N(){for(var e=0;e<S.length;e++)k[S[e].name]&&S[e].emphasis&&""!==S[e].tag&&(u(S[e].tag)?toolbar.querySelectorAll("."+k.css+"_tool_"+S[e].cls).forEach(function(e){e.classList.add(emphasize)}):document.querySelector("."+k.css+"_tool_"+S[e].cls).classList.remove(emphasize));if(k.format&&Array.isArray(k.formats)){for(var t=!1,s=0;s<k.formats.length;s++){var o=[];if(o[0]=k.formats[s][0],0<k.formats[s][0].length&&u(o)){H(k.formats[s][1]),t=!0;break}}t||H(k.formats[0][1])}q("",!1),C(!1)}var j={};function f(e){if(e)for(var t=e.currentTarget,s=0,o=0,n=j[e.type];o<n.aEls.length;o++)if(n.aEls[o]===t){for(;s<n.aEvts[o].length;s++)n.aEvts[o][s].call(t,e);break}}function O(e,t,s){if(j.hasOwnProperty(t)){for(var o=j[t],n=-1,r=0;r<o.aEls.length;r++)if(o.aEls[r]===e){n=r;break}if(-1===n)o.aEls.push(e),o.aEvts.push([s]),e["on"+t]=f;else{var a=o.aEvts[n];e["on"+t]!==f&&(a.splice(0),e["on"+t]=f);for(var l=0;l<a.length;l++)if(a[l]===s)return;a.push(s)}}else j[t]={aEls:[e],aEvts:[[s]]},e["on"+t]=f}function R(e,t){if(j.hasOwnProperty(t)){for(var s=j[t],o=-1,n=0;n<s.aEls.length;n++)if(s.aEls[n]===e){o=n;break}if(-1!==o)for(var r=0,a=s.aEvts[o];r<a.length;r++)for(;a.length;)a.pop()}}function p(e,t){e.style.transitionProperty="height, margin, padding",e.style.transitionDuration="".concat(t,"ms"),e.style.boxSizing="border-box",e.style.height="".concat(e.offsetHeight,"px"),e.offsetHeight,e.style.overflow="hidden",e.style.height="0px",e.style.paddingTop="0px",e.style.paddingBottom="0px",e.style.marginTop="0px",e.style.marginBottom="0px",setTimeout(function(){e.style.display="none",e.style.removeProperty("height"),e.style.removeProperty("padding-top"),e.style.removeProperty("padding-bottom"),e.style.removeProperty("margin-top"),e.style.removeProperty("margin-bottom"),e.style.removeProperty("overflow"),e.style.removeProperty("transition-duration"),e.style.removeProperty("transition-property")},t)}function m(e,t){e.style.removeProperty("display");var s=window.getComputedStyle(e).display,s=(e.style.display=s="none"===s?"block":s,e.offsetHeight);e.style.overflow="hidden",e.style.height="0px",e.style.paddingTop="0px",e.style.paddingBottom="0px",e.style.marginTop="0px",e.style.marginBottom="0px",e.offsetHeight,e.style.boxSizing="border-box",e.style.transitionProperty="height, margin, padding",e.style.transitionDuration="".concat(t,"ms"),e.style.height="".concat(s,"px"),e.style.removeProperty("padding-top"),e.style.removeProperty("padding-bottom"),e.style.removeProperty("margin-top"),e.style.removeProperty("margin-bottom"),setTimeout(function(){e.style.removeProperty("height"),e.style.removeProperty("overflow"),e.style.removeProperty("transition-duration"),e.style.removeProperty("transition-property")},t)}return function(){if(g){var e,t;if(g.dataset.jste&&"undefined"!==g.dataset.jste?g.dataset.jste="false":g.dataset.jste="true",k.status&&"false"!==g.dataset.jste.toLowerCase()){var s=(v.thisElement=g).tagName.toLowerCase();g.setAttribute("data-origin",s);var o,n=(n=g.matches("[value]")||"textarea"===s?g.value:g.innerHTML).replace(/"/g,'"').replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&"),r=(g.insertAdjacentHTML("afterend",'<div class="'+k.css+'"></div>'),v.JSTEContainer=L(g,"."+k.css),JSTEContainer.innerHTML='<div class="'+k.css+'_toolbar" role="toolbar" unselectable></div><div class="'+k.css+'_linkform" style="display:none" role="dialog"></div><div class="'+k.css+'_editor"></div>',v.toolbar=JSTEContainer.querySelector("."+k.css+"_toolbar"),v.linkform=JSTEContainer.querySelector("."+k.css+"_linkform"),v.editor=JSTEContainer.querySelector("."+k.css+"_editor"),v.emphasize=k.css+"_tool_depressed",linkform.insertAdjacentHTML("beforeend",'<div class="'+k.css+'_linktypeselect" unselectable></div><input class="'+k.css+'_linkinput" type="text" value=""><div class="'+k.css+'_linkbutton" unselectable>'+k.button+'</div> <div style="height:1px;float:none;clear:both"></div>'),v.linktypeselect=linkform.querySelector("."+k.css+"_linktypeselect"),v.linkinput=linkform.querySelector("."+k.css+"_linkinput"),v.linkbutton=linkform.querySelector("."+k.css+"_linkbutton"),linktypeselect.insertAdjacentHTML("beforeend",'<div class="'+k.css+'_linktypeview" unselectable></div><div class="'+k.css+'_linktypes" role="menu" unselectable></div>'),v.linktypes=linktypeselect.querySelector("."+k.css+"_linktypes"),v.linktypeview=linktypeselect.querySelector("."+k.css+"_linktypeview"),v.setdatalink=k.css+"-setlink",editor.insertAdjacentHTML("afterend",'<div class="'+k.css+"_source "+k.css+'_hiddenField"></div>'),JSTEContainer.querySelector("."+k.css+"_source"));r.appendChild(thisElement),"textarea"!==s&&(o="",Array.prototype.forEach.call(thisElement.attributes,function(){"type"!==this.nodeName&&"value"!==this.nodeName&&(o=o+" "+this.nodeName+'="'+this.nodeValue+'"')}),thisElement.outerHTML="<textarea "+o+">"+n+"</textarea>",thisElement=r.querySelector("textarea")),editor.setAttribute("contenteditable","true"),editor.innerHTML=n;for(var a=0;a<S.length;a++)if(k[S[a].name]){var l=0<S[a].key.length&&null!=k.titletext[a].hotkey&&"undefined"!==k.titletext[a].hotkey&&""!==k.titletext[a].hotkey?" (Ctrl+"+k.titletext[a].hotkey+")":"",l=null!=k.titletext[a].title&&"undefined"!==k.titletext[a].title&&""!==k.titletext[a].title?k.titletext[a].title+l:"",i=(toolbar.insertAdjacentHTML("beforeend",'<div class="'+k.css+"_tool "+k.css+"_tool_"+S[a].cls+'" role="button" data-tool="'+a+'" unselectable><a class="'+k.css+'_tool_icon" unselectable></a></div>'),toolbar.querySelector("."+k.css+'_tool[data-tool="'+a+'"]'));if(i.dataset.tag=S[a].tag,i.dataset.command=S[a].command,i.dataset.emphasis=S[a].emphasis,i.dataset.title=l,"format"===S[a].name&&Array.isArray(k.formats)){i=0<k.formats[0][1].length&&"undefined"!==k.formats[0][1]?k.formats[0][1]:"";toolbar.querySelector("."+k.css+"_tool_"+S[a].cls).querySelector("."+k.css+"_tool_icon").outerHTML='<a class="'+k.css+'_tool_label" unselectable><span class="'+k.css+'_tool_text" unselectable>'+i+'</span><span class="'+k.css+'_tool_icon" unselectable></span></a>',toolbar.querySelector("."+k.css+"_tool_"+S[a].cls).insertAdjacentHTML("beforeend",'<div class="'+k.css+'_formats" unselectable></div>');for(var c=0;c<k.formats.length;c++)toolbar.querySelector("."+k.css+"_formats").insertAdjacentHTML("beforeend","<a "+k.css+'-formatval="'+k.formats[c][0]+'" class="'+k.css+"_format "+k.css+"_format_"+c+'" role="menuitem" unselectable>'+k.formats[c][1]+"</a>");toolbar.querySelectorAll("."+k.css+"_formats").forEach(function(e){e.dataset.status="false"})}else if("fsize"===S[a].name&&Array.isArray(k.fsizes)){toolbar.querySelector("."+k.css+"_tool_"+S[a].cls).insertAdjacentHTML("beforeend",'<div class="'+k.css+'_fontsizes" unselectable></div>');for(var d=0;d<k.fsizes.length;d++)toolbar.querySelector("."+k.css+"_fontsizes").insertAdjacentHTML("beforeend","<a "+k.css+'-styleval="'+k.fsizes[d]+'" class="'+k.css+'_fontsize" style="font-size:'+k.fsizes[d]+k.funit+'" role="menuitem" unselectable>Abcdefgh...</a>')}else if("color"===S[a].name&&Array.isArray(b)){toolbar.querySelector("."+k.css+"_tool_"+S[a].cls).insertAdjacentHTML("beforeend",'<div class="'+k.css+'_cpalette" unselectable></div>');for(var u=0;u<b.length;u++)null!=b[u]?toolbar.querySelector("."+k.css+"_cpalette").insertAdjacentHTML("beforeend","<a "+k.css+'-styleval="'+b[u]+'" class="'+k.css+'_color" style="background-color: rgb('+b[u]+')" role="gridcell" unselectable></a>'):toolbar.querySelector("."+k.css+"_cpalette").insertAdjacentHTML("beforeend",'<div class="'+k.css+'_colorSeperator"></div>')}}linktypes.dataset.linktype="0";for(var f=0;f<3;f++)linktypes.insertAdjacentHTML("beforeend","<a "+k.css+'-linktype="'+f+'" unselectable>'+k.linktypes[f]+"</a>"),linktypeview.innerHTML='<div class="'+k.css+'_linktypearrow" unselectable></div><div class="'+k.css+'_linktypetext">'+linktypes.querySelectorAll("a")[linktypes.dataset.linktype].textContent+"</div>";var p,m="",m=/msie/.test(_)?"-ms-":/chrome/.test(_)||/safari/.test(_)||/yandex/.test(_)?"-webkit-":/mozilla/.test(_)?"-moz-":/opera/.test(_)?"-o-":/konqueror/.test(_)?"-khtml-":"",y=(k.placeholder&&""!==k.placeholder&&(JSTEContainer.prepend('<div class="'+k.css+'_placeholder" unselectable><div class="'+k.css+'_placeholder_text">'+k.placeholder+"</div></div>"),O(p=JSTEContainer.querySelector("."+k.css+"_placeholder"),"click",function(){editor.focus()})),JSTEContainer.querySelectorAll("[unselectable]").forEach(function(i){i.style[m+"user-select"]="none",i.classList.add("unselectable"),i.setAttribute("unselectable","on"),["selectstart","mousedown"].forEach(function(e){var t=i,s=void 0;if(j.hasOwnProperty(e)){for(var o=j[e],n=-1,r=0;r<o.aEls.length;r++)if(o.aEls[r]===t){n=r;break}if(-1!==n)for(var a=0,l=o.aEvts[n];a<l.length;a++)l[a]===s&&l.splice(a,1)}})}),toolbar.querySelectorAll("."+k.css+"_tool")),h=(v.formatbar=toolbar.querySelector("."+k.css+"_formats"),v.fsizebar=toolbar.querySelector("."+k.css+"_fontsizes"),v.cpalette=toolbar.querySelector("."+k.css+"_cpalette"),y.forEach(function(e){R(e,"click"),O(e,"click",function(e){"displaysource"!==this.dataset.command||void 0!==toolbar.dataset.sourceOpened&&"false"!==toolbar.dataset.sourceOpened?(void 0===toolbar.dataset.sourceOpened||"false"===toolbar.dataset.sourceOpened?"linkcreator"===this.dataset.command?void 0===toolbar.dataset.linkOpened||"false"===toolbar.dataset.linkOpened?A():(T(!1),C(!1)):"formats"===this.dataset.command?("formats"!==this.dataset.command||e.target.classList.contains(k.css+"_format")||(C(!0),formatbar.querySelectorAll("a").forEach(function(e){O(e,"click",function(){this.querySelectorAll("*").forEach(function(e){O(e,"click",function(e){return e.preventDefault(),!1})}),H(this.textContent),E("formatBlock","<"+this.getAttribute(k.css+"-formatval")+">"),C(!1)})})),q("",!1),editor.matches(":not(:focus)")&&editor.focus()):"fSize"===this.dataset.command||"colors"===this.dataset.command?(("fSize"===this.dataset.command&&!e.target.classList.contains(k.css+"_fontsize")||"colors"===this.dataset.command&&!e.target.classList.contains(k.css+"_color"))&&x(this.dataset.command),C(!1),editor.matches(":not(:focus)")&&editor.focus()):(editor.matches(":not(:focus)")&&editor.focus(),E(this.dataset.command,null),q("",!1),C(!1),w(),void 0===this.dataset.emphasis||"true"!==this.dataset.emphasis.toLowerCase()||this.classList.contains(emphasize)?this.classList.remove(emphasize):this.classList.add(emphasize),r.classList.add(k.css+"_hiddenField"),editor.classList.remove(k.css+"_hiddenField")):(toolbar.dataset.sourceOpened="false",toolbar.querySelectorAll("."+k.css+"_tool").forEach(function(e){e.classList.remove(k.css+"_hiddenField")}),r.classList.add(k.css+"_hiddenField"),editor.classList.remove(k.css+"_hiddenField")),k.placeholder&&""!==k.placeholder&&(""!==editor.innerHTML?p.style.display="none":p.style.display="")):(toolbar.querySelector("."+k.css+"_tool").classList.add(k.css+"_hiddenField"),this.classList.remove(k.css+"_hiddenField"),toolbar.dataset.sourceOpened="true",thisElement.style.height=editor.outerHeight,r.classList.remove(k.css+"_hiddenField"),editor.classList.add(k.css+"_hiddenField"),thisElement.focus(),T(!1),q("",!1),C(!1),k.placeholder&&""!==k.placeholder&&(p.style.display="none")),editor.dispatchEvent(new Event("change"))}),O(e,"mouseover",function(e){var r,a,l;k.title&&""!==this.dataset.title&&(e.target.classList.contains(k.css+"_tool")||e.target.classList.contains(k.css+"_tool_icon"))&&(document.querySelectorAll("."+k.css+"_title").forEach(function(e){e.remove()}),JSTEContainer.insertAdjacentHTML("beforeend",'<div class="'+k.css+'_title"><div class="'+k.css+'_titleArrow"><div class="'+k.css+'_titleArrowIcon"></div></div><div class="'+k.css+'_titleText">'+this.dataset.title+"</div></div>"),r=document.querySelector("."+k.css+"_title"),e=this.offsetTop,a=this.offsetLeft+this.outerWidth-r.outerWidth/2-this.outerWidth/2,l=e+this.outerHeight+5,setTimeout(function(){var e,t,s,o,n;r.style.top=l,r.style.left=a,t=200,(e=r)&&(s=0,o=50/t,n=window.setInterval(function(){s+=o,(e.style.opacity=s)<=0&&(e.style.display="none"),(s<=0||1<=s)&&clearInterval(n)},50))},400))}),O(e,"mouseleave",function(){document.querySelectorAll("."+k.css+"_title").forEach(function(e){e.remove()})})}),null);return["keypress","keyup","keydown","drop","cut","copy","paste","DOMCharacterDataModified","DOMSubtreeModified"].forEach(function(e){O(editor,e,function(){void 0!==toolbar.dataset.sourceOpened&&"false"!==toolbar.dataset.sourceOpened.toLowerCase()||this.dispatchEvent(new Event("change")),w(),"function"==typeof k.change&&"number"!=typeof k.change.nodeType&&k.change(),k.placeholder&&""!==k.placeholder&&(""!==this.textContent?p.style.display="none":p.style.display="")})}),O(editor,"change",function(){void 0!==toolbar.dataset.sourceOpened&&"false"!==toolbar.dataset.sourceOpened.toLowerCase()||(clearTimeout(h),h=setTimeout(M,10))}),O(editor,"keydown",function(e){if(e.ctrlKey)for(var t=0;t<S.length;t++)if(k[S[t].name]&&e.keyCode===S[t].key.charCodeAt(0))return""!==S[t].command&&"linkcreator"!==S[t].command?E(S[t].command,null):"linkcreator"===S[t].command&&A(),!1}),["mouseup","keyup"].forEach(function(e){O(editor,e,N)}),O(editor,"focus",function(){var e,t;"function"==typeof k.focus&&"number"!=typeof k.focus.nodeType&&k.focus(),JSTEContainer.classList.add(k.css+"_focused"),/opera/.test(_)&&((e=document.createRange()).selectNodeContents(editor),e.collapse(!1),(t=window.getSelection()).removeAllRanges(),t.addRange(e))}),O(editor,"focusout",function(){y.forEach(function(e){e.classList.remove(emphasize)}),q("",!1),C(!1),w(),"function"==typeof k.blur&&"number"!=typeof k.blur.nodeType&&k.blur(),JSTEContainer.classList.remove(k.css+"_focused"),Array.isArray(k.formats)&&H(k.formats[0][1])}),["keydown","keyup"].forEach(function(e){O(thisElement,e,function(){setTimeout(z,0),this.style.height=this.scrollHeight,""==this.value&&(this.style.height=0)})}),O(thisElement,"focus",function(){JSTEContainer.classList.add(k.css+"_focused")}),O(thisElement,"focusout",function(){JSTEContainer.classList.remove(k.css+"_focused")}),v.container=JSTEContainer,v}0<g.closest("."+k.css).length&&(s=g.closest("."+k.css).querySelector("."+k.css+"_editor").innerHTML,e="",Array.prototype.forEach.call(g.attributes,function(){"style"!==this.nodeName&&(e=e+" "+this.nodeName+'="'+this.nodeValue+'"')}),n=">"+s,"input"!==(t=g.matches("[data-origin]")&&""!==g.getAttribute("data-origin")?g.getAttribute("data-origin"):"textarea")&&"option"!==t||(n='value="'+(s=s.replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">"))+'">'),s=g.cloneNode(),g.dataset.jste="false",g.closest("."+k.css).insertAdjacentHTML("beforeend",s).remove(),s.outerHTML="<"+t+e+n+"</"+t+">")}}(),{vars:k}};"undefined"!=typeof module&&(module.exports=jste);
//# sourceMappingURL=jste.min.js.map