Socket
Socket
Sign inDemoInstall

@baianat/align

Package Overview
Dependencies
Maintainers
2
Versions
51
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@baianat/align - npm Package Compare versions

Comparing version 0.0.8 to 0.0.9

4

dist/js/align.min.js

@@ -1,2 +0,2 @@

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("highlight.js")):"function"==typeof define&&define.amd?define(["highlight.js"],t):e.Align=t(e.hljs)}(this,function(e){"use strict";function t(e){return"string"==typeof e?document.querySelector(e):e}function i(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=void 0;return function(){var n=arguments,s=function(){i=null,t||e.apply(void 0,n)},o=t&&!i;i=requestAnimationFrame(s),o&&e.apply(void 0,arguments)}}function n(e,t,i){return Math.round(Math.max(Math.min(Number(e),i),t))}function s(){var e=navigator.appVersion;return-1!=e.indexOf("Win")?"Win":-1!=e.indexOf("Mac")?"Mac":-1!=e.indexOf("X11")?"UNIX":-1!=e.indexOf("Linux")?"Linux":"Other"}function o(e){k=e}function r(e,t,i){var n=document.createElement("button");return n.classList.add(k+"button"),n.id=e,i&&(n.dataset.tooltip=i),n.insertAdjacentHTML("afterbegin",'\n <svg class="icon" viewBox="0 0 24 24">\n <path d="'+t+'"/>\n </svg>\n '),n}function a(e,t){var i=document.createElement("div"),n=document.createElement("select");return i.classList.add(k+"select"),n.id=e,t.forEach(function(t){var i=document.createElement("option");i.value=t,i.innerText=!1===t?e:t,n.appendChild(i)}),i.appendChild(n),i.insertAdjacentHTML("beforeend",'\n <svg viewBox="0 0 24 24">\n <polygon points="8,15 12,19 16,15 "/>\n <polygon points="8,9 12,5 16,9 "/>\n </svg>'),i}function l(e,t){var i=document.createElement("input");return i.classList.add(""+k+e),i.id=e,i.type=t,i}e=e&&e.hasOwnProperty("default")?e.default:e;var c,u="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},d=function(e,t){return t={exports:{}},e(t,t.exports),t.exports}(function(e,t){!function(t,i){e.exports=function(){function e(){Element.prototype.matches||(Element.prototype.matches=Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector),Element.prototype.closest||(Element.prototype.closest=function(e){var t=this;if(!document.documentElement.contains(t))return null;do{if(t.matches(e))return t;t=t.parentElement}while(null!==t);return null})}function t(e){return"string"==typeof e?document.querySelector(e):e}function i(e){"function"==typeof e&&e()}function n(e,t){for(var i=[],n=0;n<e;n++){var s="function"==typeof t?t():t;i.push(s)}return i}function s(e,t){return e=Math.ceil(e),t=Math.floor(t),Math.floor(Math.random()*(t-e+1))+e}function o(e,t){for(;e!==document&&null!==e;){if(e===t)return!0;e=e.parentNode}return!1}function r(e){return e>255?255:e<0?0:e}function a(e){return isNaN(Number(e))?"00":("0"+Number(e).toString(16)).slice(-2)}function l(e){return isNaN(parseInt(e,16))?"0":parseInt(e,16)}function c(){return"rgb("+s(0,255)+", "+s(0,255)+", "+s(0,255)+")"}function d(e){return e=e.match(/^rgba?[\s+]?\([\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?/i),e&&4===e.length?"#"+("0"+parseInt(r(e[1]),10).toString(16)).slice(-2)+("0"+parseInt(r(e[2]),10).toString(16)).slice(-2)+("0"+parseInt(r(e[3]),10).toString(16)).slice(-2):""}function h(e){if((e=e.match(/^rgba?[\s+]?\([\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?/i))&&4===e.length){var t=e[1]/255,i=e[2]/255,n=e[3]/255,s=0,o=0,r=0,a=Math.min(t,i,n),l=Math.max(t,i,n);return r=(a+l)/2,a!==l&&(o=r>.5?(l-a)/(2-l-a):(l-a)/(l+a)),t>=l&&a!==l&&(s=(i-n)/(l-a)*60),i>=l&&a!==l&&(s=60*(2+(n-t)/(l-a))),n>=l&&a!==l&&(s=60*(4+(t-i)/(l-a))),s=s<0?parseInt(s+360):parseInt(s),o=parseInt(100*o),r=parseInt(100*r),"hsl("+s+", "+o+"%, "+r+"%)"}}function v(e,t){return{x:e*Math.cos(t*Math.PI*2),y:e*Math.sin(t*Math.PI*2)}}var m=("undefined"!=typeof window?window:void 0!==u||"undefined"!=typeof self&&self,function(e,t){return t={exports:{}},e(t,t.exports),t.exports}(function(e,t){!function(t,i){e.exports=function(){function e(e){return"string"==typeof e?document.querySelector(e):e}function t(e,t){return e?parseInt(e,10):parseInt(t,10)}function i(e,t){e.parentNode.insertBefore(t,e),t.appendChild(e)}var n=function(t,i){void 0===i&&(i={});var n=i.gradient;void 0===n&&(n=null);var s=i.classes;void 0===s&&(s=null);var o=i.colorCode;void 0===o&&(o=!1);var r=i.editable;void 0===r&&(r=!1);var a=i.reverse;void 0===a&&(a=!1);var l=i.label;void 0===l&&(l=!0);var c=i.min;void 0===c&&(c=0);var u=i.max;void 0===u&&(u=10);var d=i.step;void 0===d&&(d=1);var h=i.value;void 0===h&&(h=0),this.el=e(t),this.settings={gradient:n,classes:s,colorCode:o,editable:r,reverse:a,label:l,min:c,max:u,step:d,value:h},this.init()};return n.create=function(e,t){n(e,t)},n.prototype.init=function(){this.initElements(),this.min=t(this.el.min,this.settings.min),this.max=t(this.el.max,this.settings.max),this.step=t(this.el.step,this.settings.step),this.callbacks={},this.settings.gradient&&this.initGradient(),this.updateWidth(),this.update(t(this.el.value,this.settings.value)),this.initEvents()},n.prototype.initElements=function(){this.wrapper=document.createElement("div"),this.track=document.createElement("div"),this.handle=document.createElement("div"),this.fill=document.createElement("div"),this.wrapper.classList.add("slider"),this.settings.editable&&this.wrapper.classList.add("is-editable"),this.settings.reverse&&this.wrapper.classList.add("is-reverse"),this.settings.classes&&this.wrapper.classList.add(this.settings.classes),this.track.classList.add("slider-track"),this.handle.classList.add("slider-handle"),this.fill.classList.add("slider-fill"),this.el.classList.add("slider-input"),i(this.el,this.wrapper),this.track.appendChild(this.fill),this.track.appendChild(this.handle),this.wrapper.appendChild(this.track),this.settings.label&&(this.label=document.createElement("div"),this.label.classList.add("slider-label"),this.handle.appendChild(this.label))},n.prototype.initGradient=function(){if(this.settings.gradient.length>1)return this.track.style.backgroundImage="linear-gradient(90deg, "+this.settings.gradient+")",this.gradient=this.settings.gradient,void(this.colorCode=this.settings.colorCode);this.track.style.backgroundImage="none",this.track.style.backgroundColor=this.settings.gradient[0],this.handle.style.backgroundColor=this.settings.gradient[0],this.gradient=null},n.prototype.initEvents=function(){var e=this;this.track.addEventListener("mousedown",this.select.bind(this),!1),this.track.addEventListener("touchstart",this.select.bind(this),!1),this.settings.editable&&!this.settings.colorCode&&this.el.addEventListener("change",function(t){e.update(e.el.value)},!1)},n.prototype.select=function(e){e.preventDefault(),this.updateWidth(),this.click(e),this.callbacks.tempDrag=this.dragging.bind(this),this.callbacks.tempRelease=this.release.bind(this),document.addEventListener("mousemove",this.callbacks.tempDrag,!1),document.addEventListener("touchmove",this.callbacks.tempDrag,!1),document.addEventListener("touchend",this.callbacks.tempRelease,!1),document.addEventListener("mouseup",this.callbacks.tempRelease,!1)},n.prototype.dragging=function(e){e.preventDefault();var t="mousemove"===e.type?e.clientX:e.touches[0].clientX,i=t-this.currentX;if(1===e.buttons||"mousemove"!==e.type){this.track.classList.add("is-dragging");var n=parseInt(i/this.stepWidth+.5,10),s=parseInt((n+this.min)/this.step,10)*this.step;s!==this.currentValue&&this.update(s)}},n.prototype.release=function(){this.track.classList.remove("is-dragging"),document.removeEventListener("mousemove",this.callbacks.tempDrag),document.removeEventListener("touchmove",this.callbacks.tempDrag),document.removeEventListener("mouseup",this.callbacks.tempRelease),document.removeEventListener("touchend",this.callbacks.tempRelease)},n.prototype.click=function(e){e.preventDefault();var t="mousedown"===e.type?e.clientX:e.touches[0].clientX,i=t-this.currentX;if(1===e.buttons||"mousemove"!==e.type){var n=parseInt(i/this.stepWidth+.5,10),s=parseInt((n+this.min)/this.step,10)*this.step;s!==this.currentValue&&this.update(s)}},n.prototype.updateWidth=function(){this.currentX=this.track.getBoundingClientRect().left,this.width=this.track.clientWidth,this.stepWidth=this.width/(this.max-this.min)},n.prototype.getFillPercentage=function(e){return 100*(e-this.min)/(this.max-this.min)},n.prototype.normalizeValue=function(e){return e>=this.max?this.max:e<=this.min?this.min:isNaN(Number(e))?this.value:Number(e)},n.prototype.newGradient=function(e){this.settings.gradient=e,this.initGradient(),this.update(void 0,!0)},n.prototype.getHandleColor=function(e){for(var t=this,i=this.gradient.length-1,s=e/100,o=1;o<=i;o++)if(s>=(o-1)/i&&s<=o/i){var r=(s-(o-1)/i)/(1/i);return n.mixColors(t.gradient[o-1],t.gradient[o],r)}return"#000000"},n.prototype.update=function(e,t){if(void 0===t&&(t=!1),Number(e)!==this.value){var i=this.normalizeValue(e),n=this.getFillPercentage(i);if(this.handle.style.left=n+"%",this.fill.style.left=n+"%",this.value=i,this.el.value=this.value,this.settings.label&&(this.label.innerHTML=this.value),this.gradient){var s=this.getHandleColor(n);this.handle.style.backgroundColor=s,this.settings.colorCode&&(this.el.value=s,this.label.innerHTML=s)}t||(this.el.dispatchEvent(new Event("change")),this.el.dispatchEvent(new Event("input")))}},n.hexAverage=function(e,t,i){void 0===i&&(i=.5);var n=parseInt(e,16)*(1-i)+parseInt(t,16)*i;return("00"+Math.floor(n+.5).toString(16)).slice(-2)},n.mixColors=function(e,t,i){return e=e.replace("#",""),t=t.replace("#",""),"#"+(n.hexAverage(e.slice(0,-4),t.slice(0,-4),i)+n.hexAverage(e.slice(2,-2),t.slice(2,-2),i)+n.hexAverage(e.slice(-2),t.slice(-2),i)).toUpperCase()},n}()}()})),p=function(e,i){void 0===i&&(i={});var s=i.defaultColor;void 0===s&&(s=c());var o=i.radius;void 0===o&&(o=200);var r=i.mode;void 0===r&&(r="rgb");var a=i.events;void 0===a&&(a={});var l=i.recentColors;void 0===l&&(l=n(6,c));var u=i.disableLum;void 0===u&&(u=!1);var d=i.guideIcon;void 0===d&&(d='<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="12"/></svg>'),this.el=t(e),this.options={defaultColor:s,radius:o,mode:r,events:a,recentColors:l,disableLum:u,guideIcon:d},this.init()};return p.prototype.init=function(){this.recentColors=this.options.recentColors,this.lastMove={x:0,y:0},this.isMenuActive=!1,e(),this._initElements(),this._initWheel(),this._initEvents(),this.selectColor(this.options.defaultColor,!0)},p.prototype._initElements=function(){var e=this;this.picker=document.createElement("div"),this.picker.insertAdjacentHTML("afterbegin",'\n <button class="picker-guide">\n '+this.options.guideIcon+'\n </button>\n <div class="picker-menu is-hidden" tabindex="-1">\n <div class="picker-wheel">\n <canvas class="picker-canvas"></canvas>\n <div class="picker-cursor"></div>\n </div>\n '+(this.options.disableLum?"":'<input class="picker-saturation" type="number" min="0" max="100" value="100">')+'\n <input id="red" type="number" min="0" max="255" value="0">\n <input id="green" type="number" min="0" max="255" value="0">\n <input id="blue" type="number" min="0" max="255" value="0">\n <div class="picker-input">\n <button class="picker-submit">\n <svg class="icon" viewBox="0 0 24 24">\n <path d="M9 16.2L4.8 12l-1.4 1.4L9 19 21 7l-1.4-1.4L9 16.2z"/>\n </svg>\n </button>\n </div>\n <div class="picker-recent"></div>\n </div>\n '),this.menu=this.picker.querySelector(".picker-menu"),this.recent=this.picker.querySelector(".picker-recent"),this.guide=this.picker.querySelector(".picker-guide"),this.canvas=this.picker.querySelector(".picker-canvas"),this.wheel=this.picker.querySelector(".picker-wheel"),this.submit=this.picker.querySelector(".picker-submit"),this.cursor=this.picker.querySelector(".picker-cursor"),this.saturation=this.picker.querySelector(".picker-saturation"),this.rgbSliders={red:this.picker.querySelector("#red"),green:this.picker.querySelector("#green"),blue:this.picker.querySelector("#blue")},this.el.parentNode.insertBefore(this.picker,this.el),this.el.classList.add("picker-value"),this.picker.classList.add("picker"),this.submit.parentNode.insertBefore(this.el,this.submit),this.guide.style.color=this.options.defaultColor,this.guide.style.fill=this.options.defaultColor,this.sliders={},this.options.disableLum||(this.sliders.saturation=new m(this.saturation,{gradient:["#FFFFFF","#000000"],label:!1})),Object.keys(this.rgbSliders).forEach(function(t){e.sliders[t]=new m(e.rgbSliders[t],{gradient:["#000000","#FFFFFF"],label:!1,editable:!0,reverse:!0})}),this.recentColors.forEach(function(t){var i=document.createElement("a");i.classList.add("picker-color"),i.style.backgroundColor=t,e.recent.appendChild(i),i.addEventListener("mousedown",function(e){return e.preventDefault()}),i.addEventListener("click",function(i){return e.selectColor(t)})})},p.prototype._initWheel=function(){this.canvas.width=this.options.radius,this.canvas.height=this.options.radius,this.context=this.canvas.getContext("2d"),this.circle={path:new Path2D,xCords:this.canvas.width/2,yCords:this.canvas.height/2,radius:this.canvas.width/2},this.circle.path.moveTo(this.circle.xCords,this.circle.yCords),this.circle.path.arc(this.circle.xCords,this.circle.yCords,this.circle.radius,0,360),this.circle.path.closePath(),this.updateWheelColors()},p.prototype._initEvents=function(){var e=this;this.events=[new Event("input"),new Event("change")],this.guide.addEventListener("click",function(){i(e.options.events.beforerOpen),e.togglePicker()}),this.menu.addEventListener("mousedown",function(t){if(t.target===e.menu&&0===t.button){var i={},n={},s={};t.preventDefault(),i.x=t.clientX,i.y=t.clientY;var o=function(t){n.x=t.clientX,n.y=t.clientY,s.x=e.lastMove.x+n.x-i.x,s.y=e.lastMove.y+n.y-i.y,e.menu.style.transform="translate("+s.x+"px, "+s.y+"px)"},r=function t(){e.lastMove=s,document.removeEventListener("mousemove",o),document.removeEventListener("mouseup",t)};document.addEventListener("mousemove",o),document.addEventListener("mouseup",r)}}),this.wheel.addEventListener("mousedown",function(t){t.preventDefault();var i=function(t){var i=e.getMouseCords(t);if(e.context.isPointInPath(e.circle.path,i.x,i.y)){var n=e.getColorFromWheel(i);return e.selectColor(n,!1,i),n}return e.el.value},n=function t(n){var s=i(n);s!==e.el.value&&(e.updateRecentColors(s),e.selectColor(s,!1,e.mouse)),document.removeEventListener("mousemove",i),document.removeEventListener("mouseup",t)};document.addEventListener("mousemove",i),document.addEventListener("mouseup",n)}),this.options.disableLum||this.saturation.addEventListener("change",function(){e.updateWheelColors()}),Object.keys(this.rgbSliders).forEach(function(t){e.rgbSliders[t].addEventListener("change",function(t){var i=e.getColorFromSliders();e.selectColor(i)})}),this.el.addEventListener("focus",function(t){var i=function(){e.selectColor(e.el.value,!0)},n=function t(){e.el.removeEventListener("change",i),e.el.removeEventListener("blur",t)};e.el.addEventListener("change",i),e.el.addEventListener("blur",n)}),this.submit.addEventListener("click",function(t){i(e.options.events.beforeSubmit),e.selectColor(e.el.value),e.closePicker(),i(e.options.events.afterSubmit)})},p.prototype.updateWheelColors=function(){var e=this,t=this.circle.xCords,i=this.circle.yCords,n=this.circle.radius;this.context.clearRect(0,0,this.canvas.width,this.canvas.height);for(var s=0;s<360;s+=1){var o=e.context.createRadialGradient(t,i,0,t,i,n),r=(s-2)*Math.PI/180,a=(s+2)*Math.PI/180;e.context.beginPath(),e.context.moveTo(t,i),e.context.arc(t,i,n,r,a),e.context.closePath(),o.addColorStop(0,"hsl("+s+", "+(e.options.disableLum?100:e.saturation.value)+"%, 100%)"),o.addColorStop(.5,"hsl("+s+", "+(e.options.disableLum?100:e.saturation.value)+"%, 50%)"),o.addColorStop(1,"hsl("+s+", "+(e.options.disableLum?100:e.saturation.value)+"%, 0%)"),e.context.fillStyle=o,e.context.fill()}},p.prototype.updateRecentColors=function(e){var t=this;this.recentColors.length>=6&&this.recentColors.shift(),e&&this.recentColors.push(e),this.recent.childNodes.length>=6&&this.recent.removeChild(this.recent.firstChild);var i=document.createElement("a");i.classList.add("picker-color"),i.style.backgroundColor=e,this.recent.appendChild(i),i.addEventListener("click",function(i){i.preventDefault(),t.selectColor(e)})},p.prototype.updateSlidersInputs=function(e){var t=a(this.rgbSliders.red.value),i=a(this.rgbSliders.green.value),n=a(this.rgbSliders.blue.value);this.sliders.red.newGradient(["#00"+i+n,"#ff"+i+n]),this.sliders.green.newGradient(["#"+t+"00"+n,"#"+t+"ff"+n]),this.sliders.blue.newGradient(["#"+t+i+"00","#"+t+i+"ff"])},p.prototype.updateCursor=function(e){var t=this.getColorFromSliders(),i=d(t),n=h(t),s=n.match(/^hsl?[\s+]?\([\s+]?(\d+)[\s+]?,[\s+]?(\d+)\%[\s+]?,[\s+]?(\d+)\%[\s+]?/i),o=(100-s[3])*(this.options.radius/200),r=v(o,s[1]/360),a=this.options.radius/2;if(this.options.disableLum||(this.sliders.saturation.update(s[2]),this.sliders.saturation.newGradient(["#FFFFFF",i])),this.cursor.style.backgroundColor=n,e)return void(this.cursor.style.transform="translate("+e.x+"px, "+e.y+"px)");this.cursor.style.transform="translate("+(r.x+a)+"px, "+(r.y+a)+"px)"},p.prototype.selectColor=function(e,t,n){var s=this;if(void 0===t&&(t=!1),"#"===e.slice(0,1)||"RGB"===e.slice(0,3).toUpperCase()||"HSL"===e.slice(0,3).toUpperCase()){i(this.options.events.beforeSelect);var o="#"===e.slice(0,1)?e:d(e),r=h(e);this.el.value="hex"===this.options.mode?o:"hsl"===this.options.mode?r:e,this.guide.style.color=e,this.guide.style.fill=e,this.sliders.red.update(l(o.slice(1,3)),!0),this.sliders.green.update(l(o.slice(3,5)),!0),this.sliders.blue.update(l(o.slice(5,7)),!0),this.updateSlidersInputs(),this.updateCursor(n),i(this.options.events.afterSelect),t||this.events.forEach(function(e){return s.el.dispatchEvent(e)})}},p.prototype.getColorFromSliders=function(){return"rgb("+this.rgbSliders.red.value+", "+this.rgbSliders.green.value+", "+this.rgbSliders.blue.value+")"},p.prototype.getColorFromWheel=function(e){var t=this.context.getImageData(e.x,e.y,1,1).data;return"rgb("+t[0]+", "+t[1]+", "+t[2]+")"},p.prototype.getMouseCords=function(e){var t=this.canvas.getBoundingClientRect(),i={x:e.clientX-t.left,y:e.clientY-t.top};return this.mouse=i,i},p.prototype.togglePicker=function(){if(this.isMenuActive)return void this.closePicker();this.openPiker()},p.prototype.closePicker=function(){this.menu.classList.add("is-hidden"),this.isMenuActive=!1,document.removeEventListener("click",this.documentCallback)},p.prototype.openPiker=function(){var e=this;this.menu.classList.remove("is-hidden"),this.isMenuActive=!0;var t=function(t){if(!o(t.target,e.menu)&&!o(t.target,e.guide))return void e.closePicker();i(e.options.events.clicked)};this.documentCallback=t.bind(this),document.addEventListener("click",this.documentCallback),i(this.options.events.afterOpen)},p}()}()}),h=(function(){function e(e){this.value=e}function t(t){function i(e,t){return new Promise(function(i,s){var a={key:e,arg:t,resolve:i,reject:s,next:null};r?r=r.next=a:(o=r=a,n(e,t))})}function n(i,o){try{var r=t[i](o),a=r.value;a instanceof e?Promise.resolve(a.value).then(function(e){n("next",e)},function(e){n("throw",e)}):s(r.done?"return":"normal",r.value)}catch(e){s("throw",e)}}function s(e,t){switch(e){case"return":o.resolve({value:t,done:!0});break;case"throw":o.reject(t);break;default:o.resolve({value:t,done:!1})}o=o.next,o?n(o.key,o.arg):r=null}var o,r;this._invoke=i,"function"!=typeof t.return&&(this.return=void 0)}"function"==typeof Symbol&&Symbol.asyncIterator&&(t.prototype[Symbol.asyncIterator]=function(){return this}),t.prototype.next=function(e){return this._invoke("next",e)},t.prototype.throw=function(e){return this._invoke("throw",e)},t.prototype.return=function(e){return this._invoke("return",e)}}(),function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}),v=function(){function e(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,i,n){return i&&e(t.prototype,i),n&&e(t,n),t}}(),m=function(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e},p=null,f=function(){function e(){h(this,e)}return v(e,[{key:"selectedRange",set:function(e){e&&(p=e)},get:function(){return p}}],[{key:"updateSelection",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:e.selectedRange;if(t){var i=window.getSelection();i.removeAllRanges(),i.addRange(t)}}},{key:"updateSelectedRange",value:function(){var t=window.getSelection();t.rangeCount&&3===t.anchorNode.nodeType&&(e.selectedRange=t.getRangeAt(0))}}]),e}(),g=function(){var e=s();return{cmdKey:"Mac"===e?"⌘":"Ctrl",shift:"Mac"===e?"⇧":"Shift",ctrl:"Mac"===e?"⌃":"Ctrl",alt:"Mac"===e?"⌥":"Alt",tab:"Mac"===e?"⇥":"Tab"}}(),b={bold:{element:"button",command:"bold",tooltip:"Bold ("+g.cmdKey+" B)"},italic:{element:"button",command:"italic",tooltip:"Italic ("+g.cmdKey+" I)"},underline:{element:"button",command:"underline",tooltip:"Underline ("+g.cmdKey+" U)"},strikeThrough:{element:"button",command:"strikeThrough",tooltip:"Strike through"},undo:{element:"button",command:"undo",tooltip:"Undo ("+g.cmdKey+" Z)"},redo:{element:"button",command:"redo",tooltip:"Redo ("+g.cmdKey+" "+g.shift+" Z)"},removeFormat:{element:"button",command:"removeFormat",tooltip:"Remove format ("+g.cmdKey+" \\)"},justifyLeft:{element:"button",command:"justifyLeft",tooltip:"Align left ("+g.cmdKey+" L)"},justifyCenter:{element:"button",command:"justifyCenter",tooltip:"Align center ("+g.cmdKey+" E)"},justifyRight:{element:"button",command:"justifyRight",tooltip:"Align right ("+g.cmdKey+" R)"},selectAll:{element:"button",command:"selectAll",tooltip:"Select all ("+g.cmdKey+" A)"},justifyFull:{element:"button",command:"justifyFull",tooltip:"Justify full ("+g.cmdKey+" J)"},createLink:{element:"button",tooltip:"Hyperlink",func:function(e){var t=prompt("Write the URL here","");t&&""!==t&&e.align.execute("createLink",t)}},h1:{element:"button",command:"formatblock",value:"h1",tooltip:"Heading 1"},h2:{element:"button",command:"formatblock",value:"h2",tooltip:"Heading 2"},blockquote:{element:"button",command:"formatblock",value:"blockquote",tooltip:"Quote"},p:{element:"button",command:"formatblock",value:"p",tooltip:"Paragraph"},orderedList:{element:"button",command:"insertOrderedList",tooltip:"Ordered list"},unorderedList:{element:"button",command:"insertUnorderedList",tooltip:"Unordered list"},insertLine:{element:"button",command:"insertHorizontalRule",tooltip:"Insert line"},indent:{element:"button",command:"indent",useCSS:!0,tooltip:"Indent ("+g.tab+")"},outdent:{element:"button",command:"outdent",useCSS:!0,tooltip:"Outdent ("+g.shift+" "+g.tab+")"},superscript:{element:"button",command:"superscript",tooltip:"Superscript ("+g.cmdKey+" "+g.shift+" =)"},subscript:{element:"button",command:"subscript",tooltip:"Subscript ("+g.cmdKey+" =)"},pre:{element:"button",command:"formatblock",value:"pre",func:"highlight",tooltip:"Script"},html:{element:"button",func:"toggleHTML",tooltip:"Show HTML"},fontSize:{element:"select",command:"fontSize"},fontName:{element:"select",init:"applyFont",command:"fontName",useCSS:!0},separator:{element:"styling",class:"styler-separator"},color:{element:"input",type:"text",command:"foreColor",useCSS:!0,init:d,initConfig:{defaultColor:"#000000",mode:"hex",disableLum:!0,guideIcon:'\n <svg viewBox="0 0 24 24">\n <path d="M0 20h24v4H0z"/>\n <path style="fill: #000" d="M11 3L5.5 17h2.25l1.12-3h6.25l1.12 3h2.25L13 3h-2zm-1.38 9L12 5.67 14.38 12H9.62z"/>\n </svg>\n ',events:{beforeSubmit:function(){f.updateSelection()},afterOpen:function(){f.updateSelectedRange()},afterSelect:function(){f.updateSelectedRange()}}}},backColor:{element:"input",type:"text",command:"backColor",useCSS:!0,init:d,initConfig:{defaultColor:"#fdfdfd",mode:"hex",disableLum:!0,guideIcon:'\n <svg viewBox="0 0 24 24">\n <path style="fill: #000" d="M16.56 8.94L7.62 0 6.21 1.41l2.38 2.38-5.15 5.15c-.59.59-.59 1.54 0 2.12l5.5 5.5c.29.29.68.44 1.06.44s.77-.15 1.06-.44l5.5-5.5c.59-.58.59-1.53 0-2.12zM5.21 10L10 5.21 14.79 10H5.21zM19 11.5s-2 2.17-2 3.5c0 1.1.9 2 2 2s2-.9 2-2c0-1.33-2-3.5-2-3.5z"/>\n <path d="M0 20h24v4H0z"/>\n </svg>\n ',events:{beforeSubmit:function(){f.updateSelection()},afterOpen:function(){f.updateSelectedRange()},afterSelect:function(){f.updateSelectedRange()}}}},addImage:{element:"custom",data:function(){return{button:document.createElement("button"),input:document.createElement("input"),icon:'<svg class="icon" viewBox="0 0 24 24">\n <path d="M21 19V5c0-1.1-.9-2-2-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2zM8.5 13.5l2.5 3.01L14.5 12l4.5 6H5l3.5-4.5z"></path>\n </svg>'}},create:function(){this.$data=this.data,this.data=this.$data();var e=this.data.button,t=this.data.input,i=this.data.icon;return e.classList.add("styler-button"),e.appendChild(t),e.insertAdjacentHTML("beforeend",i),t.classList.add("styler-input"),t.type="file",t.id="addImage",t.addEventListener("change",this.action.bind(this)),e},action:function(){var e=this.data.input.files[0];if(e&&window.getSelection().rangeCount){var t=document.createElement("img"),i=new FileReader;i.addEventListener("load",function(){t.src=i.result,t.classList.add("align-image"),t.dataset.alignFilename=e.name}),i.readAsDataURL(e),f.selectedRange=window.getSelection().getRangeAt(0),f.selectedRange.insertNode(t),document.execCommand("enableObjectResizing",!1,!0),this.data.input.value=null}}}},y=(c={blockquote:"M6 17h3l2-4V7H5v6h3zm8 0h3l2-4V7h-6v6h3z",bold:"M15.6 10.79c.97-.67 1.65-1.77 1.65-2.79 0-2.26-1.75-4-4-4H7v14h7.04c2.09 0 3.71-1.7 3.71-3.79 0-1.52-.86-2.82-2.15-3.42zM10 6.5h3c.83 0 1.5.67 1.5 1.5s-.67 1.5-1.5 1.5h-3v-3zm3.5 9H10v-3h3.5c.83 0 1.5.67 1.5 1.5s-.67 1.5-1.5 1.5z",fontSize:"M9 4v3h5v12h3V7h5V4H9zm-6 8h3v7h3v-7h3V9H3v3z",h1:"M19.1 5.1c-2 .2-2.2.3-2.2 2.3v9.3c0 2 .2 2.1 2.2 2.3v.7h-6.6V19c2.1-.2 2.3-.3 2.3-2.3v-4.6H6.5v4.6c0 2 .2 2.1 2.2 2.3v.7H2.1V19c1.9-.2 2.1-.3 2.1-2.3V7.4c0-2-.2-2.1-2.2-2.3v-.7h6.5v.7c-1.9.2-2 .3-2 2.3V11h8.2V7.4c0-2-.2-2.1-2.1-2.3v-.7h6.5v.7zm2.8 14.5h-1.1v-5c-.4.5-.9.8-1.4 1v-1.2c.3-.1.6-.3.9-.7.3-.3.5-.7.7-1.1h.9v7z",h2:"M18.2 5.1c-2 .2-2.2.3-2.2 2.3v9.3c0 2 .2 2.1 2.2 2.3v.7h-6.6V19c2.1-.2 2.3-.3 2.3-2.3v-4.6H5.6v4.6c0 2 .2 2.1 2.2 2.3v.7H1.3V19c1.9-.2 2.1-.3 2.1-2.3V7.4c0-2-.2-2.1-2.2-2.3v-.7h6.5v.7c-1.9.2-2 .3-2 2.3V11h8.2V7.4c0-2-.2-2.1-2.1-2.3v-.7h6.5v.7zm4.6 13.3v1.2H19c0-.5.2-.9.4-1.3s.6-1 1.2-1.6c.5-.5.8-.9.9-1.1.2-.3.2-.6.2-.8 0-.3-.1-.5-.2-.7s-.3-.2-.5-.2c-.5 0-.7.4-.8 1.1l-1.1-.1c.1-.7.3-1.2.6-1.5.3-.3.8-.5 1.3-.5.6 0 1 .2 1.3.6.3.4.5.8.5 1.3 0 .3 0 .6-.1.8-.1.3-.2.5-.4.8-.2.3-.4.6-.8 1-.3.4-.6.6-.7.8s-.2.2-.2.4h2.2z",html:"M19 12h-2v3h-3v2h5v-5zM7 9h3V7H5v5h2V9zm14-6H3c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h18c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16.01H3V4.99h18v14.02z",image:"M21 19V5c0-1.1-.9-2-2-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2zM8.5 13.5l2.5 3.01L14.5 12l4.5 6H5l3.5-4.5z",indent:"M3 21h18v-2H3v2zM3 8v8l4-4-4-4zm8 9h10v-2H11v2zM3 3v2h18V3H3zm8 6h10V7H11v2zm0 4h10v-2H11v2z",italic:"M10 4v3h2.21l-3.42 8H6v3h8v-3h-2.21l3.42-8H18V4z",justifyCenter:"M7 15v2h10v-2H7zm-4 6h18v-2H3v2zm0-8h18v-2H3v2zm4-6v2h10V7H7zM3 3v2h18V3H3z",justifyFull:"M3 21h18v-2H3v2zm0-4h18v-2H3v2zm0-4h18v-2H3v2zm0-4h18V7H3v2zm0-6v2h18V3H3z",justifyLeft:"M15 15H3v2h12v-2zm0-8H3v2h12V7zM3 13h18v-2H3v2zm0 8h18v-2H3v2zM3 3v2h18V3H3z",justifyRight:"M3 21h18v-2H3v2zm6-4h12v-2H9v2zm-6-4h18v-2H3v2zm6-4h12V7H9v2zM3 3v2h18V3H3z",p:"M12.3 4.3c1.7 0 3.1.3 4.1 1S18 7.1 18 8.7c0 3.1-2.4 4.6-4.7 4.8h-1.1l-1.8-.5v3.6c0 2 .2 2.1 2.4 2.3v.7H6V19c1.9-.2 2.1-.4 2.1-2.3V7.4c0-2.1-.2-2.2-2-2.3v-.8h6.2zm-2 8c.3.1 1 .3 1.7.3 1.5 0 3.4-.8 3.4-3.8 0-2.6-1.6-3.6-3.5-3.6-.7 0-1.2.1-1.3.3-.2.2-.3.4-.3 1.1v5.7z",pre:"M14 2H6c-1.1 0-1.99.9-1.99 2L4 20c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8l-6-6zm2 16H8v-2h8v2zm0-4H8v-2h8v2zm-3-5V3.5L18.5 9H13z",removeFormat:"M15 16h4v2h-4zm0-8h7v2h-7zm0 4h6v2h-6zM3 18c0 1.1.9 2 2 2h6c1.1 0 2-.9 2-2V8H3v10zM14 5h-3l-1-1H6L5 5H2v2h12z",strikeThrough:"M7.24 8.75c-.26-.48-.39-1.03-.39-1.67 0-.61.13-1.16.4-1.67.26-.5.63-.93 1.11-1.29.48-.35 1.05-.63 1.7-.83.66-.19 1.39-.29 2.18-.29.81 0 1.54.11 2.21.34.66.22 1.23.54 1.69.94.47.4.83.88 1.08 1.43.25.55.38 1.15.38 1.81h-3.01c0-.31-.05-.59-.15-.85-.09-.27-.24-.49-.44-.68-.2-.19-.45-.33-.75-.44-.3-.1-.66-.16-1.06-.16-.39 0-.74.04-1.03.13-.29.09-.53.21-.72.36-.19.16-.34.34-.44.55-.1.21-.15.43-.15.66 0 .48.25.88.74 1.21.38.25.77.48 1.41.7H7.39c-.05-.08-.11-.17-.15-.25zM21 12v-2H3v2h9.62c.18.07.4.14.55.2.37.17.66.34.87.51.21.17.35.36.43.57.07.2.11.43.11.69 0 .23-.05.45-.14.66-.09.2-.23.38-.42.53-.19.15-.42.26-.71.35-.29.08-.63.13-1.01.13-.43 0-.83-.04-1.18-.13s-.66-.23-.91-.42c-.25-.19-.45-.44-.59-.75-.14-.31-.25-.76-.25-1.21H6.4c0 .55.08 1.13.24 1.58.16.45.37.85.65 1.21.28.35.6.66.98.92.37.26.78.48 1.22.65.44.17.9.3 1.38.39.48.08.96.13 1.44.13.8 0 1.53-.09 2.18-.28s1.21-.45 1.67-.79c.46-.34.82-.77 1.07-1.27s.38-1.07.38-1.71c0-.6-.1-1.14-.31-1.61-.05-.11-.11-.23-.17-.33H21z",text:"M5 17v2h14v-2H5zm4.5-4.2h5l.9 2.2h2.1L12.75 4h-1.5L6.5 15h2.1l.9-2.2zM12 5.98L13.87 11h-3.74L12 5.98z",underline:"M12 17c3.31 0 6-2.69 6-6V3h-2.5v8c0 1.93-1.57 3.5-3.5 3.5S8.5 12.93 8.5 11V3H6v8c0 3.31 2.69 6 6 6zm-7 2v2h14v-2H5z",insertColumn:"M13 12h7v1.5h-7zm0-2.5h7V11h-7zm0 5h7V16h-7zM21 4H3c-1.1 0-2 .9-2 2v13c0 1.1.9 2 2 2h18c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm0 15h-9V6h9v13z",unorderedList:"M4 10.5c-.83 0-1.5.67-1.5 1.5s.67 1.5 1.5 1.5 1.5-.67 1.5-1.5-.67-1.5-1.5-1.5zm0-6c-.83 0-1.5.67-1.5 1.5S3.17 7.5 4 7.5 5.5 6.83 5.5 6 4.83 4.5 4 4.5zm0 12c-.83 0-1.5.68-1.5 1.5s.68 1.5 1.5 1.5 1.5-.68 1.5-1.5-.67-1.5-1.5-1.5zM7 19h14v-2H7v2zm0-6h14v-2H7v2zm0-8v2h14V5H7z",orderedList:"M2 17h2v.5H3v1h1v.5H2v1h3v-4H2v1zm1-9h1V4H2v1h1v3zm-1 3h1.8L2 13.1v.9h3v-1H3.2L5 10.9V10H2v1zm5-6v2h14V5H7zm0 14h14v-2H7v2zm0-6h14v-2H7v2z"},m(c,"indent","M3 21h18v-2H3v2zM3 8v8l4-4-4-4zm8 9h10v-2H11v2zM3 3v2h18V3H3zm8 6h10V7H11v2zm0 4h10v-2H11v2z"),m(c,"outdent","M11 17h10v-2H11v2zm-8-5l4 4V8l-4 4zm0 9h18v-2H3v2zM3 3v2h18V3H3zm8 6h10V7H11v2zm0 4h10v-2H11v2z"),m(c,"superscript","M16 18.6L14.6 20 9 14.4 3.4 20 2 18.6 7.6 13 2 7.4 3.4 6 9 11.6 14.6 6 16 7.4 10.4 13l5.6 5.6zm2.3-14.2c0-.2.1-.4.1-.6.1-.2.2-.3.3-.4.1-.1.3-.2.4-.3.2-.1.4-.1.5-.1.2 0 .3 0 .4.1.1.1.3.1.3.2.1.1.2.2.2.4.1.1.1.3.1.5s-.1.4-.2.6c-.1.2-.2.3-.4.5-.2.1-.4.3-.6.4-.2.1-.5.3-.7.4-.2.1-.5.3-.7.4s-.2.3-.4.5-.3.3-.4.5c-.1.2-.2.4-.2.7V9h5V8h-3.8c.1-.2.3-.4.5-.6.3-.2.6-.4.8-.6s.6-.4.9-.5c.3-.2.6-.4.8-.6s.4-.5.6-.7c.1-.3.2-.6.2-.9 0-.3 0-.5-.1-.8s-.2-.5-.4-.7c-.2-.2-.4-.3-.7-.5-.4 0-.7-.1-1.2-.1-.4 0-.7.1-1 .2s-.6.3-.8.5c-.2.2-.4.5-.5.8-.2.2-.3.5-.3.9h1.3z"),m(c,"subscript","M16 16.6L14.6 18 9 12.4 3.4 18 2 16.6 7.6 11 2 5.4 3.4 4 9 9.6 14.6 4 16 5.4 10.4 11l5.6 5.6zm2.3.8c0-.2.1-.4.1-.6.1-.2.2-.3.3-.4.1-.1.3-.2.4-.3s.3-.1.5-.1.3 0 .4.1c.1.1.3.1.3.2.1.1.2.2.2.4s.1.3.1.5-.1.4-.2.6c-.1.2-.2.3-.4.5-.2.1-.4.3-.6.4-.2.1-.5.3-.7.4-.2.1-.5.3-.7.4s-.4.3-.6.5c-.2.2-.3.3-.4.5-.1.2-.2.4-.2.6v.9h5v-1H18c.1-.2.3-.4.5-.6.2-.2.5-.4.8-.5s.6-.4.9-.5c.3-.2.6-.4.8-.6s.4-.5.6-.7c.2-.3.2-.6.2-.9 0-.3 0-.5-.1-.8s-.2-.5-.4-.7c-.2-.2-.4-.3-.7-.5-.3-.1-.7-.2-1.1-.2-.4 0-.7.1-1 .2-.3.1-.6.3-.8.5-.2.2-.4.5-.5.8-.1.3-.2.6-.3 1h1.4z"),m(c,"createLink","M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5z"),m(c,"selectAll","M19.51 3.08L3.08 19.51c.09.34.27.65.51.9.25.24.56.42.9.51L20.93 4.49c-.19-.69-.73-1.23-1.42-1.41zM11.88 3L3 11.88v2.83L14.71 3h-2.83zM5 3c-1.1 0-2 .9-2 2v2l4-4H5zm14 18c.55 0 1.05-.22 1.41-.59.37-.36.59-.86.59-1.41v-2l-4 4h2zm-9.71 0h2.83L21 12.12V9.29L9.29 21z"),m(c,"insertLine","M4 19h6v-2H4v2zM20 5H4v2h16V5zm-3 6H4v2h13.25c1.1 0 2 .9 2 2s-.9 2-2 2H15v-2l-3 3 3 3v-2h2c2.21 0 4-1.79 4-4s-1.79-4-4-4z"),
m(c,"undo","M12.5 8c-2.65 0-5.05.99-6.9 2.6L2 7v9h9l-3.62-3.62c1.39-1.16 3.16-1.88 5.12-1.88 3.54 0 6.55 2.31 7.6 5.5l2.37-.78C21.08 11.03 17.15 8 12.5 8z"),m(c,"redo","M18.4 10.6C16.55 8.99 14.15 8 11.5 8c-4.65 0-8.58 3.03-9.96 7.22L3.9 16c1.05-3.19 4.05-5.5 7.6-5.5 1.95 0 3.73.72 5.12 1.88L13 16h9V7l-3.6 3.6z"),c),k="",L=function(){function e(t){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=i.mode,s=void 0===n?"default":n,o=i.commands,r=void 0===o?["bold","italic","underline"]:o,a=i.tooltip,l=void 0!==a&&a;h(this,e),this.align=t,this.settings={mode:s,commands:r,tooltip:l},this.init()}return v(e,[{key:"init",value:function(){var e=this;o("styler-"),this.styler=document.createElement("ul"),this.styler.classList.add("styler","is-"+this.settings.mode),this.cmds={},this.settings.commands.forEach(function(t){var i=document.createElement("li"),n="string"==typeof t?t:Object.keys(t)[0],s=b[n];if(!s)return void console.warn(n+" is not found");var o=e.cmds[n]={schema:s};switch(s.element){case"button":o.el=r(n,y[n],e.getTooltip(s)),o.el.addEventListener("click",function(){return e.cmdCallback(s,s.value)}),i.appendChild(o.el);break;case"select":var c=a(n,t[n]),u=o.el=c.querySelector("select");u.addEventListener("change",function(){return e.cmdCallback(s,u[u.selectedIndex].value)}),i.appendChild(c);break;case"input":o.el=l(n,s.type),o.el.addEventListener("change",function(){e.cmdCallback(s,o.el.value)}),i.appendChild(o.el);break;case"styling":i.classList.add(s.class);break;case"custom":var d=s.create();i.appendChild(d);break;default:console.warn(n+" element not found")}"function"==typeof s.init&&(s.init=new s.init(o.el,s.initConfig)),"string"==typeof s.init&&(e.align[s.init](s,t),s.init=null),e.styler.appendChild(i)}),this.align.el.appendChild(this.styler),"bubble"===this.settings.mode&&this.initBubble()}},{key:"cmdCallback",value:function(e,t){e.command&&this.execute(e.command,t,e.useCSS),"string"==typeof e.func&&this.align[e.func](this,t),"function"==typeof e.func&&e.func(this,t)}},{key:"initBubble",value:function(){this.styler.classList.add("is-hidden"),window.addEventListener("scroll",i(this.updateBubblePosition.bind(this)))}},{key:"execute",value:function(e,t){var i;(i=this.align).execute.apply(i,arguments)}},{key:"updateBubblePosition",value:function(){if(f.selectedRange){var e=f.selectedRange.getBoundingClientRect(),t=this.align.el.getBoundingClientRect(),i=this.styler.getBoundingClientRect(),s=window.scrollY,o=e.top+s-i.height-10,r=e.left+(e.width-i.width)/2,a=t.left,l=t.left+t.width-i.width,c=n(r,a,l),u=o<s+50?e.top+e.height+10:e.top-i.height-10;this.styler.style.top=u+"px",this.styler.style.left=c+"px"}}},{key:"showStyler",value:function(){this.styler.classList.add("is-visible"),this.styler.classList.remove("is-hidden"),this.updateBubblePosition()}},{key:"hideStyler",value:function(){this.styler.classList.remove("is-visible"),this.styler.classList.add("is-hidden")}},{key:"updateStylerStates",value:function(){if(this.updateStylerCommands(),"bubble"===this.settings.mode)return f.selectedRange.collapsed?void this.hideStyler():void this.showStyler()}},{key:"getTooltip",value:function(e){return!(!e.tooltip||!this.settings.tooltip)&&(this.align.settings.shortcuts?e.tooltip:e.tooltip.replace(/(\([^)]+\))/g,""))}},{key:"updateStylerCommands",value:function(){var e=this;Object.keys(this.cmds).forEach(function(t){var i=e.cmds[t],n=i.schema.command,s=i.schema.value,o=i.schema.init;if(n){if(document.queryCommandState(n))return void i.el.classList.add("is-active");if(document.queryCommandValue(n)===s)return void i.el.classList.add("is-active");if(o)return void o.selectColor(document.queryCommandValue(n),!0);document.queryCommandValue(n)&&(i.el.value=document.queryCommandValue(n)),i.el.classList.remove("is-active")}})}}]),e}();return function(){function i(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},s=n.toolbar,o=void 0===s?null:s,r=n.bubble,a=void 0===r?null:r,l=n.shortcuts,c=void 0!==l&&l;h(this,i),this.el=t(e),this.settings={defaultText:this.el.innerHTML,toolbar:o,bubble:a,shortcuts:c},this.init()}return v(i,[{key:"init",value:function(){this.HTML=!1,this.el.innerText="",this.settings.toolbar&&(this.settings.toolbar.mode="toolbar",this.toolbar=new L(this,this.settings.toolbar)),this.settings.bubble&&(this.settings.bubble.mode="bubble",this.settings.bubble.tooltip=!1,this.bubble=new L(this,this.settings.bubble)),this.initEditor(),this.initEvents()}},{key:"initEditor",value:function(){document.execCommand("defaultParagraphSeparator",!1,"p"),this.editor=document.createElement("div"),this.editor.contentEditable="true",this.editor.classList.add("align-content"),this.editor.innerHTML=this.settings.defaultText+"\n",this.el.appendChild(this.editor),this.editor.focus(),this.cmdKey="Mac"===s()?"metaKey":"ctrlKey",this.cmdKeyPressed=!1,f.updateSelectedRange()}},{key:"initEvents",value:function(){var e=this;this.editor.addEventListener("focus",function(){e.highlight()}),window.addEventListener("mouseup",this.updateStylers.bind(this)),window.addEventListener("keydown",function(t){if(!t.defaultPrevented){if(e.updateStylers(),t[e.cmdKey]&&e.settings.shortcuts)switch(t.key.toUpperCase()){case"B":t.preventDefault(),e.execute("bold");break;case"I":t.preventDefault(),e.execute("italic");break;case"U":t.preventDefault(),e.execute("underline");break;case"E":t.preventDefault(),e.execute("justifyCenter");break;case"R":t.preventDefault(),e.execute("justifyRight");break;case"L":t.preventDefault(),e.execute("justifyLeft");break;case"J":t.preventDefault(),e.execute("justifyFull");break;case"A":t.preventDefault(),e.execute("selectAll");break;case"Z":if(t.preventDefault(),t.shiftKey){e.execute("redo");break}e.execute("undo");break;case"\\":t.preventDefault(),e.execute("removeFormat");break;case"=":if(t.preventDefault(),t.shiftKey){e.execute("superscript");break}e.execute("subscript")}switch(t.key){case"Tab":if(t.preventDefault(),t.shiftKey){e.execute("outdent",!1,!0);break}e.execute("indent",!1,!0)}}},!0)}},{key:"highlight",value:function(){if(e){Array.from(this.editor.querySelectorAll("pre")).forEach(function(t){e.highlightBlock(t)})}}},{key:"toggleHTML",value:function(){if(this.HTML=!this.HTML,this.HTML){var e=document.createTextNode(this.editor.innerHTML),t=document.createElement("pre");return this.editor.innerHTML="",t.id="content",t.style.whiteSpace="pre-wrap",t.appendChild(e),this.editor.appendChild(t),void this.highlight()}this.editor.innerHTML=this.editor.innerText,this.editor.contentEditable=!0,this.editor.focus()}},{key:"updateStylers",value:function(){var e=this;f.updateSelectedRange(),setTimeout(function(){e.settings.toolbar&&e.toolbar.updateStylerStates(),e.settings.bubble&&e.bubble.updateStylerStates()},16)}},{key:"applyFont",value:function(e,t){this.el.style.fontFamily=t.fontName[0]}},{key:"execute",value:function(e,t){var i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];this.HTML||(document.execCommand("styleWithCSS",!1,i),document.execCommand(e,!1,t),document.execCommand("styleWithCSS",!1,!1),this.el.focus(),this.updateStylers())}},{key:"content",get:function(){return document.createTextNode(this.editor.innerHTML)}}],[{key:"extend",value:function(e,t){b[e]=t}},{key:"extendIcons",value:function(e,t){y[e]=t}}]),i}()});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("highlight.js")):"function"==typeof define&&define.amd?define(["highlight.js"],t):e.Align=t(e.hljs)}(this,function(e){"use strict";function t(e){return"string"==typeof e?document.querySelector(e):e}function i(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=void 0;return function(){var n=arguments,s=function(){i=null,t||e.apply(void 0,n)},o=t&&!i;i=requestAnimationFrame(s),o&&e.apply(void 0,arguments)}}function n(e,t,i){return Math.round(Math.max(Math.min(Number(e),i),t))}function s(){if("undefined"!=typeof window&&"undefined"!=typeof document){var e=navigator.appVersion;return-1!==e.indexOf("Win")?"Win":-1!==e.indexOf("Mac")?"Mac":-1!==e.indexOf("X11")?"UNIX":-1!==e.indexOf("Linux")?"Linux":"Other"}}function o(e){b=e}function r(e,t,i){var n=document.createElement("button");return n.classList.add(b+"button"),n.id=e,i&&(n.dataset.tooltip=i),n.insertAdjacentHTML("afterbegin",'\n <svg class="icon" viewBox="0 0 24 24">\n <path d="'+t+'"/>\n </svg>\n '),n}function a(e,t){var i=document.createElement("div"),n=document.createElement("select");return i.classList.add(b+"select"),n.id=e,t.forEach(function(t){var i=document.createElement("option");i.value=t,i.innerText=!1===t?e:t,n.appendChild(i)}),i.appendChild(n),i.insertAdjacentHTML("beforeend",'\n <svg viewBox="0 0 24 24">\n <polygon points="8,15 12,19 16,15 "/>\n <polygon points="8,9 12,5 16,9 "/>\n </svg>'),i}function l(e,t){var i=document.createElement("input");return i.classList.add(""+b+e),i.id=e,i.type=t,i}e=e&&e.hasOwnProperty("default")?e.default:e;var c="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},u=function(e,t){return t={exports:{}},e(t,t.exports),t.exports}(function(e,t){!function(t,i){e.exports=function(){function e(){Element.prototype.matches||(Element.prototype.matches=Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector),Element.prototype.closest||(Element.prototype.closest=function(e){var t=this;if(!document.documentElement.contains(t))return null;do{if(t.matches(e))return t;t=t.parentElement}while(null!==t);return null})}function t(e){return"string"==typeof e?document.querySelector(e):e}function i(e){"function"==typeof e&&e()}function n(e,t){for(var i=[],n=0;n<e;n++){var s="function"==typeof t?t():t;i.push(s)}return i}function s(e,t){return e=Math.ceil(e),t=Math.floor(t),Math.floor(Math.random()*(t-e+1))+e}function o(e,t){for(;e!==document&&null!==e;){if(e===t)return!0;e=e.parentNode}return!1}function r(e){return e>255?255:e<0?0:e}function a(e){return isNaN(Number(e))?"00":("0"+Number(e).toString(16)).slice(-2)}function l(e){return isNaN(parseInt(e,16))?"0":parseInt(e,16)}function u(){return"rgb("+s(0,255)+", "+s(0,255)+", "+s(0,255)+")"}function d(e){return e=e.match(/^rgba?[\s+]?\([\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?/i),e&&4===e.length?"#"+("0"+parseInt(r(e[1]),10).toString(16)).slice(-2)+("0"+parseInt(r(e[2]),10).toString(16)).slice(-2)+("0"+parseInt(r(e[3]),10).toString(16)).slice(-2):""}function h(e){if((e=e.match(/^rgba?[\s+]?\([\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?/i))&&4===e.length){var t=e[1]/255,i=e[2]/255,n=e[3]/255,s=0,o=0,r=0,a=Math.min(t,i,n),l=Math.max(t,i,n);return r=(a+l)/2,a!==l&&(o=r>.5?(l-a)/(2-l-a):(l-a)/(l+a)),t>=l&&a!==l&&(s=(i-n)/(l-a)*60),i>=l&&a!==l&&(s=60*(2+(n-t)/(l-a))),n>=l&&a!==l&&(s=60*(4+(t-i)/(l-a))),s=s<0?parseInt(s+360):parseInt(s),o=parseInt(100*o),r=parseInt(100*r),"hsl("+s+", "+o+"%, "+r+"%)"}}function v(e,t){return{x:e*Math.cos(t*Math.PI*2),y:e*Math.sin(t*Math.PI*2)}}var m=("undefined"!=typeof window?window:void 0!==c||"undefined"!=typeof self&&self,function(e,t){return t={exports:{}},e(t,t.exports),t.exports}(function(e,t){!function(t,i){e.exports=function(){function e(e){return"string"==typeof e?document.querySelector(e):e}function t(e,t){return e?parseInt(e,10):parseInt(t,10)}function i(e,t){e.parentNode.insertBefore(t,e),t.appendChild(e)}var n=function(t,i){void 0===i&&(i={});var n=i.gradient;void 0===n&&(n=null);var s=i.classes;void 0===s&&(s=null);var o=i.colorCode;void 0===o&&(o=!1);var r=i.editable;void 0===r&&(r=!1);var a=i.reverse;void 0===a&&(a=!1);var l=i.label;void 0===l&&(l=!0);var c=i.min;void 0===c&&(c=0);var u=i.max;void 0===u&&(u=10);var d=i.step;void 0===d&&(d=1);var h=i.value;void 0===h&&(h=0),this.el=e(t),this.settings={gradient:n,classes:s,colorCode:o,editable:r,reverse:a,label:l,min:c,max:u,step:d,value:h},this.init()};return n.create=function(e,t){n(e,t)},n.prototype.init=function(){this.initElements(),this.min=t(this.el.min,this.settings.min),this.max=t(this.el.max,this.settings.max),this.step=t(this.el.step,this.settings.step),this.callbacks={},this.settings.gradient&&this.initGradient(),this.updateWidth(),this.update(t(this.el.value,this.settings.value)),this.initEvents()},n.prototype.initElements=function(){this.wrapper=document.createElement("div"),this.track=document.createElement("div"),this.handle=document.createElement("div"),this.fill=document.createElement("div"),this.wrapper.classList.add("slider"),this.settings.editable&&this.wrapper.classList.add("is-editable"),this.settings.reverse&&this.wrapper.classList.add("is-reverse"),this.settings.classes&&this.wrapper.classList.add(this.settings.classes),this.track.classList.add("slider-track"),this.handle.classList.add("slider-handle"),this.fill.classList.add("slider-fill"),this.el.classList.add("slider-input"),i(this.el,this.wrapper),this.track.appendChild(this.fill),this.track.appendChild(this.handle),this.wrapper.appendChild(this.track),this.settings.label&&(this.label=document.createElement("div"),this.label.classList.add("slider-label"),this.handle.appendChild(this.label))},n.prototype.initGradient=function(){if(this.settings.gradient.length>1)return this.track.style.backgroundImage="linear-gradient(90deg, "+this.settings.gradient+")",this.gradient=this.settings.gradient,void(this.colorCode=this.settings.colorCode);this.track.style.backgroundImage="none",this.track.style.backgroundColor=this.settings.gradient[0],this.handle.style.backgroundColor=this.settings.gradient[0],this.gradient=null},n.prototype.initEvents=function(){var e=this;this.track.addEventListener("mousedown",this.select.bind(this),!1),this.track.addEventListener("touchstart",this.select.bind(this),!1),this.settings.editable&&!this.settings.colorCode&&this.el.addEventListener("change",function(t){e.update(e.el.value)},!1)},n.prototype.select=function(e){e.preventDefault(),this.updateWidth(),this.click(e),this.callbacks.tempDrag=this.dragging.bind(this),this.callbacks.tempRelease=this.release.bind(this),document.addEventListener("mousemove",this.callbacks.tempDrag,!1),document.addEventListener("touchmove",this.callbacks.tempDrag,!1),document.addEventListener("touchend",this.callbacks.tempRelease,!1),document.addEventListener("mouseup",this.callbacks.tempRelease,!1)},n.prototype.dragging=function(e){e.preventDefault();var t="mousemove"===e.type?e.clientX:e.touches[0].clientX,i=t-this.currentX;if(1===e.buttons||"mousemove"!==e.type){this.track.classList.add("is-dragging");var n=parseInt(i/this.stepWidth+.5,10),s=parseInt((n+this.min)/this.step,10)*this.step;s!==this.currentValue&&this.update(s)}},n.prototype.release=function(){this.track.classList.remove("is-dragging"),document.removeEventListener("mousemove",this.callbacks.tempDrag),document.removeEventListener("touchmove",this.callbacks.tempDrag),document.removeEventListener("mouseup",this.callbacks.tempRelease),document.removeEventListener("touchend",this.callbacks.tempRelease)},n.prototype.click=function(e){e.preventDefault();var t="mousedown"===e.type?e.clientX:e.touches[0].clientX,i=t-this.currentX;if(1===e.buttons||"mousemove"!==e.type){var n=parseInt(i/this.stepWidth+.5,10),s=parseInt((n+this.min)/this.step,10)*this.step;s!==this.currentValue&&this.update(s)}},n.prototype.updateWidth=function(){this.currentX=this.track.getBoundingClientRect().left,this.width=this.track.clientWidth,this.stepWidth=this.width/(this.max-this.min)},n.prototype.getFillPercentage=function(e){return 100*(e-this.min)/(this.max-this.min)},n.prototype.normalizeValue=function(e){return e>=this.max?this.max:e<=this.min?this.min:isNaN(Number(e))?this.value:Number(e)},n.prototype.newGradient=function(e){this.settings.gradient=e,this.initGradient(),this.update(void 0,!0)},n.prototype.getHandleColor=function(e){for(var t=this,i=this.gradient.length-1,s=e/100,o=1;o<=i;o++)if(s>=(o-1)/i&&s<=o/i){var r=(s-(o-1)/i)/(1/i);return n.mixColors(t.gradient[o-1],t.gradient[o],r)}return"#000000"},n.prototype.update=function(e,t){if(void 0===t&&(t=!1),Number(e)!==this.value){var i=this.normalizeValue(e),n=this.getFillPercentage(i);if(this.handle.style.left=n+"%",this.fill.style.left=n+"%",this.value=i,this.el.value=this.value,this.settings.label&&(this.label.innerHTML=this.value),this.gradient){var s=this.getHandleColor(n);this.handle.style.backgroundColor=s,this.settings.colorCode&&(this.el.value=s,this.label.innerHTML=s)}t||(this.el.dispatchEvent(new Event("change")),this.el.dispatchEvent(new Event("input")))}},n.hexAverage=function(e,t,i){void 0===i&&(i=.5);var n=parseInt(e,16)*(1-i)+parseInt(t,16)*i;return("00"+Math.floor(n+.5).toString(16)).slice(-2)},n.mixColors=function(e,t,i){return e=e.replace("#",""),t=t.replace("#",""),"#"+(n.hexAverage(e.slice(0,-4),t.slice(0,-4),i)+n.hexAverage(e.slice(2,-2),t.slice(2,-2),i)+n.hexAverage(e.slice(-2),t.slice(-2),i)).toUpperCase()},n}()}()})),p=function(e,i){void 0===i&&(i={});var s=i.defaultColor;void 0===s&&(s=u());var o=i.radius;void 0===o&&(o=200);var r=i.mode;void 0===r&&(r="rgb");var a=i.events;void 0===a&&(a={});var l=i.recentColors;void 0===l&&(l=n(6,u));var c=i.disableLum;void 0===c&&(c=!1);var d=i.guideIcon;void 0===d&&(d='<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="12"/></svg>'),this.el=t(e),this.options={defaultColor:s,radius:o,mode:r,events:a,recentColors:l,disableLum:c,guideIcon:d},this.init()};return p.prototype.init=function(){this.recentColors=this.options.recentColors,this.lastMove={x:0,y:0},this.isMenuActive=!1,e(),this._initElements(),this._initWheel(),this._initEvents(),this.selectColor(this.options.defaultColor,!0)},p.prototype._initElements=function(){var e=this;this.picker=document.createElement("div"),this.picker.insertAdjacentHTML("afterbegin",'\n <button class="picker-guide">\n '+this.options.guideIcon+'\n </button>\n <div class="picker-menu is-hidden" tabindex="-1">\n <div class="picker-wheel">\n <canvas class="picker-canvas"></canvas>\n <div class="picker-cursor"></div>\n </div>\n '+(this.options.disableLum?"":'<input class="picker-saturation" type="number" min="0" max="100" value="100">')+'\n <input id="red" type="number" min="0" max="255" value="0">\n <input id="green" type="number" min="0" max="255" value="0">\n <input id="blue" type="number" min="0" max="255" value="0">\n <div class="picker-input">\n <button class="picker-submit">\n <svg class="icon" viewBox="0 0 24 24">\n <path d="M9 16.2L4.8 12l-1.4 1.4L9 19 21 7l-1.4-1.4L9 16.2z"/>\n </svg>\n </button>\n </div>\n <div class="picker-recent"></div>\n </div>\n '),this.menu=this.picker.querySelector(".picker-menu"),this.recent=this.picker.querySelector(".picker-recent"),this.guide=this.picker.querySelector(".picker-guide"),this.canvas=this.picker.querySelector(".picker-canvas"),this.wheel=this.picker.querySelector(".picker-wheel"),this.submit=this.picker.querySelector(".picker-submit"),this.cursor=this.picker.querySelector(".picker-cursor"),this.saturation=this.picker.querySelector(".picker-saturation"),this.rgbSliders={red:this.picker.querySelector("#red"),green:this.picker.querySelector("#green"),blue:this.picker.querySelector("#blue")},this.el.parentNode.insertBefore(this.picker,this.el),this.el.classList.add("picker-value"),this.picker.classList.add("picker"),this.submit.parentNode.insertBefore(this.el,this.submit),this.guide.style.color=this.options.defaultColor,this.guide.style.fill=this.options.defaultColor,this.sliders={},this.options.disableLum||(this.sliders.saturation=new m(this.saturation,{gradient:["#FFFFFF","#000000"],label:!1})),Object.keys(this.rgbSliders).forEach(function(t){e.sliders[t]=new m(e.rgbSliders[t],{gradient:["#000000","#FFFFFF"],label:!1,editable:!0,reverse:!0})}),this.recentColors.forEach(function(t){var i=document.createElement("a");i.classList.add("picker-color"),i.style.backgroundColor=t,e.recent.appendChild(i),i.addEventListener("mousedown",function(e){return e.preventDefault()}),i.addEventListener("click",function(i){return e.selectColor(t)})})},p.prototype._initWheel=function(){this.canvas.width=this.options.radius,this.canvas.height=this.options.radius,this.context=this.canvas.getContext("2d"),this.circle={path:new Path2D,xCords:this.canvas.width/2,yCords:this.canvas.height/2,radius:this.canvas.width/2},this.circle.path.moveTo(this.circle.xCords,this.circle.yCords),this.circle.path.arc(this.circle.xCords,this.circle.yCords,this.circle.radius,0,360),this.circle.path.closePath(),this.updateWheelColors()},p.prototype._initEvents=function(){var e=this;this.events=[new Event("input"),new Event("change")],this.guide.addEventListener("click",function(){i(e.options.events.beforerOpen),e.togglePicker()}),this.menu.addEventListener("mousedown",function(t){if(t.target===e.menu&&0===t.button){var i={},n={},s={};t.preventDefault(),i.x=t.clientX,i.y=t.clientY;var o=function(t){n.x=t.clientX,n.y=t.clientY,s.x=e.lastMove.x+n.x-i.x,s.y=e.lastMove.y+n.y-i.y,e.menu.style.transform="translate("+s.x+"px, "+s.y+"px)"},r=function t(){e.lastMove=s,document.removeEventListener("mousemove",o),document.removeEventListener("mouseup",t)};document.addEventListener("mousemove",o),document.addEventListener("mouseup",r)}}),this.wheel.addEventListener("mousedown",function(t){t.preventDefault();var i=function(t){var i=e.getMouseCords(t);if(e.context.isPointInPath(e.circle.path,i.x,i.y)){var n=e.getColorFromWheel(i);return e.selectColor(n,!1,i),n}return e.el.value},n=function t(n){var s=i(n);s!==e.el.value&&(e.updateRecentColors(s),e.selectColor(s,!1,e.mouse)),document.removeEventListener("mousemove",i),document.removeEventListener("mouseup",t)};document.addEventListener("mousemove",i),document.addEventListener("mouseup",n)}),this.options.disableLum||this.saturation.addEventListener("change",function(){e.updateWheelColors()}),Object.keys(this.rgbSliders).forEach(function(t){e.rgbSliders[t].addEventListener("change",function(t){var i=e.getColorFromSliders();e.selectColor(i)})}),this.el.addEventListener("focus",function(t){var i=function(){e.selectColor(e.el.value,!0)},n=function t(){e.el.removeEventListener("change",i),e.el.removeEventListener("blur",t)};e.el.addEventListener("change",i),e.el.addEventListener("blur",n)}),this.submit.addEventListener("click",function(t){i(e.options.events.beforeSubmit),e.selectColor(e.el.value),e.closePicker(),i(e.options.events.afterSubmit)})},p.prototype.updateWheelColors=function(){var e=this,t=this.circle.xCords,i=this.circle.yCords,n=this.circle.radius;this.context.clearRect(0,0,this.canvas.width,this.canvas.height);for(var s=0;s<360;s+=1){var o=e.context.createRadialGradient(t,i,0,t,i,n),r=(s-2)*Math.PI/180,a=(s+2)*Math.PI/180;e.context.beginPath(),e.context.moveTo(t,i),e.context.arc(t,i,n,r,a),e.context.closePath(),o.addColorStop(0,"hsl("+s+", "+(e.options.disableLum?100:e.saturation.value)+"%, 100%)"),o.addColorStop(.5,"hsl("+s+", "+(e.options.disableLum?100:e.saturation.value)+"%, 50%)"),o.addColorStop(1,"hsl("+s+", "+(e.options.disableLum?100:e.saturation.value)+"%, 0%)"),e.context.fillStyle=o,e.context.fill()}},p.prototype.updateRecentColors=function(e){var t=this;this.recentColors.length>=6&&this.recentColors.shift(),e&&this.recentColors.push(e),this.recent.childNodes.length>=6&&this.recent.removeChild(this.recent.firstChild);var i=document.createElement("a");i.classList.add("picker-color"),i.style.backgroundColor=e,this.recent.appendChild(i),i.addEventListener("click",function(i){i.preventDefault(),t.selectColor(e)})},p.prototype.updateSlidersInputs=function(e){var t=a(this.rgbSliders.red.value),i=a(this.rgbSliders.green.value),n=a(this.rgbSliders.blue.value);this.sliders.red.newGradient(["#00"+i+n,"#ff"+i+n]),this.sliders.green.newGradient(["#"+t+"00"+n,"#"+t+"ff"+n]),this.sliders.blue.newGradient(["#"+t+i+"00","#"+t+i+"ff"])},p.prototype.updateCursor=function(e){var t=this.getColorFromSliders(),i=d(t),n=h(t),s=n.match(/^hsl?[\s+]?\([\s+]?(\d+)[\s+]?,[\s+]?(\d+)\%[\s+]?,[\s+]?(\d+)\%[\s+]?/i),o=(100-s[3])*(this.options.radius/200),r=v(o,s[1]/360),a=this.options.radius/2;if(this.options.disableLum||(this.sliders.saturation.update(s[2]),this.sliders.saturation.newGradient(["#FFFFFF",i])),this.cursor.style.backgroundColor=n,e)return void(this.cursor.style.transform="translate("+e.x+"px, "+e.y+"px)");this.cursor.style.transform="translate("+(r.x+a)+"px, "+(r.y+a)+"px)"},p.prototype.selectColor=function(e,t,n){var s=this;if(void 0===t&&(t=!1),"#"===e.slice(0,1)||"RGB"===e.slice(0,3).toUpperCase()||"HSL"===e.slice(0,3).toUpperCase()){i(this.options.events.beforeSelect);var o="#"===e.slice(0,1)?e:d(e),r=h(e);this.el.value="hex"===this.options.mode?o:"hsl"===this.options.mode?r:e,this.guide.style.color=e,this.guide.style.fill=e,this.sliders.red.update(l(o.slice(1,3)),!0),this.sliders.green.update(l(o.slice(3,5)),!0),this.sliders.blue.update(l(o.slice(5,7)),!0),this.updateSlidersInputs(),this.updateCursor(n),i(this.options.events.afterSelect),t||this.events.forEach(function(e){return s.el.dispatchEvent(e)})}},p.prototype.getColorFromSliders=function(){return"rgb("+this.rgbSliders.red.value+", "+this.rgbSliders.green.value+", "+this.rgbSliders.blue.value+")"},p.prototype.getColorFromWheel=function(e){var t=this.context.getImageData(e.x,e.y,1,1).data;return"rgb("+t[0]+", "+t[1]+", "+t[2]+")"},p.prototype.getMouseCords=function(e){var t=this.canvas.getBoundingClientRect(),i={x:e.clientX-t.left,y:e.clientY-t.top};return this.mouse=i,i},p.prototype.togglePicker=function(){if(this.isMenuActive)return void this.closePicker();this.openPiker()},p.prototype.closePicker=function(){this.menu.classList.add("is-hidden"),this.isMenuActive=!1,document.removeEventListener("click",this.documentCallback)},p.prototype.openPiker=function(){var e=this;this.menu.classList.remove("is-hidden"),this.isMenuActive=!0;var t=function(t){if(!o(t.target,e.menu)&&!o(t.target,e.guide))return void e.closePicker();i(e.options.events.clicked)};this.documentCallback=t.bind(this),document.addEventListener("click",this.documentCallback),i(this.options.events.afterOpen)},p}()}()}),d=(function(){function e(e){this.value=e}function t(t){function i(e,t){return new Promise(function(i,s){var a={key:e,arg:t,resolve:i,reject:s,next:null};r?r=r.next=a:(o=r=a,n(e,t))})}function n(i,o){try{var r=t[i](o),a=r.value;a instanceof e?Promise.resolve(a.value).then(function(e){n("next",e)},function(e){n("throw",e)}):s(r.done?"return":"normal",r.value)}catch(e){s("throw",e)}}function s(e,t){switch(e){case"return":o.resolve({value:t,done:!0});break;case"throw":o.reject(t);break;default:o.resolve({value:t,done:!1})}o=o.next,o?n(o.key,o.arg):r=null}var o,r;this._invoke=i,"function"!=typeof t.return&&(this.return=void 0)}"function"==typeof Symbol&&Symbol.asyncIterator&&(t.prototype[Symbol.asyncIterator]=function(){return this}),t.prototype.next=function(e){return this._invoke("next",e)},t.prototype.throw=function(e){return this._invoke("throw",e)},t.prototype.return=function(e){return this._invoke("return",e)}}(),function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}),h=function(){function e(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,i,n){return i&&e(t.prototype,i),n&&e(t,n),t}}(),v=null,m=function(){function e(){d(this,e)}return h(e,[{key:"selectedRange",set:function(e){e&&(v=e)},get:function(){return v}}],[{key:"updateSelection",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:e.selectedRange;if(t){var i=window.getSelection();i.removeAllRanges(),i.addRange(t)}}},{key:"updateSelectedRange",value:function(){var t=window.getSelection();t.rangeCount&&3===t.anchorNode.nodeType&&(e.selectedRange=t.getRangeAt(0))}}]),e}(),p=function(){var e=s();return{cmdKey:"Mac"===e?"⌘":"Ctrl",shift:"Mac"===e?"⇧":"Shift",ctrl:"Mac"===e?"⌃":"Ctrl",alt:"Mac"===e?"⌥":"Alt",tab:"Mac"===e?"⇥":"Tab"}}(),f={bold:{element:"button",command:"bold",tooltip:"Bold ("+p.cmdKey+" B)"},italic:{element:"button",command:"italic",tooltip:"Italic ("+p.cmdKey+" I)"},underline:{element:"button",command:"underline",tooltip:"Underline ("+p.cmdKey+" U)"},strikeThrough:{element:"button",command:"strikeThrough",tooltip:"Strike through"},undo:{element:"button",command:"undo",tooltip:"Undo ("+p.cmdKey+" Z)"},redo:{element:"button",command:"redo",tooltip:"Redo ("+p.cmdKey+" "+p.shift+" Z)"},removeFormat:{element:"button",command:"removeFormat",tooltip:"Remove format ("+p.cmdKey+" \\)"},justifyLeft:{element:"button",command:"justifyLeft",tooltip:"Align left ("+p.cmdKey+" L)"},justifyCenter:{element:"button",command:"justifyCenter",tooltip:"Align center ("+p.cmdKey+" E)"},justifyRight:{element:"button",command:"justifyRight",tooltip:"Align right ("+p.cmdKey+" R)"},selectAll:{element:"button",command:"selectAll",tooltip:"Select all ("+p.cmdKey+" A)"},justifyFull:{element:"button",command:"justifyFull",tooltip:"Justify full ("+p.cmdKey+" J)"},createLink:{element:"button",tooltip:"Hyperlink",func:function(e){var t=prompt("Write the URL here","");t&&""!==t&&e.align.execute("createLink",t)}},h1:{element:"button",command:"formatblock",value:"h1",tooltip:"Heading 1"},h2:{element:"button",command:"formatblock",value:"h2",tooltip:"Heading 2"},blockquote:{element:"button",command:"formatblock",value:"blockquote",tooltip:"Quote"},p:{element:"button",command:"formatblock",value:"p",tooltip:"Paragraph"},orderedList:{element:"button",command:"insertOrderedList",tooltip:"Ordered list"},unorderedList:{element:"button",command:"insertUnorderedList",tooltip:"Unordered list"},insertLine:{element:"button",command:"insertHorizontalRule",tooltip:"Insert line"},indent:{element:"button",command:"indent",useCSS:!0,tooltip:"Indent ("+p.tab+")"},outdent:{element:"button",command:"outdent",useCSS:!0,tooltip:"Outdent ("+p.shift+" "+p.tab+")"},superscript:{element:"button",command:"superscript",tooltip:"Superscript ("+p.cmdKey+" "+p.shift+" =)"},subscript:{element:"button",command:"subscript",tooltip:"Subscript ("+p.cmdKey+" =)"},pre:{element:"button",command:"formatblock",value:"pre",func:"highlight",tooltip:"Script"},html:{element:"button",func:"toggleHTML",tooltip:"Show HTML"},fontSize:{element:"select",command:"fontSize"},fontName:{element:"select",init:"applyFont",command:"fontName",useCSS:!0},separator:{element:"styling",class:"styler-separator"},color:{element:"input",type:"text",command:"foreColor",useCSS:!0,init:u,initConfig:{defaultColor:"#000000",mode:"hex",disableLum:!0,guideIcon:'\n <svg viewBox="0 0 24 24">\n <path d="M0 20h24v4H0z"/>\n <path style="fill: #000" d="M11 3L5.5 17h2.25l1.12-3h6.25l1.12 3h2.25L13 3h-2zm-1.38 9L12 5.67 14.38 12H9.62z"/>\n </svg>\n ',events:{beforeSubmit:function(){m.updateSelection()},afterOpen:function(){m.updateSelectedRange()},afterSelect:function(){m.updateSelectedRange()}}}},backColor:{element:"input",type:"text",command:"backColor",useCSS:!0,init:u,initConfig:{defaultColor:"#fdfdfd",mode:"hex",disableLum:!0,guideIcon:'\n <svg viewBox="0 0 24 24">\n <path style="fill: #000" d="M16.56 8.94L7.62 0 6.21 1.41l2.38 2.38-5.15 5.15c-.59.59-.59 1.54 0 2.12l5.5 5.5c.29.29.68.44 1.06.44s.77-.15 1.06-.44l5.5-5.5c.59-.58.59-1.53 0-2.12zM5.21 10L10 5.21 14.79 10H5.21zM19 11.5s-2 2.17-2 3.5c0 1.1.9 2 2 2s2-.9 2-2c0-1.33-2-3.5-2-3.5z"/>\n <path d="M0 20h24v4H0z"/>\n </svg>\n ',events:{beforeSubmit:function(){m.updateSelection()},afterOpen:function(){m.updateSelectedRange()},afterSelect:function(){m.updateSelectedRange()}}}},addImage:{element:"custom",data:function(){return{button:document.createElement("button"),input:document.createElement("input"),icon:'<svg class="icon" viewBox="0 0 24 24">\n <path d="M21 19V5c0-1.1-.9-2-2-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2zM8.5 13.5l2.5 3.01L14.5 12l4.5 6H5l3.5-4.5z"></path>\n </svg>'}},create:function(){this.$data=this.data,this.data=this.$data();var e=this.data.button,t=this.data.input,i=this.data.icon;return e.classList.add("styler-button"),e.appendChild(t),e.insertAdjacentHTML("beforeend",i),t.classList.add("styler-input"),t.type="file",t.id="addImage",t.addEventListener("change",this.action.bind(this)),e},action:function(){var e=this.data.input.files[0];if(e&&window.getSelection().rangeCount){var t=document.createElement("img"),i=new FileReader;i.addEventListener("load",function(){t.src=i.result,t.classList.add("align-image"),t.dataset.alignFilename=e.name}),i.readAsDataURL(e),m.selectedRange=window.getSelection().getRangeAt(0),m.selectedRange.insertNode(t),document.execCommand("enableObjectResizing",!1,!0),this.data.input.value=null}}}},g={blockquote:"M6 17h3l2-4V7H5v6h3zm8 0h3l2-4V7h-6v6h3z",bold:"M15.6 10.79c.97-.67 1.65-1.77 1.65-2.79 0-2.26-1.75-4-4-4H7v14h7.04c2.09 0 3.71-1.7 3.71-3.79 0-1.52-.86-2.82-2.15-3.42zM10 6.5h3c.83 0 1.5.67 1.5 1.5s-.67 1.5-1.5 1.5h-3v-3zm3.5 9H10v-3h3.5c.83 0 1.5.67 1.5 1.5s-.67 1.5-1.5 1.5z",fontSize:"M9 4v3h5v12h3V7h5V4H9zm-6 8h3v7h3v-7h3V9H3v3z",h1:"M19.1 5.1c-2 .2-2.2.3-2.2 2.3v9.3c0 2 .2 2.1 2.2 2.3v.7h-6.6V19c2.1-.2 2.3-.3 2.3-2.3v-4.6H6.5v4.6c0 2 .2 2.1 2.2 2.3v.7H2.1V19c1.9-.2 2.1-.3 2.1-2.3V7.4c0-2-.2-2.1-2.2-2.3v-.7h6.5v.7c-1.9.2-2 .3-2 2.3V11h8.2V7.4c0-2-.2-2.1-2.1-2.3v-.7h6.5v.7zm2.8 14.5h-1.1v-5c-.4.5-.9.8-1.4 1v-1.2c.3-.1.6-.3.9-.7.3-.3.5-.7.7-1.1h.9v7z",h2:"M18.2 5.1c-2 .2-2.2.3-2.2 2.3v9.3c0 2 .2 2.1 2.2 2.3v.7h-6.6V19c2.1-.2 2.3-.3 2.3-2.3v-4.6H5.6v4.6c0 2 .2 2.1 2.2 2.3v.7H1.3V19c1.9-.2 2.1-.3 2.1-2.3V7.4c0-2-.2-2.1-2.2-2.3v-.7h6.5v.7c-1.9.2-2 .3-2 2.3V11h8.2V7.4c0-2-.2-2.1-2.1-2.3v-.7h6.5v.7zm4.6 13.3v1.2H19c0-.5.2-.9.4-1.3s.6-1 1.2-1.6c.5-.5.8-.9.9-1.1.2-.3.2-.6.2-.8 0-.3-.1-.5-.2-.7s-.3-.2-.5-.2c-.5 0-.7.4-.8 1.1l-1.1-.1c.1-.7.3-1.2.6-1.5.3-.3.8-.5 1.3-.5.6 0 1 .2 1.3.6.3.4.5.8.5 1.3 0 .3 0 .6-.1.8-.1.3-.2.5-.4.8-.2.3-.4.6-.8 1-.3.4-.6.6-.7.8s-.2.2-.2.4h2.2z",html:"M19 12h-2v3h-3v2h5v-5zM7 9h3V7H5v5h2V9zm14-6H3c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h18c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16.01H3V4.99h18v14.02z",image:"M21 19V5c0-1.1-.9-2-2-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2zM8.5 13.5l2.5 3.01L14.5 12l4.5 6H5l3.5-4.5z",italic:"M10 4v3h2.21l-3.42 8H6v3h8v-3h-2.21l3.42-8H18V4z",justifyCenter:"M7 15v2h10v-2H7zm-4 6h18v-2H3v2zm0-8h18v-2H3v2zm4-6v2h10V7H7zM3 3v2h18V3H3z",justifyFull:"M3 21h18v-2H3v2zm0-4h18v-2H3v2zm0-4h18v-2H3v2zm0-4h18V7H3v2zm0-6v2h18V3H3z",justifyLeft:"M15 15H3v2h12v-2zm0-8H3v2h12V7zM3 13h18v-2H3v2zm0 8h18v-2H3v2zM3 3v2h18V3H3z",justifyRight:"M3 21h18v-2H3v2zm6-4h12v-2H9v2zm-6-4h18v-2H3v2zm6-4h12V7H9v2zM3 3v2h18V3H3z",p:"M12.3 4.3c1.7 0 3.1.3 4.1 1S18 7.1 18 8.7c0 3.1-2.4 4.6-4.7 4.8h-1.1l-1.8-.5v3.6c0 2 .2 2.1 2.4 2.3v.7H6V19c1.9-.2 2.1-.4 2.1-2.3V7.4c0-2.1-.2-2.2-2-2.3v-.8h6.2zm-2 8c.3.1 1 .3 1.7.3 1.5 0 3.4-.8 3.4-3.8 0-2.6-1.6-3.6-3.5-3.6-.7 0-1.2.1-1.3.3-.2.2-.3.4-.3 1.1v5.7z",pre:"M14 2H6c-1.1 0-1.99.9-1.99 2L4 20c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8l-6-6zm2 16H8v-2h8v2zm0-4H8v-2h8v2zm-3-5V3.5L18.5 9H13z",removeFormat:"M15 16h4v2h-4zm0-8h7v2h-7zm0 4h6v2h-6zM3 18c0 1.1.9 2 2 2h6c1.1 0 2-.9 2-2V8H3v10zM14 5h-3l-1-1H6L5 5H2v2h12z",strikeThrough:"M7.24 8.75c-.26-.48-.39-1.03-.39-1.67 0-.61.13-1.16.4-1.67.26-.5.63-.93 1.11-1.29.48-.35 1.05-.63 1.7-.83.66-.19 1.39-.29 2.18-.29.81 0 1.54.11 2.21.34.66.22 1.23.54 1.69.94.47.4.83.88 1.08 1.43.25.55.38 1.15.38 1.81h-3.01c0-.31-.05-.59-.15-.85-.09-.27-.24-.49-.44-.68-.2-.19-.45-.33-.75-.44-.3-.1-.66-.16-1.06-.16-.39 0-.74.04-1.03.13-.29.09-.53.21-.72.36-.19.16-.34.34-.44.55-.1.21-.15.43-.15.66 0 .48.25.88.74 1.21.38.25.77.48 1.41.7H7.39c-.05-.08-.11-.17-.15-.25zM21 12v-2H3v2h9.62c.18.07.4.14.55.2.37.17.66.34.87.51.21.17.35.36.43.57.07.2.11.43.11.69 0 .23-.05.45-.14.66-.09.2-.23.38-.42.53-.19.15-.42.26-.71.35-.29.08-.63.13-1.01.13-.43 0-.83-.04-1.18-.13s-.66-.23-.91-.42c-.25-.19-.45-.44-.59-.75-.14-.31-.25-.76-.25-1.21H6.4c0 .55.08 1.13.24 1.58.16.45.37.85.65 1.21.28.35.6.66.98.92.37.26.78.48 1.22.65.44.17.9.3 1.38.39.48.08.96.13 1.44.13.8 0 1.53-.09 2.18-.28s1.21-.45 1.67-.79c.46-.34.82-.77 1.07-1.27s.38-1.07.38-1.71c0-.6-.1-1.14-.31-1.61-.05-.11-.11-.23-.17-.33H21z",text:"M5 17v2h14v-2H5zm4.5-4.2h5l.9 2.2h2.1L12.75 4h-1.5L6.5 15h2.1l.9-2.2zM12 5.98L13.87 11h-3.74L12 5.98z",underline:"M12 17c3.31 0 6-2.69 6-6V3h-2.5v8c0 1.93-1.57 3.5-3.5 3.5S8.5 12.93 8.5 11V3H6v8c0 3.31 2.69 6 6 6zm-7 2v2h14v-2H5z",insertColumn:"M13 12h7v1.5h-7zm0-2.5h7V11h-7zm0 5h7V16h-7zM21 4H3c-1.1 0-2 .9-2 2v13c0 1.1.9 2 2 2h18c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm0 15h-9V6h9v13z",unorderedList:"M4 10.5c-.83 0-1.5.67-1.5 1.5s.67 1.5 1.5 1.5 1.5-.67 1.5-1.5-.67-1.5-1.5-1.5zm0-6c-.83 0-1.5.67-1.5 1.5S3.17 7.5 4 7.5 5.5 6.83 5.5 6 4.83 4.5 4 4.5zm0 12c-.83 0-1.5.68-1.5 1.5s.68 1.5 1.5 1.5 1.5-.68 1.5-1.5-.67-1.5-1.5-1.5zM7 19h14v-2H7v2zm0-6h14v-2H7v2zm0-8v2h14V5H7z",orderedList:"M2 17h2v.5H3v1h1v.5H2v1h3v-4H2v1zm1-9h1V4H2v1h1v3zm-1 3h1.8L2 13.1v.9h3v-1H3.2L5 10.9V10H2v1zm5-6v2h14V5H7zm0 14h14v-2H7v2zm0-6h14v-2H7v2z",indent:"M3 21h18v-2H3v2zM3 8v8l4-4-4-4zm8 9h10v-2H11v2zM3 3v2h18V3H3zm8 6h10V7H11v2zm0 4h10v-2H11v2z",outdent:"M11 17h10v-2H11v2zm-8-5l4 4V8l-4 4zm0 9h18v-2H3v2zM3 3v2h18V3H3zm8 6h10V7H11v2zm0 4h10v-2H11v2z",superscript:"M16 18.6L14.6 20 9 14.4 3.4 20 2 18.6 7.6 13 2 7.4 3.4 6 9 11.6 14.6 6 16 7.4 10.4 13l5.6 5.6zm2.3-14.2c0-.2.1-.4.1-.6.1-.2.2-.3.3-.4.1-.1.3-.2.4-.3.2-.1.4-.1.5-.1.2 0 .3 0 .4.1.1.1.3.1.3.2.1.1.2.2.2.4.1.1.1.3.1.5s-.1.4-.2.6c-.1.2-.2.3-.4.5-.2.1-.4.3-.6.4-.2.1-.5.3-.7.4-.2.1-.5.3-.7.4s-.2.3-.4.5-.3.3-.4.5c-.1.2-.2.4-.2.7V9h5V8h-3.8c.1-.2.3-.4.5-.6.3-.2.6-.4.8-.6s.6-.4.9-.5c.3-.2.6-.4.8-.6s.4-.5.6-.7c.1-.3.2-.6.2-.9 0-.3 0-.5-.1-.8s-.2-.5-.4-.7c-.2-.2-.4-.3-.7-.5-.4 0-.7-.1-1.2-.1-.4 0-.7.1-1 .2s-.6.3-.8.5c-.2.2-.4.5-.5.8-.2.2-.3.5-.3.9h1.3z",subscript:"M16 16.6L14.6 18 9 12.4 3.4 18 2 16.6 7.6 11 2 5.4 3.4 4 9 9.6 14.6 4 16 5.4 10.4 11l5.6 5.6zm2.3.8c0-.2.1-.4.1-.6.1-.2.2-.3.3-.4.1-.1.3-.2.4-.3s.3-.1.5-.1.3 0 .4.1c.1.1.3.1.3.2.1.1.2.2.2.4s.1.3.1.5-.1.4-.2.6c-.1.2-.2.3-.4.5-.2.1-.4.3-.6.4-.2.1-.5.3-.7.4-.2.1-.5.3-.7.4s-.4.3-.6.5c-.2.2-.3.3-.4.5-.1.2-.2.4-.2.6v.9h5v-1H18c.1-.2.3-.4.5-.6.2-.2.5-.4.8-.5s.6-.4.9-.5c.3-.2.6-.4.8-.6s.4-.5.6-.7c.2-.3.2-.6.2-.9 0-.3 0-.5-.1-.8s-.2-.5-.4-.7c-.2-.2-.4-.3-.7-.5-.3-.1-.7-.2-1.1-.2-.4 0-.7.1-1 .2-.3.1-.6.3-.8.5-.2.2-.4.5-.5.8-.1.3-.2.6-.3 1h1.4z",createLink:"M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5z",selectAll:"M19.51 3.08L3.08 19.51c.09.34.27.65.51.9.25.24.56.42.9.51L20.93 4.49c-.19-.69-.73-1.23-1.42-1.41zM11.88 3L3 11.88v2.83L14.71 3h-2.83zM5 3c-1.1 0-2 .9-2 2v2l4-4H5zm14 18c.55 0 1.05-.22 1.41-.59.37-.36.59-.86.59-1.41v-2l-4 4h2zm-9.71 0h2.83L21 12.12V9.29L9.29 21z",insertLine:"M4 19h6v-2H4v2zM20 5H4v2h16V5zm-3 6H4v2h13.25c1.1 0 2 .9 2 2s-.9 2-2 2H15v-2l-3 3 3 3v-2h2c2.21 0 4-1.79 4-4s-1.79-4-4-4z",undo:"M12.5 8c-2.65 0-5.05.99-6.9 2.6L2 7v9h9l-3.62-3.62c1.39-1.16 3.16-1.88 5.12-1.88 3.54 0 6.55 2.31 7.6 5.5l2.37-.78C21.08 11.03 17.15 8 12.5 8z",
redo:"M18.4 10.6C16.55 8.99 14.15 8 11.5 8c-4.65 0-8.58 3.03-9.96 7.22L3.9 16c1.05-3.19 4.05-5.5 7.6-5.5 1.95 0 3.73.72 5.12 1.88L13 16h9V7l-3.6 3.6z"},b="",y=function(){function e(t){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=i.mode,s=void 0===n?"default":n,o=i.commands,r=void 0===o?["bold","italic","underline"]:o,a=i.tooltip,l=void 0!==a&&a;d(this,e),this.align=t,this.settings={mode:s,commands:r,tooltip:l},this.init()}return h(e,[{key:"init",value:function(){var e=this;o("styler-"),this.styler=document.createElement("ul"),this.styler.classList.add("styler","is-"+this.settings.mode),this.cmds={},this.settings.commands.forEach(function(t){var i=document.createElement("li"),n="string"==typeof t?t:Object.keys(t)[0],s=f[n];if(!s)return void console.warn(n+" is not found");var o=e.cmds[n]={schema:s};switch(s.element){case"button":o.el=r(n,g[n],e.getTooltip(s)),o.el.addEventListener("click",function(){return e.cmdCallback(s,s.value)}),i.appendChild(o.el);break;case"select":var c=a(n,t[n]),u=o.el=c.querySelector("select");u.addEventListener("change",function(){return e.cmdCallback(s,u[u.selectedIndex].value)}),i.appendChild(c);break;case"input":o.el=l(n,s.type),o.el.addEventListener("change",function(){e.cmdCallback(s,o.el.value)}),i.appendChild(o.el);break;case"styling":i.classList.add(s.class);break;case"custom":var d=s.create();i.appendChild(d);break;default:console.warn(n+" element not found")}"function"==typeof s.init&&(s.init=new s.init(o.el,s.initConfig)),"string"==typeof s.init&&(e.align[s.init](s,t),s.init=null),e.styler.appendChild(i)}),this.align.el.appendChild(this.styler),"bubble"===this.settings.mode&&this.initBubble()}},{key:"cmdCallback",value:function(e,t){e.command&&this.execute(e.command,t,e.useCSS),"string"==typeof e.func&&this.align[e.func](this,t),"function"==typeof e.func&&e.func(this,t)}},{key:"initBubble",value:function(){this.styler.classList.add("is-hidden"),window.addEventListener("scroll",i(this.updateBubblePosition.bind(this)))}},{key:"execute",value:function(e,t){var i;(i=this.align).execute.apply(i,arguments)}},{key:"updateBubblePosition",value:function(){if(m.selectedRange){var e=m.selectedRange.getBoundingClientRect(),t=this.align.el.getBoundingClientRect(),i=this.styler.getBoundingClientRect(),s=window.scrollY,o=e.top+s-i.height-10,r=e.left+(e.width-i.width)/2,a=t.left,l=t.left+t.width-i.width,c=n(r,a,l),u=o<s+50?e.top+e.height+10:e.top-i.height-10;this.styler.style.top=u+"px",this.styler.style.left=c+"px"}}},{key:"showStyler",value:function(){this.styler.classList.add("is-visible"),this.styler.classList.remove("is-hidden"),this.updateBubblePosition()}},{key:"hideStyler",value:function(){this.styler.classList.remove("is-visible"),this.styler.classList.add("is-hidden")}},{key:"updateStylerStates",value:function(){if(this.updateStylerCommands(),"bubble"===this.settings.mode)return m.selectedRange.collapsed?void this.hideStyler():void this.showStyler()}},{key:"getTooltip",value:function(e){return!(!e.tooltip||!this.settings.tooltip)&&(this.align.settings.shortcuts?e.tooltip:e.tooltip.replace(/(\([^)]+\))/g,""))}},{key:"updateStylerCommands",value:function(){var e=this;Object.keys(this.cmds).forEach(function(t){var i=e.cmds[t],n=i.schema.command,s=i.schema.value,o=i.schema.init;if(n){if(document.queryCommandState(n))return void i.el.classList.add("is-active");if(document.queryCommandValue(n)===s)return void i.el.classList.add("is-active");if(o)return void o.selectColor(document.queryCommandValue(n),!0);document.queryCommandValue(n)&&(i.el.value=document.queryCommandValue(n)),i.el.classList.remove("is-active")}})}}]),e}();return function(){function i(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},s=n.toolbar,o=void 0===s?null:s,r=n.bubble,a=void 0===r?null:r,l=n.shortcuts,c=void 0!==l&&l;d(this,i),this.el=t(e),this.settings={defaultText:this.el.innerHTML,toolbar:o,bubble:a,shortcuts:c},this.init()}return h(i,[{key:"init",value:function(){this.HTML=!1,this.el.innerText="",this.settings.toolbar&&(this.settings.toolbar.mode="toolbar",this.toolbar=new y(this,this.settings.toolbar)),this.settings.bubble&&(this.settings.bubble.mode="bubble",this.settings.bubble.tooltip=!1,this.bubble=new y(this,this.settings.bubble)),this.initEditor(),this.initEvents()}},{key:"initEditor",value:function(){document.execCommand("defaultParagraphSeparator",!1,"p"),this.editor=document.createElement("div"),this.editor.contentEditable="true",this.editor.classList.add("align-content"),this.editor.innerHTML=this.settings.defaultText+"\n",this.el.appendChild(this.editor),this.editor.focus(),this.cmdKey="Mac"===s()?"metaKey":"ctrlKey",this.cmdKeyPressed=!1,m.updateSelectedRange()}},{key:"initEvents",value:function(){var e=this;this.editor.addEventListener("focus",function(){e.highlight()}),window.addEventListener("mouseup",this.updateStylers.bind(this)),window.addEventListener("keydown",function(t){if(!t.defaultPrevented){if(e.updateStylers(),t[e.cmdKey]&&e.settings.shortcuts)switch(t.key.toUpperCase()){case"B":t.preventDefault(),e.execute("bold");break;case"I":t.preventDefault(),e.execute("italic");break;case"U":t.preventDefault(),e.execute("underline");break;case"E":t.preventDefault(),e.execute("justifyCenter");break;case"R":t.preventDefault(),e.execute("justifyRight");break;case"L":t.preventDefault(),e.execute("justifyLeft");break;case"J":t.preventDefault(),e.execute("justifyFull");break;case"A":t.preventDefault(),e.execute("selectAll");break;case"Z":if(t.preventDefault(),t.shiftKey){e.execute("redo");break}e.execute("undo");break;case"\\":t.preventDefault(),e.execute("removeFormat");break;case"=":if(t.preventDefault(),t.shiftKey){e.execute("superscript");break}e.execute("subscript")}switch(t.key){case"Tab":if(t.preventDefault(),t.shiftKey){e.execute("outdent",!1,!0);break}e.execute("indent",!1,!0)}}},!0)}},{key:"highlight",value:function(){if(e){Array.from(this.editor.querySelectorAll("pre")).forEach(function(t){e.highlightBlock(t)})}}},{key:"toggleHTML",value:function(){if(this.HTML=!this.HTML,this.HTML){var e=document.createTextNode(this.editor.innerHTML),t=document.createElement("pre");return this.editor.innerHTML="",t.id="content",t.style.whiteSpace="pre-wrap",t.appendChild(e),this.editor.appendChild(t),void this.highlight()}this.editor.innerHTML=this.editor.innerText,this.editor.contentEditable=!0,this.editor.focus()}},{key:"updateStylers",value:function(){var e=this;m.updateSelectedRange(),setTimeout(function(){e.settings.toolbar&&e.toolbar.updateStylerStates(),e.settings.bubble&&e.bubble.updateStylerStates()},16)}},{key:"applyFont",value:function(e,t){this.el.style.fontFamily=t.fontName[0]}},{key:"execute",value:function(e,t){var i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];this.HTML||(document.execCommand("styleWithCSS",!1,i),document.execCommand(e,!1,t),document.execCommand("styleWithCSS",!1,!1),this.el.focus(),this.updateStylers())}},{key:"content",get:function(){return document.createTextNode(this.editor.innerHTML)}}],[{key:"extend",value:function(e,t){f[e]=t}},{key:"extendIcons",value:function(e,t){g[e]=t}}]),i}()});
{
"name": "@baianat/align",
"version": "0.0.8",
"version": "0.0.9",
"description": "ES6 text editor",

@@ -5,0 +5,0 @@ "main": "dist/js/align.js",

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc