PageSourceSearch

https://digbi-web-akl7i.ondigitalocean.app/article-editor-2-4-8/article-editor.min.js

js digbi-web-akl7i.ondigitalocean.app collected 2026-10-03 14:56:57 UTC 274,754 bytes, 1 lines download raw bytes

1var CodeMirror;!function(){function o(t,e){return this.parse(t,e)}function t(t,e){return i=e,h.dom(t).each(function(t){(s=t.dataget(h.namespace))||(s=new p(t,i,r),t.dataset(h.namespace,s),h.instances[r]=s,r++)}),s;var i,s}var i={settings:{},post:function(t){return new s("post",t)},get:function(t){return new s("get",t)},request:function(t,e){return new s(t,e)}},s=function(t,e){this.p=this.extend({method:t,url:"",before:function(){},success:function(){},error:function(){},data:!1,async:!0,headers:{}},e),this.p=this.extend(this.p,i.settings),this.p.method=this.p.method.toUpperCase(),this.prepareData(),this.xhr=new XMLHttpRequest,this.xhr.open(this.p.method,this.p.url,this.p.async),this.setHeaders(),!1!==("function"!=typeof this.p.before||this.p.before(this.xhr))&&this.send()},n=(s.prototype={extend:function(e,i){return i&&Object.keys(i).forEach(function(t){e[t]=i[t]}),e},prepareData:function(){var t;-1===["POST","PUT"].indexOf(this.p.method)||this.isFormData()||(this.p.headers["Content-Type"]="application/x-www-form-urlencoded"),"object"!=typeof this.p.data||this.isFormData()||(this.p.data=this.toParams(this.p.data)),"GET"===this.p.method&&(t=-1!==this.p.url.search(/\?/)?"&":"?",this.p.url=this.p.data?this.p.url+t+this.p.data:this.p.url)},setHeaders:function(){this.xhr.setRequestHeader("X-Requested-With",this.p.headers["X-Requested-With"]||"XMLHttpRequest"),Object.keys(this.p.headers).forEach(function(t){this.xhr.setRequestHeader(t,this.p.headers[t])}.bind(this))},isFormData:function(){return void 0!==window.FormData&&this.p.data instanceof window.FormData},isComplete:function(){return!(this.xhr.status<200||300<=this.xhr.status&&304!==this.xhr.status)},send:function(){this.p.async?(this.xhr.onload=this.loaded.bind(this),this.xhr.send(this.p.data)):(this.xhr.send(this.p.data),this.loaded.call(this))},loaded:function(){var t;this.isComplete()?(t=this.parseResponse(),"function"==typeof this.p.success&&this.p.success(t,this.xhr)):(t=this.parseResponse(),"function"==typeof this.p.error&&this.p.error(t,this.xhr,this.xhr.status))},parseResponse:function(){var t=this.xhr.response,e=this.parseJson(t);return e||t},parseJson:function(t){try{var e=JSON.parse(t);if(e&&"object"==typeof e)return e}catch(t){}return!1},toParams:function(e){return Object.keys(e).map(function(t){return encodeURIComponent(t)+"="+encodeURIComponent(e[t])}).join("&")}},[0]),a="data"+(new Date).getTime(),r=(o.ready=function(t){document.addEventListener("DOMContentLoaded",t)},o.prototype={get length(){return this.nodes.length},parse:function(t,e){var i;if(t){if(t instanceof o)return this.nodes=t.nodes,t;i=/^\s*<(\w+|!)[^>]*>/.test(t)?this.create(t):"string"!=typeof t?t.nodeType&&11===t.nodeType?t.childNodes:t.nodeType||this._isWindowNode(t)?[t]:t:this._query(t,e)}else i=[];this.nodes=this._slice(i)},create:function(t){if(/^<(\w+)\s*\/?>(?:<\/\1>|)$/.test(t))return[document.createElement(RegExp.$1)];var e=[],i=document.createElement("div");i.innerHTML=t;for(var s=0,n=i.childNodes.length;s<n;s++)e.push(i.childNodes[s]);return e},dataset:function(e,i){return this.each(function(t){n[this.dataindex(t.get())][e]=i})},dataget:function(t){return n[this.dataindex(this.get())][t]},dataindex:function(t){var e=t[a],i=n.length;return e||(e=i,t&&(t[a]=i),n[e]={}),e},add:function(t){return this.nodes=this.nodes.concat(this._array(t)),this},get:function(t){return this.nodes[t||0]||!1},getAll:function(){return this.nodes},eq:function(t){return new o(this.nodes[t])},first:function(){return new o(this.nodes[0])},last:function(){return new o(this.nodes[this.nodes.length-1])},contents:function(){return this.get().childNodes},each:function(t){for(var e=this.nodes.length,i=0;i<e;i++)t.call(this,new o(this.nodes[i]),i);return this},is:function(t){return 0<this.filter(t).length},filter:function(e){return void 0===e?this:new o(this.nodes.filter.call(this.nodes,"function"==typeof e?function(t){return e(new o(t))}:function(t){return e&&e.nodeType||e instanceof Node?e===t:(t.matches=t.matches||t.msMatchesSelector||t.webkitMatchesSelector,1===t.nodeType&&t.matches(e||"*"))}))},not:function(e){return this.filter(function(t){return!new o(t).is(e||!0)})},find:function(s){var n=[];return this.each(function(t){for(var t=t.get(),e=this._query(s,t),i=0;i<e.length;i++)n.push(e[i])}),new o(n)},children:function(t){var s=[];return this.each(function(t){t=t.get();if(t.children)for(var e=t.children,i=0;i<e.length;i++)s.push(e[i])}),new o(s).filter(t)},parent:function(t){var e=this.get(),e=e.parentNode||!1;return e?new o(e).filter(t):new o},parents:function(i,s){s=this._context(s);var n=[];return this.each(function(t){for(var e=t.get().parentNode;e&&e!==s;)i&&!new o(e).is(i)||n.push(e),e=e.parentNode}),new o(n)},closest:function(i,s){s=this._context(s);var n=[],a=i&&i.nodeType;return this.each(function(t){var e=t.get();do{if(e&&(a&&e===i||new o(e).is(i)))return n.push(e)}while((e=e.parentNode)&&e!==s)}),new o(n)},next:function(t){return this._sibling(t,"nextSibling")},nextElement:function(t){return this._sibling(t,"nextElementSibling")},prev:function(t){return this._sibling(t,"previousSibling")},prevElement:function(t){return this._sibling(t,"previousElementSibling")},css:function(n,a){var t;return void 0===a&&"object"!=typeof n?(t=this.get(),"width"===n||"height"===n?t.style?this._getHeightOrWidth(n)+"px":void 0:t.style?getComputedStyle(t,null)[n]:void 0):this.each(function(t){var e,i=t.get(),s={};for(e in"object"==typeof n?s=n:s[n]=a,s)i.style&&(i.style[e]=s[e])})},attr:function(n,a,o){var t;return o=o?"data-":"",void 0===a&&"object"!=typeof n?(t=this.get())&&3!==t.nodeType?"checked"===n?t.checked:this._boolean(t.getAttribute(o+n)):void 0:this.each(function(t){var e,i=t.get(),s={};for(e in"object"==typeof n?s=n:s[n]=a,s)3!==i.nodeType&&("checked"===e?i.checked=s[e]:i.setAttribute(o+e,s[e]))})},data:function(t,e){if(void 0!==t&&!0!==t)return this.attr(t,e,!0);function i(t){return t[1].toUpperCase()}var s,n,a,o=/^data-(.+)$/,r=this.get().attributes,p={};for(s in r)r[s]&&o.test(r[s].nodeName)&&(n=r[s].nodeName.match(o)[
11],a=r[s].value,!0!==t&&(n=n.replace(/-([a-z])/g,i)),a=-1!==a.search(/^{/)?this._object(a):this._number(a)?parseFloat(a):this._boolean(a),p[n]=a);return p},val:function(e){var t;return void 0===e?(t=this.get()).type&&"checkbox"===t.type?t.checked:t.value:this.each(function(t){t=t.get();t.type&&"checkbox"===t.type?t.checked=e:t.value=e})},removeAttr:function(i){return this.each(function(t){var e=t.get();i.split(" ").forEach(function(t){3!==e.nodeType&&e.removeAttribute(t)})})},addClass:function(t){return this._eachClass(t,"add")},removeClass:function(t){return this._eachClass(t,"remove")},toggleClass:function(t){return this._eachClass(t,"toggle")},hasClass:function(t){var e=this.get();return!!e.classList&&e.classList.contains(t)},empty:function(){return this.each(function(t){t.get().innerHTML=""})},html:function(t){return void 0===t?this.get().innerHTML||"":this.empty().append(t)},text:function(e){return void 0===e?this.get().textContent||"":this.each(function(t){t.get().textContent=e})},after:function(t){return this._inject(t,function(t,e){if("string"==typeof t)e.insertAdjacentHTML("afterend",t);else if(null!==e.parentNode)for(var i=t instanceof Node?[t]:this._array(t).reverse(),s=0;s<i.length;s++)e.parentNode.insertBefore(i[s],e.nextSibling);return e})},before:function(t){return this._inject(t,function(t,e){if("string"==typeof t)e.insertAdjacentHTML("beforebegin",t);else for(var i=t instanceof Node?[t]:this._array(t),s=0;s<i.length;s++)e.parentNode.insertBefore(i[s],e);return e})},append:function(t){return this._inject(t,function(t,e){if("string"==typeof t||"number"==typeof t)e.insertAdjacentHTML("beforeend",t);else for(var i=t instanceof Node?[t]:this._array(t),s=0;s<i.length;s++)e.appendChild(i[s]);return e})},prepend:function(t){return this._inject(t,function(t,e){if("string"==typeof t||"number"==typeof t)e.insertAdjacentHTML("afterbegin",t);else for(var i=t instanceof Node?[t]:this._array(t).reverse(),s=0;s<i.length;s++)e.insertBefore(i[s],e.firstChild);return e})},wrap:function(t){return this._inject(t,function(t,e){t="string"==typeof t||"number"==typeof t?this.create(t)[0]:t instanceof Node?t:this._array(t)[0];return e.parentNode&&e.parentNode.insertBefore(t,e),t.appendChild(e),t})},unwrap:function(){return this.each(function(t){for(var e=t.get(),i=document.createDocumentFragment();e.firstChild;){var s=e.removeChild(e.firstChild);i.appendChild(s)}e.parentNode.replaceChild(i,e)})},replaceWith:function(t){return this._inject(t,function(t,e){for(var i=document.createDocumentFragment(),s="string"==typeof t||"number"==typeof t?this.create(t):t instanceof Node?[t]:this._array(t),n=0;n<s.length;n++)i.appendChild(s[n]);t=i.childNodes[0];return e.parentNode&&e.parentNode.replaceChild(i,e),t})},remove:function(){return this.each(function(t){t=t.get();t.parentNode&&t.parentNode.removeChild(t)})},clone:function(i){var s=[];return this.each(function(t){var t=t.get(),e=this._clone(t);i&&(e=this._cloneEvents(t,e)),s.push(e)}),new o(s)},show:function(){return this.each(function(t){var e,t=t.get();t.style&&this._hasDisplayNone(t)&&(e=t.getAttribute("domTargetShow"),t.style.display=e||"block",t.removeAttribute("domTargetShow"))}.bind(this))},hide:function(){return this.each(function(t){var e,t=t.get();t.style&&!this._hasDisplayNone(t)&&("block"!==(e=t.style.display)&&t.setAttribute("domTargetShow",e),t.style.display="none")})},scrollTop:function(t){var e=this.get(),i=this._isWindowNode(e),s=9===e.nodeType?e.scrollingElement||e.body.parentNode||e.body||e.documentElement:e;if(void 0===t)return i?e.pageYOffset:s.scrollTop;t=parseInt(t),i?e.scrollTo(0,t):s.scrollTop=t},offset:function(){return this._getPos("offset")},position:function(){return this._getPos("position")},width:function(t){return void 0!==t?this.css("width",parseInt(t)+"px"):this._getSize("width","Width")},height:function(t){return void 0!==t?this.css("height",parseInt(t)+"px"):this._getSize("height","Height")},outerWidth:function(){return this._getSize("width","Width","outer")},outerHeight:function(){return this._getSize("height","Height","outer")},innerWidth:function(){return this._getSize("width","Width","inner")},innerHeight:function(){return this._getSize("height","Height","inner")},click:function(){return this._trigger("click")},focus:function(){return this._trigger("focus")},blur:function(){return this._trigger("blur")},on:function(o,r,p){return this.each(function(t){for(var e=t.get(),i=o.split(" "),s=0;s<i.length;s++){var n=this._getEventName(i[s]),a=this._getEventNamespace(i[s]);r=p?this._getOneHandler(r,o):r,e.addEventListener(n,r),e._e=e._e||{}
1,e._e[a]=e._e[a]||{},e._e[a][n]=e._e[a][n]||[],e._e[a][n].push(r)}})},one:function(t,e){return this.on(t,e,!0)},off:function(o,r){function p(t,e,i){return t===i}function l(t,e,i,s){return e===s}function h(t,e,i,s){return t===i&&e===s}function e(){return!0}return void 0===o?this.each(function(t){this._offEvent(t.get(),!1,!1,r,e)}):this.each(function(t){for(var e=t.get(),i=o.split(" "),s=0;s<i.length;s++){var n=this._getEventName(i[s]),a=this._getEventNamespace(i[s]);"_events"===a?this._offEvent(e,n,a,r,p):n||"_events"===a?this._offEvent(e,n,a,r,h):this._offEvent(e,n,a,r,l)}})},serialize:function(t){for(var e={},i=this.get().elements,s=0;s<i.length;s++){var n=i[s];if((!/(checkbox|radio)/.test(n.type)||n.checked)&&(n.name&&!n.disabled&&"file"!==n.type)){if("select-multiple"===n.type)for(var a=0;a<n.options.length;a++){var o=n.options[a];o.selected&&(e[n.name]=o.value)}e[n.name]=this._number(n.value)?parseFloat(n.value):this._boolean(n.value)}}return t?e:this._params(e)},scroll:function(){this.get().scrollIntoView({behavior:"smooth"})},fadeIn:function(t,e){var i=this._anim(t,e,500);return this.each(function(t){t.css({display:"block",opacity:0,animation:"fadeIn "+i.speed+"s ease-in-out"}).removeClass("hidden"),t.one("animationend",function(){t.css({opacity:"",animation:""}),i.fn&&i.fn(t)})})},fadeOut:function(t,e){var i=this._anim(t,e,300);return this.each(function(t){t.css({opacity:1,animation:"fadeOut "+i.speed+"s ease-in-out"}),t.one("animationend",function(){t.css({display:"none",opacity:"",animation:""}),i.fn&&i.fn(t)})})},slideUp:function(t,e){var i=this._anim(t,e,300);return this.each(function(t){t.height(t.height()),t.css({overflow:"hidden",animation:"slideUp "+i.speed+"s ease-out"}),t.one("animationend",function(){t.css({display:"none",height:"",animation:""}),i.fn&&i.fn(t)})})},slideDown:function(t,e){var i=this._anim(t,e,400);return this.each(function(t){t.height(t.height()),t.css({display:"block",overflow:"hidden",animation:"slideDown "+i.speed+"s ease-in-out"}).removeClass("hidden"),t.one("animationend",function(){t.css({overflow:"",height:"",animation:""}),i.fn&&i.fn(t)})})},_queryContext:function(t,e){return 3!==(e=this._context(e)).nodeType&&"function"==typeof e.querySelectorAll?e.querySelectorAll(t):[]},_query:function(t,e){var i=document;return e?this._queryContext(t,e):/^[.#]?[\w-]*$/.test(t)?"#"===t[0]?(e=i.getElementById(t.slice(1)))?[e]:[]:"."===t[0]?i.getElementsByClassName(t.slice(1)):i.getElementsByTagName(t):i.querySelectorAll(t)},_context:function(t){return t?"string"==typeof t?document.querySelector(t):t:document},_sibling:function(i,s){var n,a=i&&i.nodeType;return this.each(function(t){var e=t.get();do{if((e=e[s])&&(a&&e===i||new o(e).is(i)))return void(n=e)}while(e)}),new o(n)},_slice:function(t){return t&&0!==t.length?t.length?[].slice.call(t.nodes||t):[t]:[]},_array:function(t){if(void 0===t)return[];if(t instanceof NodeList){for(var e=[],i=0;i<t.length;i++)e[i]=t[i];return e}return t instanceof o?t.nodes:t},_object:function(t){t=t.replace(/(\w+:)|(\w+ :)/g,function(t){return'"'+t.substring(0,t.length-1)+'":'});return JSON.parse(t)},_params:function(e){var i="";return Object.keys(e).forEach(function(t){i+="&"+this._encodeUri(t)+"="+this._encodeUri(e[t])}.bind(this)),i.replace(/^&/,"")},_boolean:function(t){return"true"===t||"false"!==t&&t},_number:function(t){return!isNaN(t)&&!isNaN(parseFloat(t))},_inject:function(t,e){for(var i=this.nodes.length,s=[];i--;){var n="function"==typeof t?t.call(this,this.nodes[i]):t,n=0===i?n:this._clone(n),n=e.call(this,n,this.nodes[i]);n&&(n.dom?s.push(n.get()):s.push(n))}return new o(s)},_clone:function(t){if(void 0!==t)return"string"==typeof t?t:t instanceof Node||t.nodeType?t.cloneNode(!0):"length"in t?[].map.call(this._array(t),function(t){return t.cloneNode(!0)}):void 0},_cloneEvents:function(t,e){var i=t._e;if(i)for(var s in(e._e=i)._events)if(i._events.hasOwnProperty(s))for(var n=0;n<i._events[s].length;n++)e.addEventListener(s,i._events[s][n]);return e},_trigger:function(t){var e=this.get();return e&&3!==e.nodeType&&e[t](),this},_encodeUri:function(t){return encodeURIComponent(t).replace(/!/g,"%21").replace(/'/g,"%27").replace(/\(/g,"%28").replace(/\)/g,"%29").replace(/\*/g,"%2A").replace(/%20/g,"+")},_getSize:function(t,e){var i=this.get(),s=0,s=3===i.nodeType?0:9===i.nodeType?this._getDocSize(i,e):this._isWindowNode(i)?window["inner"+e]:this._getHeightOrWidth(t);return Math.round(s)},_getDocSize:function(t,e){var i=t.body,t=t.documentElement;return Math.max(i["scroll"+e],i["offset"+e],t["client"+e],t["scroll"+e],t["offset"+e])},_getPos:function(t){var e,i=this.get(),s={top:0,left:0};return 3===i.nodeType||this._isWindowNode(i)||9===i.nodeType?s:"position"===t?{top:i.offsetTop,left:i.offsetLeft}:"offset"===t?(t=i.getBoundingClientRect(),e=(i=i.ownerDocument).documentElement,i=i.defaultView,{top:t.top+i.pageYOffset-e.clientTop,left:t.left+i.pageXOffset-e.clientLeft}):s},_getHeightOrWidth:function(t,e){var i,s,t=t.charAt(0).toUpperCase()+t.slice(1),e=e||"offset",n=0,a=this.get(),o=getComputedStyle(a,null),r=this.parents().filter(function(t){t=t.get();return 1===t.nodeType&&"none"===getComputedStyle(t,null).display&&t});return"none"===o.display&&r.add(a),0!==r.length?(i="visibility: hidden !important; display: block !important;",s=[],r.each(function(t){var e=t.attr("style");null!==e&&s.push(e),t.attr("style",null!==e?e+";"+i:i)}),n=a[e+t],r.each(function(t,e){void 0===s[e]?t.removeAttr("style"):t.attr("style",s[e])})):n=a[e+t],n},_eachClass:function(i,s){return this.each(function(t){var e;i&&(e=t.get(),i.split(" ").forEach(function(t){e.classList&&e.classList[s](t)}))})},_getOneHandler:function(t,e){var i=this;return function(){t.apply(this,arguments),i.off(e)}},_getEventNamespace:function(t){var t=t.split("."),e=t[1]||"_events";return t[2]?e+t[2]:e},_getEventName:function(t){return t.split(".")[0]}
1,_offEvent:function(t,e,i,s,n){for(var a in t._e)if(t._e.hasOwnProperty(a))for(var o in t._e[a])if(n(o,a,e,i))for(var r=t._e[a][o],p=0;p<r.length;p++)void 0!==s&&r[p].toString()!==s.toString()||(t.removeEventListener(o,r[p]),t._e[a][o].splice(p,1),0===t._e[a][o].length&&delete t._e[a][o],0===Object.keys(t._e[a]).length&&delete t._e[a])},_hasDisplayNone:function(t){return"none"===t.style.display||"none"===(t.currentStyle||getComputedStyle(t,null)).display},_anim:function(t,e,i){return t="function"==typeof t?(e=t,i):t||i,{fn:e,speed:t/1e3}},_isWindowNode:function(t){return t===window||t.parent&&t.parent===window}},0),h=t,p=(h.dom=function(t,e){return new o(t,e)},h.ajax=i,h.instances=[],h.namespace="article-editor",h.prefix="arx",h.version="2.4.8",h.settings={},h.lang={},h._mixins={},h._repository={},h._subscribe={},h.keycodes={BACKSPACE:8,DELETE:46,UP:38,DOWN:40,ENTER:13,SPACE:32,ESC:27,TAB:9,CTRL:17,META:91,SHIFT:16,ALT:18,RIGHT:39,LEFT:37},h.add=function(t,e,i){var s;if(i.translations&&(h.lang=h.extend(!0,h.lang,i.translations)),i.defaults&&((s={})[e]=i.defaults,h.opts=h.extend(!0,h.opts,s)),i.parser&&((s={})[i.type]=i.parser,h.opts.parser=h.extend({},!0,h.opts.parser,s)),i.nested&&h.opts.nested.push(i.type),"mixin"===t)h._mixins[e]=i;else{if(i.subscribe)for(var n in i.subscribe)if(i.subscribe.hasOwnProperty(n))for(var a=n.split(","),o=0;o<a.length;o++){var r=a[o].trim();void 0===h._subscribe[r]&&(h._subscribe[r]=[]),h._subscribe[r].push({module:e,func:i.subscribe[n]})}function p(){}if((p.prototype=i).mixins)for(var l=0;l<i.mixins.length;l++)h.inherit(p,h._mixins[i.mixins[l]]);h._repository[e]={type:t,proto:p,obj:i}}},h.extend=function(){var t={},e=!1,i=0,s=arguments.length;for("[object Boolean]"===Object.prototype.toString.call(arguments[0])&&(e=arguments[0],i++);i<s;i++){n=void 0;var n,a=arguments[i];for(n in a)Object.prototype.hasOwnProperty.call(a,n)&&(e&&"[object Object]"===Object.prototype.toString.call(a[n])?t[n]=h.extend(!0,t[n],a[n]):t[n]=a[n])}return t},h.error=function(t){throw t},h.inherit=function(t,e){function i(){}i.prototype=e;var s,n=new i;for(s in t.prototype)t.prototype.__lookupGetter__(s)?n.__defineGetter__(s,t.prototype.__lookupGetter__(s)):n[s]=t.prototype[s];return t.prototype=n,t.prototype.super=e,t},h.addLang=function(t,e){void 0===h.lang[t]&&(h.lang[t]={}),h.lang[t]=h.extend(!0,h.lang[t],e)},t.opts={plugins:[],content:!1,placeholder:!1,css:!1,custom:{css:!1,js:!1},editor:{classname:"entry",disabled:!1,focus:!1,sync:!0,drop:!0,lang:"en",add:"top",addbar:!1,https:!1,padding:!0,markup:"paragraph",mobile:400,enterKey:!0,scrollTarget:window,direction:"ltr",spellcheck:!0,grammarly:!0,notranslate:!1,reloadmarker:!0,minHeight:"100px",maxHeight:!1,doctype:"<!doctype html>",csscache:!1},selection:{multiple:!0},control:!0,source:!0,image:{states:!0,upload:!1,url:!0,select:!1,selectMethod:"get",name:"file",data:!1,drop:!0,multiple:!0,clipboard:!0,types:["image/*"],tag:"figure",newtab:!1,link:!0,width:!1},classes:!1,codemirrorSrc:!1,codemirror:!1,state:{limit:100},path:{title:"## editor.title ##",sticky:!0,stickyMinHeight:200,stickyTopOffset:0},autosave:{url:!1,name:!1,data:!1,method:"post"},paste:{clean:!0,autoparse:!0,paragraphize:!0,plaintext:!1,linkTarget:!1,images:!0,links:!0,keepStyle:[],keepClass:[],keepAttrs:["td","th"],formTags:["form","input","button","select","textarea","legend","fieldset"],blockTags:["pre","div","h1","h2","h3","h4","h5","h6","table","tbody","thead","tfoot","th","tr","td","ul","ol","li","blockquote","p","hr","figure","iframe","figcaption","address","section","header","footer","aside","article","audio","source"],inlineTags:["a","svg","img","br","strong","ins","code","del","span","samp","kbd","sup","sub","mark","var","cite","small","b","u","em","i","abbr"]},clean:{comments:!1,enter:!0,enterinline:!1},tab:{key:!0,spaces:!1},topbar:{undoredo:!1,shortcuts:!0},toolbar:{hide:[],sticky:!0,stickyMinHeight:200,stickyTopOffset:0},buttons:{editor:["add","template","mobile","html"],topbar:["undo","redo","shortcut"],toolbar:!1,tags:{b:["bold"],strong:["bold"],i:["italic"],em:["italic"],del:["deleted"],u:["underline"],a:["link"]},types:!1,icons:!1,hidden:{}}
1,card:{classname:"card",template:'<div class="card"><div class="card-head"><h3>Card title</h3></div><div class="card-body"><p>Card body</p></div></div>'},text:{classname:"arx-text"},noneditable:{classname:"noneditable"},embed:{responsive:"embed-responsive",script:!0,checkbox:!1},code:{template:"<pre></pre>",spaces:4},line:!0,layer:{template:"<div></div>"},table:{template:"<table><tr><td></td><td></td></tr><tr><td></td><td></td></tr></table>"},quote:{template:"<blockquote><p>Quote...</p><p><cite>Author Attribution</cite></p></blockquote>"},snippets:!1,templates:!1,grid:{classname:"grid",classes:"",overlay:!0,offset:{left:0,right:0},columns:12,gutter:"1.25rem",patterns:{"6|6":"column column-6|column column-6","4|4|4":"column column-4|column column-4|column column-4","3|3|3|3":"column column-3|column column-3|column column-3|column column-3","2|2|2|2|2|2":"column column-2|column column-2|column column-2|column column-2|column column-2|column column-2","3|6|3":"column column-3|column column-6|column column-3","2|8|2":"column column-2|column column-8|column column-2","5|7":"column column-5|column column-7","7|5":"column column-7|column column-5","4|8":"column column-4|column column-8","8|4":"column column-8|column column-4","3|9":"column column-3|column column-9","9|3":"column column-9|column column-3","2|10":"column column-2|column column-10","10|2":"column column-10|column column-2",12:"column column-12"}},link:{size:30,nofollow:!1,target:!1},addbar:["paragraph","image","embed","line","table","snippet","quote","code","grid","layer"],addbarAdd:[],addbarHide:[],format:["p","h1","h2","h3","ul","ol"],formatAdd:!1,outset:{none:"none",left:"outset-left",both:"outset-both",right:"outset-right"},align:{left:"align-left",center:"align-center",right:"align-right",justify:"align-justify"},valign:{none:"none",top:"valign-top",middle:"valign-middle",bottom:"valign-bottom"},shortcutsRemove:!1,shortcutsBase:{"meta+z":"## shortcuts.meta-z ##","meta+shift+z":"## shortcuts.meta-shift-z ##","meta+a":"## shortcuts.meta-a ##","meta+shift+a":"## shortcuts.meta-shift-a ##","meta+click":"## shortcuts.meta-click ##"},shortcuts:{"ctrl+shift+d, meta+shift+d":{title:"## shortcuts.meta-shift-d ##",name:"meta+shift+d",command:"block.duplicate"},"ctrl+shift+up, meta+shift+up":{title:"## shortcuts.meta-shift-up ##",name:"meta+shift+&uarr;",command:"block.moveUp"},"ctrl+shift+down, meta+shift+down":{title:"## shortcuts.meta-shift-down ##",name:"meta+shift+&darr;",command:"block.moveDown"},"ctrl+shift+m, meta+shift+m":{title:"## shortcuts.meta-shift-m ##",name:"meta+shift+m",command:"inline.removeFormat"},"ctrl+b, meta+b":{title:"## shortcuts.meta-b ##",name:"meta+b",command:"inline.set",params:{tag:"b"}},"ctrl+i, meta+i":{title:"## shortcuts.meta-i ##",name:"meta+i",command:"inline.set",params:{tag:"i"}},"ctrl+u, meta+u":{title:"## shortcuts.meta-u ##",name:"meta+u",command:"inline.set",params:{tag:"u"}},"ctrl+h, meta+h":{title:"## shortcuts.meta-h ##",name:"meta+h",command:"inline.set",params:{tag:"sup"}},"ctrl+l, meta+l":{title:"## shortcuts.meta-l ##",name:"meta+l",command:"inline.set",params:{tag:"sub"}},"ctrl+alt+0, meta+alt+0":{title:"## shortcuts.meta-alt-0 ##",name:"meta+alt+0",command:"block.format",params:{tag:"p"}},"ctrl+alt+1, meta+alt+1":{title:"## shortcuts.meta-alt-1 ##",name:"meta+alt+1",command:"block.format",params:{tag:"h1"}},"ctrl+alt+2, meta+alt+2":{title:"## shortcuts.meta-alt-2 ##",name:"meta+alt+2",command:"block.format",params:{tag:"h2"}},"ctrl+alt+3, meta+alt+3":{title:"## shortcuts.meta-alt-3 ##",name:"meta+alt+3",command:"block.format",params:{tag:"h3"}},"ctrl+alt+4, meta+alt+4":{title:"## shortcuts.meta-alt-4 ##",name:"meta+alt+4",command:"block.format",params:{tag:"h4"}},"ctrl+alt+5, meta+alt+5":{title:"## shortcuts.meta-alt-5 ##",name:"meta+alt+5",command:"block.format",params:{tag:"h5"}},"ctrl+alt+6, meta+alt+6":{title:"## shortcuts.meta-alt-6 ##",name:"meta+alt+6",command:"block.format",params:{tag:"h6"}},"ctrl+shift+7, meta+shift+7":{title:"## shortcuts.meta-shift-7 ##",name:"meta+shift+7",command:"block.format",params:{tag:"ol"}},"ctrl+shift+8, meta+shift+8":{title:"## shortcuts.meta-shift-8 ##",name:"meta+shift+8",command:"block.format",params:{tag:"ul"}},"ctrl+], meta+]":{title:"## shortcuts.meta-indent ##",name:"meta+]",command:"list.indent"},"ctrl+[, meta+[":{title:"## shortcuts.meta-outdent ##",name:"meta+[",command:"list.outdent"},"ctrl+k, meta+k":{title:"## shortcuts.meta-k ##",name:"meta+k",command:"link.format"}},disableMode:!1,markerChar:"\ufeff",containers:{main:["bars","editor","source","statusbar"],bars:["pathbar","toolbar"]},tags:{denied:["font","html","head","link","title","body","meta","applet","marquee"],incode:["!DOCTYPE","!doctype","html","head","link","title","body","meta","textarea","style"],form:["form","input","button","select","textarea","legend","fieldset"],inl
1ine:["a","svg","span","strong","strike","b","u","em","i","code","del","ins","samp","kbd","sup","sub","mark","var","cite","small","abbr"],block:["pre","hr","ul","ol","li","p","h1","h2","h3","h4","h5","h6","dl","dt","dd","div","table","tbody","thead","tfoot","tr","th","td","blockquote","output","figcaption","figure","address","main","section","header","footer","aside","article","iframe","audio","source"],parser:["pre","hr","ul","ol","dl","p","h1","h2","h3","h4","h5","h6","div","table","address","blockquote","figure","main","section","header","footer","aside","article","iframe"]},bsmodal:!1,regex:{youtube:/^https?\:\/\/(?:www\.youtube(?:\-nocookie)?\.com\/|m\.youtube\.com\/|youtube\.com\/)?(?:ytscreeningroom\?vi?=|youtu\.be\/|vi?\/|user\/.+\/u\/\w{1,2}\/|embed\/|watch\?(?:.*\&)?vi?=|\&vi?=|\?(?:.*\&)?vi?=)([^#\&\?\n\/<>"']*)/gi,vimeo:/(http|https)?:\/\/(?:www.|player.)?vimeo.com\/(?:channels\/(?:\w+\/)?|groups\/(?:[^\/]*)\/videos\/|album\/(?:\d+)\/video\/|video\/|)(\d+)(?:\/[a-zA-Z0-9_-]+)?/gi,imageurl:/((https?|www)[^\s]+\.)(jpe?g|png|gif)(\?[^\s-]+)?/gi,url:/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z\u00F0-\u02AF0-9()!@:%_+.~#?&//=]*)/gi,aurl1:/(\b(https?|ftp):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/gim,aurl2:/(^|[^\/])(www\.[\S]+(\b|$))/gim},addbarExtend:{},buttonsObj:{undo:{title:"## buttons.undo ##",command:"state.undo"},redo:{title:"## buttons.redo ##",command:"state.redo"},shortcut:{title:"## buttons.shortcuts ##",observer:"shortcut.observe",command:"shortcut.popup"},template:{title:"## buttons.templates ##",command:"template.popup",observer:"template.observe"},mobile:{title:"## buttons.mobile-view ##",command:"editor.toggleView"},html:{title:"## buttons.html ##",command:"source.toggle"},paragraph:{title:"## blocks.paragraph ##",command:"block.add"},image:{title:"## blocks.image ##",command:"image.popup",observer:"image.observe"},embed:{title:"## blocks.embed ##",command:"embed.popup",observer:"embed.observe"},line:{title:"## blocks.line ##",command:"block.add",observer:"block.observe"},table:{title:"## blocks.table ##",command:"table.add",observer:"table.observe"},snippet:{title:"## blocks.snippet ##",command:"snippet.popup",observer:"snippet.observe"},quote:{title:"## blocks.quote ##",command:"block.add",observer:"block.observe"},text:{title:"## blocks.text ##",command:"block.add"},code:{title:"## blocks.code ##",command:"block.add",observer:"block.observe"},grid:{title:"## blocks.grid ##",command:"grid.popup",observer:"grid.observe"},layer:{title:"## blocks.layer ##",command:"block.add",observer:"block.observe"},card:{title:"## blocks.card ##",command:"block.add"},trash:{title:"## buttons.delete ##",command:"block.remove"}},nested:[],parser:{},parserTags:[],formatObj:{p:{title:"## blocks.paragraph ##",type:"paragraph",shortcut:"Ctrl+Alt+0"},div:{title:"## blocks.text ##",type:"text"},h1:{title:'<span style="font-size: 20px; font-weight: bold;">## headings.h1 ##</span>',type:"heading",shortcut:"Ctrl+Alt+1"},h2:{title:'<span style="font-size: 16px; font-weight: bold;">## headings.h2 ##</span>',type:"heading",shortcut:"Ctrl+Alt+2"},h3:{title:'<span style="font-weight: bold;">## headings.h3 ##</span>',type:"heading",shortcut:"Ctrl+Alt+3"},h4:{title:'<span style="font-weight: bold;">## headings.h4 ##</span>',type:"heading",shortcut:"Ctrl+Alt+4"},h5:{title:'<span style="font-weight: bold;">## headings.h5 ##</span>',type:"heading",shortcut:"Ctrl+Alt+5"},h6:{title:'<span style="font-weight: bold;">## headings.h6 ##</span>',type:"heading",shortcut:"Ctrl+Alt+6"},ol:{title:"1. ## list.ordered-list ##",type:"list",shortcut:"Ctrl+Shift+7"},ul:{title:"&bull; ## list.unordered-list ##",type:"list",shortcut:"Ctrl+Shift+8"},dl:{title:"## blocks.dlist ##",type:"dlist"},address:{title:"<em>## blocks.address ##</em>",type:"address"}}},t.lang.en={accessibility:{"help-label":"Rich text editor"},editor:{title:"Article",multiple:"Multiple"},placeholders:{figcaption:"Type caption (optional)",text:"Type something...",code:"Edit to add code...",layer:"Press enter to add a new text..."},popup:{link:"Link",add:"Add",grid:"Grid",back:"Back",image:"Image",snippets:"Snippets","add-image":"Add Image"},shortcuts:{"meta-a":"Select text in the block","meta-shift-a":"Select all blocks","meta-click":"Select multiple blocks","meta-z":"Undo","meta-shift-z":"Redo","meta-shift-m":"Remove inline format","meta-b":"Bold","meta-i":"Italic","meta-u":"Underline","meta-h":"Superscript","meta-l":"Subscript","meta-k":"Link","meta-alt-0":"Normal text","meta-alt-1":"Heading 1","meta-alt-2":"Heading 2","meta-alt-3":"Heading 3","meta-alt-4":"Heading 4","meta-alt-5":"Heading 5","meta-alt-6":"Heading 6","meta-shift-7":"Ordered List","meta-shift-8":"Unordered List","meta-indent":"Indent","meta-outdent":"Outdent","meta-shift-backspace":"Delete block","meta-shift-d":"Duplicate block","meta-shift-up":"Move line up","meta-shift-down":"Move line down"},headings:{h1:"Heading 1",h2:"Heading 2",h3:"Heading 3",h4:"Heading 4",h5:"Heading 5",h6:"Heading 6"},inline:{bold:"Bold",italic:"Italic",deleted:"Deleted"},list:{"unordered-list":"Unordered List","ordered-list":"Ordered List",indent:"Indent",outdent:"Outdent"},link:{link:"Link","edit-link":"Edit link",unlink:"Unlink","link-in-new-tab":"Open link in new tab",save:"Save",insert:"Insert",cancel:"Cancel",text:"Text",url:"URL"},table:{width:"Width",nowrap:"Nowrap",save:"Save",cancel:"Cancel","table-cell":"Table Cell","add-head":"Add head","remove-head":"Remove head","add-row-below":"Add row below","add-row-above":"Add row above","remove-row":"Remove row","add-column-after":"Add column after","add-column-before":"Add column before","remove-column":"Remove c
1olumn"},image:{or:"or","alt-text":"Alt Text",save:"Save",link:"Link",width:"Width",delete:"Delete",cancel:"Cancel",insert:"Insert",caption:"Caption","link-in-new-tab":"Open link in new tab","url-placeholder":"Paste url of image...","upload-new-placeholder":"Drag to upload a new image<br>or click to select"},code:{code:"Code",insert:"Insert",save:"Save",cancel:"Cancel"},embed:{embed:"Embed",caption:"Caption",insert:"Insert",save:"Save",cancel:"Cancel",description:"Paste any embed/html code or enter the url (vimeo or youtube video only)","responsive-video":"Responsive video"},upload:{placeholder:"Drag to upload <br>or click to select"},templates:{templates:"Templates"},snippets:{snippets:"Snippets"},form:{link:"Link",url:"Url",text:"Text",name:"Name","alt-text":"Alt Text",image:"Image",upload:"Upload",alignment:"Alignment",outset:"Outset",valign:"Valign"},buttons:{"mobile-view":"Mobile View",cancel:"Cancel",insert:"Insert",unlink:"Unlink",save:"Save",add:"Add","transform-to-text":"Transform to text",align:"Alignment",valign:"Valign",outset:"Outset",indent:"Indent",outdent:"Outdent",head:"Head",row:"Row",cell:"Cell",html:"HTML",templates:"Templates",shortcuts:"Keyboard Shortcuts",format:"Format",bold:"Bold",italic:"Italic",deleted:"Deleted",underline:"Underline",table:"Table",link:"Link",undo:"Undo",redo:"Redo",style:"Style",config:"Config",settings:"Settings",text:"Text",embed:"Embed",grid:"Grid",image:"Image",list:"List",delete:"Delete",duplicate:"Duplicate",sort:"Sort",edit:"Edit",inline:"Inline"},blocks:{noneditable:"Noneditable",paragraph:"Paragraph",heading:"Heading",image:"Image",figcaption:"Figcaption",embed:"Embed",line:"Line",code:"Code",quote:"Quote",quoteitem:"Paragraph",snippet:"Snippet",column:"Column",grid:"Grid",list:"List",table:"Table",layer:"Layer",row:"Row",text:"Text",cell:"Cell",dlist:"Definition List",address:"Address",form:"Form",card:"Card"}},function(t,e,i){for(var s=["keycodes","prefix","dom","ajax","_repository","_subscribe"],n=0;n<s.length;n++)this[s[n]]=h[s[n]];this.uuid=i,this.$win=this.dom(window),this.$doc=this.dom(document),this.$body=this.dom("body"),this.$element=t,(this.app=this).initialSettings=e,this._initer=["setting","lang"],this._priority=["container","editor","accessibility","state"],this._plugins=[],this.started=!1,this.start()});p.prototype={start:function(t){!this.isTextarea()||this.isStarted()||(t&&(this.initialSettings=t),this._initCore(),this._plugins=this.setting.get("plugins"),this.broadcast("app.before.start"),this._initModules(),this._initPlugins(),this._startPriority(),this._startModules(),this._startPlugins(),this.started=!0,this.broadcast("app.start"),this._loadModulesAndPlugins(),!1!==this.opts.disableMode&&this.disable())},isStarted:function(){return this.started},isTextarea:function(){return"TEXTAREA"===this.$element.get().tagName},stop:function(){this.isStopped()||(this.broadcast("app.before.stop"),this._stopPlugins(),this._stopPriority(),this._stopModules(),this.started=!1,this.broadcast("app.stop"))},isStopped:function(){return!this.started},destroy:function(){clearTimeout(this.app.sync.typingTimer),this.stop(),this.broadcast("app.destroy"),this.$element.dataset(h.namespace,!1);var t=h.instances.indexOf(this.uuid);-1<t&&h.instances.splice(t,1)},disable:function(){this.block.unset(),this.blocks.unset(),this.selection.removeAllRanges(),this.source.is()&&this.source.close(),this.popup.close(!1),this.toolbar.disableSticky(),this.toolbar.disable(),this.path.disable(),this.topbar.disable(),this.editor.getOverlay().addClass(this.prefix+"-editor-disabled"),this.opts.disableMode=!0},enable:function(){this.toolbar.enableSticky(),this.toolbar.enable(),this.path.enable(),this.topbar.enable(),this.editor.getOverlay().removeClass(this.prefix+"-editor-disabled"),this.opts.disableMode=!1},broadcast:function(t,e){var i=e instanceof p.Event?e:new p.Event(t,e);if(void 0!==this._subscribe[t])for(var s=this._subscribe[t],n=0;n<s.length;n++){var a=this[s[n].module];a&&s[n].func.call(a,i)}e=this.setting.has("subscribe")?this.setting.get("subscribe"):{};return"function"==typeof e[t]&&e[t].call(this,i),i},broadcastParams:function(t,e){return this.broadcast(t,e).getAll()},broadcastHtml:function(t,e){return this.broadcast(t,{html:e}).get("html")},create:function(t){void 0===this._repository[t]&&h.error('The class "'+t+'" does not exist.');
1for(var e,i=[].slice.call(arguments,1),s=new this._repository[t].proto,n=(s._name=t,s.app=this,["uuid","prefix","dom","ajax"]),a=0;a<n.length;a++)s[n[a]]=this[n[a]];return this.lang&&(s.lang=this.lang),this.opts&&(s.opts=this.opts),(e=s.init?s.init.apply(s,i):e)||s},api:function(t){for(var e=[].slice.call(arguments,1),i=t.split("."),s=i.pop(),n=this,a=0;a<i.length;a++)n=n[i[a]];if(n&&"function"==typeof n[s])return n[s].apply(n,e)},_initCore:function(){for(var t=0;t<this._initer.length;t++)this[this._initer[t]]=this.create(this._initer[t]);this.setting&&(this.opts=this.setting.dump())},_initModules:function(){for(var t in this._repository)"module"===this._repository[t].type&&-1===this._initer.indexOf(t)&&(this[t]=this.create(t))},_initPlugins:function(){var t,e=this.setting.get("plugins");for(t in this._repository)"plugin"===this._repository[t].type&&-1!==e.indexOf(t)&&(this[t]=this.create(t))},_startPriority:function(){for(var t=0;t<this._priority.length;t++)this._call(this[this._priority[t]],"start")},_startModules:function(){this._iterate("module","start")},_startPlugins:function(){this._iterate("plugin","start")},_stopPriority:function(){for(var t=this._priority.slice().reverse(),e=0;e<t.length;e++)this._call(this[t[e]],"stop")},_stopModules:function(){this._iterate("module","stop")},_stopPlugins:function(){this._iterate("plugin","stop")},_loadModulesAndPlugins:function(){this._iterate("module","load"),this._iterate("plugin","load")},_iterate:function(t,e){for(var i in this._repository){var s;this._repository.hasOwnProperty(i)&&(s="module"===t?"load"===e||-1===this._priority.indexOf(i):-1!==this._plugins.indexOf(i),this._repository[i].type===t)&&s&&this._call(this[i],e)}},_call:function(t,e){"function"==typeof t[e]&&t[e].apply(t)}},p.Event=function(t,e){this.name=t,this.params=void 0===e?{}:e,this.stopped=!1},p.Event.prototype={is:function(t){if(!Array.isArray(t))return this.get(t);for(var e=0;e<t.length;e++)if(this.params[t[e]])return!0},has:function(t){return void 0!==this.params[t]},getAll:function(){return this.params},get:function(t){return this.params[t]},set:function(t,e){this.params[t]=e},stop:function(){this.stopped=!0},isStopped:function(){return this.stopped}},t.add("mixin","block",{defaults:{id:{getter:"getId",setter:"setId"},html:{getter:"getHtml",setter:"setHtml"},align:{getter:"getAlign",setter:"setAlign"},valign:{getter:"getValign",setter:"setValign"},outset:{getter:"getOutset",setter:"setOutset"}},init:function(t,e){this.$block=t?this.dom(t):this.create(e),this._build(e),this._buildData(),this._render()},isType:function(t){return-1!==(Array.isArray(t)?t:[t]).indexOf(this.type)},isBlock:function(){return!0},isAllowedButton:function(t,e){var i=this.getType();if(void 0!==this.opts.buttons.hidden[i]){var s=this.opts.buttons.hidden[i];if(Array.isArray(s)&&-1!==s.indexOf(t))return!1}if(void 0===e.blocks)return!0;s=e.blocks;if(!s.except||-1===s.except.indexOf(i)){if(Array.isArray(s.types)&&-1!==s.types.indexOf(i))return!0;if(s.all){if(!0===s.all||"all"===s.all)return!0;if("editable"===s.all&&this.isEditable())return!0;if("first-level"===s.all&&this.isFirstLevel())return!0;if("noneditable"===s.all&&!this.isEditable())return!0}}return!1},isFirstLevel:function(){return this.$block.attr("data-"+this.prefix+"-first-level")},isSecondLevel:function(){return-1!==["quoteitem","row","cell"].indexOf(this.type)},isEditable:function(){return void 0!==this.editable&&!0===this.editable},isInlineBlock:function(){return void 0!==this.inline},isAllSelected:function(){return!this.isEditable()||this.app.selection.isAll(this.$block)},isEmpty:function(){var t;return this.isEmptiable()?!!this.$block.hasClass(this.prefix+"-empty-layer")||(t=(t=this.$block.html()).trim(),""===(t=this._cleanEmpty(t))):this.isEditable()?this._isEmpty():void 0},isEmptiable:function(){return void 0!==this.emptiable},isCaretStart:function(){var t;return"code"===this.getType()?this.app.caret.is(this.$block,"start",!1,!1):"list"===this.getType()?(t=this.app.selection.getCurrent(),0===this.dom(t).closest("li").prev().length&&this.app.caret.is(this.$block,"start")):!this.isEditable()||this.app.caret.is(this.$block,"start")},isCaretEnd:function(){return"code"===this.getType()?this.app.caret.is(this.$block,"end",!1,!1):"address"===this.getType()?this.app.caret.is(this.$block,"end",!1,!0,!1):!this.isEditable()||this.app.caret.is(this.$block,"end")},getData:function(t){var e={};
1return Object.keys(this.data).forEach(function(t){e[t]=this[this.data[t].getter].apply(this)}.bind(this)),t?e[t]:e},getType:function(){return this.type},getTag:function(){return!!this.$block&&this.$block.get().tagName.toLowerCase()},getTitle:function(){var t=this.getType(),e=this.lang.get("blocks"),i=this.$block.attr("data-title");return void 0!==e[t]?e[t]:i},getOffset:function(){var t=this.app.editor.getFrame().offset(),e=this.$block.offset();return{top:t.top+e.top,left:t.left+e.left}},getBlock:function(){return this.$block},getHtml:function(){return this.$block.html()},getPlainText:function(){var t=this.$block.html();return this.app.content.getTextFromHtml(t,{nl:!0})},getOuterHtml:function(){return this.$block.get().outerHTML},getParent:function(t){t=t?"="+t:"";t=this.$block.parent().closest("[data-"+this.prefix+"-type"+t+"]");return 0!==t.length&&t.dataget("instance")},getNext:function(t){t=t?"="+t:"";var e=this.$block.nextElement();return!(0===e.length||!e.is("[data-"+this.prefix+"-type"+t+"]"))&&e.dataget("instance")},getPrev:function(t){t=t?"="+t:"";var e=this.$block.prevElement();return!(0===e.length||!e.is("[data-"+this.prefix+"-type"+t+"]"))&&e.dataget("instance")},getChildFirst:function(t){t=this.$block.find("[data-"+this.prefix+"-type"+(t=t?"="+t:"")+"]").first();return 0!==t.length&&t.dataget("instance")},getChildLast:function(t){t=this.$block.find("[data-"+this.prefix+"-type"+(t=t?"="+t:"")+"]").last();return 0!==t.length&&t.dataget("instance")},getId:function(){return this.$block.attr("id")},getAlign:function(){var t=this.opts.align;if(!t)return!1;var e,i="left";for(e in t)this.$block.hasClass(t[e])&&(i=e);return i},getValign:function(){var t=this.opts.valign;if(!t)return!1;var e,i="none";for(e in t)this.$block.hasClass(t[e])&&(i=e);return i},getOutset:function(){var t=this.opts.outset;if(!t)return!1;var e,i="none";for(e in t)this.$block.hasClass(t[e])&&(i=e);return i},getCaption:function(){var t=this.$block.find("figcaption");return 0!==t.length?t.html().trim():""},setData:function(t){for(var e in t)this.data[e]&&this[this.data[e].setter].call(this,t[e])},setEmpty:function(){this.$block.html(""),this.isEmptiable()&&this._addEmptyButton(this.$block)},setSelectAll:function(){this.isEditable()&&this.app.selection.select(this.$block)},setHtml:function(t){this.$block.html(t),""!==t&&this._buildInstancesInside(this.$block)},setId:function(t){""===t?this.$block.removeAttr("id"):this.$block.attr("id",t)},setAlign:function(t){this._removeObjClasses(this.opts.align),this.$block.addClass(this.opts.align[t])},setValign:function(t){this._removeObjClasses(this.opts.valign),"none"!==t&&this.$block.addClass(this.opts.valign[t])},setOutset:function(t){this._removeObjClasses(this.opts.outset),"none"!==t&&this.$block.addClass(this.opts.outset[t]),this.app.control.updatePosition()},setCaption:function(t){var e;""===t?this.$block.find("figcaption").remove():(0===(e=this.$block.find("figcaption")).length&&((e=this.dom("<figcaption>")).attr("data-placeholder",this.lang.get("placeholders.figcaption")),this.$block.append(e),this.app.create("block.figcaption",e)),e.html(t))},setClassFromObj:function(t,e){this._removeObjClasses(t);t=t[e];"none"===t&&!1===t||this.$block.addClass(t)},hasClass:function(t){t="string"==typeof t?[t]:t;for(var e=0;e<t.length;e++)if(this.$block.hasClass(t[e]))return t[e];return!1},remove:function(t){var e=this.getParent(),i=this.getType();this.$block.remove(),e&&e.isEmptiable()&&e.isEmpty()&&e.setEmpty(),t&&this.app.broadcast("block.remove",{type:i,parent:e})},duplicate:function(t){var e=this.getType(),i=this.$block.clone();return i.removeClass(this.prefix+"-block-focus "+this.prefix+"-block-multiple-hover"),t&&i.html(""),this.app.create("block."+e,i)},duplicateEmpty:function(){return this.duplicate(!0)},insertEmpty:function(t){return(t=t||{}).instance=this.app.block.create(),this.insert(t)},insert:function(t){var t=h.extend({},{instance:!1,position:!1,caret:!1,remove:!0,type:"input"},t),e=t.instance.getBlock();if(this.isEditable()&&this.app.selection.deleteContents(),"list"!==t.instance.getType()||"list"!==this.getType())return t.instance.isInlineBlock()&&this.isInlineBlock()?(this.$block.after(e),this.$block.remove()):t.instance.isInlineBlock()&&this.isEditable()?this.app.insertion.insertNode(t.instance.getBlock(),!1,!0):this.isEditable()&&"card"!==this.getType()?(t.position=this.app.insertion.detectPosition(this.$block,t.position),"split"===t.position?this.app.element.split(this.$block).before(e):(this.$block[t.position](e),t.remove&&this.isEmpty()&&this.$block.remove())):(t.position=t.position||"after",this.$block[t.position](e)),this.app.editor.build(),t.caret&&this.app.block.set(t.instance,t.caret),this.app.toolbar.observe(),this.app.broadcast("block.add",{instance:t.instance,type:t.type}),t.instance;"duplicate"===t.type?(t.position=t.position||"after",this.$block[t.position](e),t.caret&&this.app.block.set(t.instance,t.caret)):this.app.insertion.insertListToList(e,this.$block,t.caret)},appendNext:function(){var t,e,i,s,n,a,o=this.getNext();o.isEmpty()?o.remove():this.isEmpty()?(this.remove(),this.app.block.set(o,"start")):(t=o.getHtml(),e=this.getType(),a=o.getType(),n=i=!0,"code"===e&&"code"!==a&&(t=o.getPlainText()),"dlist"===a?"dlist"===e?(s=o.getBlock().children(),this.$block.append(s),i=!1):t=o.getPlainText(!0):"list"===a&&(n="list"===e?(s=o.getBlock().children(),this.$block.append(s),!(i=!1)):(t=this._appendListHtml(o.getBlock(),t),o.isEmpty())),i&&((a=this.app.selection.getTopInline())&&this.app.caret.set(a,"after"),this.app.insertion.insertHtml(t,"start"),this._buildInstancesInside(this.$block)),n&&o.remove())},appendToPrev:function(){var t,e,i,s,n,a,o=this.getPrev();this.isEmpty()?(this.remove(),this.app.block.set(o,"end")):o.isEmpty()?(o.remove(),this.app.control.updatePosition()):(t=o.getType(),e=this.getHtml(),n=i=!0,"code"!==(a=this.getType())&&"code"===t&&(e=this.getPlainText()),"dlist"===a?"dlist"===t?(s=this.getBlock().children(),this.app.block.set(o,"end"),o.getBlock().append(s),i=!1):e=this.getPlainText(!0):"list"===a&&(n="list"===t?(s=this.getBlock().children(),this.app.block.set(o,"end"),o.getBlock().append(s),!(i=!1)):(e=this._appendListHtml(this.getBlock(),e),this.isEmpty())),i&&(this.app.block.set(o,"end"),(a=this.app.selection.getTopInline())&&this.app.caret.set(a,"after"),this.app.insertion.insertHtml(e,"start"),this._buildInstancesInside(o.getBlock())),n&&this.remove())},append:function(t,e){this.isEmptiable()&&this.isEmpty()&&(this.$block.html(""),this.$block.removeClass(this.prefix+"-empty-layer")),this.$block.append(t.getBlock()),!1!==e&&this.app.block.set(t),this.app.broadcast("block.add",{instance:t})},change:function(t,e){var i=t.getBlock();this.$block.after(i),this.$block.remove(),this.app.editor.build(),this.app.toolbar.observe(),this.app.block.set(t),!1!==e&&this.app.broadcast("block.change",{instance:t})},moveUp:function(){var t=this.getPrev();t&&this._move(t,"before")},moveDown:function(t){var e=this.getNext();e&&this._move(e,"after")},_appendListHtml:function(t,e){t=t.find("li").first();return e=(e=(e=t.html().trim()).replace(/<\/li>/gi,"</li><br>")).replace(/<(ul|ol)/gi,"<br><$1"),e=(e=(e=this.app.content.removeTags(e,["ul","ol","li"])).trim()).replace(/<br\s?\/?>$/gi,""),t.remove(),e},_move:function(t,e){this.isEditable()&&this.app.selection.save(this.$block),t.getBlock()[e](this.$block,!0),this.app.block.set(this.$block,!1,!0),this.isEditable()&&this.app.selection.restore(this.$block)},_build:function(t){this.isEmptiable()&&this.isEmpty()&&this._addEmptyButton(this.$block),this.build&&this.build(t),this._buildInstancesInside(this.$block)},_buildData:function(){this.data||(this.data={}),this.data=h.extend({},!0,this.defaults,this.data)},_buildInstancesInside:function(t){t.find("[data-"+this.prefix+"-type]").each(this._buildInstanceInside.bind(this))},_buildInstanceInside:function(t){var e;t.dataget("instance")||(e=t.attr("data-"+this.prefix+"-type"),this.app.create("block."+e,t))},_buildItems:function(t,e){t=this.$block.find(t);0!==t.length&&t.each(function(t){this.app.create("block."+e,t)}.bind(this))},_buildCaption:function(){"figure"===this.getTag()&&this.$block.find("figcaption").attr("data-placeholder",this.lang.get("placeholders.figcaption"))},_isEmpty:function(){var t=this.$block.text();return""===this._cleanEmpty(t)},_getNameByTag:function(){var t=this.getTag();return this.app.utils.capitalize(t)},_render:function(){this._renderEdit(),this._renderDraggable(),this._renderEditable()},_renderDraggable:function(){void 0!==this.draggable&&!1===this.draggable&&(this.$block.on("dragstart",function(t){return t.preventDefault(),!1}),this.$block.find("img").on("dragstart",function(t){return t.preventDefault(),!1}))},_renderEditable:function(){this.isEditable()?this.$block.attr("contenteditable",!0):void 0!==this.editable&&!1===this.editable&&this.$block.attr("contenteditable",!1),this.isEditable()&&!this.opts.editor.grammarly&&this.$block.attr("data-gramm_editor",!1)},_renderEdit:function(){this.$block.dataset("instance",this),this.$block.attr("data-"+this.prefix+"-type",this.getType())},_cleanEmpty:function(t){return t=(t=-1!==(t=this.app.utils.removeInvisibleChars(t)).search(/^<br\s?\/?>$/)?"":t).replace(/\n/g,"")},_removeObjClasses:function(t){t=this._buildObjClasses(t);this.$block.removeClass(t.join(" ")),this.app.element.removeEmptyAttrs(this.$block,["class"])},_buildObjClasses:function(t){var e,i=[];for(e in t)t[e]&&i.push(t[e]);return i},_addEmptyButton:function(t){var e;t.hasClass(this.prefix+"-empty-layer")||(t.addClass(this.prefix+"-empty-layer"),e=this.dom("<span>").addClass(this.prefix+"-plus-button"),this.app.create("button",{name:"plus",element:e},{command:"addbar.popup"}),t.append(e))}}
1),t.add("mixin","tool",{init:function(t,e,i,s){this.name=t,this.setter=i.get("setter"),this.popup=i,this.data=s,this.obj=this._observe(e),this.obj&&this._build()},getElement:function(){return this.$tool},getInput:function(){return this.$input},getValue:function(){return this.$input.val().trim()},setValue:function(t){this.$input.val(t)},setFocus:function(){this.$input.focus()},trigger:function(t){this.setValue(t),this.setter&&this.app.api(this.setter,this.popup)},_build:function(){this._buildTool(),this._buildLabel(),this._buildInputElement(),this._buildInput(),this._buildEvent(),this._has("placeholder")&&this.$input.attr("placeholder",this.lang.parse(this.obj.placeholder)),this._has("width")&&this.$input.css("width",this.obj.width),this._has("classname")&&this.$input.addClass(this.obj.classname)},_buildInputElement:function(){this.$input=this.dom("<"+this._getInputParam("tag")+">").addClass(this.prefix+this._getInputParam("classname")),this.$input.attr({name:this.name,type:this._getInputParam("type"),"data-type":this.type}),this.$input.dataset("instance",this)},_buildInput:function(){},_buildEvent:function(){var t;-1===["segment"].indexOf(this.type)&&this.setter&&(t="checkbox"===this.type||"select"===this.type?"change":"keydown blur",t="number"===this.type?t+" change":t,this.$input.on(t,this._catchSetter.b
1ind(this)))},_buildTool:function(){this.$tool=this.dom("<div>").addClass(this.prefix+"-form-item").dataset("instance",this)},_buildLabel:function(){"checkbox"!==this.type&&this._has("label")&&(this.$label=this.dom("<label>").addClass(this.prefix+"-form-label").html(this.lang.parse(this.obj.label)),this.$tool.append(this.$label))},_getInputParam:function(t){return this.input&&void 0!==this.input[t]?this.input[t]:""},_get:function(t){return this.obj[t]},_has:function(t){return Object.prototype.hasOwnProperty.call(this.obj,t)},_observe:function(t){return t=Object.prototype.hasOwnProperty.call(t,"observer")?this.app.api(t.observer,t,this.name):t},_catchSetter:function(t){"keydown"===t.type&&13!==t.which||("keydown"===t.type&&t.preventDefault(),this.app.api(this.setter,this.popup))}}),t.add("module","lang",{init:function(){this.langKey=this.app.setting.get("editor.lang"),this.vars=this._build()},get:function(t){var e=this._get(t,this.vars);return void 0===(e=void 0===e&&"en"!==this.langKey?this._get(t,h.lang.en):e)?"":e},parse:function(t){if("string"==typeof t){var e=t.match(/## (.*?) ##/g);if(e)for(var i=0;i<e.length;i++){var s=e[i].replace(/^##\s/g,"").replace(/\s##$/g,"");t=t.replace(e[i],this.get(s))}}return t},_get:function(t,e){var i=t.split("."),t=1===i.length?e[t]:void 0!==e[i[0]]?e[i[0]][i[1]]:void 0;return t},_build:function(){var t=h.lang.en;return t="en"!==this.langKey?"undefined"!==h.lang[this.langKey]?h.lang[this.langKey]:t:t}}),t.add("module","setting",{init:function(){this.opts=this._build()},dump:function(){return this.opts},has:function(t){var e=t.split("."),t=1===e.length?void 0!==this.opts[t]:void 0!==this.opts[e[0]]&&void 0!==this.opts[e[1]];return t},set:function(t,e,i){void 0===this.opts[t]&&(this.opts[t]={}),void 0===i?this.opts[t]=e:this.opts[t][e]=i},get:function(t){var e=t.split("."),t=1===e.length?this.opts[t]:void 0!==this.opts[e[0]]?this.opts[e[0]][e[1]]:void 0;return t},_build:function(){var t=h.extend(!0,{},h.opts,this.app.initialSettings);return h.extend(!0,t,h.settings)}}),t.add("module","container",{init:function(){this.blurclass=this.prefix+"-in-blur",this.focusclass=this.prefix+"-in-focus"},start:function(){this._buildMain(),this._buildContainers(this.$main,this.opts.containers.main),this._buildBSModal()},stop:function(){this.$main.remove()},get:function(t){return this["$"+t]},setFocus:function(){this.$main.removeClass(this.blurclass).addClass(this.focusclass)},setBlur:function(){this.$main.removeClass(this.focusclass).addClass(this.blurclass)},isFocus:function(){return this.$main.hasClass(this.focusclass)},_buildMain:function(){this.$main=this.dom("<div>").attr(this.prefix+"-uuid",this.uuid),this.$main.addClass(this.prefix+"-container "+this.prefix+"-container-"+this.uuid),this.app.$element.after(this.$main)},_buildContainers:function(t,e){for(var i=0;i<e.length;i++){var s=e[i],n="$"+s;this[n]=this._createContainer(s),void 0!==this.opts.containers[s]&&this._buildContainers(this[n],this.opts.containers[s]),t.append(this[n])}},_buildBSModal:function(){this.opts.bsmodal=0!==this.$main.closest(".modal-dialog").length},_createContainer:function(t){return this.dom("<div>").addClass(this.prefix+"-"+t+"-container")}}),t.add("module","accessibility",{start:function(){this._buildRole(),this._buildLabel()},_buildRole:function(){this.app.editor.getEditor().attr({"aria-labelledby":this.prefix+"-voice",role:"presentation"})},_buildLabel:function(){var t=this.lang.get("accessibility.help-label"),t=this._createLabel(t);this.app.container.get("main").prepend(t)},_createLabel:function(t){var e=this.dom("<span />").addClass(this.prefix+"-voice-label");return e.attr({id:this.prefix+"-voice-"+this.uuid,"aria-hidden":!1}),e.html(t),e}}),t.add("module","utils",{isMobile:function(){return"ontouchstart"in document.documentElement},createInvisibleChar:function(){return document.createTextNode(this.opts.markerChar)},searchInvisibleChars:function(t){return t.search(/^\uFEFF$/g)},removeInvisibleChars:function(t){return t.replace(/\uFEFF/g,"")},wrap:function(t,e){var i=this.dom("<div>").html(t);return e(i),t=i.html(),i.remove(),t},extendArray:function(t,e){if(t=t.concat(t),e)for(var i=0;i<e.length;i++)t.push(e[i]);return t},removeFromArrayByValue:function(t,e){var i;e=Array.isArray(e)?e:[e];for(var s=0;s<e.length;s++)-1<(i=t.indexOf(e[s]))&&t.splice(i,1);return t},sumOfArray:function(t){return t.reduce(function(t,e){return parseInt(t)+parseInt(e)},0)},getObjectIndex:function(t,e){return Object.keys(t).indexOf(e)},insertToObject:function(s,n,a,o){return Object.keys(a).reduce(function(t,e,
1i){return i===o&&(t[s]=n),t[e]=a[e],t},{})},getRandomId:function(){for(var t="",e="abcdefghijklmnopqrstuvwxyz0123456789",i=0;i<12;i++)t+=e.charAt(Math.floor(Math.random()*e.length));return t},escapeRegExp:function(t){return t.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")},capitalize:function(t){return(t=t.toLowerCase()).charAt(0).toUpperCase()+t.slice(1)},extendData:function(t,e){for(var i in e)t="elements"===i?this._extendDataElements(t,e[i]):this._setData(t,i,e[i]);return t},_extendDataElements:function(s,t){return this.dom(t).each(function(t){var e,i;"FORM"===t.get().tagName?(e=t.serialize(!0),Object.keys(e).forEach(function(t){s=this._setData(s,t,e[t])}.bind(this))):(i=t.attr("name")?t.attr("name"):t.attr("id"),s=this._setData(s,i,t.val()))}.bind(this)),s},_setData:function(t,e,i){return t instanceof FormData?t.append(e,i):t[e]=i,t}}),t.add("module","paragraphizer",{init:function(){this.remStart="#####replace",this.remEnd="#####";this.tags=this.opts.tags.parser.concat(["form","audio","figcaption","object","style","script","iframe","select","input","textarea","button","option","map","area","math","fieldset","legend","hgroup","nav","details","menu","summary"])},paragraphize:function(t){for(var e=[],i=[],s=(t=this._storeTags(t,e),t=(t=this.app.content.storeComments(t,i)).trim(),""),n=(t=(t=(t=(t=(t=(t=this._trimLinks(t)).replace(/xparagraphmarkerz(?:\r\n|\r|\n)$/g,"")).replace(/xparagraphmarkerz$/g,"")).replace(/xparagraphmarkerz(?:\r\n|\r|\n)/g,"\n")).replace(/xparagraphmarkerz/g,"\n")).replace(/[\n]+/g,"\n")).split("\n"),a=0;a<n.length;a++)s+="<p>"+n[a].trim()+"</p>\n";return t=(t=(t=(t=s.replace(/\n$/,"")).replace(new RegExp("<p>\\s+#####","gi"),"#####")).replace(new RegExp("<p>#####","gi"),"#####")).replace(new RegExp("#####</p>","gi"),"#####"),t=this._restoreTags(t,e),t=(t=(t=(t=(t=(t=this.app.content.restoreComments(t,i)).replace(/<(p|h1|h2|h3|h4|h5|h6|li|td|th)(.*?)>[\s\n]*<\/\1>/gi,"<$1$2></$1>")).replace(/<p(.*?)><\/?br\s?\/?><\/p>/gi,"<p$1></p>")).replace(/<div(.*?)><\/?br\s?\/?><\/div>/gi,"<div$1></div>")).replace(/<\/?br\s?\/?><\/div>/gi,"</div>")).replace(/<\/?br\s?\/?><\/li>/gi,"</li>")},_storeTags:function(t,i){return this.app.utils.wrap(t,function(t){t.find(this.tags.join(", ")).each(function(t,e){this._replaceTag(t,e,i)}.bind(this))}.bind(this))},_restoreTags:function(t,e){for(var i=0;i<e.length;i++){var s=e[i].replace(/\$/gi,"&#36;");t=t.replace(this.remStart+i+this.remEnd,s)}return t},_replaceTag:function(t,e,i){t=t.get(),e=document.createTextNode(this.remStart+e+this.remEnd+"xparagraphmarkerz");i.push(t.outerHTML),t.parentNode.replaceChild(e,t)},_trimLinks:function(t){return this.app.utils.wrap(t,function(t){t.find("a").each(this._trimLink.bind(this))}.bind(this))},_trimLink:function(t){t.html(t.html().trim())}}),t.add("module","element",{is:function(t,e,i){var s=!1,t="text"===e?t:this._getNode(t);return"inline"===e?s=this._isElement(t)&&this._isInlineTag(t.tagName,i):"blocks"===e?s=this._isElement(t)&&t.hasAttribute("data-"+this.prefix+"-type"):"blocks-first"===e?s=this._isElement(t)&&t.hasAttribute("data-"+this.prefix+"-first-level"):"block"===e?s=this._isElement(t)&&this._isBlockTag(t.tagName,i):"element"===e?s=this._isElement(t):"text"===e?s="string"==typeof t&&!/^\s*<(\w+|!)[^>]*>/.test(t)||this.isTextNode(t):"list"===e?s=this._isElement(t)&&-1!==["ul","ol"].indexOf(t.tagName.toLowerCase()):"heading"===e&&(s=this._isElement(t)&&-1!==["h1","h2","h3","h4","h5","h6"].indexOf(t.tagName.toLowerCase())),s},isEmptyOrImageInline:function(t){var e,i,s,t=this.dom(t).get();return!!(t&&3!==t.nodeType&&(e=t.tagName.toLowerCase(),i="false"===t.getAttribute("contenteditable"),(s=this.is(t,"inline"))&&this.isEmpty(t)||s&&i||-1!==["svg","img"].indexOf(e)))},isEmpty:function(t){t=this._getNode(t);return!!t&&(3===t.nodeType?""===t.textContent.trim().replace(/\n/,""):""===t.innerHTML)},isTag:function(t,e){return this._getNode(t).tagName.toLowerCase()===e},isTextNode:function(t){t=this._getNode(t);return t&&t.nodeType&&3===t.nodeType},isVisible:function(t){t=this._getNode(t);return!!(t.offsetWidth||t.offsetHeight||t.getClientRects().length)},isScrollVisible:function(t){var e=this.app.scroll.getTarget(),t=this.dom(t),e=e.scrollTop()+e.height();return t.offset().top<=e},getFirstLevel:function(t){return this.dom(t).closest("[data-"+this.prefix+"-first-level]")},getDataBlock:function(t){return this.dom(t).closest("[data-"+this.prefix+"-type]")},getType:function(t){return this.dom(t).attr("data-"+this.prefix+"-type")},getAllInlines:function(t){for(var e=[],i=t;i;)this.is(i,"inline")&&e.push(i),i=i.parentNode;return e},getClosest:function(t,e){return this.dom(t).closest(this.getTypesSelector(e))},getParents:function(t,e){return this.dom(t).parents(this.getTypesSelector(e))},getChildren:function(t,e){return this.dom(t).find(this.getTypesSelector(e))},getTypesSelector:function(t){return"[data-"+this.prefix+"-type="+t.join("],[data-"+this.prefix+"-type=")+"]"},hasClass:function(t,e){e="string"==typeof e?[e]:e;for(var i=this.dom(t),s=e.length,n=0,a=0;a<s;a++)i.hasClass(e[a])&&n++;return s===n},scrollTo:function(t,e){var i,s;this.isScrollVisible(t)||(e=e||60,t=t.offset(),i=this.app.scroll.getTarget(),s=t.top-e,i.scrollTop(s),setTimeout(function(){i.scrollTop(s)},1))},replaceToTag:function(t,n,a){return this.dom(t).replaceWith(function(t){var e=this.dom("<"+n+">");if(a||e.append(t.innerHTML),t.attributes)for(var i=t.attributes,s=0;s<i.length;s++)e.attr(i[s].nodeName,i[s].value);if(a)for(;0<t.childNodes.length;)e.append(this.dom(t.firstChild));return e}.bind(this))},split:function(t){var e=this.dom(t),i=(t=e.get()).tagName.toLowerCase(),s=this.app.content.extractHtmlFromCaret(t),i=(s.nodeType&&11===s.nodeType&&(s=this.dom(s.childNodes)),this.dom("<"+i+" />")),t=((i=this.cloneAttrs(t,i)).append(s),e.after(i),e.children().last(
1)),s=(this.is(t,"inline")&&(s=t.html(),""===(s=this.app.utils.removeInvisibleChars(s)))&&t.remove(),this.getType(i));return s&&this.app.create("block."+s,i,!0),""===e.html()&&e.remove(),i},cloneEmpty:function(t){t=this.dom(t).get().tagName.toLowerCase();return this.dom("<"+t+">")},cloneAttrs:function(t,e){for(var i=this.dom(e),s=this._getNode(t).attributes,n=s.length;n--;){var a=s[n];i.attr(a.name,a.value)}return i},getAttrs:function(t){var e=this._getNode(t),i={};if(null!=e.attributes&&e.attributes.length)for(var s=0;s<e.attributes.length;s++){var n=e.attributes[s].nodeValue,n=this._isNumber(n)?parseFloat(n):this._getBooleanFromStr(n);i[e.attributes[s].nodeName]=n}return i},removeEmptyAttrs:function(t,e){var t=this.dom(t),e=e.join(" "),i=!1;return void 0===t.attr(e)||null===t.attr(e)?i=!0:""===t.attr(e)&&(t.removeAttr(e),i=!0),i},getBlocks:function(t,e,i){var s=this._getNode(t).childNodes,n=[],a=e||this.opts.tags.parser;i&&(a=this.app.utils.extendArray(a,i));for(var o=0;o<s.length;o++)1===s[o].nodeType&&-1!==a.indexOf(s[o].tagName.toLowerCase())&&n.push(s[o]);return n},hasBlocks:function(t){return 0!==this.getBlocks(t).length},hasTextSiblings:function(t){var t=this._getNode(t),e=t.previousSibling&&3===t.previousSibling.nodeType&&!this.isEmpty(t.previousSibling),t=t.nextSibling&&3===t.nextSibling.nodeType&&!this.isEmpty(t.nextSibling);return e||t},_getNode:function(t){return this.dom(t).get()},_getBooleanFromStr:function(t){return"true"===t||"false"!==t&&t},_isBlockTag:function(t,e){return-1!==this.app.utils.extendArray(this.opts.tags.block,e).indexOf(t.toLowerCase())},_isInlineTag:function(t,e){return-1!==this.app.utils.extendArray(this.opts.tags.inline,e).indexOf(t.toLowerCase())},_isElement:function(t){return t&&t.nodeType&&1===t.nodeType},_isTag:function(t){return void 0!==t&&t},_isNumber:function(t){return!isNaN(t)&&!isNaN(parseFloat(t))}}),t.add("module","scroll",{init:function(){this.scrolltop=!1},save:function(){this.scrolltop=this.getTarget().scrollTop()},restore:function(){!1!==this.scrolltop&&(this.getTarget().scrollTop(this.scrolltop),this.scrolltop=!1)},isTarget:function(){return this.opts.editor.scrollTarget!==window},getTarget:function(){return this.dom(this.opts.editor.scrollTarget)}}),t.add("module","button",{init:function(t,e,i,s){"object"==typeof t?(this.name=t.name,this.obj=e,this._buildFromElement(t.element)):t&&(this.type=s||!1,this.name=t,s=this._observe(e),this.obj=void 0===s?e:s,this.obj)&&this._build(t,i)},setColor:function(t,e){t=t.getName();"background"!==t&&"text-color"!==t||this.setBackground(e["background"===t?"background-color":"color"])},isButton:function(){return!0},isAddbar:function(){return this._has("addbar")},isControl:function(){return this._has("control")},getName:function(){return this.name},getTitle:function(){return this.title},getParams:function(){return!!this._has("params")&&this.obj.params},getOffset:function(){return this.$button.offset()},getDimension:function(){return{width:this.$button.width(),height:this.$button.height()}},getElement:function(){return this.$button},setBackground:function(t){this._background("add",t)},resetBackground:function(){this._background("remove","")},_has:function(t){return Object.prototype.hasOwnProperty.call(this.obj,t)},_observe:function(t){return t=Object.prototype.hasOwnProperty.call(t,"observer")?this.app.api(t.observer,t,this.name):t},_background:function(t,e){this.$icon["remove"===t?"removeClass":"addClass"](this.prefix+"-button-icon-color").css({"background-color":e,color:""!==e?this.app.color.invert(e):""})},_buildFromElement:function(t){this.$button=this.dom(t),this.$button.addClass(this.prefix+"-button-target"),this._buildData()},_build:function(t,e){this._buildTitle(),this._buildElement(),this._buildIcon(),this._buildData(e)},_buildData:function(t){this.$button.attr({tabindex:"-1","data-name":this.name,"data-command":this.obj.command||!1}),this.$button.dataset("instance",this);var e=this._has("command")?"_catch":"_stop";this.$button.on("click."+this.prefix+"-button",this[e].bind(this)),this.$button.on("dragstart."+this.prefix+"-button",function(t){t.preventDefault()}
1),t&&(this._buildTooltip(),this._buildBackground(),this._buildPosition(t))},_buildTitle:function(){this.title=void 0!==this.obj.title?this.lang.parse(this.obj.title):""},_buildElement:function(){this.$button=this.dom('<a href="#"></a>'),this.$button.addClass(this.prefix+"-button "+this.prefix+"-button-target"),this.type&&this.$button.addClass(this.prefix+"-button-"+this.type),this._has("classname")&&this.$button.addClass(this.obj.classname)},_buildIcon:function(){var t=this._has("icon"),e='<span class="'+this.prefix+"-icon-"+this.name+'"></span>';this.$icon=this._buildIconElement(),t&&!0!==this.obj.icon&&(e=-1!==this.obj.icon.search(/</)?this.obj.icon:'<span class="'+this.prefix+"-icon-"+this.obj.icon+'"></span>'),this.opts.buttons.icons&&void 0!==this.opts.buttons.icons[this.name]&&(e=this.opts.buttons.icons[this.name]),this.$icon.append(e),this.$button.append(this.$icon)},_buildIconElement:function(){return this.dom("<span>").addClass(this.prefix+"-button-icon")},_buildTooltip:function(){("toolbar"===this.type||"context"===this.type&&this.opts.tooltip.context)&&this.app.tooltip.build(this.$button,this.title)},_buildBackground:function(){this._has("background")&&this.setBackground(this.obj.background)},_buildPosition:function(t){var e,i;this._has("position")?"first"===(e=this.obj.position)?t.prepend(this.$button):"object"==typeof e&&(i=e[e=Object.prototype.hasOwnProperty.call(e,"after")?"after":"before"],(i=this._findPositionElement(i,t))?i[e](this.$button):t.append(this.$button)):t.append(this.$button)},_findPositionElement:function(t,e){var i;if(Array.isArray(t))for(var s=0;s<t.length&&0===(i=e.find("[data-name="+t[s]+"]")).length;s++);else i=e.find("[data-name="+t+"]");return 0!==i.length?i:0},_stop:function(t){t.preventDefault(),t.stopPropagation()},_catch:function(t){t.preventDefault(),t.stopPropagation();var e,i,s=this.dom(t.target).closest("."+this.prefix+"-button-target");s.hasClass("disable")||(this.app.editor.setFocus(),e=s.attr("data-command"),i=s.attr("data-name"),s=s.dataget("instance"),this.app.api(e,this.getParams(),s,i,t),this.app.tooltip.close())}}),t.add("module","tooltip",{init:function(){this.classname=this.prefix+"-tooltip",this.eventname=this.prefix+"-button-"+this.uuid},stop:function(){this.close()},build:function(t,e){(e=this._cleanTitle(e))&&(t.attr("data-tooltip",e),t.on("mouseover."+this.eventname,this.open.bind(this)),t.on("mouseout."+this.eventname,this.close.bind(this)))},open:function(t){t=this._getButton(t);this.app.popup.isOpen()||t.hasClass("disable")||(this.$tooltip=this._create(t),this._setPosition(t),this._fixBSModal(),this.app.$body.append(this.$tooltip))},close:function(){this.app.$body.find("."+this.classname).remove()},_create:function(t){return this.dom("<span>").addClass(this.classname).html(t.attr("data-tooltip"))},_cleanTitle:function(t){return!!t&&t.replace(/(<([^>]+)>)/gi,"")},_setPosition:function(t){var e=t.offset(),t=t.height();this.$tooltip.css({top:e.top+t+"px",left:e.left+"px"})},_fixBSModal:function(){this.opts.bsmodal&&this.$tooltip.css("z-index",1060)},_getButton:function(t){return this.dom(t.target).closest("."+this.prefix+"-button-target")}}),t.add("module","fragment",{build:function(t){return this.is(t)?t:this.create(t)},insert:function(t){var e,i=this.app.selection.get();i.range&&(i.collapsed?3!==(e=i.range.startContainer).nodeType&&"BR"===e.tagName&&e.parentNode.removeChild(e):i.range.deleteContents(),t.frag?i.range.insertNode(t.frag):i.range.insertNode(t))},createContainer:function(t){var e=this.dom("<div>");return"string"==typeof t?e.html(t):e.append(this.dom(t).clone(!0)),e.get()},create:function(t){for(var e,i,s="string"==typeof t?this.createContainer(t):t,n=document.createDocumentFragment(),a=[],o=0;r=s.firstChild;){o++;var r=n.appendChild(r);1===o&&(e=r),a.push(r),i=r}return{frag:n,first:e,last:i,nodes:a}},is:function(t){return"object"==typeof t&&t.frag}}),t.add("module","clipboard",{getContent:function(t){var e=this.isPlainText(t)?"text/plain":"text/html",t=t.getData(e);return"text/plain"==e?this.app.content.escapeHtml(t):t},setContent:function(t,e,i){t=t.clipboardData;e=this.app.parser.unparse(e),e='<meta type="'+this.prefix+'-editor"/>'+e,i=i||this.app.content.getTextFromHtml(e,{nl:!0}),t.setData("text/html",e),t.setData("text/plain",i)},isPlainText:function(t){var e=t.getData("text/plain"),t=t.getData("text/html");return(!t||""===t.trim())&&null!==e}}),t.add("module","codemirror",{init:function(){this.cm=!1},create:function(t){var e,i;if(this.is())return e="object"==typeof this.opts.codemirror?this.opts.codemirror:{},i=this.opts.codemirrorSrc||CodeMirror,this.cm=i.fromTextArea(this.dom(t.el).get(),e),t.height&&this.cm.setSize(null,t.height),t.focu
1s&&this.cm.focus(),this.cm},destroy:function(){this.cm&&(this.cm.toTextArea(),this.cm=!1)},is:function(){return this.opts.codemirror},val:function(t){return t=this.is()&&this.cm?this.cm.getValue():t}}),t.add("class","upload",{defaults:{type:"image",box:!1,url:!1,cover:!0,name:"file",data:!1,multiple:!0,placeholder:!1,hidden:!0,target:!1,success:!1,error:!1,remove:!1,trigger:!1,input:!1},init:function(t,e,i){this.eventname=this.prefix+"-upload",t&&this._build(t,e,i)},send:function(t,e,i,s){this.p=this._buildParams(i,s),this._send(t,e)},complete:function(t,e){this._complete(t,e)},setImage:function(t){this.p.input||(this.$image&&this.$image.remove(),this.$remove&&this.$remove.remove(),""===t?this.$placeholder.show():(this.$placeholder.hide(),this._buildImage(t),this.p.remove&&this._buildRemove()))},_build:function(t,e,i){this.p=this._buildParams(e,i),this.$element=this.dom(t),"INPUT"===this.$element.get().tagName?this._buildByInput():this._buildByBox()},_buildImage:function(t){this.$image=this.dom("<img>"),this.$image.attr("src",t),this.$box.append(this.$image),!1===this.p.input&&(this.$box.off("click."+this.eventname),this.$image.on("click."+this.eventname,this._click.bind(this)))},_buildRemove:function(){this.$remove=this.dom("<span>"),this.$remove.addClass(this.prefix+"-upload-remove"),this.$remove.on("click",this._removeImage.bind(this)),this.$box.append(this.$remove)},_buildParams:function(t,e){return t=h.extend(!0,this.defaults,t),e&&(t.trigger=e),t},_buildByInput:function(){this.$input=this.$element,this.p.box?(this._buildBox(),this._buildPlaceholder()):this.p.input=!0,this._buildAccept(),this._buildMultiple(),this._buildEvents()},_buildByBox:function(){this._buildInput(),this._buildAccept(),this._buildMultiple(),this._buildBox(),this._buildPlaceholder(),this._buildEvents()},_buildBox:function(){this.$box=this.dom("<div>").addClass(this.prefix+"-form-upload-box"),this.$element.before(this.$box),!1===this.p.cover&&this.$box.addClass(this.prefix+"-form-upload-cover-off"),this.p.hidden&&this.$element.hide()},_buildPlaceholder:function(){this.p.placeholder&&(this.$placeholder=this.dom("<span>").addClass(this.prefix+"-form-upload-placeholder"),this.$placeholder.html(this.p.placeholder),this.$box.append(this.$placeholder))},_buildInput:function(){this.$input=this.dom("<input>"),this.$input.attr("type","file"),this.$input.attr("name",this._getUploadParam()),this.$input.hide(),this.$element.before(this.$input)},_buildAccept:function(){var t;"image"===this.p.type&&(t=this.opts.image.types.join(","),this.$input.attr("accept",t))},_buildMultiple:function(){"image"===this.p.type&&(this.p.multiple?this.$input.attr("multiple","multiple"):this.$input.removeAttr("multiple"))},_buildEvents:function(){this.$input.on("change."+this.eventname+"-"+this.uuid,this._change.bind(this)),!1===this.p.input&&(this.$box.on("click."+this.eventname,this._click.bind(this)),this.$box.on("drop."+this.eventname,this._drop.bind(this)),this.$box.on("dragover."+this.eventname,this._dragover.bind(this)),this.$box.on("dragleave."+this.eventname,this._dragleave.bind(this)))},_buildData:function(t,e,i){if("single"===this.p.multiple)i.append(t,e[0]);else if(this.p.multiple)for(var s=0;s<e.length;s++)i.append(t+"[]",e[s]);else i.append(t+"[]",e[0]);return i},_removeImage:function(t){t&&(t.preventDefault(),t.stopPropagation()),this.$image&&this.$image.remove(),this.$remove&&this.$remove.remove(),this.$placeholder.show(),!1===this.p.input&&this.$box.on("click."+this.eventname,this._click.bind(this)),t&&this.app.api(this.p.remove,t)},_getUploadParam:function(){return this.p.name},_click:function(t){t.preventDefault(),this.$input.click()},_change:function(t){this._send(t,this.$input.get().files)},_drop:function(t){t.preventDefault(),this._send(t)},_dragover:function(t){return t.preventDefault(),this._setStatus("hover"),!1},_dragleave:function(t){return t.preventDefault(),this._removeStatus(),!1},_setStatus:function(t){!this.p.input&&this.p.box&&(this._removeStatus(),this.$box.addClass(this.prefix+"-form-upload-"+t))},_removeStatus:function(){if(!this.p.input&&this.p.box)for(var t=["hover","error"],e=0;e<t.length;e++)this.$box.removeClass(this.prefix+"-form-upload-"+t[e])},_send:function(t,e){e=e||t.dataTransfer.files;var i=new FormData,s=this._getUploadParam(),i=this._buildData(s,e,i);
1i=this.app.utils.extendData(i,this.p.data),this._sendData(t,e,i)},_sendData:function(e,i,s){"function"==typeof this.p.url?this.p.url.call(this.app,this,{data:s,files:i,e:e}):(this.app.progress.show(),this.ajax.post({url:this.p.url,data:s,before:function(t){if(this.app.broadcast("upload.before.send",{xhr:t,data:s,files:i,e:e}).isStopped())return this.app.progress.hide(),!1}.bind(this),success:function(t){this._complete(t,e)}.bind(this),error:function(t){this._complete(t,e)}.bind(this)}))},_complete:function(t,e){t&&t.error?(this._setStatus("error"),this.p.error&&(this.app.broadcast("upload.error",{response:t}),this.app.api(this.p.error,t,e))):(this._removeStatus(),this._trigger(t),this.p.success&&(this.app.broadcast("upload.complete",{response:t}),this.app.api(this.p.success,t,e))),setTimeout(function(){this.app.progress.hide()}.bind(this),500)},_trigger:function(t){var e;this.p.trigger&&t&&t.url&&(e=this.p.trigger.instance)[this.p.trigger.method].call(e,t.url)}}),t.add("module","progress",{stop:function(){this.hide()},show:function(){this.hide(),this.$progress=this.dom("<div>").addClass(this.prefix+"-editor-progress"),this.$progress.attr("id",this.prefix+"-progress"),this.$progressBar=this.dom("<span>"),this.$progress.append(this.$progressBar),this.app.$body.append(this.$progress)},hide:function(){this.app.$body.find("#"+this.prefix+"-progress").remove()}}),t.add("module","autosave",{send:function(){this.opts.autosave.url&&this._sending()},_getName:function(){var t=this.opts.autosave.name||(t=this.app.$element.attr("name"))||"content"+this.uuid;return t},_sending:function(){var e=this._getName(),i={};i[e]=this.app.$element.val(),i=this.app.utils.extendData(i,this.opts.autosave.data),this.ajax.request(this.opts.autosave.method,{url:this.opts.autosave.url,data:i,before:function(t){if(this.app.broadcast("autosave.before.send",{xhr:t,name:e,data:i}).isStopped())return!1}.bind(this),success:function(t){this._complete(t,e,i)}.bind(this)})},_complete:function(t,e,i){var s=t&&t.error?"autosave.error":"autosave.send";this.app.broadcast(s,{name:e,data:i,response:t})}}),t.add("module","statusbar",{init:function(){this.classname=this.prefix+"-statusbar"},start:function(){this._build()},add:function(t,e){return this.update(t,e)},update:function(t,e){var i=this.get(t);return(i=0===i.length?this._buildItem(t):i).html(e)},get:function(t){return this.$statusbar.find(t?"[data-name="+t+"]":"[data-name]")},remove:function(t){this.get(t).remove()},clear:function(){this.$statusbar.html("")},_build:function(){this.$statusbar=this.dom("<div>").attr("dir",this.opts.editor.direction),this.$statusbar.addClass(this.classname+" "+this.classname+"-"+this.uuid),this.app.container.get("statusbar").append(this.$statusbar)},_buildItem:function(t){var e=this.dom("<span>").addClass(this.classname+"-item");return e.attr("data-name",t),this.$statusbar.append(e),e}}),t.add("module","shortcut",{init:function(){if(this.opts.shortcutsRemove)for(var t=this.opts.shortcutsRemove,e=0;e<t.length;e++)this.remove(t[e]);this.shortcuts=this.opts.shortcuts,this.hotkeys={8:"backspace",9:"tab",10:"return",13:"return",16:"shift",17:"ctrl",18:"alt",19:"pause",20:"capslock",27:"esc",32:"space",33:"pageup",34:"pagedown",35:"end",36:"home",37:"left",38:"up",39:"right",40:"down",45:"insert",46:"del",59:";",61:"=",96:"0",97:"1",98:"2",99:"3",100:"4",101:"5",102:"6",103:"7",104:"8",105:"9",106:"*",107:"+",109:"-",110:".",111:"/",112:"f1",113:"f2",114:"f3",115:"f4",116:"f5",117:"f6",118:"f7",119:"f8",120:"f9",121:"f10",122:"f11",123:"f12",144:"numlock",145:"scroll",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},this.hotkeysShiftNums={"`":"~",1:"!",2:"@",3:"#",4:"$",5:"%",6:"^",7:"&",8:"*",9:"(",0:")","-":"_","=":"+",";":": ","'":'"',",":"<",".":">","/":"?","\\":"|"}},add:function(t,e){this.shortcuts[t]=e},remove:function(t){this.opts.shortcutsBase=this._remove(t,this.opts.shortcutsBase),this.opts.shortcuts=this._remove(t,this.opts.shortcuts)},popup:function(t,e){var i=/(Mac|iPhone|iPod|iPad)/i.test(navigator.platform)?"<b>&#8984;</b>":"ctrl",s={},n=this._buildPopupItems(s,0,this.opts.shortcutsBase,i,"base");this._buildPopupItems(s,n,this.opts.shortcuts,i),this.app.popup.create("shortcuts",{width:"360px",items:s}),this.app.popup.open({button:e})},handle:function(t){if((this.triggered=!1)===this.shortcuts)return!t.ctrlKey&&!t.metaKey||66!==t.which&&73!==t.which||t.preventDefault(),!0;if(t.ctrlKey||t.metaKey||t.shoftKey||t.altKey)for(var e in this.shortcuts)this.shortcuts.hasOwnProperty(e)&&this._build(t,e,this.shortcuts[e]);return this.triggered}
1,_buildPopupItems:function(t,e,i,s,n){for(var a in i)if(i.hasOwnProperty(a)){for(var o=this.dom("<div>").addClass(this.prefix+"-popup-shortcut-item"),r="base"===n?i[a]:i[a].title,r=this.dom("<span>").addClass(this.prefix+"-popup-shortcut-title").html(this.lang.parse(r)),p=this.dom("<span>").addClass(this.prefix+"-popup-shortcut-kbd"),l=("base"===n?a:i[a].name).replace("meta",s).split("+"),h=0;h<l.length;h++)l[h]="<span>"+l[h]+"</span>";p.html(l.join("+")),o.append(r),o.append(p),t[e]={html:o},e++}return e},_build:function(t,e,i){for(var s=e.split(","),n=s.length,a=0;a<n;a++)"string"!=typeof s[a]||Object.prototype.hasOwnProperty.call(i,"trigger")||this._handler(t,s[a].trim(),i)},_handler:function(t,e,i){e=e.toLowerCase().split(" ");for(var s=this.hotkeys[t.keyCode],n=91!==t.which&&String.fromCharCode(t.which).toLowerCase(),a="",o={},r=["meta","ctrl","alt","shift"],p=0;p<r.length;p++){var l=r[p];t[l+"Key"]&&s!==l&&(a+=l+"+")}93===t.keyCode&&(a+="meta+"),s&&(o[a+s]=!0),n&&(o[a+n]=!0,o[a+this.hotkeysShiftNums[n]]=!0,"shift+"===a)&&(o[this.hotkeysShiftNums[n]]=!0);for(var h=e.length,c=0;c<h;c++)if(o[e[c]])return t.preventDefault(),this.triggered=!0,void this.app.api(i.command,i.params,t)},_remove:function(i,s){return Object.keys(s).reduce(function(t,e){return e!==i&&(t[e]=s[e]),t},{})}}),t.add("module","offset",{get:function(t){t=this._getEl(t);var e,i=this.app.editor.getWinNode().getSelection(),s=!1;return i&&0<i.rangeCount&&(e=i.getRangeAt(0),t.contains(i.anchorNode))&&((i=e.cloneRange()).selectNodeContents(t),i.setEnd(e.startContainer,e.startOffset),s={start:t=i.toString().length,end:t+e.toString().length}),s},set:function(t,e){!1===e&&(e={start:0,end:0}),t=this._getEl(t);var i,s=0,n=this.app.editor.getDocNode().createRange(),a=[t],o=!1,r=!1;for(n.setStart(t,0),n.collapse(!0);!r&&(i=a.pop());)if(3===i.nodeType){var p=s+i.length;!o&&e.start>=s&&e.start<=p&&(n.setStart(i,e.start-s),o=!0),o&&e.end>=s&&e.end<=p&&(n.setEnd(i,e.end-s),r=!0),s=p}else for(var l=i.childNodes.length;l--;)a.push(i.childNodes[l]);this.app.selection.setRange(n)},_getEl:function(t){return(t?this.dom(t):this.app.editor.getLayout()).get()}}),t.add("module","marker",{build:function(t){t=this.dom("<span>").attr("id","selection-marker-"+t);return t.addClass(this.prefix+"-selection-marker"),t.html(this.opts.markerChar),t.get()},insert:function(){this.remove();var t,e,i,s=this.app.selection.get(),n=!s.collapsed;s.range&&(t=this.build("start"),e=this.build("end"),i=s.range.cloneRange(),n&&(i.collapse(!1),i.insertNode(e)),i.setStart(s.range.startContainer,s.range.startOffset),i.collapse(!0),i.insertNode(t),s.range.setStartAfter(t),n&&s.range.setEndBefore(e),this.app.selection.setRange(s.range))},restore:function(){var t,e,i=this.find("start"),s=this.find("end"),n=this.app.selection.get(),n=n.range||this.app.editor.getDocNode().createRange();i&&(t=!!s&&s.previousSibling,e=(!(e=i.nextSibling)||3!==e.nodeType||""!==e.textContent.replace(/[\n\t]/g,""))&&e,s?e&&"selection-marker-end"===e.id?this._restoreInject(n,i):t&&e?(n.selectNodeContents(t),n.collapse(!1),n.setStart(e,0)):t&&!e?(n.selectNodeContents(t),n.collapse(!1),n.setStartAfter(i)):(n.setStartAfter(i),n.setEndBefore(s)):e?(n.selectNodeContents(e),n.collapse(!0)):this._restoreInject(n,i),this.app.selection.setRange(n),t=i&&s?2:1,e={start:(e=this.app.offset.get()).start-t,end:e.end-t},i&&i.parentNode.removeChild(i),s&&s.parentNode.removeChild(s),this.app.editor.setWinFocus(),this.app.offset.set(!1,e))},find:function(t){t=this.app.editor.getLayout().find("#selection-marker-"+t);return 0!==t.length&&t.get()},remove:function(){var t=this.find("start"),e=this.find("end");t&&t.parentNode.removeChild(t),e&&e.parentNode.removeChild(e)},_restoreInject:function(t,e){var i=this.app.utils.createInvisibleChar();this.dom(e).after(i),t.selectNodeContents(i),t.collapse(!1)}}),t.add("module","state",{init:function(){this.started=!1,this.storage=!1,this.state=!1,this.passed=!0,this.undoStorage=[],this.redoStorage=[]},load:function(){this.clear(),this.trigger(!0)},stop:function(){this.clear()},clear:function(){this.storage=!1,this.state=!1,this.passed=!0,this.undoStorage=[],this.redoStorage=[]},get:function(){return this.undoStorage},add:function(t){t&&(t.ctrlKey||t.metaKey||this._isUndo(t)||this._isRedo(t))||!this.app.observer.trigger||(this.state=this._createState(),!1===this.started&&(this._setState(this.state,0),this.started=!0))},trigger:function(t){var e;this.passed&&(e=this._createState(),this.state?e=this.state:this.state||t||(e=this.storage,this.started=!0),this._addState(e),this.storage=this._createState(),this.state=!1)},listen:function(t){return this._isUndo(t)?(t.preventDefault(),this.undo(),!0):this._isRedo(t)?(t.preventDefault(),this.redo(),!0):void(this.passed=!0)},undo:function(){var t,e;this._hasUndo()&&(this.passed=!1,t=this._getUndo(),this._setRedo(),e=this.app.parser.parse(t[0]),this.app.editor.getLayout().html(e.children()),this._rebuild(t,"undo"),e=!(!(e=this.app.block.get())||!e.isEditable())&&e.getBlock(),this.app.offset.set(e,t[1]))},redo:function(){var t,e;this._hasRedo()&&(this.passed=!1,t=this.redoStorage.pop(),this._addState({html:t[0],offset:t[1]}),e=this.app.parser.parse(t[0]),this.app.editor.getLayout().html(e.children()),this._rebuild(t,"redo"),e=!(!(e=this.app.block.get())||!e.isEditable())&&e.getBlock(),this.app.offset.set(e,t[1]))},_rebuild:function(t,e){this.app.editor.build(),this.app.editor.getLayout().find("."+this.prefix+"-block-state").each(function(t){this.app.block.set(t)}.bind(this)),this.app.broadcast("state."+e,{html:t[0],offset:t[1]})},_isUndo:function(t){var e=t.which;return(t.ctrlKey||t.metaKey)&&90===e&&!t.shiftKey&&!t.altKey},_isRedo:function(t){var e=t.which;return(t.ctrlKey||t.metaKey)&&(90===e&&t.shiftKey||89===e&&!t.shiftKey)&&!t.altKey},_hasUndo:function(){return 0!==this.undoStorage.length},_hasRedo:function(){return 0!==this.redoStorage.length},_getUndo:function(){return 1===this.undoStorage.length?this.undoStorage[0]:this.undoStorage.pop()},_createState:function(){var t=this.app.editor.getLayout().html(),t=this.app.utils.wrap(t,function(t){t.find("."+this.prefix+"-block-focus").addClass(this.prefix+"-block-state")}.bind(this)),e=this.app.block.get(),e=!(!e||!e.isEditable())&&e.getBlock();return{html:this.app.parser.unparse(t,!0),offset:this.app.offset.get(e)}},_setState:function(t,e){this.undoStorage[e]=[t.html,t.offset]},_addState:function(t){var e=this.undoStorage[this.undoStorage.length-1];void 0===e||e[0]!==t.html?(this.undoStorage.push([t.html,t.offset]),this._removeOverStorage()):e[1]=t.offset},_setRedo:function(){var t=this._createState();this.redoStorage.push([t.html,t.offset]),this.redoStorage=this.redoStorage.slice(0,this.opts.state.limit)}
1,_removeOverStorage:function(){this.undoStorage.length>this.opts.state.limit&&(this.undoStorage=this.undoStorage.slice(0,this.undoStorage.length-this.opts.state.limit))}}),t.add("module","sync",{build:function(){this.syncedHtml=this.app.$element.val()},trigger:function(){this.opts.editor.sync&&(this.typingTimer&&clearTimeout(this.typingTimer),this.typingTimer=setTimeout(function(){var t=this._getHtml();this.is(t)&&this._sync(t)}.bind(this),300))},invoke:function(){var t=this._getHtml();this.syncedHtml=t,this._sync(t)},is:function(t){var e=!1;return this.syncedHtml!==t&&(this.syncedHtml=t,e=!0),e},_getHtml:function(){var t=this.app.editor.getLayout().html();return this.app.parser.unparse(t)},_sync:function(t){t=this.app.broadcast("editor.before.change",{html:t});t.isStopped()||(this.app.$element.val(t.get("html")),this.app.autosave.send(),this.app.state.trigger(),this.app.broadcast("editor.change",t))}}),t.add("module","placeholder",{start:function(){this.placeholder=!1,this.$layout=this.app.editor.getLayout(),this._build()},handleClick:function(t){this.dom(t.target).hasClass(this.prefix+"-placeholder")&&(t.preventDefault(),t.stopPropagation(),this.app.editor.setFocus("start"))},trigger:function(){this.placeholder&&this.app.editor.isEmpty(!0)?this.show():this.hide()},toggle:function(){this.observerTimer&&clearTimeout(this.observerTimer),this.observerTimer=setTimeout(this.trigger.bind(this),10)},show:function(){this.$layout.addClass(this.prefix+"-placeholder")},hide:function(){this.$layout.removeClass(this.prefix+"-placeholder")},change:function(t){this.opts.placeholder=t,this._rebuild(),this.app.editor.isEmpty(!0)&&this.app.editor.setEmpty()},_build:function(){this._rebuild(),this.toggle()},_rebuild:function(){var t=this.opts.placeholder,e=this.app.$element.attr("placeholder");!1===t&&!e||(this.$layout.attr("placeholder",!1!==t?t:e),this.placeholder=!0)}}),t.add("module","list",{indent:function(){var t=this.app.selection.get(),e=this.app.selection.getBlock(),i=this.dom(e),s=i.prevElement(),n=s.get(),t=t.collapsed&&e&&n&&"LI"===n.tagName;return this.app.selection.save(e),t&&(e=(s=this.dom(n)).children("ul, ol"),n=i.closest("ul, ol"),0!==e.length?e.append(i):(e=n.get().tagName.toLowerCase(),(n=this.dom("<"+e+">")).append(i),s.append(n))),this.app.selection.restore(),t},outdent:function(){var t=this.app.selection.get(),e=this.app.selection.getBlock(),i=this.dom(e),s=!1;if(t.collapsed&&e){var t=i.parent(),n=t.closest("li"),a=i.prevElement(),o=i.nextElement(),a=a.get(),o=o.get(),r=!1===a,a=!1!==a&&!1!==o;if(this.app.selection.save(e),0!==n.length){if(a){for(var p=this._getAllNext(i.get()),l=this.dom("<"+t.get().tagName.toLowerCase()+">"),h=0;h<p.length;h++)l.append(p[h]);n.after(i),i.append(l)}else n.after(i),0===t.children().length?t.remove():r&&i.append(t);s=!0}this.app.selection.restore()}return s},_getAllNext:function(t){for(var e=[];t;){if(!(t=this.dom(t).nextElement().get()))return e;e.push(t)}return e}}),t.add("module","cleaner",{cleanHtml:function(t){t=this.app.broadcastHtml("editor.before.clean",t);var e,i,s={},n=this.opts.paste.blockTags.concat(this.opts.paste.inlineTags).concat(this.opts.paste.formTags),a=this._isPages(t),o=this._isHtmlMsWord(t),r=this._isEditor(t),n=(t=this.app.content.store(t,"embed",s,0),t=this.app.content.removeDoctype(t),t=(t=this.app.content.removeTags(t,this.opts.tags.denied)).trim(),t=this.app.content.removeComments(t),t=this.app.content.removeTagsWithContent(t,["script","style"]),t=a?this._cleanPages(t):t,t=o?t:this._cleanGDocs(t),t=this._encodePhp(t),t=this.app.content.removeTagsExcept(t,n),t=o?this._cleanMsWord(t):t,!1);return!r&&this.app.event.pasteEvent&&(t=this.app.content.restore(t,"embed",s),n=!0),r||(e=0!==this.opts.paste.keepClass.length?this.opts.paste.keepClass.join(","):"",i=0!==this.opts.paste.keepAttrs.length?this.opts.paste.keepAttrs.join(","):"",t=this.app.utils.wrap(t,function(t){t=t.find("*");t.not(e).removeAttr("class"),t.not(i).each(function(t){for(var e=t.get(),i=e.attributes,s=i.length-1;0<=s;s--){var n=i[s].name;"class"!==n&&"dir"!==n&&-1===n.search(/^data-/)&&("IMG"!==e.tagName||"src"!==n&&"alt"!==n)&&("A"!==e.tagName||"href"!==n&&"target"!==n)&&e.removeAttribute(n)}})})),n||(t=this.app.content.restore(t,"embed",s)),t=r?this.app.content.cacheStyle(t):this.app.content.removeStyleAttr(t),t=(t=(t=(t=(t=(t=this.app.content.removeEmptyInlines(t)).replace(/<figure[^>]*><\/figure>/gi,"")).replace(/<p>&nbsp;<\/p>/gi,"<p></p>")).replace(/<p><br\s?\/?><\/p>/gi,"<p></p>")).replace(/^<li/gi,"<ul><li")).replace(/<\/li>$/gi,"</li></ul>"),(o||a)&&(t=(t=t.replace(/<p><\/p>/gi,"")).replace(/<p>\s<\/p>/gi,"")),t=this.app.utils.wrap(t,function(t){t.find(".Apple-converted-s
1pace").unwrap(),t.find("ul, ol").each(this._placeListToItem.bind(this)),t.find("li p").unwrap()}.bind(this)),this.app.broadcastHtml("editor.clean",t)},_encodePhp:function(t){return t=(t=(t=t.replace("<?php","&lt;?php")).replace("<?","&lt;?")).replace("?>","?&gt;")},_isEditor:function(t){return t.match(new RegExp('meta\\stype="'+this.prefix+'-editor"',"i"))},_isHtmlMsWord:function(t){return t.match(/class="?Mso|style="[^"]*\bmso-|style='[^'']*\bmso-|w:WordDocument/i)},_isPages:function(t){return t.match(/name="Generator"\scontent="Cocoa\sHTML\sWriter"/i)},_placeListToItem:function(t){var t=t.get(),e=t.previousSibling;e&&"LI"===e.tagName&&((e=this.dom(e)).find("p").unwrap(),e.append(t))},_cleanPages:function(t){return t=(t=t.replace(/\sclass="s[0-9]"/gi,"")).replace(/\sclass="p[0-9]"/gi,"")},_cleanGDocs:function(t){return t=(t=(t=(t=(t=(t=-1!==t.search(/docs-internal-guid/i)?(t=this.app.utils.wrap(t,function(t){t.find("h1, h2, h3, h4, h5, h6").each(function(t){t.find("span").unwrap()})})).replace(/ dir="[^>]*"/gi,""):t).replace(/<b\sid="internal-source-marker(.*?)">([\w\W]*?)<\/b>/gi,"$2")).replace(/<b(.*?)id="docs-internal-guid(.*?)">([\w\W]*?)<\/b>/gi,"$3")).replace(/<span[^>]*(font-style:\s?italic;\s?font-weight:\s?(bold|600|700)|font-weight:\s?(bold|600|700);\s?font-style:\s?italic)[^>]*>([\w\W]*?)<\/span>/gi,"<b><i>$4</i></b>")).replace(/<span[^>]*font-style:\s?italic[^>]*>([\w\W]*?)<\/span>/gi,"<i>$1</i>")).replace(/<span[^>]*font-weight:\s?(bold|600|700)[^>]*>([\w\W]*?)<\/span>/gi,"<b>$2</b>")},_cleanMsWord:function(t){t=(t=(t=(t=(t=(t=t.replace(/<!--[\s\S]+?-->/gi,"")).trim()).replace(/<(!|script[^>]*>.*?<\/script(?=[>\s])|\/?(\?xml(:\w+)?|meta|link|style|\w:\w+)(?=[\s/>]))[^>]*>/gi,"")).replace(/<(\/?)s>/gi,"<$1strike>")).replace(/&nbsp;/gi," ")).replace(/<span\s+style\s*=\s*"\s*mso-spacerun\s*:\s*yes\s*;?\s*"\s*>([\s\u00a0]*)<\/span>/gi,function(t,e){return 0<e.length?e.replace(/./," ").slice(Math.floor(e.length/2)).split("").join(" "):""});for(var e="",i=(t=(t=(t=(t=(t=(t=this.app.utils.wrap(t,function(t){t.find("p").each(function(t){var e=/mso-list:\w+ \w+([0-9]+)/.exec(t.attr("style"));e&&t.attr("data-listLevel",parseInt(e[1],10))}),this._parseWordLists(t),t.find("[align]").removeAttr("align"),t.find("[name]").removeAttr("name"),t.find("span").each(function(t){var e=t.attr("style");/mso-list:Ignore/.exec(e)?t.remove():t.unwrap()}),t.find("[style]").removeAttr("style"),t.find("[class^='Mso']").removeAttr("class"),t.find("a").filter(function(t){return!t.attr("href")}).unwrap()}.bind(this))).replace(/<p><img(.*?)>/gi,"<p><img$1></p><p>")).replace(/<p[^>]*><\/p>/gi,"")).replace(/<li>·/gi,"<li>")).trim()).replace(/\/(p|ul|ol|h1|h2|h3|h4|h5|h6|blockquote)>\s+<(p|ul|ol|h1|h2|h3|h4|h5|h6|blockquote)/gi,"/$1>\n<$2")).split(/\n/),s=0;s<i.length;s++){var n=""!==i[s]&&-1===i[s].search(/>$/)?" ":"\n";e+=i[s]+n}return e=e.trim()},_parseWordLists:function(t){var a,o=0,r=null,p=null;t.find("p").each(function(t){var e=t.attr("data-listLevel");if(null!==(e=null===e&&t.hasClass("MsoListParagraphCxSpMiddle")?1:e)){var i=t.text(),i=/^\s*\w+\./.test(i)?"<ol></ol>":"<ul></ul>";if(t.hasClass("MsoListParagraphCxSpFirst")||t.hasClass("MsoNormal")?(p=this.dom(i),t.before(p)):o<e&&0!==o&&(a=this.dom(i),r.append(a),p=a),e<o)for(var s=o-e+1,n=0;n<s;n++)p=p.parent();t.find("span").first().unwrap(),r=this.dom("<li>"+t.html().trim()+"</li>"),null===p&&(t.before(i),p=t.prev()),p.append(r),t.remove(),o=e}else p=null,o=0}.bind(this))}}),t.add("module","tidy",{init:function(){},parse:function(t){t=this.app.content.encodeAttrSings(t);var e,i=["li"],s=["li"],n=(this.lineBefore=new RegExp("^<(/?"+i.join("|/?")+"|"+s.join("|")+")[ >]"),this.lineAfter=new RegExp("^<(/?"+i.join("|/?")+"|/"+s.join("|/")+")[ >]"),this.newLevel=new RegExp("^</?("+["p","ul","ol","li","div","h1","h2","h3","h4","h5","h6","blockquote","figure","figcaption","table","thead","tbody","tfoot","tr","td","th","dl","dt","dd"].join("|")+")[ >]"),0),a=t.length,o=0,r="",p="",l="";for(this.cleanlevel=0;n<a;n++){if(o=n,-1===t.substr(n).indexOf("<"))return p+=t.substr(n),this.finish(p);for(;o<a&&"<"!==t.charAt(o);)o++;for(n===o||(l=t.substr(n,o-n)).match(/^\s{2,}
1$/g)||("\n"===p.charAt(p.length-1)?p+=this.getTabs():"\n"===l.charAt(0)&&(p+="\n"+this.getTabs(),l=l.replace(/^\s+/,"")),p+=l),e=o;o<a&&">"!==t.charAt(o);)o++;var h,n=o;if("!--"===(r=t.substr(e,o-e)).substr(1,3)){if(!r.match(/--$/)){for(;"--\x3e"!==t.substr(o,3);)o++;o+=2,r=t.substr(e,o-e),n=o}"\n"!==p.charAt(p.length-1)&&(p+="\n"),p=p+this.getTabs()+(r+">\n")}else"!"===r[1]?p=this.placeTag(r+">",p):"?"===r[1]?p+=r+">\n":h===r.match(/^<(script|style|pre)/i)?(h[1]=h[1].toLowerCase(),r=this.cleanTag(r),p=this.placeTag(r,p),(e=String(t.substr(n+1)).toLowerCase().indexOf("</"+h[1]))&&(l=t.substr(n+1,e),n+=e,p+=l)):(r=this.cleanTag(r),p=this.placeTag(r,p))}return this.finish(p)},getTabs:function(){for(var t="",e=0;e<this.cleanlevel;e++)t+="    ";return t},finish:function(t){return t=(t=(t=(t=(t=(t=(t=t.replace(/\n\s*\n/g,"\n")).replace(/^[\s\n]*/,"")).replace(/[\s\n]*$/,"")).replace(/<li(.*?)>[\s\n]*/gi,"<li$1>")).replace(/<(p|h1|h2|h3|h4|h5|h6|li|td|th)(.*?)>[\s\n]*<\/\1>/gi,"<$1$2></$1>")).replace(/[\s\n]*<\/li>/gi,"</li>")).replace(/<script(.*?)>\n<\/script>/gi,"<script$1><\/script>"),t=this.app.content.decodeAttrSings(t),this.cleanlevel=0,t},cleanTag:function(t){var e,i="",s="";for((t=(t=(t=t.replace(/\n/g," ")).replace(/\s{2,}/g," ")).replace(/^\s+|\s+$/g," ")).match(/\/$/)&&(s="/",t=t.replace(/\/+$/,""));e=/\s*([^= ]+)(?:=((['"']).*?\3|[^ ]+))?/.exec(t);)e[2]?i+=e[1].toLowerCase()+"="+e[2]:e[1]&&(i+=e[1].toLowerCase()),i+=" ",t=t.substr(e[0].length);return i.replace(/\s*$/,"")+s+">"},placeTag:function(t,e){var i=t.match(this.newLevel);return(t.match(this.lineBefore)||i)&&(e=e.replace(/\s*$/,""),e+="\n"),i&&"/"===t.charAt(1)&&this.cleanlevel--,"\n"===e.charAt(e.length-1)&&(e+=this.getTabs()),i&&"/"!==t.charAt(1)&&this.cleanlevel++,e+=t,(t.match(this.lineAfter)||t.match(this.newLevel))&&(e=e.replace(/ *$/,""),e+="\n"),e}}),t.add("module","source",{start:function(){this.eventname=this.prefix+"-source-events",this._build()},toggle:function(){this.is()?this.close():this.open()},is:function(){return"none"!==this.app.container.get("source").css("display")},open:function(){this.app.broadcast("source.before.open");var t=this.app.editor.getContent(),t=this.app.tidy.parse(t),e=this.app.container.get("editor").height(),t=(this.$source.height(e),this.$source.val(t),this.$source.on("focus."+this.eventname,this._handleFocus.bind(this)),this.$source.on("input."+this.eventname,this._handleChanges.bind(this)),this.$source.on("keydown."+this.eventname,this.app.input.handleTextareaTab.bind(this)),this.app.editor.unselectAll(),this.app.container.get("editor").hide(),this.app.container.get("source").show(),this.app.codemirror.create({el:this.$source,height:e,focus:!0}));t&&(t.on("change",this._handleChanges.bind(this)),t.on("focus",this._handleFocus.bind(this))),this.app.editor.disableUI(),this.app.toolbar.setToggled("html"),this.app.broadcast("source.open")},close:function(){this.app.broadcast("source.before.close");var t=this.getContent();this.app.codemirror.destroy(),this.$source.off("."+this.eventname),this.app.container.get("source").hide(),this.app.container.get("editor").show(),this.app.editor.setContent({html:t,caret:"start"}),this.app.editor.enableUI(),this.app.toolbar.unsetToggled("html"),this.app.broadcast("source.close")},update:function(t){var e=this.app.editor.isTextarea()?"val":"html";this.app.$element[e](t)},getContent:function(){var t=this.$source.val();return this.app.codemirror.val(t)},_build:function(){this.opts.source&&(this.$source=this.dom("<textarea>").addClass(this.prefix+"-source"),this.$source.attr("data-gramm_editor",!1),this.app.container.get("source").append(this.$source))},_handleFocus:function(){this.app.editor.setFocus()},_handleChanges:function(t){var e=this.getContent();this.update(e),this.app.broadcast("source.change",{e:t})}}),t.add("module","content",{init:function(){this._selectors={code:["pre","code"],embed:["figure"],noneditable:["."+this.opts.noneditable.classname],images:["img"],links:["a"]}},paragraphize:function(t){return this.app.paragraphizer.paragraphize(t)},encodeEntities:function(t){return this.decodeEntities(t).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")},encodeCode:function(t){return t=(t=(t=(t=(t=(t=(t=(t=this.encodeAttrSings(t)).replace(/<\s/gi,"&lt; ")).replace(/<([^>]+)</gi,"&lt;$1<")).replace(/<(.*?)>/gi,"xtagstartz$1xtagendz")).replace(/xtagstartzpre(.*?)xtagendz/g,"<pre$1>")).replace(/xtagstartzcode(.*?)xtagendz/g,"<code$1>")).replace(/xtagstartz\/codextagendz/g,"</code>")).replace(/xtagstartz\/prextagendz/g,"</pre>
1"),t=(t=(t=this._encodeCode(t)).replace(/xtagstartz([\w\W]*?)xtagendz/g,"<$1>")).replace(/xtagstartz\/(.*?)xtagendz/g,"</$1>"),t=this.decodeAttrSings(t)},encodeAttrSings:function(t){var e=t.match(/="(.*?)"/g);if(null!==e)for(var i,s=0;s<e.length;s++)-1===e[s].search(/^"</)&&-1===e[s].search(/>"$/)&&(i=(i=e[s].replace(">","xmoresignz")).replace("<","xlesssignz"),t=t.replace(e[s],i));return t},decodeAttrSings:function(t){return t=(t=t.replace(/xmoresignz/gi,">")).replace(/xlesssignz/gi,"<")},decodeEntities:function(t){return String(t).replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&amp;/g,"&")},decodeHref:function(t){var e=t.match(new RegExp('(href=".*?)(&amp;)(.*?">)',"g"));if(null!==e)for(var i=0;i<e.length;i++)t=t.replace(e[i],e[i].replace(/&amp;/g,"&"));return t},sanitize:function(t){return t=this.app.utils.wrap(t,function(t){t.find("[src]").each(this._sanitizeSrc),t.find("a").each(this._sanitizeHref),t.find("a,b,i,strong,em,svg,img,details,audio").each(this._sanitizeEvents)}.bind(this))},escapeHtml:function(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")},store:function(t,e,i,s){for(var n=this._selectors[e],a=0;a<n.length;a++){var o=this._getElementsFromHtml(t,n[a]);t=this._store(t,e,o,i,s)}return t},restore:function(t,e,i){if(void 0!==i[e])for(var s=0;s<i[e].length;s++)t=t.replace("####_"+e+s+"_####",i[e][s]);return t},storeComments:function(t,e){var i=t.match(new RegExp("\x3c!--([\\w\\W]*?)--\x3e","gi"));if(null!==i)for(var s=0;s<i.length;s++)t=t.replace(i[s],"#####xstarthtmlcommentzz"+s+"xendhtmlcommentzz#####"),e.push(i[s]);return t},restoreComments:function(t,e){for(var i=0;i<e.length;i++){var s=e[i].replace(/\$/gi,"&#36;");t=t.replace("#####xstarthtmlcommentzz"+i+"xendhtmlcommentzz#####",s)}return t},cacheStyle:function(t){var e=this.opts.tags.block.join(",")+",img,"+this.opts.tags.inline.join(",");return this.app.utils.wrap(t,function(t){t.find(e).each(this._cacheStyle.bind(this))}.bind(this))},recacheStyle:function(t){return this.app.utils.wrap(t,function(t){t.find("[data-"+this.prefix+"-style-cache]").each(this._recacheStyle.bind(this))}.bind(this))},fixListMargin:function(t){var e,i=parseInt(t.css("margin-left"));0!==i&&(e=parseInt(t.css("padding-left")),t.css({"margin-left":0,"padding-left":e+i+"px"}),t.attr(this.prefix+"-list-left",i))},unfixListMargin:function(t){t.attr(this.prefix+"-list-left")&&(t.css({"padding-left":"","margin-left":""}),t.removeAttr(this.prefix+"-list-left"))},addNofollow:function(t){return this.opts.link.nofollow?this.app.utils.wrap(t,function(t){t.find("a").attr("rel","nofollow")}):t},addHttps:function(t){return t=this.opts.editor.https?(t=(t=t.replace('href="http://','href="https://')).replace('src="http://','src="https://')).replace('srcset="http://','srcset="https://'):t},addSpaceToBlocks:function(t){return t.replace(/<\/(div|li|dt|dd|td|p|H[1-6])>\n?/gi,"</$1> ")},addBrToBlocks:function(t){return t.replace(/<\/(div|li|dt|dd|td|p|H[1-6])>\n?/gi,"</$1><br>")},addPredefinedTagClass:function(t){var e=t.get().tagName.toLowerCase(),i=void 0!==this.opts.classes.tags?this.opts.classes.tags:this.opts.classes;void 0!==i[e]&&t.addClass(i[e])},addPredefinedBlockClass:function(t){var e=t.attr("data-"+this.prefix+"-type"),i=this.opts.classes.blocks;void 0!==i[e]&&t.addClass(i[e])},getPredefinedBlocks:function(){var e=[];
1return Object.keys(this.opts.classes.blocks).forEach(function(t){e.push(t)}),e},getPredefinedTags:function(){var e=[],t=void 0!==this.opts.classes.tags?this.opts.classes.tags:this.opts.classes;return Object.keys(t).forEach(function(t){e.push(t)}),e},getText:function(t){var e="";if(3===t.nodeType)e=t.nodeValue;else{for(var i=0;i<t.childNodes.length;i++)e+=this.getText(t.childNodes[i]);var s=1===t.nodeType?getComputedStyle(t).getPropertyValue("display"):"";(s.match(/^block/)||s.match(/list/)||"BR"===t.tagName||"HR"===t.tagName)&&(e+="\n")}return e},getTextFromHtml:function(t,e){var i={},s=(e=h.extend({},{br:!1,nl:!1,trimlines:!0,images:!1,links:!1},e),t=this.store(t,"code",i,0),t=e.links?this.store(t,"links",i,0):t,t=(t=(t=(t=(t=(t=(t=(t=(t=e.images?this.store(t,"images",i,0):t).replace(/<(ul|ol)>\s+<li>/gi,"<$1><li>")).replace(/<li[^>]*>\n/gi,"<li$1>")).replace(/<p[^>]*>(\s+|)<\/p>/gi,"xemptyz")).replace(/<!--[\s\S]*?-->/gi,"")).replace(/<style[\s\S]*?style>/gi,"")).replace(/<script[\s\S]*?script>/gi,"")).replace(/<\/(div|li|dt|dd|td|p|H[1-6])>\n?/gi,"</$1>\n")).replace(/&(lt|gt);/gi,"x$1z"),this.dom("<div>").html(t));if(t=this.getText(s.get()),e.trimlines){for(var n="",a=t.split("\n"),o=0;o<a.length;o++)n+=a[o].trim()+"\n";t=n}return t=(t=(t=t.replace(/[\n]+/g,"\n")).replace("xemptyz","\n")).replace(/x(lt|gt)z/gi,"&$1;"),t=e.br?(t=t.replace(/\n/g,"<br>\n")).replace(/<br\s?\/?>\n?$/gi,""):e.nl?t:t.replace(/\n/gi," "),t=this.restore(t,"code",i),t=e.links?this.restore(t,"links",i):t,t=(t=(t=(t=(t=e.images?this.restore(t,"images",i):t).replace(/<pre[^>]*>/g,"")).replace(/<code[^>]*>/g,"")).replace(/<\/pre>\n?/g,"")).replace(/<\/code>/g,""),(t=e.images?t:(t=t.replace(/<img[\s\S]*?>/gi,"")).replace(/<a[^>]*>(\s+|)<\/a>/gi,"")).trim()},extractHtmlFromCaret:function(t){var e,t=this.dom(t).get(),i=this.app.selection.getRange();if(i)return(e=i.cloneRange()).selectNodeContents(t),e.setStart(i.endContainer,i.endOffset),e.extractContents()},isEmptyHtml:function(t,e){return t=t.trim(),t=(t=(t=(t=(t=(t=(t=(t=(t=this.app.utils.removeInvisibleChars(t)).replace(/^&nbsp;$/gi,"1")).replace(/&nbsp;/gi,"")).replace(/<\/?br\s?\/?>/g,"")).replace(/\s/g,"")).replace(/^<p>\s\S<\/p>$/i,"")).replace(/<hr(.*?[^>])>$/i,"hr")).replace(/<iframe(.*?[^>])>$/i,"iframe")).replace(/<source(.*?[^>])>$/i,"source"),t=this.removeComments(t),""===(t=(t=(t=(t=e?t.replace(/<p[^>]*><\/p>/gi,""):t).replace(/<[^/>]><\/[^>]+>/gi,"")).replace(/<[^/>]><\/[^>]+>/gi,"")).trim())},isLine:function(t){var e=document.createElement("div");return e.innerHTML=t,0===this.dom(e).find(this.opts.tags.block.join(",")+",img").length},removeDoctype:function(t){return t.replace(new RegExp("<!doctype[^>]*>","gi"),"")},removeComments:function(t){return t.replace(/<!--[\s\S]*?-->\n?/g,"")},removeTags:function(t,i){return t.replace(i?/<\/?([a-z][a-z0-9]*)\b[^>]*>/gi:/(<([^>]+)>)/gi,i?function(t,e){return-1===i.indexOf(e.toLowerCase())?t:""}:"")},removeTagsExcept:function(t,i){return void 0===i?t.replace(/(<([^>]+)>)/gi,""):t.replace(/<\/?([a-z][a-z0-9]*)\b[^>]*>/gi,function(t,e){return-1===i.indexOf(e.toLowerCase())?"":t})},removeTagsWithContent:function(t,e){return this.app.utils.wrap(t,function(t){t.find(e.join(",")).remove()})},removeMarkers:function(t){return this.app.utils.wrap(t,function(t){t.find("."+this.prefix+"-plus-button").remove(),t.find("."+this.prefix+"pastemarker").removeClass(this.prefix+"pastemarker"),t.find("."+this.prefix+"pasteitems").removeClass(this.prefix+"pasteitems"),t.find("."+this.prefix+"-selection-marker").remove()}.bind(this))},removeEmptySpans:function(t){return this.app.utils.wrap(t,function(t){t.find("span").each(this._removeEmptySpan.bind(this))}.bind(this))},removeEmptyInlines:function(t){return this.app.utils.wrap(t,function(t){t.find(this.opts.tags.inline.join(",")).each(this._removeEmptyTag.bind(this))}.bind(this))},removeEmptyAttrs:function(t,i){return this.app.utils.wrap(t,function(t){for(var e=0;e<i.length;e++)t.find("["+i[e]+'=""]').removeAttr(i[e])})},removeBlockTags:function(t,e,i){var s=this.opts.tags.block.concat();return i&&(s=this.app.utils.removeFromArrayByValue(s,i)),e=e&&(e?this.app.utils.extendArray(s,e):s),this.removeTags(t,e)},removeBlockTagsInside:function(t,e){return this.blockListTags=this.app.utils.removeFromArrayByValue(this.opts.tags.block.concat(),["ul","ol","li"]),this.app.utils.wrap(t,function(t){t.find(e.join(",")).each(this._removeBlockTagsInside.bind(this))}.bind(this))},removeInlineStyles:function(t){var e=this.app.utils.removeFromArrayByValue(this.opts.tags.inline,"a");return this.app.utils.wrap(t,function(t){t.find(e.join(",")).removeAttr("style")})},removeStyleAttr:function(t,e){return e=e||"",this.app.utils.wrap(t,function(t){t.find("*").not("[data-"+this.prefix+"-style-cache]"+e).removeAttr("style")}.bind(this))},_cacheStyle:function(t){var e="data-"+this.prefix+"-style-cache",i=t.attr("style");i?(i=i.replace(/"/g,""),t.attr(e,i)):t.removeAttr(e)},_recacheStyle:function(t){var e="data-"+this.prefix+"-style-cache",i=t.attr(e);t.attr("style",i).removeAttr(e)},_cleanEmpty:function(t){return t=t.trim(),t=(t=(t=this.app.utils.removeInvisibleChars(t)).replace(/<\/?br\s?\/?>/g,"")).replace(/\s/g,"")}
1,_removeEmptySpan:function(t){0===t.get().attributes.length&&t.unwrap()},_removeEmptyTag:function(t){var e=t.html().trim();0===t.get().attributes.length&&""===e&&t.unwrap()},_removeBlockTagsInside:function(t){var e="LI"===t.get().tagName?this.blockListTags:this.opts.tags.block;t.find(e.join(",")).append("<br>").unwrap()},_store:function(t,e,i,s,n){if(i){void 0===s[e]&&(s[e]=[]);for(var a=0;a<i.length;a++)s[e][n]=i[a],t=t.replace(i[a],"####_"+e+n+"_####"),n++}return t},_getElementsFromHtml:function(t,e){var i=[];return this.dom("<div>").html(t).find(e).each(function(t){i.push(t.get().outerHTML)}),i},_sanitizeSrc:function(t){var t=t.get(),e=t.getAttribute("src");(-1!==e.search(/^javascript:/i)||"IMG"!==t.tagName&&-1!==e.search(/^data:/i))&&t.setAttribute("src","")},_sanitizeHref:function(t){var t=t.get(),e=t.getAttribute("href");e&&-1!==e.search(/^javascript:/i)&&t.setAttribute("href","")},_sanitizeEvents:function(t){t.removeAttr("onload onerror ontoggle onwheel onmouseover oncopy")},_encodeCode:function(t){return this.app.utils.wrap(t,function(t){t.find("pre code, pre, code").each(this._encodeNode.bind(this))}.bind(this))},_encodeNode:function(t){var t=t.get(),e=t.firstChild,i=t.innerHTML;"PRE"===t.tagName&&e&&"CODE"===e.tagName||(i=(i=i.replace(/xtagstartz/g,"<")).replace(/xtagendz/g,">"),e=this.decodeEntities(i),t.textContent=this._encodeNodeHtml(e))},_encodeNodeHtml:function(t){return t=t.replace(/&nbsp;/g," ").replace(/<br\s?\/?>/g,"\n"),t=this.opts.code.spaces?t.replace(/\t/g,new Array(this.opts.code.spaces+1).join(" ")):t}}),t.add("module","autoparse",{parse:function(t){if(this.opts.paste.autoparse){var e=this.app.block.get(),i=[],s=(t=this.app.content.storeComments(t,i),t=this.app.content.removeDoctype(t),["figure","html","form","pre","div","span","video","object","iframe","code","a","img","link","script"]),n=["div","img","html","span"],a=[],o=0;for(c=0;c<s.length;c++){var r=-1!==n.indexOf(s[c])?"<"+s[c]+"[^>]*>":"<"+s[c]+"[^>]*>([\\w\\W]*?)</"+s[c]+">",p=t.match(new RegExp(r,"gi"));if(null!==p)for(var l=0;l<p.length;l++)t=t.replace(p[l],"#####replaceparse"+o+"#####"),a.push(p[l]),o++}if((t=!(t=t.replace("&amp;","&")).match(this.opts.regex.aurl1)&&!t.match(this.opts.regex.aurl2)||t.match(this.opts.regex.imageurl)?t:this._formatLinks(t)).match(this.opts.regex.imageurl))for(var h=t.match(this.opts.regex.imageurl),c=0;c<h.length;c++)t=t.replace(h[c],this._splitBlock(e,'<img src="'+h[c]+'">'));t=this._restoreReplaced(a,t),t=this.app.content.restoreComments(t,i),t=this._restoreReplaced(a,t)}return t},_splitBlock:function(t,e){return t?"\n"+e+"\n":e},_formatLinks:function(t){var s=!1!==this.opts.paste.linkTarget?' target="'+this.opts.paste.linkTarget+'"':"",n=this.opts.editor.https?"https":"http",a=this;return t=(t=t.replace(this.opts.regex.aurl1,function(t){return'<a href="'+t+'"'+s+">"+a._subLinkText(t)+"</a>"})).replace(this.opts.regex.aurl2,function(t,e,i){return e+'<a href="'+n+"://"+i+'"'+s+">"+a._subLinkText(i)+"</a>"})},_subLinkText:function(t){return t=-1===(t=t.length>this.opts.link.size?t.substring(0,this.opts.link.size)+"...":t).search("%")?decodeURIComponent(t):t},_restoreReplaced:function(t,e){for(var i=0;i<t.length;i++)e=e.replace("#####replaceparse"+i+"#####",t[i]);return e}}),t.add("module","caret",{set:function(t,e){var t=this.dom(t).get(),i=this.app.editor.getDocNode().createRange();t&&this._isInPage(t)&&(this.app.editor.setWinFocus(),this._isInline(t)&&this._isNon(t)&&("start"===e?e="before":"end"===e&&(e="after")),this[{start:"_setStart",end:"_setEnd",before:"_setBefore",after:"_setAfter"}[e]](i,t),this.app.selection.setRange(i))},is:function(t,e,i,s,n){var t=this.dom(t).get(),a=this.app.editor.getWinNode().getSelection(),o=!1;return t&&a.isCollapsed&&(a=this._getPosition(t,s,n),n=this._getSize(t,i,s),"end"===e?o=a===n:"start"===e&&(o=0===a)),o},_setStart:function(t,e){t.setStart(e,0),t.collapse(!0);var i=this._getInlineInside(e);i&&(t=this._setStartInline(t,i)),this._isInline(e)&&this._insertInvisibleNode(t)},_setStartInline:function(t,e){e=this.app.element.getAllInlines(e)[0];t.selectNodeContents(e),t.collapse(!0)},_setEnd:function(t,e){var i=1===e.nodeType&&e.lastChild,s=i&&this._isInline(i);t.selectNodeContents(e=s?i:e),t.collapse(!1)},_setBefore:function(t,e){t.setStartBefore(e),t.collapse(!0),this._isInline(e)&&this._insertInvisibleNode(t,e)},_setAfter:function(t,e){t.setStartAfter(e),t.collapse(!0);
1var i=3!==e.nodeType&&e.tagName.toLowerCase();!this._isInline(e)&&"br"!==i&&"svg"!==i||this._insertInvisibleNode(t)},_insertInvisibleNode:function(t,e){var i=this.app.utils.createInvisibleChar();return e?e.parentNode.insertBefore(i,e):t.insertNode(i),t.selectNodeContents(i),t.collapse(!1),i},_getInlineInside:function(t){t=t.firstChild;if(this._isInline(t)){for(var e=t.firstChild;e;){if(this._isInline(e))return e;e=e.firstChild}return t}},_getSize:function(t,e,i){var s,n=3===t.nodeType,a=e&&0!==e.length?((s=this.dom(t).clone()).find(e.join(",")).remove(),s.html().trim()):(a=n?t.textContent:t.innerHTML,n||!1===i?a:a.trim());return this._trimmed(a,n,i).length},_getPosition:function(t,e,i){var s=this.app.editor.getWinNode().getSelection().getRangeAt(0),n=s.cloneRange(),a=document.createElement("div"),o=3===t.nodeType,t=(n.selectNodeContents(t),n.setEnd(s.endContainer,s.endOffset),a.appendChild(n.cloneContents()),o||!1===e?a.innerHTML:a.innerHTML.trim()),s=-1!==t.search(/<\/?br\s?\/?>$/g)?1:0;return!1===i&&(s=0),(t=this._trimmed(t,o,e)).length+s},_trimmed:function(t,e,i){return!1===i?t.replace(/\n$/g,""):""===(t=(t=(t=this.app.utils.removeInvisibleChars(t)).replace(/<\/?([a-z][a-z0-9]*)\b[^>]*>/gi,"")).replace(/\s+/g," "))||e?t:t.replace(/\s$/,"")},_isInline:function(t){return this.app.element.is(t,"inline")},_isInPage:function(t){var e=!1,i=this.app.editor.getDocNode();return e=t&&t.nodeType?t!==i.body&&i.body.contains(t):e},_isNon:function(t){return"false"===t.getAttribute("contenteditable")}}),t.add("module","selection",{init:function(){this.savedSelection=!1,this.savedMarker=!1,this.savedPosition=!1,this.savedRange=!1},get:function(){var t=this._getSelection(),e=this._getRange(t),i=this._getCurrent(t);return{selection:t,range:e,collapsed:this._getCollapsed(t,e),current:i,parent:this._getParent(i)}},getRange:function(){return this._getRange(this.get().selection)},getNodes:function(t){var e=this.get(),i=t&&(t.type&&"inline"===t.type||t.tags&&-1!==t.tags.indexOf("a")),s=i?"_getAllRangeNodes":"_getRangeNodes",n=[];return 0<(n=this.app.editor.isAllSelected()?this.app.editor.getLayout().children().getAll():e.selection&&e.range?this[s](e.range):n).length?this._filterNodes(n,e.range,i,t):n},getCurrent:function(){var t=this._getSelection();return this._getCurrent(t)},getParent:function(){var t=this.getCurrent();return this._getParent(t)},getElement:function(t){return this._getElement(t,"element")},getInline:function(t){return this._getElement(t,"inline")},getTopInline:function(t){for(var e=t?this.dom(t).get():this.getCurrent(),i=[];e&&this._getElement(e,"inline");)i.push(e),e=e.parentNode;return i[i.length-1]},getDataBlock:function(t){var e=this._getSelection(),i=t||this._getCurrent(e);if(i)for(i=this.dom(i).get();i;){if(1===i.nodeType&&i.getAttribute("data-"+this.prefix+"-type"))return this.dom(i);i=i.parentNode}return this.dom()},getBlock:function(t){return this._getElement(t,"block")},getText:function(t,e){var i,s,n=this.get(),a=!1;return!!n.selection&&(t&&n.range?(e=void 0===e?1:e,i=this.app.editor.getLayout().get(),s=n.range.cloneRange(),"before"===t?(s.collapse(!0),s.setStart(i,0),a=s.toString().slice(-e)):"after"===t&&(s.selectNodeContents(i),s.setStart(n.range.endContainer,n.range.endOffset),a=s.toString().slice(0,e))):a=n.selection?n.selection.toString():"",a)},getHtml:function(){var t,e="",i=this.get();return i.selection&&(i=i.range.cloneContents(),(t=document.createElement("div")).appendChild(i),e=(e=t.innerHTML).replace(/<p><\/p>$/i,"")),e},getPosition:function(){var t,e=this.getRange(),i={top:0,left:0,width:0,height:0};return this.app.editor.getWinNode().getSelection&&e.getBoundingClientRect&&(t=(e=e.cloneRange()).startOffset-1,e.setStart(e.startContainer,t<0?0:t),i={top:(t=e.getBoundingClientRect()).top,bottom:t.bottom,left:t.left,width:t.right-t.left,height:t.bottom-t.top}),i},set:function(t,e){t&&(t.removeAllRanges(),t.addRange(e))},setRange:function(t){this.set(this.app.editor.getWinNode().getSelection(),t)},is:function(t){if(void 0===t)return this.get().selection;for(var e=this.dom(t).get(),i=this.getNodes(),s=0;s<i.length;s++)if(i[s]===e)return!0;return!1},isCollapsed:function(){var t=this.get();return this._getCollapsed(t.selection,t.range)},isIn:function(t){var t=this.dom(t).get(),e=this.getCurrent();return!(!e||!t)&&t.contains(e)},isAll:function(t){var e=!t,t=(t?this.dom(t):this.app.editor.getLayout()).get(),i=this.app.editor.getW
1inNode().getSelection(),s=this._getRange(i),e=e||this.is(t);return!i.isCollapsed&&!!e&&void 0!==t.textContent&&t.textContent.trim().length===s.toString().trim().length},select:function(t){var t=(t?this.dom(t):this.app.editor.getLayout()).get(),e=this.app.editor.getDocNode().createRange();e.selectNodeContents(t),this.setRange(e)},removeAllRanges:function(){var t=this._getSelection();t&&t.removeAllRanges()},deleteContents:function(){var t=this.getRange();!this.isCollapsed()&&t&&t.deleteContents()},collapse:function(t){t=t||"start";var e=this.get();e.selection&&!e.collapsed&&("start"===t?e.selection.collapseToStart():e.selection.collapseToEnd())},save:function(t){var e;t||(t=(e=this.app.block.get())?e.getBlock():this.app.editor.getLayout()),this.savedSelection={el:t,offset:this.app.offset.get(t)}},restore:function(t){var e;this.savedMarker||this.savedSelection&&(this.app.editor.setWinFocus(),e=this.savedSelection.el,this.dom(e).dataget("instance")&&!1!==t&&this.app.block.set(e),e&&(e.focus(),this.app.offset.set(e,this.savedSelection.offset)),this.savedSelection=!1)},saveMarker:function(){this.savedMarker=!0,this.app.marker.insert()},restoreMarker:function(){this.app.marker.restore(),this.savedMarker=!1,this.savedSelection=!1},_getSelection:function(){return this.app.editor.getSelection()},_getRange:function(t){return!!t&&0<t.rangeCount&&t.getRangeAt(0)},_getCurrent:function(t){return!!t&&t.anchorNode},_getParent:function(t){return!!t&&t.parentNode},_getElement:function(t,e){var i=this._getSelection();if(i)for(var s=t||this._getCurrent(i),s=this.dom(s).get();s;){if(this.app.element.is(s,e))return s;s=s.parentNode}return!1},_getCollapsed:function(t,e){var i=!1;return i=t&&t.isCollapsed||e&&0===e.toString().length?!0:i},_getNextNode:function(t){if(t.firstChild)return t.firstChild;for(;t;){if(t.nextSibling)return t.nextSibling;t=t.parentNode}},_getRangeNodes:function(t,e){var i,s=t.startContainer.childNodes[t.startOffset]||t.startContainer,n=t.endContainer.childNodes[t.endOffset]||t.endContainer,a=t.commonAncestorContainer,o=[];if(e){for(this.app.editor.isLayout(s)||o.push(s),i=s.parentNode;i&&!this.app.editor.isLayout(i)&&(o.push(i),i!==a);i=i.parentNode);for(o.reverse(),i=s;i&&(3===i.nodeType||0!==this.dom(i.parentNode).closest(a).length)&&(o.push(i),i!==n);i=this._getNextNode(i));}else for(3===s.nodeType&&o.push(this.getBlock(s)),i=s;i&&i!==a&&(3===i.nodeType||0!==this.dom(i.parentNode).closest(a).length)&&(o.push(i),i!==n);i=this._getNextNode(i));return o},_getAllRangeNodes:function(t){return this._getRangeNodes(t,!0)},_filterNodes:function(t,e,i,s){for(var n=(n=this.getText())?n.replace(/[-[\]/{}()*+?.\\^$|]/g,"\\$&"):"",a=[],o=0;o<t.length;o++){var r=!0;this.app.editor.isLayout(t[o])&&(r=!1),s&&(r=s.types?this._filterByTypes(r,s,t[o]):r,r=s.selected?this._filterBySelected(r,s,t[o],e,n):r,r=s.type?this._filterByType(r,s,t[o],i):r,r=s.tags?this._filterByTags(r,s,t[o]):r),r&&a.push(t[o])}var p=[];if(s&&("blocks"===s.type||"blocks-first"===s.type)){for(var l,h=0;h<a.length;h++)"blocks-first"===s.type?l=this.app.element.is(a[h],"blocks-first")?a[h]:this.app.element.getFirstLevel(a[h]).get():"blocks"===s.type&&(l=this.app.element.is(a[h],"blocks")?a[h]:this.app.element.getDataBlock(a[h]).get()),this._isInNodesArray(p,l)||p.push(l);a=p}return a},_filterByTypes:function(t,e,i){var s;return!0===e.types?(s=this.app.element.getType(i))||(t=!1):(s=this.app.element.getType(i),-1===e.types.indexOf(s)&&(t=!1)),t},_filterByType:function(t,e,i,s){var n=e.type;return"blocks"!==n&&"blocks-first"!==n||(n="block"),!s||e.links?this.app.element.is(i,n)||(t=!1):(1!==i.nodeType||"A"!==i.tagName)&&this.app.element.is(i,n)||(t=!1),t},_filterByTags:function(t,e,i){var s=void 0!==i.tagName;return t=s&&-1!==e.tags.indexOf(i.tagName.toLowerCase())?t:!1},_filterBySelected:function(t,e,i,s,n){return!0!==e.selected||this._containsNodeText(s,i)?"inside"===e.selected&&(1===i.nodeType&&"A"===i.tagName?t=!0:this._isTextSelected(i,n)||(t=!1)):t=!1,t},_isTextSelected:function(t,e){t=9!==t.nodeType?this.app.utils.removeInvisibleChars(t.textContent):"";return e===t||-1!==t.search(e)||-1!==e.search(new RegExp("^"+this.app.utils.escapeRegExp(t)+"$"))},_isBackwards:function(){var t,e=!1,i=this.get();return i&&!i.collapsed&&((t=this.app.editor.getDocNode().createRange()).setStart(i.selection.anchorNode,i.selection.anchorOffset),t.setEnd(i.selection.focusNode,i.selection.focusOffset),e=t.collapsed,t.detach()),e},_containsNodeText:function(t,e){for(var i,s,n,a=this.app.editor.getDocNode().createTreeWalker(e,NodeFilter.SHOW_TEXT,{acceptNode:function(t){return NodeFilter.FILTER_ACCEPT}},!1);n=a.nextNode();)i=i||n,s=n;var o=t.cloneRange();return i?(o.setStart(i,0),o.setEnd(s,s.length)):o.selectNodeContents(e),t.compareBoundaryPoints(Range.START_TO_START,o)<1&&-1<t.compareBoundaryPoints(Range.END_TO_END,o)},_isInNodesArray:function(t,e){return-1!==t.indexOf(e)}}),t.add("module","inline",{removeFormat:function(){this.app.popup.close();for(var t=this.app.block.get().getBlock(),e=(this.app.selection.save(t),this.app.selection.getNodes({type:"inline"})),i=0;i<e.length;i++){var s=this.dom(e[i]);s.attr("data-"+this.prefix+"-type")||s.unwrap()}
1this.app.selection.restore(),this.app.editor.observeUI()},set:function(t){this.app.popup.isOpen()&&this.app.popup.close(),this.params=t;t=[],t=this.app.selection.get().collapsed?this.formatCollapsed():this.formatUncollapsed();return this.app.editor.observeUI(),this.app.broadcast("inline.format",{nodes:t}),this.app.sync.trigger(),t},formatCollapsed:function(){var t,e,i,s,n,a=this.app.selection.getInline(),o=this.dom(a),r=this._getParamsTags(),r=this._isSameTag(a,r),p=!(!this.params||!this.params.caret)&&this.params.caret;return a?this.app.content.isEmptyHtml(a.innerHTML)?r?(this.app.caret.set(a,p||"after"),o.remove()):(e=this.app.element.replaceToTag(a,this.params.tag),this.app.caret.set(e,p||"start")):r?(this.app.caret.is(e=a,"end")?p="after":(r=this.app.content.extractHtmlFromCaret(a),i=this.dom("<"+this.params.tag+" />"),(s=document.createElement("div")).appendChild(r),(i=this.app.element.cloneAttrs(a,i)).append(s.innerHTML),o.after(i),e=i),this.app.caret.set(e,p||"before")):t=this._insertInline(this.params.tag,p):t=this._insertInline(this.params.tag,p),t&&this.params&&void 0!==this.params.attr&&(n=this.dom(t),Object.keys(this.params.attr).forEach(function(t){n.attr(t,this.params.attr[t])}.bind(this))),t||[]},formatUncollapsed:function(){for(var t=this.app.block.get(),e=this._getBlock(t),i=(this.app.selection.save(),this._convertTags("u",t),this._convertTags("del",t),this.app.selection.restore(),this.app.selection.getNodes({type:"inline"})),s=(this.app.selection.save(),this._convertToStrike(i),this.app.selection.restore(),this.app.selection.save(),this.app.editor.getDocNode().execCommand("strikethrough"),this._revertToInlines(t)),n=(this.app.selection.restore(),[]),a=this.app.selection.getText(),o=0;o<s.length;o++)this._isInSelection(s[o],a)&&n.push(s[o]);if(this._clearEmptyStyle(),this.params&&void 0!==this.params.attr)for(var r=0;r<n.length;r++)this._applyAttrs(n[r]);return 1===e.length&&e.get().normalize(),this.app.selection.save(),this._revertTags("u",t),this._revertTags("del",t),this.app.selection.restore(),this.params&&this.params.caret&&this.app.caret.set(n[n.length-1],this.params.caret),n},_applyAttrs:function(e){Object.keys(this.params.attr).forEach(function(t){e.setAttribute(t,this.params.attr[t])}.bind(this))},_clearEmptyStyle:function(){for(var t=this.app.selection.getNodes({type:"inline"}),e=0;e<t.length;e++){this._clearEmptyStyleAttr(t[e]);var i=t[e].childNodes;if(i)for(var s=0;s<i.length;s++)this._clearEmptyStyleAttr(i[s])}},_clearEmptyStyleAttr:function(t){3!==t.nodeType&&""===t.getAttribute("style")&&t.removeAttribute("style")},_isSameTag:function(t,e){return t&&-1!==e.indexOf(t.tagName.toLowerCase())},_isInSelection:function(t,e){t=this.app.utils.removeInvisibleChars(t.textContent);return e=(e=e.replace(/\n/g,"")).replace(/\s/g,""),t=t.replace(/\s/g,""),-1!==e.search(new RegExp(this.app.utils.escapeRegExp(t)))},_insertInline:function(t,e){return this.app.insertion.insertNode(document.createElement(t),e||"start")},_convertTags:function(e,t){this.params.tag!==e&&this._getBlock(t).find(e).each(function(t){this.app.element.replaceToTag(t,"span").addClass(this.prefix+"-convertable-"+e)}.bind(this))},_revertTags:function(e,t){this._getBlock(t).find("span."+this.prefix+"-convertable-"+e).each(function(t){t=this.app.element.replaceToTag(t,e);t.removeClass(this.prefix+"-convertable-"+e),this.app.element.removeEmptyAttrs(t,["class"])&&t.removeAttr("class")}.bind(this))},_convertToStrike:function(t){for(var e=this._getParamsTags(),i=0;i<t.length;i++){var s=t[i],s=this.dom(s),n=t[i].tagName.toLowerCase();-1!==e.indexOf(n)&&this._replaceToStrike(s)}},_getParamsTags:function(){var t=[this.params.tag];return"b"===this.params.tag||"strong"===this.params.tag?t=["b","strong"]:"i"!==this.params.tag&&"em"!==this.params.tag||(t=["i","em"]),t},_replaceToStrike:function(t){t.replaceWith(function(){return this.dom("<strike>").append(t.html())}.bind(this))},_revertToInlines:function(t){var e=[],t=this._getBlock(t);return t.find("*").each(function(t){t.get().style.textDecorationLine&&(t.css("text-decoration-line",""),t.wrap("<u>"),""===t.attr("style"))&&t.removeAttr("style")}.bind(this)),t.find("strike").each(function(t){t=this.app.element.replaceToTag(t,this.params.tag);e.push(t.get())}.bind(this)),e},_getBlock:function(t){return!t||this.app.editor.isBlocksSelection()?this.dom(this.app.blocks.getSelectedBlocks()):t.getBlock()}}),t.add("module","popup",{init:function(){this.stack=!1,this.stacks=[],this.name=!1,this.supername=!1,this.autoclose=!0,this.control=!1,this.saved=!1},start:function(){this._build(),this._buildDepth()},stop:function(){this._stopEvents(),this._stop()},stopStack:function(){this._stopEvents(),this.app.toolbar.unsetToggled(),this.$popup.removeAttr("data-"+this.prefix+"-popup-name"),this.$popup.removeClass("open")},isOpen:function(t){var e=this.$popup.hasClass("open");return(!t||this._getName()===t)&&e},create:function(t,e){return this.isOpen(t)||(this._reset(),this.name=t,this.supername=t,this.stack=this._createStack(t,e)),this.stack},add:function(t,e){return this._createStack(t,e,!0)},setStack:function(t){this.stack=t,this.name=t.getName()},setData:function(t){this.stack.setData(t)},setFocus:function(t){this.stack.setFocus(t)}
1,setWidth:function(t){this.stack.setWidth(t)},getName:function(){return this.name},getElement:function(){return this.$popup},getButton:function(){return this.button},getStack:function(t){return t?this.stacks[t]:this.stack},getBody:function(){return this.stack.getBody()},getItems:function(){return this.stack.getItems()},getFooter:function(){return this.stack.getFooter()},getFooterPrimary:function(){return this.stack.getFooterPrimary()},getTool:function(t){return this.stack.getTool(t)},getInput:function(t){return this.stack.getInput(t)},getFormItem:function(t){return this.stack.getFormItem(t)},getData:function(t){return this.stack.getData(t)},open:function(t){this.isOpen()?this.isOpen(this.supername)?(this.saved=!0,this.close(!1)):(this.saved=!0,this.close(!1),this._open(t,!1)):(this.saved=!1,this._open(t))},openStack:function(t){var t=this.getStack(t),e={};this.stack&&this.stack.isCollapsed()&&(e={collapse:!0},this.removeStack(this.stack)),t.open(e)},close:function(t,e){!1===this.autoclose&&!0!==t&&!e||!this.isOpen()||t&&this._isPopupTarget(t)||(this._stopEvents(),this._resetToolbarToggledButton(),!1!==t&&!1===this.saved&&(this.app.scroll.save(),this.app.selection.restore(),this.app.scroll.restore()),this.$popup.hide(),this._closed())},closeStacks:function(){for(var t in this.stacks)"object"==typeof this.stacks[t]&&this.stacks[t].close()},removeStack:function(t){t=t.getName();delete this.stacks[t],this.$popup.find("[data-"+this.prefix+"-stack-name="+t+"]").remove()},updatePosition:function(t){this._buildPosition(t),this._buildHeight()},resize:function(){var t=this.$popup.attr("data-width"),e=this.app.editor.getWidth();if("100%"!==t&&parseInt(t)<e)return;this.$popup.css("width",e+"px")},_build:function(){this.$popup=this.dom("<div>").addClass(this.prefix+"-popup "+this.prefix+"-popup-"+this.uuid),this.$popup.hide(),this.$popup.attr("dir",this.opts.editor.direction),this.app.$body.append(this.$popup)},_buildDepth:function(){this.opts.bsmodal&&this.$popup.css("z-index",1061)},_buildButton:function(t){t&&(this.button=!!Object.prototype.hasOwnProperty.call(t,"button")&&t.button)},_buildControl:function(t){t&&(this.control=!!Object.prototype.hasOwnProperty.call(t,"control")&&t.control)},_buildName:function(){this.$popup.attr("data-"+this.prefix+"-popup-name",this.name),this.$popup.addClass(this.prefix+"-popup-"+this.name)},_buildHeader:function(){this.header=this.app.create("popup.header",this)},_buildHeight:function(){var t,e=this.app.scroll.getTarget(),i=this.$popup.offset(),i=this.app.scroll.isTarget()?(t=i.top-e.offset().top,e.height()-parseInt(e.css("border-bottom-width"))):(t=i.top-e.scrollTop(),e.height());this.$popup.css("max-height",i-t-10+"px")},_buildPosition:function(){var t=this._isButton()&&this.button.isControl()||this._isControl()?this._buildPositionControl():this._isButton()?this._buildPositionButton():this._buildPositionModal();this.$popup.css({top:t.top-1+"px",left:t.left+"px"})},_buildPositionButton:function(){var t=this.app.editor.getRect(),e=this.button.getOffset(),i=this.button.getDimension(),s=this.$popup.width(),n=this.$popup.height(),a={};return this._isToolbarButton()||this._isTopbarButton()?(a={top:e.top+i.height,left:e.left}).left+s>t.right&&(a.left=e.left+i.width-s):((a={top:e.top+t.top+i.height,left:e.left+t.left+i.width/2-s/2}).left+s>t.right&&(a.left=t.left+t.width-s),a.top+n>this.app.$doc.height()&&(a.top=a.top-n-i.height)),(a.left<t.left||a.left<0)&&(a.left=t.left),a},_buildPositionControl:function(){var t=this.app.block.get(),t=(t=t.isSecondLevel()?t.getFirstLevel():t).getBlock().offset();return{top:t.top,left:t.left}},_buildPositionModal:function(){var t,e;return e=(t=this.opts.toolbar?(t=(e=this.app.container.get("toolbar")).height(),(e=e.offset()).top+t):(e=(t=(t=this.app.block.get()).isSecondLevel()?t.getFirstLevel():t).getBlock().offset()).top,e.left),{top:t,left:e}},_getName:function(){return this.$popup.attr("data-"+this.prefix+"-popup-name")},_setToolbarToggledButton:function(){var t;this.app.toolbar.unsetToggled(),this._isToolbarButton()&&(t=this.button.getName(),this.app.toolbar.setToggled(t))}
1,_createStack:function(t,e,i){Object.prototype.hasOwnProperty.call(e,"collapse")&&!1===e.collapse&&(i=!1),Object.prototype.hasOwnProperty.call(e,"autoclose")&&(this.autoclose=e.autoclose);e=this.app.create("popup.stack",t,e,i,this);return this.stacks[t]=e},_open:function(t,e){this._buildButton(t),this._buildControl(t),this._buildName(),this._buildHeader(),this.app.broadcast("popup.before.open").isStopped()?this.stopStack():(this._setToolbarToggledButton(),this._startEvents(),!1!==e&&this.app.editor.isPopupSelection()&&this.app.selection.save(),this.stack=this._findActiveStack(),this.stack.open(t,!1,!1),this._buildPosition(),!1===e?(this.$popup.show(),this._opened()):this.$popup.fadeIn(100,this._opened.bind(this)))},_opened:function(){this._buildHeight(),this.$popup.addClass("open"),this.app.broadcast("popup.open"),this.stack.renderFocus()},_closed:function(){var t="data-"+this.prefix+"-popup-name",e=this.$popup.attr(t);this.$popup.removeAttr(t),this.$popup.removeClass("open "+this.prefix+"-popup-"+e),this.saved=!1,this.app.broadcast("popup.close")},_isPopupTarget:function(t){return 0!==this.dom(t.target).closest("."+this.prefix+"-popup").length},_isButton:function(){return this.button},_isControl:function(){return this.control},_isToolbarButton:function(){return this.button&&("toolbar"===this.button.type||"context"===this.button.type)},_isTopbarButton:function(){return this.button&&"topbar"===this.button.type},_findActiveStack:function(){for(var t in this.stacks)"object"==typeof this.stacks[t]&&this.stacks[t].isActive()&&(this.stack=this.stacks[t]);return this.stack},_reset:function(){this.button=!1,this.control=!1,this.autoclose=!0,this.stack=!1,this.stacks=[],this.$popup.html(""),this.$popup.removeClass("has-footer has-items has-form")},_resetToolbarToggledButton:function(){var t;this.button&&(t=this.button.getName(),this.app.toolbar.unsetToggled(t))},_startEvents:function(){var t=this.prefix+"-popup";this.app.scroll.getTarget().on("resize."+t,this.updatePosition.bind(this)),this.app.scroll.getTarget().on("scroll."+t,this._buildPosition.bind(this))},_stopEvents:function(){this.app.scroll.getTarget().off("."+this.prefix+"-popup")},_stop:function(){this.$popup&&this.$popup.remove()}}),t.add("class","popup.item",{defaults:{container:!1,title:!1,html:!1,toggle:!0,active:!1,divider:!1,remover:!1,classname:!1,params:!1,instance:!1,observer:!1,command:!1},init:function(t,e,i){this.popup=t,this.name=e,this.params=this._buildParams(i),this._build(),this._buildContainer(),this._buildIcon(),this._buildTitle(),this._buildImage(),this._buildShortcut(),this._buildActive(),this._buildHidden(),this._buildDivider(),this._buildCommand(),this._buildRemover()},getPopup:function(){return this.popup},getName:function(){return this.name},getParams:function(){return this.params.params},getElement:function(){return this.$item},getInstance:function(){return this.params.instance},isControl:function(){return this.params.control},_build:function(){this.$item=this.params.html?this.dom(this.params.html):this.dom("<div>"),this.$item.addClass(this.prefix+"-popup-item "+this.prefix+"-popup-stack-item"),this.$item.attr({"data-name":this.name})},_buildContainer:function(){this.params.container&&this.$item.addClass(this.prefix+"-popup-item-container")},_buildTitle:function(){this.params.title&&(this.$title=this.dom("<span>").addClass(this.prefix+"-popup-item-title"),this.$title.html(this.lang.parse(this.params.title)),this.$item.append(this.$title))},_buildImage:function(){this.params.image&&(this.$image=this.dom("<span>").addClass(this.prefix+"-popup-item-image"),this.$image.html(this.params.image),this.$item.append(this.$image))},_buildIcon:function(){this.params.icon&&(this.$icon=this.dom("<span>").addClass(this.prefix+"-popup-item-icon"),this.opts.buttons.icons&&void 0!==this.opts.buttons.icons[this.name]?this.$icon.html(this.opts.buttons.icons[this.name]):!0===this.params.icon?this.$icon.addClass(this.prefix+"-icon-"+this.name):-1!==this.params.icon.search(/</)?this.$icon.html(this.params.icon):this.$icon.addClass(this.prefix+"-icon-"+this.params.icon),this.$item.append(this.$icon))},_buildShortcut:function(){var t;this.params.shortcut&&(t=/(Mac|iPhone|iPod|iPad)/i.test(navigator.platform)?"<b>&#8984;</b>":"ctrl",t=this.params.shortcut.replace("Ctrl",t),this.$shortcut=this.dom("<span>").addClass(this.prefix+"-popup-item-shortcut"),this.$shortcut.html(t),this.$item.append(this.$shortcut))},_buildParams:function(t){return h.extend({},!0,this.defaults,t)},_buildActive:function(){this.params.active&&this.$item.addClass("active")},_buildHidden:function(){this.params.hidden&&this.$item.addClass(this.prefix+"-popup-item-hidden")},_buildDivider:function(){this.params.divider&&this.$item.addClass(this.prefix+"-popup-item-divider-"+this.params.divider)},_buildCommand:function(){this.params.command&&(this.$item.on("click."+this.prefix+"-popup-item-"+this.uuid,this._catch.bind(this)),this.$item.attr("data-command",this.params.command))},_buildRemover:function(){var t;this.params.title&&this.params.remover&&((t=this.dom("<span>").addClass(this.prefix+"-popup-item-trash "+this.prefix+"-icon-trash")).attr("data-command",this.params.remover),t.on("click."+this.prefix+"-popup-item-"+this.uuid,this._catchRemover.bind(this)),this.$item.append(t))}
1,_catchRemover:function(t){t.preventDefault(),t.stopPropagation();var e=this.dom(t.target).closest("."+this.prefix+"-popup-stack-item"),t=this.dom(t.target).closest("."+this.prefix+"-popup-item-trash").attr("data-command"),i=e.attr("data-name");this.app.api(t,this,i),e.fadeOut(200,function(t){t.remove()})},_catch:function(t){t.preventDefault(),t.stopPropagation();var e=this.dom(t.target).closest("."+this.prefix+"-popup-stack-item"),i=e.attr("data-name"),s=e.attr("data-command");this.popup.$items.find("."+this.prefix+"-popup-stack-item").removeClass("active"),this.params.toggle&&e.addClass("active"),this.app.api(s,this.getParams(),this,i,t)}}),t.add("class","popup.stack",{defaults:{active:!1,title:!1,type:!1,width:!1,setter:!1,getter:!1,builder:!1,observer:!1,instance:!1,collapse:!1,form:!1,items:!1,focus:!1,footer:!1},init:function(t,e,i,s){this.defaultWidth="240px",this.popup=s,this.name=t,this.tools={},this.data=!1,this.items=!1,this.formitems=!1,this.params=h.extend({},!0,this.defaults,e),i&&(this.params.collapse=!0),this._build(),this._observe()},set:function(t,e){this.params[t]=e},setData:function(t){this.data=t},setFocus:function(t){void 0!==this.tools[t]&&this.tools[t].setFocus()},setWidth:function(t){var e=this.app.popup.getElement();e.attr("data-width",t),"100%"===t&&(t=this.app.editor.getWidth()+"px"),e.css("width",t),this.app.$win.on("resize."+this.prefix+"-popup-"+this.uuid,this.popup.resize.bind(this.popup)),this.popup.resize()},setItemsData:function(t){this.items=t},get:function(t){return this.params[t]},getElement:function(){return this.$stack},getName:function(){return this.name},getBody:function(){return this.$body},getInstance:function(){return this.get("instance")},getItemsData:function(){return this.items},getItems:function(){return this.$items},getFooter:function(){return this.$footer},getFooterPrimary:function(){return this.$footer.find("."+this.prefix+"-form-button-primary")},getTool:function(t){return void 0!==this.tools[t]&&this.tools[t]},getInput:function(t){t=this.getTool(t);return t?t.getInput():this.dom()},getFormItem:function(t){t=this.getTool(t);return t?t.getInput().closest("."+this.prefix+"-form-item"):this.dom()},getData:function(t){var e;return t?void 0!==this.tools[t]&&(e=this.tools[t].getValue()):(e={},Object.keys(this.tools).forEach(function(t){e[t]=this.tools[t].getValue()}.bind(this))),e},hasForm:function(){return this.formitems},hasFooter:function(){return 0!==this.footerbuttons},hasItems:function(){return!1!==this.items},isCollapsed:function(){return this.get("collapse")},isActive:function(){return this.get("active")},open:function(t,e,i){if((t&&t.focus&&this.set("focus",t.focus),this.popup.closeStacks(),this.app.popup.setStack(this),!1!==i)&&this.app.broadcast("popup.before.open").isStopped())return void this.popup.stopStack();t&&t.collapse?(this._buildItems(),this._renderItems()):this.render(),this.popup.header.render(this.popup.stacks),this.popup.header.setActive(this),this.$stack.show(),this._renderWidth(),this.popup._buildPosition(),!1!==e&&this.renderFocus(),!1!==i&&this.app.broadcast("popup.open")},close:function(){this.$stack.hide()},collapse:function(){var t=this._getPrev();this.isCollapsed()&&this.popup.removeStack(this),t.open({collapse:!0})},render:function(){this._renderType(),this._renderItems(),this._renderForm(),this._renderFooter(),this._renderEnv()},renderFocus:function(){this.get("focus")&&this.setFocus(this.get("focus"))},_observe:function(){this.params.observer&&this.app.api(this.params.observer,this)},_getPrev:function(){var t,e;for(e in this.popup.stacks)if(this.popup.stacks.hasOwnProperty(e)){if(e===this.name)return t;t=this.popup.stacks[e]}},_build:function(){this._buildElement(),this._buildBody(),this._buildFooter(),this._buildParams()},_buildElement:function(){this.$stack=this.dom("<div>").addClass(this.prefix+"-popup-stack "+this.prefix+"-popup-stack-"+this.name),this.$stack.hide(),this.$stack.attr("data-"+this.prefix+"-stack-name",this.name),this.popup.getElement().append(this.$stack)},_buildBody:function(){this.$body=this.dom("<div>").addClass(this.prefix+"-popup-body"),this.$stack.append(this.$body)},_buildFooter:function(){this.$footer=this.dom("<div>").addClass(this.prefix+"-popup-footer"),this.$stack.append(this.$footer)},_buildParams:function(){this.params.width=this.params.width||this.defaultWidth,this.params.setter=this.params.setter||!1,this.params.getter=this.params.getter||!1,this.data=!!this.params.getter&&this.app.api(this.params.getter,this),this._buildItems()},_buildItems:function(){this.params.builder?this.items=this.app.api(this.params.builder,this):this.params.items&&(this.items=this.params.items)},_renderWidth:function(){this.setWidth(this.get("width"))},_renderType:function(){this.$stack.removeClass(this.prefix+"-popup-type-grid");var t=this.get("type");t&&this.$stack.addClass(this.prefix+"-popup-type-"+t)},_renderItems:function(){if(this.items)for(var t in this.$items?this.$items.html(""):(this.$items=this.dom("<div>").addClass(this.prefix+"-popup-items"),this.$body.append(this.$items)),this.items){var e;this.items.hasOwnProperty(t)&&(Object.prototype.hasOwnProperty.call(this.items[t],"observer")&&this.items[t].observer&&void 0!==(e=this.app.api(this.items[t].observer,this.items[t],t,this))&&(this.items[t]=e),!1!==this.items[t])&&(e=this.app.create("popup.item",this,t,this.items[t]).getElement(),this._renderItemPosition(this.$items,e,this.items[t]))}}
1,_renderItemPosition:function(t,e,i){var s;i.position?"first"===(i=i.position)?t.prepend(e):"object"==typeof i&&(s=i[i=Object.prototype.hasOwnProperty.call(i,"after")?"after":"before"],(s=this._findPositionElement(s,t))?s[i](e):t.append(e)):t.append(e)},_renderEnv:function(){var t=this.popup.getElement();t.removeClass("has-footer has-items has-form"),this.hasForm()&&t.addClass("has-form"),this.hasFooter()&&t.addClass("has-footer"),this.hasItems()&&t.addClass("has-items")},_renderForm:function(){this.formitems=this.get("form"),this.formitems&&(this.$form?this.$form.html(""):(this.$form=this.dom("<form>").addClass(this.prefix+"-popup-form"),this.$body.append(this.$form)),this._renderTools(),this._renderData(),this.$form.find("input[type=text],input[type=url],input[type=email]").on("keydown."+this.prefix+"-popup",function(t){if(13===t.which)return t.preventDefault(),!1}.bind(this)))},_renderTools:function(){Object.keys(this.formitems).forEach(function(t){this._renderTool(t,this.formitems[t])}.bind(this))},_renderTool:function(t,e){var e=this.app.create("tool."+e.type,t,e,this,this.data),i=e.getElement();i&&(this.tools[t]=e,this.$form.append(i))},_renderData:function(){if(this.data)for(var t in this.data)void 0!==this.tools[t]&&this.tools[t].setValue(this.data[t])},_renderFooter:function(){this.footerbuttons=0;var t=this.get("footer");if(t)for(var e in this.$footer.html(""),t)t.hasOwnProperty(e)&&!1!==t[e]&&(e=this.app.create("popup.button",e,this,t[e]),this.$footer.append(e.getElement()),this.footerbuttons++)},_findPositionElement:function(t,e){var i;if(Array.isArray(t))for(var s=0;s<t.length&&0===(i=e.find("[data-name="+t[s]+"]")).length;s++);else i=e.find("[data-name="+t+"]");return 0!==i.length?i:0}}),t.add("class","popup.header",{init:function(t){this.popup=t,this._build()},setActive:function(t){this.$headerbox.find("."+this.prefix+"-popup-header-item").removeClass("active"),this.$headerbox.find("[data-"+this.prefix+"-name="+t.getName()+"]").addClass("active")},render:function(t){this._reset(),0<this._buildItems(t)&&this._buildClose()},_build:function(){this.$header=this.dom("<div>").addClass(this.prefix+"-popup-header"),this.$headerbox=this.dom("<div>").addClass(this.prefix+"-popup-header-box"),this.$header.append(this.$headerbox),this.popup.getElement().prepend(this.$header)},_buildClose:function(){var t=this.dom("<span>").addClass(this.prefix+"-popup-close");t.one("click",this._catchClose.bind(this)),this.$header.append(t)},_buildItems:function(t){var e,i,s=Object.keys(t).length,n=0,a=0;for(e in t)t.hasOwnProperty(e)&&"object"==typeof t[e]&&(a++,(i=t[e].get("title"))?(n++,this._buildItem(t[e],i,s)):1===a&&1<s&&(n++,this._buildItem(t[e],"## popup.back ##",s)));return n},_buildItem:function(t,e,i){var i=1<i,s=i?this.dom("<a>").attr("href","#"):this.dom("<span>");i&&(s.dataset("stack",t),s.addClass(this.prefix+"-popup-header-item-link"),s.on("click",this._catchStack.bind(this))),s.attr("data-"+this.prefix+"-name",t.getName()),s.addClass(this.prefix+"-popup-header-item"),s.html(this.lang.parse(e)),this.$headerbox.append(s)},_reset:function(){this.$headerbox.html(""),this.$header.find("."+this.prefix+"-popup-close").remove()},_catchStack:function(t){t.preventDefault(),t.stopPropagation();var t=this.dom(t.target).dataget("stack"),e=this.app.popup.getStack();e.isCollapsed()&&this.app.popup.removeStack(e),t.open()},_catchClose:function(t){t.preventDefault(),t.stopPropagation(),this.popup.close()}}),t.add("class","popup.button",{init:function(t,e,i){this.name=t,this.obj=i,this.popup=e,this.$button=this.dom("<button>").addClass(this.prefix+"-form-button"),this.$button.attr("data-name",this.name),this.$button.html(this.lang.parse(this.obj.title)),this.$button.dataset("instance",this),this._has("type")&&this.$button.addClass(this.prefix+"-form-button-"+this.obj.type),this._has("classname")&&this.$button.addClass(this.obj.classname),this._has("fullwidth")&&this.$button.addClass(this.prefix+"-form-button-fullwidth"),this._has("right")&&this.$button.addClass(this.prefix+"-form-button-push-right"),this.$button.on("click."+this.prefix+"-popup-button"+this.uuid,this._catch.bind(this))},getName:function(){return this.name},getElement:function(){return this.$button},invokeCommand:function(){this._invoke()},_has:function(t){return Object.prototype.hasOwnProperty.call(this.obj,t)},_catch:function(t){t.preventDefault(),t.stopPropagation(),this._has("command")?this._invoke(t):this._has("close")&&this.app.popup.close()},_invoke:function(t){this.app.api(this.obj.command,this.popup,this.name,t)}}),t.add("module","editor",{init:function(){this.mobileMode=!1,this.customButtons={}},start:function(){this._buildFrame(),this._buildDisabled(),this._buildBlurClass(),this._buildOptions(),this._buildMultiple(),this._buildParserTags(),this._buildStartHtml(),this._buildLayout(),this._buildContent()},stop:function(){this.$editor=!1,this.customButtons={},this.app.$element.show()},build:function(){this.app.embed.build(),this.app.blocks.build(),this.app.image.observeStates(),this.app.parser.buildPredefinedClasse
1s(),this.app.broadcast("editor.build")},insertContent:function(t){this.app.insertion.insertContent(t)},setContent:function(t){this.app.insertion.setContent(t)},setEmpty:function(){this.app.insertion.setContent({html:""})},setWinFocus:function(){this.getWin().focus()},setFocus:function(t){this.opts.disableMode||(t?this._setFocusCaret(t):this._setFocusEvent())},setBlur:function(){!this.opts.disableMode&&this.isFocus()&&this.$editor.get&&(this.app.container.setBlur(),this.app.source.is()||(this._enableToolbarButtons(),this.app.block.unset(),this.app.blocks.unset()),this.app.selection.removeAllRanges(),this.app.source.is()||this.isMobileView()||(this.app.path.build(),this.app.toolbar.build(),this.app.control.close()),this.app.popup.close(!1),this.app.broadcast("editor.blur"))},selectAll:function(t){this.isAllSelected()||(this._setSelectAllClass(),this.app.blocks.unset(),this.app.blocks.setFirstLevel(),this.app.selection.removeAllRanges(),this.app.path.build(),this.app.toolbar.build(),this.app.control.close())},unselectAll:function(){this.isAllSelected()&&(this.unsetSelectAllClass(),this.app.block.unset(),this.app.blocks.unset())},unsetSelectAllClass:function(){this.$editor.removeClass(this.prefix+"-select-all")},addButton:function(t,e){this.customButtons[t]=e},getButtons:function(){var t,e=this.getButtonsFromArr(this.opts.buttons.editor),i={};for(t in e)!e.hasOwnProperty(t)||"html"===t&&!this.opts.source||"templates"===t&&!this.opts.templates.json||(i[t]=e[t]);return i=h.extend(!0,{},i,this.customButtons)},getContent:function(t){var e="",e=this.app.source.is()?this.app.source.getContent():(e=this._getContent(),t?this.app.tidy.parse(e):e);return e=this.app.content.decodeHref(e)},getWidth:function(){var t=this.getEditor(),e=parseInt(t.css("padding-left")),i=parseInt(t.css("padding-right"));return t.width()-e-i},getRect:function(){return this.getFrameRect()},getFrameRect:function(){var t=this.$editor.offset(),e=this.$editor.width(),i=this.$editor.height(),s=Math.round(t.top),t=Math.round(t.left);return{top:s,left:t,bottom:s+i,right:t+e,width:e,height:i}},getSelection:function(){var t=this.getWinNode().getSelection();return 0<t.rangeCount&&t},getEditor:function(){return this.getFrame()},getFrame:function(){return this.$editor||this.dom()},getLayout:function(){return this.$layout},getOverlay:function(){return this.$overlay},getHead:function(){return this.getDoc().find("head")},getBody:function(){return this.$editor?this.getDoc().find("body"):this.dom()},getDoc:function(){return this.dom(this.getDocNode())},getDocNode:function(){return!1===this.$editor?null:this.$editor.get().contentWindow.document},getWin:function(){return this.dom(this.getWinNode())},getWinNode:function(){return this.$editor.get().contentWindow},getButtonsFromArr:function(t){var e={};if(!Array.isArray(t)&&"object"==typeof t)return t;if(t)for(var i=h.extend(!0,{},this.opts.buttonsObj),s=0;s<t.length;s++){var n=t[s];void 0!==i[n]&&(e[n]=i[n])}return e},adjustHeight:function(){this.$editor&&!this.app.isStopped()&&setTimeout(function(){this.$editor.height(this.getBody().height())}.bind(this),1)},toggleView:function(t){this.mobileMode?(this.$editor.css("width",""),this.enableUI(),this.app.toolbar.unsetToggled("mobile"),this.app.event.run(),this.app.blocks.runEditableBlocks(),this.app.observer.build(),this.mobileMode=!1):(this.$editor.css("width",this.opts.editor.mobile+"px"),this.disableUI(),this.app.toolbar.setToggled("mobile"),this.app.popup.close(),this.app.control.close(),this.app.event.pause(),this.app.blocks.pauseEditableBlocks(),this.app.observer.stop(),this.mobileMode=!0),this.adjustHeight()},observeUI:function(){this.app.toolbar.observe()},enableUI:function(){this.app.path.enable(),this.app.topbar.enable(),this.app.toolbar.enable(),this.app.toolbar.enableSticky()},disableUI:function(){this.app.path.disable(),this.app.topbar.disable(),this.app.toolbar.disable(),this.app.toolbar.disableSticky()},isEditor:function(t){return this.isLayout(t)},isLayout:function(t){return this.dom(t).get()===this.$layout.get()},isTextarea:function(){return!1===this.opts.content},isAllSelected:function(){return this.$editor.hasClass(this.prefix+"-select-all")},isFocus:function(){return this.app.container.isFocus()},isEmpty:function(t){return!(1<this.app.blocks.getFirstLevel().length)&&this.app.content.isEmptyHtml(this.$layout.html(),t)},isMobileView:function(){return this.mobileMode},isPopupSelection:function(){return!0},isBlocksSelection:function(){return!1},_buildFrame:function(){this.app.$element.hide(),this.$editor=this.dom("<iframe>").addClass(this.prefix+"-editor-frame"),this.app.container.get("editor").append(this.$editor),this.$overlay=this.dom("<div>").addClass(this.prefix+"-editor-overlay"),this.app.container.get("editor").append(this.$overlay)},_buildDisabled:function(){this.opts.disableMode=this.opts.editor.disabled||null!==this.app.$element.attr("disabled")},_buildBlurClass:function(){this.app.container.get("main").addClass(this.prefix+"-in-blur")},_buildMultiple:function(){!1===this.opts.selection.multiple&&this.app.shortcut.remove("meta+click")},_buildOptions:function(){var t=this.$editor,e=this.opts.editor,i=this.opts.paste;Object.prototype.hasOwnProperty.call(i,"autolink")&&(i.autoparse=i.autolink),t.attr("dir",e.direction),t.attr("scrolling","no"),t.css("visibility","hidden"),e.minHeight&&t.css("min-height",e.minHeight),e.maxHeight&&(t.css("max-height",e.maxHeight),t.attr("scrolling","yes")),e.notranslate&&t.addClass("notranslate"),e.spellcheck||t.attr("spellcheck",!1)},_buildStartHtml:function(){var t=this._createDoctype(),e=this._createScripts(),i='<div class="'+this.opts.editor.classname+'"></div>';this._writeCode(t+"<html><head></head><body>"+i+e+"</body></html>")},_buildLayout:function(){var t=this.getBody(),e=this.opts.editor.classname.split(" ").join(".");this.$layout=t.find("."+e).first(),this.$layout.attr("dir",this.opts.editor.direction),!1===this.opts.editor.padding&&this.$layout.css("padding",0),t.css("height","auto")},_buildContent:function(){var t=this._getContentValue(),t=this.app.broadcastHtml("editor.before.load",t),t=this.app.parser.parse(t,!0,!0),t=(this.$layout.html(t.get().childNodes),this.app.parser.unparse(this.$layout.html()));this.app.$element.val(t),this._load()},_buildVisibility:function(){this.$editor.css("visibility","visible")},_buildEditorCss:function(){if(this.opts.css)for(var t=Array.isArray(this.opts.css)?this.opts.css:[this.opts.css+"arx-frame.min.css",this.opts.css+"arx-content.min.css"],e=0;e<t.length;e++)this._buildCssLink(t[e])},_buildCustomCss:function(){if(this.opts.custom.css)for(var t=0;t<this.opts.custom.css.length;t++)this._buildCssLink(this.opts.custom.css[t])},_buildCssLink:function(t){var e="object"==typeof t?t:{href:t}
1,t=("string"==typeof t?t:t.href).search(/\?/g),t=this.opts.editor.csscache?"":(-1===t?"?":"&")+(new Date).getTime(),t=(e.href=e.href+t,this.dom("<link>").attr({class:this.prefix+"-css",rel:"stylesheet"}));t.attr(e),this.getHead().append(t)},_buildGridCssVar:function(){var t;this.opts.grid&&((t=this.getDocNode().documentElement.style).setProperty("--"+this.prefix+"-grid-columns",this.opts.grid.columns),t.setProperty("--"+this.prefix+"-grid-gutter",this.opts.grid.gutter),t.setProperty("--"+this.prefix+"-grid-offset-left",this.opts.grid.offset.left),t.setProperty("--"+this.prefix+"-grid-offset-right",this.opts.grid.offset.right),this.app.initialSettings.grid)&&this.app.initialSettings.grid.patterns&&(this.opts.grid.patterns=this.app.initialSettings.grid.patterns)},_buildParserTags:function(){var t,e,i=this.opts.parser;for(t in i)i[t].parse&&i[t].tag&&(e=i[t].tag,void 0===this.opts.parserTags[e]&&(this.opts.parserTags[e]=[]),this.opts.parserTags[e].push(i[t].parse))},_buildDraggable:function(){this.app.$body.find("[data-"+this.prefix+"-drop-id]").each(function(t){t.attr("draggable",!0),t.on("dragstart",function(t){var e=this.dom(t.target).attr("data-"+this.prefix+"-drop-id");t.dataTransfer.setData("item",e)}.bind(this))}.bind(this))},_load:function(){try{this._loadImages(),this._loaded()}catch(t){h.error(t)}},_loaded:function(){this.app.sync.build(),this.app.event.build(),this.app.embed.build(),this.app.blocks.build(),this.app.image.observeStates(),this._buildVisibility(),this._buildEditorCss(),this._buildCustomCss(),this._buildGridCssVar(),this._buildDraggable(),this.getWin().on("resize."+this.prefix+"-editor-frame",this.adjustHeight.bind(this)),this.app.broadcast("editor.load"),this.adjustHeight(),setTimeout(function(){this.app.isStopped()||(this.adjustHeight(),this._setFocusOnStart(),this.app.observer.build(),this.app.broadcast("editor.ready"))}.bind(this),500),setTimeout(this.adjustHeight.bind(this),3e3)},_loadedImage:function(){this.imageslen--},_loadImages:function(){var t=this.getDoc().find("img"),e=(this.imageslen=t.length,t.each(this._loadImage.bind(this)),setInterval(function(){0===this.imageslen&&(this.adjustHeight(),clearInterval(e))}.bind(this),50))},_loadImage:function(t){var e,i=t.get();this.opts.editor.images&&(e=(e=i.src.split("/"))[e.length-1],i.src=this.opts.editor.images+e),t.one("load",this._loadedImage.bind(this))},_setFocusOnStart:function(){this.opts.editor.focus&&(this.setFocus(),this.setFocus(this.opts.editor.focus))},_setSelectAllClass:function(){this.$editor.addClass(this.prefix+"-select-all")},_setFocusCaret:function(t){t=this._getCaretPosition(t);var e=this._getFocusTarget(t);this.app.block.set(e,t)},_setFocusEvent:function(){if(!this.isFocus()){for(var t=0;t<h.instances.length;t++)h.instances[t]!==this.app&&h.instances[t].editor.setBlur();this.app.container.setFocus(),this.app.broadcast("editor.focus")}},_getCaretPosition:function(t){return!0===t?"start":t},_getFocusTarget:function(t){return"start"===t?this.app.blocks.getFirst():this.app.blocks.getLast()},_getContent:function(){var t=this.$layout.html();return this.app.parser.unparse(t)},_getContentValue:function(){return this.opts.content||this.app.$element.val()},_enableToolbarButtons:function(){this.app.source.is()||this.isMobileView()||this.app.toolbar.enable()},_writeCode:function(t){var e=this.getDocNode();e.open(),e.write(t),e.close()},_createDoctype:function(){return this.opts.editor.doctype+"\n"},_createScripts:function(){if(!this.opts.custom.js)return"";for(var t="",e=this.opts.custom.js,i=0;i<e.length;i++){var s="object"==typeof e[i]?e[i]:{src:e[i]};s.src=s.src+"?"+(new Date).getTime(),t+=this.dom("<script>").addClass(this.prefix+"-js").attr(s).get().outerHTML}return t}}),t.add("module","observer",{init:function(){this.observer=!1,this.trigger=!0},build:function(){var t;window.MutationObserver&&(t=this.app.editor.getLayout().get(),this.observer=this._build(t),this.observer.observe(t,{attributes:!0,subtree:!0,childList:!0,characterData:!0,characterDataOldValue:!0}))},stop:function(){this.observer&&this.observer.disconnect(),this.trigger=!0},_build:function(e){var i=this;return new MutationObserver(function(t){i._observe(t[t.length-1],e)})},_observe:function(t,e){"attributes"===t.type&&t.target===e||this.trigger&&(this.app.editor.adjustHeight(),this.app.broadcast("observer.change"),this.app.placeholder.toggle(
1),this.app.sync.trigger())}}),t.add("module","parser",{build:function(t){return this.$layout=this.dom("<div>"),this.$layout.html(t),this.$layout.find("[data-"+this.prefix+"-type]").each(this._build.bind(this)),this.$layout},buildElement:function(t){t.find("[data-"+this.prefix+"-type]").each(this._build.bind(this))},buildPredefinedClasses:function(t){var e,i,s;this.opts.classes&&(t=t||this.app.editor.getLayout(),e=this.app.content,i=!(s=!0),(s=void 0!==this.opts.classes.blocks&&(i=!0,void 0===this.opts.classes.tags)?!1:s)&&t.find(e.getPredefinedTags().join(",")).each(e.addPredefinedTagClass.bind(this)),i)&&(s=e.getPredefinedBlocks(),s="["+(i="data-"+this.prefix+"-type")+"="+s.join("],["+i+"=")+"]",t.find(s).each(e.addPredefinedBlockClass.bind(this)))},parse:function(t,e,i){return t=t.trim(),t=this.app.broadcastHtml("editor.before.parse",t),t=this.app.content.isEmptyHtml(t)?this.app.block.createHtml():(t=this._clean(t,i),this._parse(t)),t=this.app.broadcastHtml("editor.parse",t),!1!==e?this.build(t):t},parseLine:function(t,e){return t=" "===t?"&nbsp;":(t=(t=this.app.broadcastHtml("editor.before.parse",t)).replace(/\r?\n/g,"<br>"),t=this.app.content.encodeCode(t),t=this.app.content.sanitize(t),t=this.app.content.removeEmptySpans(t),t=this.app.content.addHttps(t),this.app.broadcastHtml("editor.parse",t)),!1!==e?this.build(t):t},unparse:function(t,e){var i={};return t=t.trim(),t=this.app.broadcastHtml("editor.before.unparse",t),this.app.content.isEmptyHtml(t)?"":(t=this._revertForms(t),t=this._revertFrames(t),t=this.app.content.store(t,"noneditable",i,0),t=this.app.content.store(t,"embed",i,0),t=this.app.content.addNofollow(t),t=this.app.content.removeMarkers(t),t=this.app.utils.removeInvisibleChars(t),t=this.app.content.recacheStyle(t),t=this.app.content.restore(t,"noneditable",i),t=this.app.content.restore(t,"embed",i),t=this.app.content.removeEmptyAttrs(t,["style","class","rel","alt","title"]),t=this._unparseAllTags(t),t=this._unparseDataType(t,e),t=this.app.content.removeEmptyAttrs(t,["style","class","rel","alt","title"]),this.opts.classes&&(t=this.app.utils.wrap(t,this.buildPredefinedClasses.bind(this))),t=this._revertEmbedFrames(t="<p></p>"===t?"":t),this.app.broadcastHtml("editor.unparse",t))},_build:function(t){var e=t.attr("data-"+this.prefix+"-type");this.app.create("block."+e,t)},_clean:function(t,e){var i={},s=[];return t=(t=this.app.content.storeComments(t,s)).replace(/¤t/gi,"&current"),e&&this.app.editor.isTextarea()&&(t=this.app.content.encodeCode(t)),t=this.app.content.sanitize(t),t=this._convertFrames(t),t=this._convertForms(t),t=this.app.content.store(t,"noneditable",i,0),t=this.app.content.store(t,"embed",i,0),t=this.app.content.removeTags(t,this.opts.tags.denied),t=this.app.content.removeDoctype(t),t=this.app.content.removeTagsWithContent(t,["script","style"]),t=this.app.content.removeEmptySpans(t),t=this.app.content.addHttps(t),t=this.app.content.removeBlockTagsInside(t,["th","td","li","dt","dd","address"]),t=this.app.content.cacheStyle(t),t=this.app.content.restore(t,"noneditable",i),t=this.app.content.restore(t,"embed",i),t=this.app.content.restoreComments(t,s),this.opts.clean.comments&&(t=this.app.content.removeComments(t)),t=this.app.content.isEmptyHtml(t)?this.app.block.createHtml():this.app.content.paragraphize(t)},_parse:function(t){return this.app.utils.wrap(t,function(t){for(var e=this.app.element.getBlocks(t),i=0;i<e.length;i++)this._parseHtml(e[i]);this.buildPredefinedClasses(t)}.bind(this))},_parseHtml:function(t){var e,i=t.tagName.toLowerCase(),s=this.dom(t),n=this.opts.parserTags;if(n[i])for(var a=0;a<n[i].length&&!(e=n[i][a].call(this.app,s));a++);(e=e||this._parseType(s,i))&&(s.attr("data-"+this.prefix+"-type",e),"image"===e&&i!==this.opts.image.tag&&(s=this.app.element.replaceToTag(s,this.opts.image.tag,!0)),-1!==this.opts.nested.indexOf(e))&&this._parseNested(s)},_parseType:function(t,e){t=t.attr("data-"+this.prefix+"-type")?t.attr("data-"+this.prefix+"-type"):this._isNoneditable(t)?"noneditable":this._parseTypeByTag(t,e);return t},_parseNested:function(t){for(var e=this.app.element.getBlocks(t),i=0;i<e.length;i++)this._parseHtml(e[i])},_parseTypeByTag:function(t,e){var i;switch(e){case"p":i="paragraph",this._isImageBlock(t,"p")&&(i="image");break;case"figure":i="embed",this._isImageBlock(t,"figure")?i="image":this._hasChild(t,"pre")?i="code":this._hasChild(t,"blockquote")&&(i="quote");break;case"div":i="layer",t.attr("data-"+this.prefix+"-type")?i=!1:this._isGridBlock(t)?i="grid":this._isColumnBlock(t)?i="column":this._isTextBlock(t)?i="text":this._isCardBlock(t)?i="card":this._isImageBlock(t,"div")&&(i="image");break;case"h1":case"h2":case"h3":case"h4":case"h5":case"h6":i="heading";break;case"blockquote":i="quote";break;case"table":i="table";break;case"pre":i="code";break;case"hr":i="line";break;
1case"dl":i="dlist";break;case"address":i="address";break;case"ul":case"ol":i="list";break;case"main":case"section":case"header":case"footer":case"aside":case"article":i="layer"}return i},_isNoneditable:function(t){return t.hasClass(this.opts.noneditable.classname)},_isColumnBlock:function(t){if(this.opts.grid)return 0!==(t=t.parent()).length&&"grid"===t.attr("data-"+this.prefix+"-type")||void 0},_isGridBlock:function(t){if(this.opts.grid)return t.hasClass(this.opts.grid.classname)},_isTextBlock:function(t){return this.opts.text&&t.hasClass(this.opts.text.classname)},_isCardBlock:function(t){return this.opts.card&&t.hasClass(this.opts.card.classname)},_isImageBlock:function(t,e){var i=t.find("img");if(0!==i.length&&("div"!==e||0===i.closest("figure").length)){var s=i,i=i.parent(),n=0!==i.length&&i.get().tagName;if(!n||"A"!==n&&"SPAN"!==n){if(n&&i.get()!==t.get())return}else s=i;if(0===s.prevElement().length&&("figure"===e||0===s.nextElement().length))return!0}},_hasChild:function(t,e){if("pre"===e){if(0!==t.find("pre").length)return!0}else if("blockquote"===e){e=t.find("blockquote");if(0===t.find("script").length&&0!==e.length)return!0}},_getPredefinedTags:function(){var e=[];return Object.keys(this.opts.classes).forEach(function(t){e.push(t)}),e},_addPredefinedClass:function(t){var e=t.get().tagName.toLowerCase();void 0!==this.opts.classes[e]&&t.addClass(this.opts.classes[e])},_unparseAllTags:function(t){return this.app.utils.wrap(t,function(t){t.find("*").removeAttr("contenteditable data-gramm_editor"),this.opts.image.states||t.find("img").removeAttr("data-image")}.bind(this))},_unparseDataType:function(t,i){return this.app.utils.wrap(t,function(t){var e=t.find("[data-"+this.prefix+"-type]");!0!==i&&e.removeClass(this.prefix+"-block-state"),e.removeAttr("data-"+this.prefix+"-first-level data-"+this.prefix+"-parsed"),e.removeClass(this.prefix+"-block-focus "+this.prefix+"-block-multiple-focus "+this.prefix+"-block-multiple-hover "+this.prefix+"-editable-pause"),e.removeClass(this.prefix+"-empty-layer"),e.each(this._unparseByType.bind(this)),e.removeAttr("data-"+this.prefix+"-type"),t.find("figcaption").removeAttr("data-"+this.prefix+"-type data-placeholder").each(this.app.content._removeEmptyTag.bind(this))}.bind(this))},_unparseByType:function(t){var e=t.attr("data-"+this.prefix+"-type");"list"===e&&this.app.content.unfixListMargin(t),this.opts.parser[e]&&this.opts.parser[e].unparse&&this.opts.parser[e].unparse.call(this.app,t)},_convertFrames:function(t){return this.app.utils.wrap(t,function(t){t.find("iframe").each(this._convertFrame.bind(this))}.bind(this))},_convertForms:function(t){return this.app.utils.wrap(t,function(t){t.find("form").each(this._convertForm.bind(this))}.bind(this))},_convertFrame:function(t){0===t.closest("figure").length&&(t.wrap("<figure>"),t.parent().addClass(this.prefix+"-figure-iframe"))},_convertForm:function(t){t=this.app.element.replaceToTag(t,"figure");t.addClass(this.prefix+"-figure-form"),t.attr("data-"+this.prefix+"-type","form")},_revertFrames:function(t){return this.app.utils.wrap(t,function(t){t.find("."+this.prefix+"-figure-iframe").each(this._revertFrame.bind(this))}.bind(this))},_revertEmbedFrames:function(t){return this.app.utils.wrap(t,function(t){t.find("figure").each(this._revertEmbedFrame.bind(this))}.bind(this))},_revertForms:function(t){return this.app.utils.wrap(t,function(t){t.find("."+this.prefix+"-figure-form").each(this._revertForm.bind(this))}.bind(this))},_revertFrame:function(t){0!==t.find("figcaption").length?t.removeClass(this.prefix+"-figure-iframe"):t.unwrap()},_revertEmbedFrame:function(t){0===t.find("figcaption").length&&0===t.find("div").length&&t.unwrap()},_revertForm:function(t){this.app.element.replaceToTag(t,"form").removeClass(this.prefix+"-figure-form")}}),t.add("module","blocks",{build:function(){this._buildFirstLevel()},is:function(){return 1<this.getSelected().length},set:function(t){t=t.closest("[data-"+this.prefix+"-first-level]"),this.unsetNotFirstLevel(),this._setFocus(t),setTimeout(function(){this.app.selection.removeAllRanges()}.bind(this),0),this.app.path.build(),this.app.toolbar.build(),this.app.control.close(),this._checkSelected()},setFirstLevel:function(){this.app.blocks.getFirstLevel().addClass(this.prefix+"-block-focus")},unset:function(){this.getBlocks().removeClass(this.prefix+"-block-focus "+this.prefix+"-block-multiple-hover")},unsetNotFirstLevel:function(){this.getBlocks().not("[data-"+this.prefix+"-first-level]").removeClass(this.prefix+"-block-focus")},unsetHover:function(){this.getBlocks().removeClass(this.prefix+"-block-multiple-hover")},getBlocks:function(){return this.app.editor.getLayout().find("[data-"+this.prefix+"-type]")},getFirstLevel:function(){return this.app.editor.getLayout().find("[data-"+this.prefix+"-first-level]")},getEditableBlocks:function(){return this.app.editor.getLayout().find("[contenteditable=true]")},getSelected:function(){return this.app.editor.getLayout().find("."+this.prefix+"-block-focus")}
1,getSelectedBlocks:function(){return this.getSelectedBlocks()},getFirst:function(){return this.getBlocks().first().dataget("instance")},getFirstSelected:function(){return this.getSelected().first().dataget("instance")},getLast:function(){return this.getBlocks().last().dataget("instance")},getLastSelected:function(){return this.getSelected().last().dataget("instance")},pauseEditableBlocks:function(){this.getEditableBlocks().attr("contenteditable",!1).addClass(this.prefix+"-editable-pause")},runEditableBlocks:function(){this.app.editor.getLayout().find("."+this.prefix+"-editable-pause").attr("contenteditable",!0).removeClass(this.prefix+"-editable-pause")},removeSelected:function(t){var e,i=this.getLastSelected();!1!==t&&i&&(e=i.getNext()),this.getSelected().each(this._removeSelectedBlock.bind(this)),e&&this.app.block.set(e,"start")},_buildFirstLevel:function(){var t="data-"+this.prefix+"-first-level",e=this.app.editor.getLayout();e.find("["+t+"]").removeAttr(t),e.children("[data-"+this.prefix+"-type]").attr(t,!0)},_checkSelected:function(){var t=this.getFirstLevel(),e=this.getSelected();0===e.length?(this.unsetHover(),this.app.block.unset()):1===e.length?(this.unsetHover(),this.app.block.set(e.eq(0),!1,!0)):t.length===e.length?(this.unsetHover(),this.app.editor.selectAll()):this.app.editor.unsetSelectAllClass()},_setFocus:function(t){var e=t.hasClass(this.prefix+"-block-focus")?"removeClass":"addClass";t[e](this.prefix+"-block-focus"),t.removeClass(this.prefix+"-block-multiple-hover")},_removeSelectedBlock:function(t){t.dataget("instance").remove({traverse:!1})}}),t.add("module","block",{init:function(){this.instance=!1,this.$block=!1},create:function(t){var e=this.app.create("block."+this.opts.editor.markup);return t&&e.getBlock().html(t),e},createHtml:function(t){return this.create(t).getOuterHtml()},is:function(t){return t?this._isBlockActive(t):this.get()},isType:function(t){if(this.is())return this.get().isType(t)},isParent:function(t){var e;if(this.is())return t=Array.isArray(t)?t:[t],e=this.get().getBlock(),0!==this.app.element.getParents(e,t).length},get:function(){return this.instance},set:function(t,e,i){t.isBlock&&(t=t.getBlock()),!0!==i&&this._isBlockActive(t)||(this.unset(),this.instance=this._getInstance(t),this.$block=this.instance.getBlock(),this.$block.addClass(this.prefix+"-block-focus"),this._setCaret(e),this.app.path.build(),this.app.toolbar.build(),this.app.control.build(),this.app.broadcast("block.set"))},unset:function(){this.instance&&(this.instance=!1,this.$block=!1,this.app.blocks.unset(),this.app.editor.unsetSelectAllClass(),this.app.path.build(),this.app.toolbar.build(),this.app.control.close(),this.app.broadcast("block.unset"))},duplicate:function(){var t,e;if(this._isAction())return t=(e=this.get()).duplicate(),e=e.insert({instance:t,position:"after",caret:"start",type:"duplicate"}),this.app.broadcast("block.duplicate",{instance:e}),e},moveUp:function(){this._isAction()&&this.get().moveUp()},moveDown:function(){this._isAction()&&this.get().moveDown()},change:function(t){var e,i;this.is()&&(e=this.get().getBlock(),i=t.getBlock(),e.after(i),e.remove(),this.app.parser.buildElement(i),this.app.editor.build(),this.set(t),this.app.broadcast("block.change",{instance:t}))},add:function(t){this.app.popup.close();var e,i=this.get(),s=(t.type&&"image"===t.type&&i&&"cell"===i.getType()&&(i=i.getParent("table")),!1),n=!1,a=t.instance||this.app.create("block."+t.name,t.source),o=(this.app.editor.isAllSelected()?(i=this.create(),this.app.editor.unsetSelectAllClass(),this.app.editor.getLayout().html("").append(i.getBlock()),n="after",s=!0):this.app.blocks.is()?(i=this.app.blocks.getLastSelected(),n="after"):i?i.isInlineBlock()?"variable"!==a.getType()&&(o=i.getParent(),this.app.caret.set(i.getBlock(),"after"),this.app.block.set(o),i=this.get()):i.isEmptiable()&&i.isEmpty()&&((o=i.getBlock()).removeClass(this.prefix+"-empty-layer"),o.html(""),n="append"):n="top"===this.opts.editor.add?(i=this.app.blocks.getFirst(),"before"):(i=this.app.blocks.getLast(),"after"),n=t.position||n,!0);return i&&(e=i.getType(),"paragraph"===t.name)&&-1!==["paragraph","text","heading"].indexOf(e)&&(o=!1),i.insert({instance:a,position:n,caret:t.caret||"end",remove:o,type:"add"}),s&&i.remove(),a},format:function(t){this.app.format.set(t)},remove:function(t){var e,i,s,n=this.get();n&&(e=n.getType(),i=n.getParent(),!t||void 0===t.traverse||!1!==t.traverse?(t=n.getNext(),s=n.getPrev(),n.remove(),t?this.app.block.set(t,"start"):s?this.app.block.set(s,"end"):this.unset()):(this.unset(),n.remove()),"image"===e&&this.app.broadcast("image.remove",{url:n.getSrc(),id:n.getId()}),this.app.broadcast("block.remove",{type:e,parent:i}),this.app.editor.isEmpty())&&this.app.editor.setEmpty()},observe:function(t,e){return!(-1!==["line","quote","layer","code"].indexOf(e)&&!this.opts[e]||"alignment"===e&&!this.opts.align||"valign"===e&&!this.opts.valign||"outset"===e&&!this.opts.outset)&&void 0},observeCard:function(t,e){if("image"===e&&!this.get().hasImage())return!1}
1,popup:function(t,e,i){var s;"alignment"===i?s=this._buildSegments("align","alignment"):"valign"===i?s=this._buildSegments("valign"):"outset"===i&&(s=this._buildSegments("outset")),this.app.popup.create(i,{setter:"block.setData",getter:"block.getData",form:s}),this.app.popup.open({button:e})},css:function(t,e){var i;this.is()&&((i=this.get().getBlock()).css(t,e),t="data-"+this.prefix+"-style-cache",e=i.attr("style"))&&(e=e.replace(/"/g,""),i.attr(t,e))},getData:function(){if(this.is())return this.get().getData()},setData:function(t){this.is()&&(t=t.getData(),this.get().setData(t))},_isBlockActive:function(t){return!this.app.blocks.is()&&this.instance&&this.dom(t).get()===this.$block.get()},_isAction:function(){return!this.app.blocks.is()&&this.is()},_buildSegments:function(t,e){var i,s={},n={},a=this.opts[t];for(i in a)a[i]&&(n[i]={name:a[i],prefix:t});return s[t]={type:"segment",label:"## form."+(e=e||t)+" ##",segments:n},s},_appendToEmptyBlock:function(t){var e=this.app.block.create();return e.append(t),e.getBlock()},_getInstance:function(t){return this.dom(t).dataget("instance")},_setCaret:function(t){var e;this.instance.isEditable()?t&&(e=this.$block,"list"!==this.instance.getType()||"start"!==t&&"end"!==t||(e="start"===t?this.$block.find("li").first():this.$block.find("li").last()),this.app.caret.set(e,t)):(this.app.scroll.save(),this.app.editor.getWin().focus(),this.$block.focus(),setTimeout(function(){this.app.selection.removeAllRanges()}.bind(this),0),this.app.scroll.restore())}}),t.add("module","event",{init:function(){this.dragoverEvent=!1,this.imageDrag=!1,this.pressedCmd=!1,this.isPopupMouseUp=!1,this.isBlockMouseUp=!1,this.pasteEvent=!1,this.events={frame:["click","contextmenu","touchstart","mouseover","mouseup","mousedown","keydown","keyup","paste","copy","cut","drop","dragstart","dragover","dragleave"],doc:["keydown","mousedown","click"],win:["focus"],editor:["click"]}},run:function(){this._runEvents()},pause:function(){this._pauseEvents()},build:function(){this._buildTargets(),this._buildPreventLinks(),this._buildEvents()},stop:function(){var t=this.prefix+"-events";this.$body.off("."+t),this.$win.off("."+t),this.app.$doc.off("."+t)},onmouseover:function(t){this._buildHover(t),this.app.broadcast("editor.mouseover",{e:t})},oncontextmenu:function(t){this.pressedCmd&&(t.preventDefault(),t=this._getBlock(t),this.app.blocks.set(t))},onclick:function(t){this.app.broadcast("editor.click",{e:t}),this._isEditorClick(t)&&!this.isBlockMouseUp&&this._setByClick(t)},onmouseup:function(t){this.app.state.add(t),this.app.broadcast("editor.mouseup",{e:t}),this.app.toolbar.observe()},onmousedown:function(t){this.app.popup.isOpen()&&this.app.popup.close(),this._setBlock(t),this._setCaretInline(t),this.app.placeholder.handleClick(t),this._isEditorClick(t)?this.isBlockMouseUp=!1:(this.isBlockMouseUp=!0,this.app.state.add(t),this.app.broadcast("editor.mousedown",{e:t}))},ontouchstart:function(t){this.app.state.add(t)},onkeydown:function(t){var e=this.app.broadcast("editor.keydown",this._buildEventKeysObj(t));if(e.isStopped())return t.preventDefault();!1===this.opts.editor.enterKey&&13===t.which?t.preventDefault():this.app.state.listen(t)||(this.pressedCmd=this._isCmdPressed(t),this._isEsc(t)&&(this.app.block.unset(),this.app.selection.removeAllRanges()),this.app.shortcut.handle(t))?this.pressedCmd=!1:this.app.input.handle(e)},onkeyup:function(t){var e;if(this.app.broadcast("editor.keyup",this._buildEventKeysObj(t)).isStopped())return t.preventDefault();t.which!==this.app.keycodes.TAB||this.app.block.is()||(t.target&&"BODY"===t.target.tagName?(e=this.app.blocks.getFirst(),this.app.editor.setFocus(),this.app.block.set(e)):this._setBlock(t)),this.pressedCmd=!1,this.app.blocks.unsetHover(),this.app.toolbar.observe()},onpaste:function(t){this._paste(t)},oncopy:function(t){this._copy(t)},oncut:function(t){this._cut(t)},ondrop:function(t){var e,i,s;return!this.opts.editor.drop||this.app.broadcast("editor.drop",{e:t}).isStopped()?t.preventDefault():(""!==(s=(e=t.dataTransfer).getData("item"))?(t.preventDefault(),(i=this.opts.draggable&&void 0!==this.opts.draggable[s]?this.opts.draggable[s]:(i=this.dom("[data-"+this.prefix+"-drop-item="+s+"]").html()).trim())&&(s="after",0!==this.app.editor.getBody().find("."+this.prefix+"-draggable-over").length&&(s="append"),this._drop(t,i,s,!1))):this.opts.image&&this.opts.image.upload&&null!==e.files&&0<e.files.length?(t.preventDefault(),this.app.image.drop(t,e)):(i=""===(i=e.getData("text/html")).trim()?e.getData("Text"):i,s=this._drop(t,i),this.imageDrag&&0!==s.instances.length&&s.instances[0].change(this.imageDrag,!1)),this._removeDragPlaceholder(),this.imageDrag=!1,void(this.app.observer.trigger=!0))},ondragstart:function(t){var e=this._getBlock(t.target);0!==e.length&&"image"===this.app.element.getType(e)&&(this.imageDrag=e.dataget("instance")),this.app.broadcast("editor.dragstart",{e:t})},ondragover:function(t){var e,i;t.preventDefault(),this.dragoverEvent=!0,this.app.observer.trigger=!1,this._removeDragPlaceholder(),-1!==t.dataTransfer.types.indexOf("item")&&0!==(e=this._getBlock(t.target)).length&&((i=e.dataget("instance")).getType("layer")&&i.isEmpty()?e.addClass(this.prefix+"-draggable-over"):(i=this.dom("<div>").addClass(this.prefix+"-draggable-placeholder"),e.after(i))),this.app.broadcast("editor.dragover",{e:t})},ondragleave:function(t){t.preventDefault(),this.dragoverEvent=!1,this._removeDragPlaceholder(),this.app.observer.trigger=!0,this.app.broadcast("editor.dragleave",{e:t})},oneditorclick:function(t){"HTML"===t.target.tagName&&this._setByClick(t)},onwinfocus:function(t){this._isRemoveRanges()&&setTimeout(function(){this.app.selection.removeAllRanges()}.bind(this),0)},ondockeydown:function(t){if(this.app.popup.isOpen()){if(this._isEnter(t)){var e=this.app.popup.getStack();if(!1!==e.hasForm()&&"TEXTAREA"!==t.target.tagName)return t.preventDefault(),void e.getFooterPrimary().dataget("instance").invokeCommand()}this._isEsc(t)&&this.app.popup.close(!1)}},ondocmousedown:function(t){this.isPopupMouseUp=0!==this.dom(t.target).closest("."+this.prefix+"-popup-"+this.uuid).length},ondocclick:function(t){this._isOutsideEditor(t)&&(this.app.popup.isOpen()?!1===this.isPopupMouseUp&&this.app.popup.close(!1):this.app.editor.setBlur(),this.pressedCmd=!1)},_buildPreventLinks:function(){var t=this.prefix+"-prevent-events";this.$body.on("click."+t+" dblclick."+t,this._preventLinks.bind(this))},_buildTargets:function(){this.$body=this.app.editor.getBody(),this.$win=this.app.editor.getW
1in()},_buildEventKeysObj:function(t){var e=t.which,i=[this.app.keycodes.UP,this.app.keycodes.DOWN,this.app.keycodes.LEFT,this.app.keycodes.RIGHT],s=!t.ctrlKey&&!t.metaKey&&(48<=e&&e<=57||65<=e&&e<=90),n=this.app.keycodes;return{e:t,key:e,ctrl:t.ctrlKey||t.metaKey,shift:t.shiftKey,alt:t.altKey,select:(t.ctrlKey||t.metaKey)&&!t.altKey&&65===e,enter:e===n.ENTER,space:e===n.SPACE,esc:e===n.ESC,tab:!(e!==n.TAB||t.shiftKey||t.altKey||t.ctrlKey||t.metaKey),delete:e===n.DELETE,backspace:e===n.BACKSPACE,alpha:s,arrow:-1!==i.indexOf(e),left:e===n.LEFT,right:e===n.RIGHT,up:e===n.UP,down:e===n.DOWN,"left-right":e===n.LEFT||e===n.RIGHT,"up-left":e===n.UP||e===n.LEFT,"down-right":e===n.DOWN||e===n.RIGHT}},_buildEvents:function(){var t=this.prefix+"-events";this._buildTargetEvents(this.$body,this.events.frame,t,""),this._buildTargetEvents(this.$win,this.events.win,t,"win"),this._buildTargetEvents(this.app.$doc,this.events.doc,t,"doc"),this._buildTargetEvents(this.app.editor.getDoc(),this.events.editor,t,"editor")},_buildTargetEvents:function(t,e,i,s){for(var n=0;n<e.length;n++)t.on(e[n]+"."+i,this["on"+s+e[n]].bind(this))},_buildHover:function(t){var e=this.app.block.get();this.pressedCmd&&e&&(0===(e=this.dom(t.target).closest("[data-"+this.prefix+"-first-level]")).length||(this.app.blocks.unsetHover(),e.hasClass(this.prefix+"-block-focus"))||e.addClass(this.prefix+"-block-multiple-hover"))},_runEvents:function(){var t=this.prefix+"-events";this._buildTargetEvents(this.$body,this.events.frame,t,""),this._buildTargetEvents(this.$win,this.events.win,t,"win")},_pauseEvents:function(){var t=this.prefix+"-events";this.$body&&(this.$body.off("."+t),this.$win.off("."+t))},_getBlock:function(t){return this.dom(t).closest("[data-"+this.prefix+"-type]")},_setByClick:function(n){var t=this.app.blocks.getFirstLevel(),e=[],a=(t.each(function(t){t=t.get().getBoundingClientRect();e.push([t.x,t.y,t.y+t.height])}),[]),o=!1,i=(e.forEach(function(t,e){var i=parseInt(n.clientY),s=parseInt(n.clientX);t[1]<i&&i<t[2]?o=e:(e=Math.hypot(t[0]-s,t[1]-i),a.push(parseInt(e)))}),!1!==o?o:a.indexOf(Math.min.apply(Math,a))),t=t.eq(i);this.app.block.set(t.dataget("instance"),"start"),this.app.editor.setFocus()},_setCaretInline:function(e){var t=this.app.block.get(),i=!1;t&&t.isEditable()&&(this.app.element.isEmptyOrImageInline(e.target)?this.app.caret.set(e.target,"after"):this.app.selection.isCollapsed()&&"CODE"===e.target.tagName&&(i=!0,setTimeout(function(){var t=this.app.selection.getElement();t&&i&&"CODE"!==t.tagName&&(this.app.caret.set(e.target,"start"),i=!1)}.bind(this),1)))},_setBlock:function(t){this.app.editor.setFocus();var e=t?this._getBlock(t.target):this.app.selection.getDataBlock();0!==e.length&&(!1===e.attr("contenteditable")&&t.preventDefault(),(this.pressedCmd?(t&&t.preventDefault(),this.app.blocks):this.app.block).set(e))},_isRemoveRanges:function(){var t=this.app.block.get();return this.app.blocks.is()||t&&t.isInlineBlock()},_isEsc:function(t){return t.which===this.app.keycodes.ESC},_isEnter:function(t){return t.which===this.app.keycodes.ENTER},_isEditorClick:function(t){if(this.app.editor.isEditor(t.target))return t.preventDefault(),!0},_isOutsideEditor:function(t){return 0===this.dom(t.target).closest("."+this.prefix+["-container-","-popup-","-control-"].join(this.uuid+",."+this.prefix)+this.uuid).length},_isCmdPressed:function(t){return!!this.opts.selection.multiple&&(t.ctrlKey||t.metaKey)&&!t.shiftKey&&!t.altKey},_isLinkClick:function(t){return 0!==this.dom(t.target).closest("a").length},_removeDragPlaceholder:function(){var t=this.app.editor.getBody();t.find("."+this.prefix+"-draggable-placeholder").remove(),t.find("."+this.prefix+"-draggable-over").removeClass(this.prefix+"-draggable-over")},_preventLinks:function(t){this._isLinkClick(t)&&t.preventDefault()},_drop:function(t,e,i,s){var n=0===(n=this.app.element.getDataBlock(t.target)).length?this.app.blocks.getFirst():n,n=(this.app.block.set(n),i||this.app.insertion.insertPoint(t),!0),t=!0,a=this.app.block.get(),o=this.app.editor.isAllSelected();if(a&&"code"===a.getType()&&!o&&(e=this.app.content.getTextFromHtml(e,{nl:!(t=n=!1),trimlines:!1})),!1===s&&(n=!1),""!==e)return e=n?this.app.autoparse.parse(e):e,this.app.insertion.insertContent({html:e,clean:n,parse:t,position:i})},_paste:function(t){t.preventDefault();var e,i,s,n,a=t.clipboardData;this.app.image.insertFromClipboard(a)||(i=a.getData("URL"),e=this.app.clipboard.getContent(a),this.pasteEvent=!0,(t=this.app.broadcast("editor.before.paste",{e:t,html:e})).isStopped()||(e=t.get("html"),e=i&&""!==i?i:e,t=this.app.block.get(),s=i=!0,n=this.app.editor.isAllSelected(),this.opts.paste.plaintext?e=this.app.content.getTextFromHtml(e,{br:!(s=i=!1)}):t&&"code"===t.getType()&&!n?e=this.app.content.getTextFromHtml(e,{nl:!(s=i=!1),trimlines:!1}):this.opts.paste.clean||(i=!1),e=this.opts.paste.links?e:this.app.content.removeTags(e,["a"]),""!==(e=this.opts.paste.images?e:this.app.content.removeTags(e,["img"]))&&((t=a.getData("text/rtf"))&&(n=this._findLocalImages(e),e=this._replaceLocalImages(e,n,this._extractImagesFromRtf(t))),e=i?this.app.autoparse.parse(e):e,a=this.app.insertion.insertContent({html:e,clean:i,parse:s}),this.opts.image.upload&&this.app.image.parseInserted(a),this.app.placeholder.toggle(
1),this.app.broadcast("editor.paste",a))),this.pasteEvent=!1)},_copy:function(t){this._action(t,"copy")},_cut:function(t){this._action(t,"cut")},_action:function(t,e){var i=this.app.block.get(),s=this.app.blocks.is(),n={html:!1,remove:"content"};!s&&!i||!s&&i&&i.isEditable()&&this.app.selection.isCollapsed()||(t.preventDefault(),this.app.editor.isAllSelected()?n={html:this.app.editor.getLayout().html(),remove:"all"}:s?n={html:this._copyFromMultiple(e),remove:"blocks"}:i&&i.isEditable()?n=this._copyFromEditable(e,i):i&&(n=this._copyFromNonEditable(e,i)),(s=this.app.broadcast("editor.before."+e,{e:t,html:n.html})).isStopped())||("cut"===e&&this._cutDeleteContent(n),i=s.get("html"),i=this.app.clipboard.setContent(t,i),this.app.broadcastHtml("editor."+e,i))},_cutDeleteContent:function(t){var e,i;"instance"===t.remove?(t.instance.remove(!0),this.app.control.close()):"all"===t.remove?this.app.editor.setEmpty():"blocks"===t.remove?this.app.blocks.removeSelected(!1):"row"===t.remove?t.instance.getBlock().find("td, th").html(""):"noneditable"===t.remove?(e=t.instance.getType(),i=t.instance.getParent("layer"),"column"===e?t.instance.setEmpty():(t.instance.remove(!0),this.app.control.close()),"layer"===e&&i&&i.isEmpty()&&i.setEmpty()):!1!==t.remove&&this.app.selection.deleteContents()},_copyFromMultiple:function(t){var e=this.app.blocks.getSelected(),i=this.dom("<div>");return e.each(function(t){i.append(t.clone())}),i.html()},_copyFromEditable:function(t,e){var i=e.getType(),s=this.app.selection.getHtml(),n="content";return"figcaption"===i||"cell"===i?n="content":e.isAllSelected()?(s=e.getOuterHtml(),n="instance"):"dlist"===i?-1===s.search(/<dl/gi)&&(s="<dl>"+s+"</dl>"):"list"===i&&(i=e.getTag(),-1!==s.search(/<li/gi))&&(s="<"+i+">"+(s=-1===s.search(/^<li/g)?"<li>"+s+"</li>":s)+"</"+i+">"),{html:s,remove:n,instance:e}},_copyFromNonEditable:function(t,e){var i=e.getBlock(),s=e.getType(),n="",a="noneditable";return"column"===s?n=i.html():"row"===s?(n="<table>"+(n=e.getOuterHtml())+"</table>",a="row"):n=e.getOuterHtml(),{html:n,remove:a,instance:e}},_findLocalImages:function(t){var e=[];return this.app.utils.wrap(t,function(t){t.find("img").each(function(t){-1!==t.attr("src").search(/^file:\/\//)&&e.push(t.attr("src"))})}),e},_extractImagesFromRtf:function(t){if(!t)return[];var e=/{\\pict[\s\S]+?\\bliptag-?\d+(\\blipupi-?\d+)?({\\\*\\blipuid\s?[\da-fA-F]+)?[\s}]*?/,i=new RegExp("(?:("+e.source+"))([\\da-fA-F\\s]+)\\}","g"),s=t.match(i);if(!s)return[];for(var n=[],a=0;a<s.length;a++){var o=!1;-1!==s[a].indexOf("\\pngblip")?o="image/png":-1!==s[a].indexOf("\\jpegblip")&&(o="image/jpeg"),o&&n.push({hex:s[a].replace(e,"").replace(/[^\da-fA-F]/g,""),type:o})}return n},_convertHexToBase64:function(t){return btoa(t.match(/\w{2}/g).map(function(t){return String.fromCharCode(parseInt(t,16))}).join(""))},_replaceLocalImages:function(t,e,i){if(e.length===i.length)for(var s=0;s<e.length;s++){var n="data:"+i[s].type+";base64,"+this._convertHexToBase64(i[s].hex);t=t.replace(new RegExp('src="'+e[s]+'"',"g"),'src="'+n+'"')}return t}}),t.add("module","input",{handle:function(t){var e=t.get("e"),i=t.get("key");this._doSelectAll(e,t)||(t.is("enter")&&t.is("shift")?this.handleShiftEnter(e,i,t):t.is("enter")?this.handleEnter(e,i,t):t.is("space")&&t.is("shift")?this.handleShiftSpace(e,i,t):t.is("space")?this.handleSpace(e,i,t):t.is("tab")&&this.opts.tab.key?this.handleTab(e,i,t):t.is("arrow")?t.is(["shift","alt","ctrl"])||this.handleArrow(e,i,t):t.is(["delete","backspace"])&&this.handleDelete(e,i,t))},handleDelete:function(t,e,i){var s,n,a=this.app.block.get(),o=i.is("backspace"),r=i.is("delete");this.app.blocks.is()?(t.preventDefault(),this.app.blocks.removeSelected()):a&&a.isEditable()&&this._trimInvisibleChar(t,i.is("backspace")?"left":"right",r)||((s=this.app.selection.getInline())&&1===s.innerHTML.length?(t.preventDefault(),s.innerHTML=""):a.handleDelete&&a.handleDelete(t,e,i)||(s=a.getNext(),e=a.getPrev(),a.isInlineBlock()?(t.preventDefault(),i=a.getBlock(),n=a.getParent(),this.app.caret.set(i,"after"),a.remove(!0),this.app.block.set(n)):a.isEditable()?a.isEditable()&&(i=a.getType(),a.isAllSelected()?(t.preventDefault(),"card"===i?this.app.block.remove():a.setEmpty()):r&&s&&a.isCaretEnd()?(t.preventDefault(),"card"!==s.getType()&&s.isEditable()?"card"!==i&&a.appendNext():this.app.block.set(s)):o&&e&&a.isCaretStart()&&(t.preventDefault(),"card"!==e.getType()&&e.isEditable()?"card"!==i&&"cell"!==i&&a.appendToPrev():(this.app.block.set(e),a.isEmpty()&&a.remove(!0)))):(t.preventDefault(),a.remove(!0),s?this.app.block.set(s,"start"):e?this.app.block.set(e,"end"):this.app.editor.isEmpty()?this.app.editor.setEmpty():this.app.block.unset())))}
1,handleArrow:function(t,e,i){var s=this.app.block.get();if(!this.app.blocks.is()){if(s.isEditable()){var n=this.app.selection.getCurrent(),a=this.app.selection.getTopInline();if(i.is("right")&&a&&"CODE"===a.tagName){var o=this.app.caret.is(a,"end"),r=this.app.caret.is(s.getBlock(),"end");if(o&&r)return t.preventDefault(),void this.app.caret.set(a,"after")}if(a&&this._catchInlineBlock(t,i,a))return;if(n&&this._catchInlineBlock(t,i,n))return}s.isEditable()&&this._trimInvisibleChar(t,i.is("left")?"left":"right")||s.handleArrow&&s.handleArrow(t,e,i)||(s.isInlineBlock()?(t.preventDefault(),o=s.getBlock(),r=s.getParent(),a=i.is("up-left")?"before":"after",this.app.caret.set(o,a),this.app.block.set(r)):this._doArrow(t,i,s))}},handleTab:function(t,e,i){var s=this.app.block.get();this.app.blocks.is()?t.preventDefault():s.handleTab&&s.handleTab(t,e,i)||(this.opts.tab.spaces&&s.isEditable()?(t.preventDefault(),e=this.opts.tab.spaces,i=document.createTextNode(Array(e+1).join(" ")),this.app.insertion.insertNode(i,"end")):s.isInlineBlock()?(t.preventDefault(),e=s.getBlock(),i=s.getParent(),this.app.caret.set(e,"after"),this.app.block.set(i)):(t.preventDefault(),(e=s.getNext())&&this.app.block.set(e,"start")))},handleShiftSpace:function(t,e,i){var s,n,a=this.app.block.get();this.app.blocks.is()||(s=a.getBlock(),a.isEditable()?a.isAllSelected()?a.setEmpty():"code"!==a.getType()&&(t.preventDefault(),this.app.insertion.insertHtml("&nbsp;","end")):a.isInlineBlock()?(t.preventDefault(),n=a.getParent(),this.app.caret.set(s,"after"),a.remove(!0),this.app.block.set(n),this.app.insertion.insertHtml("&nbsp;","end")):a.isEmptiable()&&a.isEmpty()&&(t.preventDefault(),s.removeClass(this.prefix+"-empty-layer"),s.html(""),a.insertEmpty({position:"append",caret:"start"})))},handleSpace:function(t,e,i){var s,n,a=this.app.block.get();this.app.blocks.is()?(t.preventDefault(),this.app.blocks.getLastSelected().insertEmpty({position:"after",caret:"start"}),this.app.blocks.removeSelected(!1)):(s=a.getBlock(),n=a.getType(),a.handleSpace&&a.handleSpace(t,e,i)||("row"===n?t.preventDefault():a.isEditable()&&a.isAllSelected()?a.setEmpty():a.isInlineBlock()?(t.preventDefault(),e=a.getParent(),this.app.caret.set(s,"after"),a.remove(!0),this.app.block.set(e),this.app.insertion.insertHtml("&nbsp;","end")):a.isEmptiable()&&a.isEmpty()?(t.preventDefault(),s.removeClass(this.prefix+"-empty-layer"),s.html(""),a.insertEmpty({position:"append",caret:"start"})):a.isEditable()||(t.preventDefault(),a.insertEmpty({position:"after",caret:"start"}),a.remove(!0),this.app.control.updatePosition())))},handleShiftEnter:function(t,e,i){var s=this.app.block.get(),n=s.getType(),a=s.getBlock();this.app.blocks.is()||"row"===n?t.preventDefault():s.isInlineBlock()?(t.preventDefault(),n=s.getParent(),this.app.caret.set(a,"after"),s.remove(!0),this.app.block.set(n),this.app.insertion.insertBreakline()):s.isEditable()?(t.preventDefault(),this.app.insertion.insertBreakline()):(t.preventDefault(),n="after",s.isEmptiable()&&s.isEmpty()&&(n="append",a.removeClass(this.prefix+"-empty-layer"),a.html("")),s.insertEmpty({position:n,caret:"start"}))},handleEnter:function(t,e,i){var s=this.app.block.get();if(this.app.blocks.is())t.preventDefault(),this.app.blocks.getLastSelected().insertEmpty({position:"after",caret:"start"});else{var n,a=s.getBlock();if(s.isEditable()){if(s.isAllSelected())return t.preventDefault(),void s.setEmpty();if(!this.app.selection.isCollapsed())return t.preventDefault(),void("code"===s.getType()?this.app.insertion.insertNewline():this.app.insertion.insertBreakline())}s.isInlineBlock()?(t.preventDefault(),n=s.getParent(),this.app.caret.set(a,"after"),s.remove(!0),this.app.block.set(n)):s.isEmptiable()&&s.isEmpty()?(t.preventDefault(),a.removeClass(this.prefix+"-empty-layer"),a.html(""),s.insertEmpty({position:"append",caret:"start"})):s.isEditable()||(t.preventDefault(),s.insertEmpty({position:"after",caret:"start"})),s.handleEnter&&s.handleEnter(t,e,i),this.app.control.updatePosition()}},handleTextareaTab:function(t){if(9!==t.keyCode)return!0;t.preventDefault();var t=t.target,e=t.value,i=t.selectionStart;t.value=e.substring(0,i)+"    "+e.substring(t.selectionEnd),t.selectionStart=t.selectionEnd=i+4},_isNextBlock:function(t,e){return t.is("right")&&this.app.caret.is(e,"end")&&this.app.element.getType(e.nextSibling)},_isPrevBlock:function(t,e){return t.is("left")&&this.app.caret.is(e,"start")&&this.app.element.getType(e.previousSibling)},_isSiblingInlineBlock:function(t,e){e=this.dom(e).dataget("instance");if(e&&e.isInlineBlock())return t.preventDefault(),this.app.block.set(e),!0},_isInvisibleChar:function(t){var e=this.app.selection.get(),t=this.app.selection.getText(t);return e.current&&3===e.current.nodeType&&0===this.app.utils.searchInvisibleChars(t)}
1,_catchInlineBlock:function(t,e,i){if(e.is("left")&&3===i.nodeType){var s=i.textContent;if(-1!==this.app.utils.searchInvisibleChars(s)){s=i;if(this._isSiblingInlineBlock(t,i.previousSibling))return s.parentNode.removeChild(s),!0}}if(this._isPrevBlock(e,i)){if(this._isSiblingInlineBlock(t,i.previousSibling))return!0}else if(this._isNextBlock(e,i)&&this._isSiblingInlineBlock(t,i.nextSibling))return!0},_trimInvisibleChar:function(t,e,i){var s="left"===e?"before":"after",n=this.app.selection.get(),s=this._isInvisibleChar(s);if(s&&"left"===e){var a=n.current,o=this.app.offset.get();this.dom(a).replaceWith(a.textContent.replace(/\uFEFF/g,"")),this.app.offset.set(!1,{start:o.start-1,end:o.end-1})}else if(s&&i&&n.current&&n.current.nextSibling)a=n.current.nextSibling,this.dom(a).replaceWith(a.textContent.replace(/\uFEFF/g,""));else if(s&&"right"===e)return t.preventDefault(),a=n.current,o=this.app.offset.get(),this.app.offset.set(!1,{start:o.start+1,end:o.end+1}),!0},_doSelectAll:function(t,e){var i=this.app.block.get();return this._isAllSelected(e)?(this._setEditorEmpty(t,e),!0):e.is("select")?(t.preventDefault(),this.app.blocks.is()||!i||i.isAllSelected()||i.isEmpty()?this.app.editor.selectAll():i.setSelectAll(),!0):void 0},_doArrow:function(t,e,i){var s,n,a=i.getType(),o=["code","line","image","embed","layer","grid"];if(e.is("up-left")&&i.isCaretStart()){if(n="end",!(s=i.getPrev())&&-1!==o.indexOf(a))return void this.app.insertion.insertEmptyBlock({position:"before",caret:"start"})}else if(e.is("down-right")&&i.isCaretEnd()&&(n="start",!(s=i.getNext()))&&-1!==o.indexOf(a))return void this.app.insertion.insertEmptyBlock({position:"after",caret:"start"});s&&(t.preventDefault(),this.app.block.set(s,n))},_isAllSelected:function(t){return this.app.editor.isAllSelected()&&t.is(["enter","delete","backspace","alpha","space"])},_setEditorEmpty:function(t,e){e.is(["alpha","space"])||t.preventDefault(),this.app.editor.setEmpty()}}),t.add("module","toolbar",{init:function(){this.eventname=this.prefix+"-toolbar",this.activeClass="active",this.toggledClass="toggled",this.disableClass="disable",this.customButtons={},this.aTags={},this.aTypes={}},start:function(){this.opts.toolbar?this.sticky=this.opts.toolbar:this.opts.path&&this.opts.path.sticky&&(this.sticky=this.opts.path),this._isToolbar()&&(this.$container=this.app.container.get("toolbar"),this._build()),this._buildSticky()},load:function(){this._buildActiveButtons(),this._isToolbar()&&(this.$toolbar.html(""),this._buildButtons())},stop:function(){this._isToolbar()&&(this.$toolbar.remove(),this.customButtons={},this.editorButtons={})},build:function(){this._isToolbar()&&(this.$toolbar.html(""),this._buildButtons())},observe:function(){if(this._isToolbar()&&(this.unsetActive(),!this.app.blocks.is())&&!this.app.editor.isAllSelected()&&this._isObserveButtons()){for(var t,e=this.app.block.get(),i=!!e&&e.getType(),e=!!e&&e.getTag(),s=this.app.selection.getNodes({type:"inline",selected:"inside",links:!0}),n=this._getObservedTags(e,s),a=[],o=0;o<n.length;o++)(t=this.aTags[n[o]])&&(a=a.concat(t));i&&(t=this.aTypes[i])&&(a=a.concat(t)),this._setActiveKeys(a)}},getElement:function(){return this.$toolbar},get:function(t){return this._findButton(t)},add:function(t,e){this.customButtons[t]=e},setActive:function(t){this._isToolbar()&&(this._findButtons().removeClass(this.activeClass),this._findButton(t).removeClass(this.disableClass).addClass(this.activeClass))},setToggled:function(t){this._isToolbar()&&(this._findButtons().removeClass(this.toggledClass),this._findButton(t).removeClass(this.disableClass).addClass(this.toggledClass))},unsetActive:function(t){this._isToolbar()&&(t?this._findButton(t):this._findButtons()).removeClass(this.activeClass)},unsetToggled:function(t){this._isToolbar()&&(t?this._findButton(t):this._findButtons()).removeClass(this.toggledClass)},enable:function(){this._isToolbar()&&this._findButtons().removeClass(this.disableClass)},disable:function(t){this._isToolbar()&&this._findButtons().removeClass(this.toggledClass).removeClass(this.activeClass).addClass(this.disableClass)},disableSticky:function(){var t;this._isToolbar()&&((t=this.app.container.get("bars")).removeClass(this.prefix+"-bars-sticky"),t.css("top",""))},enableSticky:function(){var t;this._isToolbar()&&this.opts.toolbar.sticky&&((t=this.app.container.get("bars")).addClass(this.prefix+"-bars-sticky"),t.css("top",this.opts.toolbar.stickyTopOffset+"px"))},isSticky:function(){var t=this.app.container.get("bars"),e=this.app.container.get("main"),e=e.offset().top+parseInt(e.css("border-top-width")),t=t.offset().top;return e<t||t<e},_build:function(){this.$toolbar=this.dom("<div>").addClass(this.prefix+"-toolbar"),this.$container.append(this.$toolbar),this.app.container.get("bars").addClass("has-toolbar")},_buildSticky:function(){var t;this.sticky&&((t=this.app.container.get("bars")).addClass(this.prefix+"-bars-sticky"),t.css("top",this.sticky.stickyTopOffset+"px"),this.app.scroll.getTarget().on("scroll."+this.prefix+"-toolbar",this._observeSticky.bind(this)))},_buildActiveButtons:function(){this.aTags=this.opts.buttons.tags||{},this.aTypes=this.opts.buttons.types||{};var i=this.customButtons;
1Object.keys(i).forEach(function(t){var e=i[t].active;e&&(this._buildActiveButton(t,e.tags,this.aTags),this._buildActiveButton(t,e.types,this.aTypes))}.bind(this))},_buildActiveButton:function(t,e,i){if(e)for(var s=0;s<e.length;s++){var n=e[s];i[n]?i[n].push(t):i[n]=[t]}},_buildButtons:function(){var t=this._getCurrentInstance(),e=t?this.app.editor.getButtonsFromArr(t.toolbar):this.app.editor.getButtons();this._createButtons(e,t),t&&this._createButtons(this.customButtons,t)},_createButtons:function(t,e){for(var i in t)!t.hasOwnProperty(i)||e&&!e.isAllowedButton(i,t[i])||this._isHidden(i)||"add"===i&&!1===this.opts.addbar||"format"===i&&!1===this.opts.format||this.app.create("button",i,t[i],this.$toolbar,"toolbar")},_observeSticky:function(){var t;this.app.source.is()?this.app.container.get("bars").css("top",0):(t=this.app.scroll.getTarget(),t=this.app.scroll.isTarget()?parseInt(t.css("padding-top")):0,this.app.container.get("bars").css("top",0-t+this.sticky.stickyTopOffset+"px"),this.isSticky()?this.app.broadcast("toolbar.sticky"):this.app.broadcast("toolbar.static"))},_findButtons:function(){return this.$toolbar.find("."+this.prefix+"-button-toolbar")},_findButton:function(t){return this.$toolbar.find("[data-name="+t+"]")},_isHidden:function(t){return-1!==this.opts.toolbar.hide.indexOf(t)},_isToolbar:function(){return this.opts.toolbar},_isObserveButtons:function(){return!(!this.opts.buttons.tags&&!this.opts.buttons.types)},_setActiveKeys:function(t){for(var e=0;e<t.length;e++)this._findButton(t[e]).addClass(this.activeClass)},_getCurrentInstance:function(){var t=!!this.app.block.is()&&this.app.block.get();return!this.app.blocks.is()&&t},_getObservedTags:function(t,e){var i=[];if(t&&i.push(t),0<e.length)for(var s=0;s<e.length;s++)i.push(e[s].tagName.toLowerCase());return i}}),t.add("module","path",{init:function(){this.activeClass="active",this.disableClass="disable",this.pathItemClass=this.prefix+"-path-item"},start:function(){this.opts.path&&(this.$container=this.app.container.get("pathbar"),this._build(),this._buildRoot(),this._buildActive())},build:function(){this.opts.path&&(this._clear(),this._buildRoot(),this.app.blocks.is()?this._buildMultipleItem():(this._buildItems(),this._buildActive()))},disable:function(){this.opts.path&&this._getAll().addClass(this.disableClass)},enable:function(){this.opts.path&&this._getAll().removeClass(this.disableClass)},_clear:function(){this.$path.find("."+this.pathItemClass).off("."+this.prefix+"-path-"+this.uuid),this.$path.html("")},_getAll:function(){return this.$path.find("."+this.pathItemClass)},_selectItem:function(t){t.stopPropagation(),t.preventDefault();var t=this.dom(t.target).closest("."+this.pathItemClass);t.hasClass(this.disableClass)||((t=t.dataget("instance"))?(this.app.popup.close(),this.app.block.set(t,"start")):(this._clear(),this._buildRoot(),this._buildActive(),this.app.block.unset()))},_createItem:function(){return this.dom('<a href="#"></a>').attr("tabindex","-1").addClass(this.pathItemClass)},_build:function(){this.$path=this.dom("<div>").addClass(this.prefix+"-path"),this.$container.append(this.$path)},_buildRoot:function(){this._buildItem(!1,this.lang.parse(this.opts.path.title))},_buildActive:function(){this.$path.find("a").removeClass(this.activeClass).last().addClass(this.activeClass)},_buildItems:function(){var t,e=this.app.block.get();e&&((t=e.getBlock().parents("[data-"+this.prefix+"-type]")).nodes.reverse(),t.each(this._buildParentItem.bind(this)),this._buildItem(e))},_buildParentItem:function(t){t=t.dataget("instance");this._buildItem(t)},_buildMultipleItem:function(){var t=this._createItem();t.addClass(this.activeClass),this._buildTitle(t,this.lang.get("editor.multiple")),this.$path.append(t)},_buildItem:function(t,e){var i=this._createItem();i.dataset("instance",t),i.on("click."+this.prefix+"-path-"+this.uuid,this._selectItem.bind(this)),this._buildTitle(i,e||t.getTitle()),this.$path.append(i)},_buildTitle:function(t,e){e=this.dom("<span>").html(e);t.append(e)}}),t.add("module","topbar",{init:function(){this.activeClass="active",this.toggledClass="disable",this.disableClass="disable",this.customButtons={}},start:function(){this._isTopbar()&&this._build()},load:function(){this._buildButtons()},get:function(t){return this._findButton(t)},add:function(t,e){this.customButtons[t]=e},setToggled:function(t){this._isTopbar()&&(this._findButtons().removeClass(this.toggledClass),this._findButton(t).addClass(this.toggledClass))},unsetToggled:function(t){this._isTopbar()&&(t?this._findButton(t):this._findButtons()).removeClass(this.toggledClass)},enable:function(){this._isTopbar()&&this._findButtons().removeClass(this.disableClass)},disable:function(){this._isTopbar()&&this._findButtons().removeClass(this.toggledClass).removeClass(this.activeClass).addClass(this.disableClass)},_isTopbar:function(){return this.opts.path},_build:function(){this.$topbar=this.dom("<div>").addClass(this.prefix+"-topbar"),this.app.container.get("pathbar").append(this.$topbar)},_buildButtons:function(){var t,e=this.app.editor.getButtonsFromArr(this.opts.buttons.topbar);for(t in e)!e.hasOwnProperty(t)||"undo"===t&&!this.opts.topbar.undoredo||"redo"===t&&!this.opts.topbar.undoredo||"shortcut"===t&&!this.opts.topbar.shortcuts||this.app.create("button",t,e[t],this.$topbar,"topbar")},_findButtons:function(){return this.$topbar.find("."+this.prefix+"-button-topbar")},_findButton:function(t){return this.$topbar.find("[data-name="+t+"]")}}),t.add("module","control",{init:function(){this.instance=!1,this.customButtons={},this.eventName=this.prefix+"-control"},start:function(){this.opts.control&&this._build()},stop:function(){this.opts.control&&this.$control.remove(),this.instance=!1,this.customButtons={}},isOpen:function(){return"none"!==this.$control.css("display")},getElement:function(){return this.$control},get:function(t){return this._findButton(t)},add:function(t,e){this.customButtons[t]=e},remove:function(t){this._findButton(t).remove()},build:function(){var t;this.opts.control&&((t=this.app.block.get())?this.open(t):this.close())},open:function(t){this.opts.control&&(this.$control.html(""),this.instance=t,0<this._buildButtons()?(t=this.app.scroll.getTarget(),this.updatePosition(),t.on("resize."+this.eventName,this.updatePosition.bind(this)),t.on("scroll."+this.eventName,this.updatePosition.bind(this)),this.app.editor.getW
1in().on("scroll."+this.eventName,this.updatePosition.bind(this)),this.instance.getBlock().on("keyup."+this.eventName,this.updatePosition.bind(this))):this.close())},close:function(){var t;this.opts.control&&(this.$control.hide(),this.instance&&(t=this.instance.getBlock(),this.app.content.unfixListMargin(t),t.off("."+this.eventName)),this.app.scroll.getTarget().off("."+this.eventName),this.app.editor.getDoc().off("."+this.eventName),this.instance=!1)},updatePosition:function(){var t,e,i,s,n,a;this.opts.control&&(this.instance?("list"===this.instance.getType()&&(t=this.instance.getBlock(),this.app.content.fixListMargin(t)),t=this.instance.isEditable(),s=this.instance.getOffset(),e=this.$control.width(),i=this.app.editor.getWin().scrollTop(),i=s.top-(n=t?4:2)-i,s=s.left-e-(t?6:4),a=(a=this.app.container.get("toolbar")).offset().top+a.height()-n,n=this.app.editor.getFrameRect(),i<a||n.bottom<i?this.$control.hide():this.$control.show(),this.app.scroll.isTarget()&&(a=this.app.scroll.getTarget()).offset().top+a.height()<i+this.$control.height()&&this.$control.hide(),!t&&s+e/2<n.left&&(s=n.left+3,i+=6),this.$control.css({top:i+"px",left:s+"px"})):this.close())},_buildButtons:function(){var t=this.app.editor.getButtonsFromArr(this.instance.control),e=0;return!1!==t&&(e=this._createButtons(t,e),e=this._createButtons(this.customButtons,e)),e},_build:function(){this.$control=this.dom("<div>").addClass(this.prefix+"-control "+this.prefix+"-control-"+this.uuid).hide(),this.opts.bsmodal&&this.$control.css("z-index",1060),this.app.$body.append(this.$control)},_createButtons:function(t,e){for(var i in t)this.instance.isAllowedButton(i,t[i])&&(this.app.create("button",i,t[i],this.$control,"control"),e++);return e},_findButton:function(t){return this.$control.find("[data-name="+t+"]")}}),t.add("module","insertion",{init:function(){this._clear()},start:function(){this.win=this.app.editor.getWinNode(),this.doc=this.app.editor.getDocNode()},getFirstInserted:function(){return this.inserted.instances[0]},getLastInserted:function(){var t=this.inserted.instances.length,t=this.inserted.instances[t-1];return t=t&&t.isInlineBlock()?t.getParent():t},getInserted:function(){return this.inserted},setContent:function(t){this._insert(t,"set");t=this.getInserted();return this.inserted=!1,t},insertContent:function(t){this._insert(t,"insert");t=this.getInserted();return this.inserted=!1,t},insertEmptyBlock:function(t){(t=t||{}).html=this.app.block.createHtml(),this._insert(t,"insert");t=this.getInserted();return this.inserted=!1,this.app.broadcast("block.add",{instance:t.instances[0],type:"input"}),t},insertNewline:function(t,e){return this._insertFragment({node:document.createTextNode(e?"\n\n":"\n")},t||"after")},insertPoint:function(t){var e,i,s=this.app.utils.createInvisibleChar(),n=this.app.editor.getDocNode(),a=t.clientX,t=t.clientY;n.caretPositionFromPoint?(e=n.caretPositionFromPoint(a,t),(i=n.getSelection().getRangeAt(0)).setStart(e.offsetNode,e.offset),i.collapse(!0),i.insertNode(s)):n.caretRangeFromPoint&&(i=n.caretRangeFromPoint(a,t)).insertNode(s),this.app.caret.set(s,"after")},insertBreakline:function(t){var e=this.app.selection.getNodes({type:"inline"});return this.app.selection.isCollapsed()&&0!==e.length?this._splitInline(e,document.createElement("br")):this._insertFragment({node:document.createElement("br")},t||"after")},insertNode:function(t,e,i){if(i){i=this.app.selection.getNodes({type:"inline"});if(0!==i.length)return this._splitInline(i,t)}return this._insertFragment({node:this.dom(t).get()},e)},insertHtml:function(t,e){return this._insertFragment({html:t},e)},insertText:function(t,e){var i,s=this.app.block.get();if(!(s&&!s.isEditable()||this.app.blocks.is()))return(s=this.win.getSelection()).getRangeAt&&s.rangeCount&&(t=this.app.content.getTextFromHtml(t,{nl:!0}),i=document.createTextNode(t),(s=s.getRangeAt(0)).deleteContents(),s.insertNode(i),this.app.caret.set(i,e=e||"end")),i;this.insertContent({html:t,caret:e})},insertListToList:function(t,e,i){var s=t.find("li"),n=s.last(),s=(s.addClass(this.prefix+"-pasteitems"),n.addClass(this.prefix+"-pastemarker"),t.children()),t=this.dom(this.app.selection.getBlock()),a=this.app.caret.is(e,"start"),o=this.app.caret.is(e,"end"),r=this.app.caret.is(t,"start"),p=this.app.caret.is(t,"end",["ul","ol"]),l=this.app.content.isEmptyHtml(t.html()),o=(a?(l&&t.remove(),e.prepend(s)):o?(l&&t.remove(),e.append(s)):l?(t.after(s),t.remove()):r?t.before(s):p?0!==(a=t.find("ul, ol")).length?a.prepend(s):t.after(s):this.app.element.split(t).before(s),this.prefix+"-pastemarker"),e=this.prefix+"-pasteitems";return i&&(n=this.app.editor.getLayout().find("."+o).removeClass(o),this.app.caret.set(n,"end")),this.app.editor.getLayout().find("."+e).removeClass(e)},detectPosition:function(t,e){var i;return e||(i=this.app.caret.is(t,"start"),e=this.app.caret.is(t,"end")?"after":i?"before":"split"),e},_insert:function(t,e){this.html=t.html,this.html=this.app.broadcastHtml("editor.before.insert",this.html),this.isParse=void 0===t.parse||t.parse,this.isClean=void 0!==t.clean&&t.clean,this.isCaret=void 0===t.caret||t.caret,this.isPosition=void 0!==t.position&&t.position,"set"===e||this.app.editor.isAllSelected()?this._setContent():this._insertContent(),this.app.broadcast("editor.insert",this.inserted)},_insertContent:function(){var t=this.app.block.get(),e=!1,i=!1;if(this._checkEmpty(),this._checkLine(),this.app.blocks.is()){if
1(this.isEmpty)return;this.isLine&&(this.html=this.app.block.createHtml(this.html)),this._clean(),this._parse(),this._parseBuild();var s=this._buildParsedNodes();this.app.blocks.getLastSelected().getBlock().after(s),this.app.blocks.removeSelected(!1)}else if(!t||this.isPosition){if(this.isEmpty)return;this.isLine&&(this.html=this.app.block.createHtml(this.html)),this._clean(),this._parse(),this._parseBuild(),s=this._buildParsedNodes();var n=!1;"top"===this.isPosition||!this.isPosition&&"top"===this.opts.editor.add?(t=this.app.blocks.getFirst(),e="before"):t&&-1!==["after","before","append"].indexOf(this.isPosition)?(e=this.isPosition,n=t.getType("layer")&&t.isEmpty()):(t=this.app.blocks.getLast(),e="after"),a=t.getBlock(),n&&(a.removeClass(this.prefix+"-empty-layer"),a.html("")),a[e](s)}else if(this._isListToList(t)){this.app.selection.deleteContents(),this._clean(),this._parse(),this._parseBuild();var a=t.getBlock(),n=this.$parsed.children().first();this.$nodes=this.insertListToList(n,a,"end"),this.isCaret=!1}else{if(!t)return;if(t.isInlineBlock()&&(n=t.getParent(),this.app.caret.set(t.getBlock(),"after"),t.remove(),this.app.block.set(n),t=n),t.isEditable()){if(this.isEmpty)return;this._clean(),this._cleanSpecial(),this.isLine?this._parseLine():this._parse(),this._parseBuild(),t.isEmpty()?(i=!0,e="after"):this.app.selection.deleteContents(),s=this._buildParsedNodes(),a=t.getBlock(),this._insertToEditable(t,a,s,e,i)}else{if(e="after",this.isEmpty)return;this.isLine&&(this.html=this.app.block.createHtml(this.html)),this._clean(),this.isLine?this._parseLine():this._parse(),this._parseBuild(),s=this._buildParsedNodes(),a=t.getBlock(),t.isEmptiable()&&t.isEmpty()&&(a.removeClass(this.prefix+"-empty-layer"),a.html(""),e="append"),a[e](s)}}this._buildInserted(),this._buildEditor(),this._buildCaret()},_insertToEditable:function(t,e,i,s,n){this.isLine?(this.$nodes=this._insertFragment({fragment:this.$parsed.get()},"end"),this.isCaret=!1):(this.app.content.isEmptyHtml(e.html())?(s="after",n=!0):s=this.detectPosition(e,s),"split"===s?this.app.element.split(e).before(i):e[s](i),n&&t.remove())},_insertFragment:function(t,e){var i,s;return t.html||t.fragment?(i=this.app.fragment.build(t.html||t.fragment),this.app.fragment.insert(i)):this.app.fragment.insert(t.node),e&&(s=t.node||("start"===e?i.first:i.last),this.app.caret.set(s,e)),t.node?this.dom(t.node):this.dom(i.nodes)},_setContent:function(){this._checkEmpty(),this._checkLine(),this.isEmpty?this.html=this.app.block.createHtml():this.isLine&&(this.html=this.app.block.createHtml(this.html)),this._clean(),this._parse(),this._parseBuild();var t=this._buildParsedNodes();this.app.editor.unsetSelectAllClass(),this.app.editor.getLayout().html("").append(t),this.isEmpty&&this.app.broadcast("editor.empty"),this._buildInserted(),this._buildEditor(),this._buildCaret()},_splitInline:function(t,e){t=this.app.element.split(t[0]);return t.before(e),""===t.html()&&t.remove(),this.dom(e)},_buildEditor:function(){this.app.placeholder.trigger(),this.app.editor.build(),this.app.editor.setFocus()},_buildCaret:function(){var t,e;this.isCaret&&(e="end","start"===this.isCaret?(t=this.getFirstInserted(),e="start"):t=this.getLastInserted(),setTimeout(function(){t&&this.app.block.set(t,e),this.app.toolbar.observe()}.bind(this),0))},_buildInserted:function(){this.inserted={$nodes:this.$nodes,instances:[]},this.inserted.$nodes.each(this._buildInstance.bind(this))},_buildInstance:function(t){var e=t.dataget("instance"),e=(e&&this.inserted.instances.push(e),t.find("[data-"+this.prefix+"-type]"));0!==e.length&&e.each(this._buildInstance.bind(this))},_buildParsedNodes:function(){return this.$parsed.get().childNodes},_clear:function(){this.html=!1,this.isLine=!1,this.isEmpty=!1,this.isSplit=!1,this.isClean=!1,this.isParse=!0,this.isCaret=!0,this.isPosition=!1},_clean:function(){this.isClean&&(this.html=this.app.cleaner.cleanHtml(this.html))},_cleanSpecial:function(t){var e,i;-1!==["cell","address","figcaption","quoteitem"].indexOf(t)?e=!0:"dlist"===t?(e=!0,i=["dt","dd"]):"list"===t&&(e=!0,i=["ul","ol","li"]),e&&(this.isLine=!0,this.html=this.app.content.addBrToBlocks(this.html),this.html=this.app.content.removeBlockTags(this.html,void 0,i),this.html=this.html.replace(/<br\s?\/?>\n?$/gi,""))},_parse:function(){this.isParse&&(this.html=this.app.parser.parse(this.html,!1))},_parseLine:function(){this.isParse&&(this.html=this.app.parser.parseLine(this.html,!1))},_parseBuild:function(){this.$parsed=this.app.parser.build(this.html),this.$nodes=this.$parsed.children()},_checkEmpty:function(){this.isEmpty=this.app.content.isEmptyHtml(this.html)},_checkLine:function(){this.isLine=this.app.content.isLine(this.html)},_isListToList:function(t){var t=t.getBlock().attr("data-"+this.prefix+"-type"),e=this.dom("<div>").html(this.html);return e.find("meta").remove(),e.find("b").unwrap(),e=e.children().first(),"list"===t&&0!==e.length&&-1!==["ul","ol"].indexOf(e.get().tagName.toLowerCase())}}),t.add("module","addbar",{init:function(){this.customButtons={}},popup:function(t,e){this.app.popup.create("addbar",{width:"476px",items:this.buildItems()}),"top"===this.opts.editor.addbar&&(e=!1),this.app.popup.open({button:e})},buildItems:function(){var t,e,i={},s=h.extend(!0,this.opts.buttonsObj),n=this.opts.addbar.concat(this.opts.addbarAdd);0!==this.opts.addbarAdd.length&&-1!==this.opts.addbarAdd.indexOf("text")&&(t=n.indexOf("text"),e=n.indexOf("paragraph"),n.splice(-1!==e?e+1:0,0,n.splice(t,1)[0]));for(var a=0;a<n.length;a++){var o=n[a];-1===this.opts.addbarHide.indexOf(o)&&(i[o]=s[o])}var r=h.extend(!0,this.customButtons),p=this.app.block.get();return Object.keys(r).forEach(function(t){i[t]=r[t]}
1),Object.keys(i).forEach(function(t){this._buildItem(p,i,i[t],t)}.bind(this)),i},add:function(t,e){this.customButtons[t]=e},_buildItem:function(t,e,i,s){i.blocks&&!t||t&&i.blocks&&!t.isAllowedButton(s,i)?e[s]=!1:e[s]={container:!0,addbar:!0,title:i.title,icon:i.icon||s,command:i.command,observer:i.observer||!1,params:{name:s}}}}),t.add("module","format",{popup:function(t,e){for(var i,s=this.app.block.get(),n=!!s&&s.getBlock(),s=s.getTag(),a=this.opts.format,o={},r=0;r<a.length;r++){var p=a[r];o[p]={title:this.opts.formatObj[p].title,params:{tag:p},command:"block.format",shortcut:this.opts.formatObj[p].shortcut}}this.opts.formatAdd&&(i=this.opts.formatAdd,Object.keys(i).forEach(function(t){o[t]={title:i[t].title,params:i[t].params,command:"block.format"}}));n=this._isActiveFormat(n,s,o);n&&(o[n].active=!0),this.app.popup.create("format",{width:"300px",items:o}),this.app.popup.open({button:e})},set:function(t){var e,i,s,n,a;this.app.popup.isOpen()&&this.app.popup.close(),this.app.blocks.is()||(a=!!(n=(s=this.app.block.get()).isEmpty())&&"start",t={type:this.opts.formatObj[t.tag].type,tag:t.tag,classname:t.classname||!1},this.tag=s.getTag(),this.type=s.getType(),this.$block=s.getBlock(),n||this.app.selection.saveMarker(),(t=this._isSameTag(t)?this._checkSameFormat(this.$block,t):t)&&(this._isListToText(t,"list")?i=this._formatListToText(t):this._isListToText(t,"dlist")?e=this._formatListToText(t,!0):this._isTextToList(t,"list")?this._formatTextToList(t,!1,a):this._isTextToList(t,"dlist")?this._formatTextToList(t,!0,a):this._replaceTo(s,t,a)),n||this.app.selection.restoreMarker(),e&&(this.app.editor.build(),this.app.block.set(e.last(),a)),i&&(this.app.editor.build(),this.app.block.set(i,a)),s=this.app.block.get(),this.app.broadcast("block.format",{instance:s}))},_isSameTag:function(t){return this.tag===t.tag&&this.type===t.type},_checkSameFormat:function(t,e){t=this.app.element.hasClass(t,e.classname);return!e.classname||t?this._buildDefaultFormat():e},_buildDefaultFormat:function(){var t=this.opts.editor.markup;return{type:t,tag:"paragraph"===t?"p":"div"}},_formatListToText:function(t,e){e=e?this._getDlistItems():this._getListItems(),e=this._createItems(e,t);return this.$block.remove(),e},_formatTextToList:function(t,e,i){var s,n=this.app.create("block."+t.type,"<"+t.tag+">").getBlock();e&&"list"===this.type?(s=0,this._getListItems().each(function(t){var e=0===s?"dt":"dd",t=this.dom("<"+e+">").html(t.html());s="dt"==e?1:0,n.append(t)}.bind(this))):e||"dlist"!==this.type?(e=this.dom(e?"<dt>":"<li>").html(this.$block.html()),n.append(e)):this._getDlistItems().each(function(t){t=this.dom("<li>").html(t.html());n.append(t)}.bind(this)),this.app.create("block."+t.type,n),this.$block.after(n),this.$block.remove(),this._setStyleAndClass(n,t),this.app.editor.build(),this.app.block.set(n,i)},_replaceTo:function(t,e,i){t=t.getBlock(),t=this._replaceToBlock(t,e);this.app.editor.build(),this.app.block.set(t,i)},_replaceToBlock:function(t,e){t=this.app.element.replaceToTag(t,e.tag);return this._setStyleAndClass(t,e),this.app.create("block."+e.type,t)},_createItems:function(t,i){var s;return t.each(function(t){var e=this.dom("<"+i.tag+">");e.html(t.html()),t.remove(),s=this.app.create("block."+i.type,e),this.$block.before(e),this._setStyleAndClass(e,i)}.bind(this)),s},_isListToText:function(t,e){return this.type===e&&-1!==["heading","address","paragraph","text"].indexOf(t.type)},_isTextToList:function(t,e){var i="list"===e?"dlist":"list";return t.type===e&&-1!==["heading","address","paragraph","text",i].indexOf(this.type)},_isActiveFormat:function(t,e,i){if(t){var s,n,a;for(n in i)i.hasOwnProperty(n)&&(a=i[n].params.classname||!1,e!==i[n].params.tag||a&&!this.app.element.hasClass(t,a)||(s=n));return s}},_setStyleAndClass:function(t,e){e.classname&&(t.removeAttr("style class data-"+this.prefix+"-style-cache"),t.addClass(e.classname))},_getListItems:function(){var t=this.$block.find("li");return t.find("ul, ol").each(function(t){t.parent().after(t)}),t.find("ul, ol").unwrap(),t},_getDlistItems:function(){return this.$block.find("dt, dd")}}
1),t.add("module","link",{popups:{format:{items:{format:{title:"## link.link ##",command:"link.format",shortcut:"Ctrl+k"},unlink:{title:"## link.unlink ##",command:"link.unlink"}}},change:{items:{edit:{title:"## link.edit-link ##",command:"link.edit",shortcut:"Ctrl+k"},unlink:{title:"## link.unlink ##",command:"link.unlink"}}},create:{title:"## popup.link ##",width:"600px",form:{text:{type:"input",label:"## link.text ##"},url:{type:"input",label:"## link.url ##"},target:{type:"checkbox",text:"## link.link-in-new-tab ##"}},footer:{insert:{title:"## link.insert ##",command:"link.insert",type:"primary"},cancel:{title:"## link.cancel ##",command:"popup.close"}}},edit:{title:"## popup.link ##",width:"600px",form:{text:{type:"input",label:"## link.text ##"},url:{type:"input",label:"## link.url ##"},target:{type:"checkbox",text:"## link.link-in-new-tab ##"}},footer:{save:{title:"## link.save ##",command:"link.save",type:"primary"},cancel:{title:"## link.cancel ##",command:"popup.close"}}}},popup:function(t,e){var i=0===this.getLink().length?"format":"change";this.app.popup.create("link",this.popups[i]),this.app.popup.open({button:e})},format:function(t){var e=this.app.selection.getText(),i=this.app.popup.create("link-create",this.popups.create),s={text:e,target:this.opts.link.target};i.setData(s),this.app.popup.open({focus:e?"url":"text"})},edit:function(){var t=this.getLink(),e=this.app.popup.create("link-edit",this.popups.edit),t={text:t.text(),url:t.attr("href"),target:t.attr("target")||this.opts.link.target},t=this._encodeUrl(t);e.setData(t),this.app.popup.open({focus:"url"})},insert:function(t){this.app.popup.close();var e=this.app.inline.set({tag:"a",caret:"after"}),e=this.dom(e);this._save(t,e,"add")},save:function(t){this.app.popup.close();var e=this.getLink();this._save(t,e,"change")},unlink:function(){this.app.popup.close();var t=this.app.selection.getNodes({tags:["a"]});if(0!==t.length){for(var e=0;e<t.length;e++){var i=this.dom(t[e]);this.app.broadcast("link.remove",{url:i.attr("href"),text:i.text()}),i.unwrap()}this.app.toolbar.observe()}},getLink:function(){var t=this.app.selection.getNodes({tags:["a"]});return 0!==t.length?this.dom(t[0]):this.dom([])},_save:function(t,e,i){t=t.getData(),t=this._cleanUrl(t);""!==(t=this._encodeUrl(t)).url&&(t=this._setUrl(e,t),1===e.length&&(t=this._setText(e,t)),(t=this._setTarget(e,t)).element=e,this.app.broadcast("link."+i,t))},_cleanUrl:function(t){return t.url=this.app.content.escapeHtml(t.url),t.url=-1!==t.url.search(/^javascript:/i)?"":t.url,t},_encodeUrl:function(t){return t.url=t.url?t.url.replace(/&amp;/g,"&"):"",t},_setUrl:function(t,e){return t.attr("href",e.url),e},_setText:function(t,e){return e.text=""===e.text?e.url:e.text,t.text(e.text),e},_setTarget:function(t,e){return e.target?t.attr("target","_blank"):t.removeAttr("target"),e}}),t.add("module","embed",{popups:{add:{title:"## embed.embed ##",width:"100%",form:{embed:{type:"textarea",label:"## embed.description ##",rows:6},caption:{type:"input",label:"## embed.caption ##"},responsive:{type:"checkbox",text:"## embed.responsive-video ##"}},footer:{insert:{title:"## buttons.insert ##",command:"embed.insert",type:"primary"},cancel:{title:"## buttons.cancel ##",command:"popup.close"}}},edit:{title:"## embed.embed ##",width:"100%",form:{embed:{type:"textarea",label:"## embed.description ##",rows:6},caption:{type:"input",label:"## embed.caption ##"},responsive:{type:"checkbox",text:"## embed.responsive-video ##"}},footer:{save:{title:"## buttons.save ##",command:"embed.save",type:"primary"},cancel:{title:"## buttons.cancel ##",command:"popup.close"}}}},build:function(t){t?this._callScripts(t):this._findScripts()},observe:function(t,e,i){var s;return!!this.opts.embed&&(s=this.app.block.get(),i&&"addbar"===i.getName()?t.command="embed.popup":s&&"embed"===s.getType()&&(t.command="embed.edit"),t)},popup:function(){var t=this.app.popup.add("embed",this.popups.add);t.open({focus:"embed"}),this.opts.embed.checkbox&&t.getInput("responsive").attr("checked",!0),this._buildCodemirror(t)},edit:function(t,e){var i=this.app.block.get(),i={embed:i.getEmbedCode(),caption:i.getCaption(),responsive:i.isResponsive()},s=this.app.popup.create("embed",this.popups.edit);
1s.setData(i),this.app.popup.open({button:e,focus:"embed"}),this._buildCodemirror(s)},insert:function(t){this.app.popup.close();var t=t.getData(),e=this._getEmbedCode(t);""!==e&&(t=this._createInstance(t,e),this.app.block.add({instance:t}))},save:function(t){this.app.popup.close();var e=this.app.block.get(),t=t.getData(),i=this._getEmbedCode(t);""===i?this.app.block.remove():(i=this._createInstance(t,i,e),this._isNeedToChange(t,i,e)&&this.app.block.change(i))},_buildCodemirror:function(t){t=t.getInput("embed");this.app.codemirror.create({el:t,height:"200px",focus:!0}),this.app.popup.updatePosition()},_findScripts:function(){var t=this.app.editor.getLayout().find("[data-"+this.prefix+"-type=embed]").find("script").getAll();this.build.call(this,t)},_callScripts:function(e){for(var i,t,s,n=0;n<e.length;n++)""!==e[n].src&&(i=e[n].src,this.app.editor.getDoc().find('head script[src="'+i+'"]').remove(),(t=this.dom("<script>").attr({src:i,async:!0,defer:"true"})).on("load",function(){var t;-1!==i.search("instagram")&&(t=this.app.editor.getWinNode()).instgrm&&t.instgrm.Embeds.process(),this.build(e.slice(n+1))}.bind(this)),s=this.app.editor.getDocNode().getElementsByTagName("head")[0])&&s.appendChild(t.get())},_getEmbedCode:function(t){t=t.embed.trim(),t=this.app.codemirror.val(t);return t=this._removeScript(t),t=this.app.content.sanitize(t),this._isHtmlString(t)||""===t?t:this._parseUrl(t)},_removeScript:function(t){return t=this.opts.embed.script?t:this.app.content.removeTagsWithContent(t,["script"])},_createInstance:function(t,e,i){i?(s=i.duplicateEmpty().getBlock()).html(e):s=this._isFigure(e)?e:"<figure>"+e+"</figure>";var s,i=this.app.create("block.embed",s);return i.setCaption(t.caption),t.responsive&&i.addResponsive(),i},_parseUrl:function(t){var e,i='<iframe width="560" height="315" src="',s='" frameborder="0" allowfullscreen></iframe>';return t.match(this.opts.regex.youtube)?(e="//www.youtube.com",-1!==t.search("youtube-nocookie.com")&&(e="//www.youtube-nocookie.com"),i+t.replace(this.opts.regex.youtube,e+"/embed/$1")+s):t.match(this.opts.regex.vimeo)?i+t.replace(this.opts.regex.vimeo,"//player.vimeo.com/video/$2")+s:t},_isNeedToChange:function(t,e,i){return i.getEmbedCode()!==e.getEmbedCode()||t.responsive!==i.isResponsive()||t.caption!==i.getCaption()||void 0},_isHtmlString:function(t){return/^\s*<(\w+|!)[^>]*>/.test(t)},_isFigure:function(t){return/^<figure/.test(t)}}),t.add("module","grid",{popup:function(){this.app.popup.add("grid",{title:"## popup.grid ##",width:"320px",items:this.buildItems()}).open()},observe:function(){if(!this.opts.grid)return!1},buildItems:function(){var t,e,i={},s=0;for(t in this.opts.grid.patterns)this.opts.grid.patterns.hasOwnProperty(t)&&(s++,e=this._createPattern(t),i["column"+s]={html:e,command:"grid.add",params:{pattern:t,columns:this.opts.grid.patterns[t]}});return i},add:function(t){this.app.popup.close();var e=""===t.columns,i=(e?t.pattern:t.columns).split("|"),s=this.dom("<div>").addClass(this.opts.grid.classname);""!==this.opts.grid.classes&&s.addClass(this.opts.grid.classes);for(var n=0;n<i.length;n++){var a=this.app.create("block.column").getBlock();e||a.addClass(i[n]),s.append(a)}t=this.app.block.add({name:"grid",source:s,caret:!1});this.app.block.set(t)},_createPattern:function(t){for(var e=this.dom("<div>").addClass(this.prefix+"-popup-grid-box"),i=t.split("|"),s=100/this.app.utils.sumOfArray(i),n=0;n<i.length;n++){var a=this.dom("<span>");a.addClass(this.prefix+"-popup-grid-column"),a.css("width",i[n]*s+"%"),e.append(a)}return e}}),t.add("module","image",{popups:{add:{title:"## popup.add-image ##",width:"100%"},edit:{title:"## popup.image ##",width:"100%",getter:"block.getData",form:{width:{type:"input",width:"100px",label:"## image.width ##",observer:"image.observeImageWidth"},alt:{type:"input",label:"## image.alt-text ##"},caption:{type:"input",label:"## image.caption ##",observer:"image.observeImageCaption"},link:{type:"input",label:"## image.link ##",observer:"image.observeImageLink"},target:{type:"checkbox",text:"## image.link-in-new-tab ##",observer:"image.observeImageLink"}},footer:{save:{title:"## image.save ##",command:"image.save",type:"primary"},cancel:{title:"## image.cancel ##",command:"popup.close"}}},editcard:{title:"## popup.image ##",width:"100%",getter:"block.getData",setter:"block.setData",form:{alt:{type:"input",label:"## image.alt-text ##"}},footer:{save:{title:"## image.save ##",command:"image.save",type:"primary"},cancel:{title:"## image.cancel ##",command:"popup.close"}}}},init:function(){this.dataStates=[]},popup:function(){var t=this.app.popup.add("image",this.popups.add),e=t.getBody();this._createImageByUrl(e),this._createOrSection(e),this._createUploadBox(e),this._createSelectBox(e),t.open()},edit:function(t,e){this._edit("edit",e)},editCard:function(t,e){this._edit("editcard",e)}
1,observe:function(t,e,i){var s;return!!this.opts.image&&(s=this.app.block.get(),i&&"addbar"===i.getName()?t.command="image.popup":s&&"image"===s.getType()&&(t.command="image.edit"),t)},observeStates:function(){this._findImages().each(this._addImageState.bind(this))},observeImageLink:function(t){return!!this.opts.image.link&&t},observeImageCaption:function(t){var e=this.app.block.get();return!(!e||"figure"!==e.getTag())&&t},observeImageWidth:function(t){return!!this.opts.image.width&&t},parseInserted:function(t){for(var e,i=[],s={url:this.opts.image.upload,name:this.opts.image.name,data:this.opts.image.data,multiple:!0,success:"image.insertFromInserted",error:"image.error"},n=(this.pasteInsertedImages=[],this.resolved=[],0),a=0;a<t.instances.length;a++){var o,r,p,l=t.instances[a];"image"===l.getType()&&(-1!==(o=l.getSrc()).search(/^data:/i)?(r=this._dataURLtoFile(o,"image"+a),i.push(r),this.pasteInsertedImages.push(l)):-1!==o.search(/^blob:/i)&&(n++,this.pasteInsertedImages.push(l),p=this,function(t,i){var s=new XMLHttpRequest;s.open("GET",t,!0),s.responseType="blob",s.onload=function(t){var e;200==s.status&&(e=s.response,e=new File([e],"image"+i,{type:"image/png"}),p.resolved.push(e))},s.send()}(o,a)))}0!==n&&(e=setInterval(function(){this.resolved.length===n&&(clearInterval(e),this.app.create("upload").send(!1,this.resolved,s))}.bind(this),100)),0!==i.length&&this.app.create("upload").send(!1,i,s)},paste:function(t,e){var i={url:this.opts.image.upload,name:this.opts.image.name,data:this.opts.image.data,multiple:!1,success:"image.insertFromBlob",error:"image.error"};this.app.create("upload").send(e,[t],i)},drop:function(t,e){for(var i=[],s=0;s<e.files.length;s++){var n=e.files[s]||e.items[s].getAsFile();n&&i.push(n)}var a,o={url:this.opts.image.upload,name:this.opts.image.name,data:this.opts.image.data,multiple:this.opts.image.multiple,success:"image.insertByDrop",error:"image.error"};0<i.length&&(0!==(a=this.dom(t.target).closest("[data-"+this.prefix+"-type]")).length&&this.app.block.set(a),this.app.create("upload").send(t,i,o))},insertFromClipboard:function(t){var e=(e=t.getData("text/plain")||t.getData("text/html")).trim();if(""===e){for(var i=t.items,s=null,n=0;n<i.length;n++)0===i[n].type.indexOf("image")&&(s=i[n].getAsFile());return null!==s?(this.paste(s),!0):void 0}},insertFromBlob:function(t){this.insert(t)},insertByDrop:function(t,e){if(this.app.block.is()){var i=this.app.block.get(),s=e.target,n=i.getType();if("card"===n&&s&&"IMG"===s.tagName&&i.hasImage()||"image"===n)return void this.change(t);e&&"card"!==n&&i.isEditable()&&this.app.insertion.insertPoint(e)}this.insert(t)},insertByUpload:function(t){this.insert(t)},insertByUrl:function(t){t.preventDefault();var t=this.$urlinput.val();""!==t.trim()&&(t={file:{url:t,id:this.app.utils.getRandomId()}},this.insert(t))},insertFromSelect:function(t){t.preventDefault();for(var e=this.dom(t.target),i={url:e.attr("data-url")},s=["id","alt","caption","link","width","height"],n=0;n<s.length;n++){var a=e.attr("data-"+s[n]);null!==a&&(i[s[n]]=a)}this.insert({file:i},!0)},insertFromInserted:function(t){var e,i=0;for(e in t)t.hasOwnProperty(e)&&(this.pasteInsertedImages[i].setImage(t[e]),i++)},changeClone:function(t){for(var e in t)if(t.hasOwnProperty(e)){this.$imageclone.attr("src",t[e].url);break}this.change(t,!1)},change:function(t,e){!1!==e&&this.app.popup.close();var i,s=this.app.block.get();for(i in t)if(t.hasOwnProperty(i))return s.setImage(t[i]),this.app.broadcast("image.change",t[i]),void this.app.broadcast("image.upload",{instance:s,data:t[i]})},save:function(t){this.app.popup.close(),this.app.block.setData(t)},insert:function(t,e){this.app.popup.close(),this.imageslen=0,this.imagescount=0;var i,s,n,a=this.opts.image.tag;for(i in t)t.hasOwnProperty(i)&&(n=this.dom("<"+a+">"),s=this._createImageFromResponseItem(t[i]),n.append(s),s=this.app.create("block.image",n),this.app.block.add({instance:s,type:"image"}),Object.prototype.hasOwnProperty.call(t[i],"caption")&&(n=this.dom("<figcaption>").html(t[i].caption),s.$block.append(n),this.app.create("block.figcaption",n)),this.app.broadcast("image."+(e?"select":"upload"),{instance:s,data:t[i]}),this.$last=s.getBlock(),this.imageslen++)},error:function(t){this.app.broadcast("image.upload.error",{response:t})},getStates:function(){var t,e,i,s=this._findImages();for(t in this.dataStates)this.dataStates.hasOwnProperty(t)&&(e=this.dataStates[t],i=s.is('[data-image="'+e.id+'"]'),this._setImageState(e.id,i));return this.dataStates},createUploadBox:function(t,e){if(t)return t=this.dom("<div>"),e.append(t),t}
1,createSelectBox:function(t,e,i){t&&(this.$selectbox=this._createImagesBox(e),"object"==typeof t?this._parseList(t,i):(e=this.opts.editor.reloadmarker?{d:(new Date).getTime()}:{},this.ajax.request(this.opts.image.selectMethod,{url:t,data:e,success:function(t){this._parseList(t,i)}.bind(this)})))},_edit:function(t,e){this.app.popup.create("image-edit",this.popups[t]),this._buildEditUpload(),this.app.popup.open({button:e})},_findImages:function(){return this.app.editor.getLayout().find("[data-image]")},_addImageState:function(t){var e=t.attr("data-image");this.dataStates[e]={type:"image",status:!0,url:t.attr("src"),$img:t,$el:t,id:e}},_setImageState:function(t,e){this.dataStates[t].status=e},_checkImageLoad:function(){this.imagescount++,this.imagescount===this.imageslen&&(this.app.block.unset(),this.app.block.set(this.$last),this.app.editor.adjustHeight())},_buildEditUpload:function(){var t,e,i;this.opts.image.upload&&(i=this.app.block.get(),t=this.app.popup.getStack().getBody(),(e=this._createFormItem()).addClass(this.prefix+"-form-item-edit-image-box"),this.$imageclone=i.getImage().clone(),this.$imageclone.removeAttr("width height style"),(i=this.dom("<div>").addClass(this.prefix+"-form-item-image")).append(this.$imageclone),e.append(i),this.$upload=this.dom("<div>"),e.append(this.$upload),t.prepend(e),this._buildUpload(this.$upload,"image.changeClone"))},_buildUpload:function(t,e){this.opts.image.upload&&(e={box:!0,placeholder:this.lang.get("image.upload-new-placeholder"),url:this.opts.image.upload,name:this.opts.image.name,data:this.opts.image.data,multiple:this.opts.image.multiple,success:e,error:"image.error"},this.app.create("upload",t,e))},_createSelectBox:function(t){this.createSelectBox(this.opts.image.select,t,"image.insertFromSelect")},_createUploadBox:function(t){this.$upload=this.createUploadBox(this.opts.image.upload,t),this._buildUpload(this.$upload,"image.insertByUpload")},_createImageFromResponseItem:function(t){for(var e,i=this.dom("<img>").attr("src",t.url).one("load",this._checkImageLoad.bind(this)),s=i,n=["id","alt","width","height"],a=0;a<n.length;a++)Object.prototype.hasOwnProperty.call(t,n[a])&&s.attr(n[a],t[n[a]]);return Object.prototype.hasOwnProperty.call(t,"id")&&s.attr("data-image",t.id),Object.prototype.hasOwnProperty.call(t,"2x")&&s.attr("srcset",t["2x"]+" 2x"),Object.prototype.hasOwnProperty.call(t,"link")&&((e=this.dom("<a>")).attr("href",t.link),i.wrap(e),s=e),s},_createImagesBox:function(t){var e=this.dom("<div>").addClass(this.prefix+"-popup-images-box");return t.append(e),e},_createOrSection:function(t){var e;this.opts.image.url&&(this.opts.image.upload||this.opts.image.select)&&((e=this.dom("<div>").addClass(this.prefix+"-popup-image-section-or")).html(this.lang.get("image.or")),t.append(e))},_createImageByUrl:function(t){var e;this.opts.image.url&&(e=this._createFormItem(),this.$urlinput=this._createUrlInput(),this.$urlbutton=this._createUrlButton(),e.append(this.$urlinput),e.append(this.$urlbutton),t.append(e))},_createFormItem:function(){return this.dom("<div>").addClass(this.prefix+"-form-container-flex")},_createUrlInput:function(){var t=this.dom("<input>").addClass(this.prefix+"-form-input");return t.attr("placeholder",this.lang.get("image.url-placeholder")),t},_createUrlButton:function(){var t=this.dom("<button>").addClass(this.prefix+"-form-button "+this.prefix+"-form-button-primary");return t.html(this.lang.get("image.insert")),t.one("click",this.insertByUrl.bind(this)),t},_parseList:function(t,e){for(var i in t)if(t.hasOwnProperty(i)){var s=t[i];if("object"==typeof s){for(var n=this.dom("<img>"),i=s.thumb||s.url,a=(n.addClass(this.prefix+"-popup-event"),n.attr("src",i),n.attr("data-url",s.url),n.attr("data-callback",e),["id","alt","caption","link","width","height"]),o=0;o<a.length;o++)Object.prototype.hasOwnProperty.call(s,a[o])&&n.attr("data-"+a[o],s[a[o]]);n.on("click."+this.prefix+"-popup-event-"+this.uuid,function(t){var e=this.dom(t.target).attr("data-callback");this.app.api(e,t)}.bind(this)),this.$selectbox.append(n)}}},_dataURLtoFile:function(t,e){for(var t=t.split(","),i=t[0].match(/:(.*?);/)[1],s=atob(t[1]),n=s.length,a=new Uint8Array(n);n--;)a[n]=s.charCodeAt(n);return new File([a],e,{type:i})}}),t.add("module","table",{popups:{cell:{title:"## table.table-cell ##",width:"300px",form:{width:{type:"input",label:"## table.width ##"},nowrap:{type:"checkbox",text:"## table.nowrap ##"}},footer:{insert:{title:"## table.save ##",command:"table.save",type:"primary"},cancel:{title:"## table.cancel ##",command:"popup.close"}}}},items:{table:{addhead:{title:"## table.add-head ##",command:"table.addHead"},removehead:{title:"## table.remove-head ##",command:"table.removeHead"}},row:{addrowbelow:{title:"## table.add-row-below ##",command:"table.addRowBelow"},addrowabove:{title:"## table.add-row-above ##",command:"table.addRowAbove"},removerow:{title:"## table.remove-row ##",command:"table.removeRow"}},cell:{addcolumnafter:{title:"## table.add-column-after ##",command:"table.addColumnAfter"},addcolumnbefore:{title:"## table.add-column-before ##",command:"table.addColumnBefore"},addrowbelow:{title:"## table.add-row-below ##",command:"table.addRowBelow"},addrowabove:{title:"## table.add-row-above ##",command:"table.addRowAbove"},removecolumn:{title:"## table.remove-column ##",command:"table.removeColumn"},removerow:{title:"## table.remove-row ##",command:"table.removeRow"}}},add:function(){var t=this.app.block.add({name:"table",source:this.opts.table.template,caret:!1}
1).getFirstCell();t&&this.app.block.set(t,"start")},observe:function(t,e,i){var s;return!!this.opts.table&&(s=this.app.block.get(),i&&"addbar"===i.getName()?t.command="table.add":s&&s.isType(["table","row","cell"])&&(t.command="table.popup"),t)},popup:function(t,e){var i=this.app.block.get().getType();this.app.popup.create("table",{items:this.items[i]}),this.app.popup.open({button:e})},addHead:function(){this.removeHead();var t=this.app.block.get().getBlock(),e=t.find("tr").first().children("td, th").length,i=this.dom("<thead>"),e=this._buildRow(e,"<th>");i.append(e),t.prepend(i),this.app.block.set(e.children("td, th").first(),"start")},addRowBelow:function(){this._addRow("below")},addRowAbove:function(){this._addRow("above")},addColumnBefore:function(){this._addColumn("before")},addColumnAfter:function(){this._addColumn("after")},removeHead:function(){this.app.popup.close();var t=this.app.block.get().getBlock().find("thead");0!==t.length&&t.remove()},removeRow:function(){this.app.popup.close(),this.app.control.close();var t=this.app.block.get();(t="cell"===t.getType()?t.getParent(["row"]):t).remove(!0)},removeColumn:function(){this.app.popup.close(),this.app.control.close();var i=this.app.block.get().getBlock(),t=i.closest("table"),e=i.closest("tr"),s=0;e.find("td, th").each(function(t,e){t.get()===i.get()&&(s=e)}),t.find("tr").each(function(t){t=t.find("td, th").get(s);this.dom(t).remove()}.bind(this))},cellSetting:function(t,e){var i=this.app.block.get();this.app.popup.create("cell",this.popups.cell).setData({width:i.getWidth(),nowrap:i.getNowrap()}),this.app.popup.open({button:e,focus:"width"})},save:function(t){this.app.popup.close();var t=t.getData(),e=this.app.block.get();""!==t.width&&e.setWidth(t.width),e.setNowrap(t.nowrap)},_addColumn:function(s){this.app.popup.close();var n,i=this.app.block.get().getBlock(),t=i.closest("table"),a=i.closest("tr"),o=0,r=(a.find("td, th").each(function(t,e){t.get()===i.get()&&(o=e)}),0);t.find("tr").each(function(t,e){t.get()===a.get()&&(r=e)}),t.find("tr").each(function(t,e){var t=t.find("td, th").get(o),t=this.dom(t),i=t.clone();i.html(""),this.app.create("block.cell",i),r===e&&(n=i),t[s](i)}.bind(this)),n&&this.app.block.set(n,"start")},_addRow:function(t){this.app.popup.close();var t="below"===t?"after":"before",e=this.app.block.get().getBlock(),i=e.closest("tr"),e=e.closest("thead"),s=i.children("td, th").length,s=this._buildRow(s,"<td>");0!==e.length?e.after(s):i[t](s),this.app.block.set(s.find("td, th").first(),"start")},_buildRow:function(t,e){var i=this.dom("<tr>");this.app.create("block.row",i);for(var s=0;s<t;s++){var n=this.dom(e);this.app.create("block.cell",n),i.append(n)}return i}}),t.add("module","snippet",{popups:{base:{title:"## popup.snippets ##",width:"100%"}},init:function(){this.json={}},observe:function(){if(!this.opts.snippets)return!1},popup:function(){var t,e=this.app.popup.add("snippets",this.popups.base),i=e.getBody();"string"==typeof this.opts.snippets?(t=this.opts.editor.reloadmarker?{d:(new Date).getTime()}:{},this.ajax.get({url:this.opts.snippets,data:t,success:function(t){this._buildPopup(t,i)}.bind(this)})):this._buildPopup(this.opts.snippets,i),e.open()},insert:function(t){var t=this.dom(t.target).closest("."+this.prefix+"-snippet-container").attr("data-snippet-key");Object.prototype.hasOwnProperty.call(this.json,t)&&(this.app.popup.close(),t=this.json[t].html,this.app.editor.insertContent({html:t,caret:"start"}))},_buildPopup:function(t,i){"string"==typeof(this.json=t)&&(this.json=JSON.parse(t)),Object.keys(this.json).forEach(function(t){var e=this._buildPreviewContainer(i,t);this._buildPreview(e,t),this._buildPreviewName(e,t)}.bind(this))},_buildPreviewContainer:function(t,e){var i=this.dom("<div>").addClass(this.prefix+"-snippet-container");return i.attr("data-snippet-key",e),i.one("click",this.insert.bind(this)),t.append(i),i},_buildPreview:function(t,e){var i,s=this.dom("<div>");Object.prototype.hasOwnProperty.call(this.json[e],"image")?(s.addClass(this.prefix+"-snippet-image"),i=this.dom("<img>").attr("src",this.json[e].image),s.html(i)):(s.addClass(this.prefix+"-sni
1ppet-preview"),s.html(this.json[e].html)),t.append(s)},_buildPreviewName:function(t,e){var i;Object.prototype.hasOwnProperty.call(this.json[e],"name")&&((i=this.dom("<div>").addClass(this.prefix+"-snippet-name")).text(this.json[e].name),t.append(i))}}),t.add("module","template",{popups:{base:{title:"## templates.templates ##",width:"100%"}},init:function(){this.json={}},observe:function(){if(!this.opts.templates)return!1},popup:function(t,e){var i;"string"==typeof this.opts.templates?(i=this.opts.editor.reloadmarker?{d:(new Date).getTime()}:{},this.ajax.get({url:this.opts.templates,data:i,success:function(t){this._buildPopup(e,t)}.bind(this)})):this._buildPopup(e,this.opts.templates)},insert:function(t){var t=this.dom(t.target).closest("."+this.prefix+"-template-container").attr("data-template-key");Object.prototype.hasOwnProperty.call(this.json,t)&&(this.app.popup.close(),t=this.json[t].html,this.app.editor.setContent({html:t,caret:!1}))},_buildPopup:function(t,e){var i=this.app.popup.create("templates",this.popups.base).getBody();this.json="string"==typeof e?JSON.parse(e):e,Object.keys(this.json).forEach(function(t){var e=this._buildPreviewContainer(i,t);this._buildPreview(e,t),this._buildPreviewName(e,t)}.bind(this)),this.app.popup.open({button:t})},_buildPreviewContainer:function(t,e){var i=this.dom("<div>").addClass(this.prefix+"-template-container");return i.attr("data-template-key",e),i.one("click",this.insert.bind(this)),t.append(i),i},_buildPreview:function(t,e){var i,s=this.dom("<div>");Object.prototype.hasOwnProperty.call(this.json[e],"image")?(s.addClass(this.prefix+"-template-image"),i=this.dom("<img>").attr("src",this.json[e].image),s.html(i)):(s.addClass(this.prefix+"-template-preview"),s.html(this.json[e].html)),t.append(s)},_buildPreviewName:function(t,e){var i;Object.prototype.hasOwnProperty.call(this.json[e],"name")&&((i=this.dom("<div>").addClass(this.prefix+"-template-name")).text(this.json[e].name),t.append(i))}}
1),t.add("class","tool.checkbox",{mixins:["tool"],type:"checkbox",input:{tag:"input",type:"checkbox",classname:"-form-checkbox"},getValue:function(){return this.$input.val()},_buildInput:function(){var t;this.$box=this.dom("<label>").addClass(this.prefix+"-form-checkbox-item"),this.$box.append(this.$input),this._has("text")&&(t=this.dom("<span>").html(this.lang.parse(this.obj.text)),this.$box.append(t)),this.$tool.append(this.$box)}}),t.add("class","tool.input",{mixins:["tool"],type:"input",input:{tag:"input",type:"text",classname:"-form-input"},_buildInput:function(){this.$tool.append(this.$input)}}),t.add("class","tool.number",{mixins:["tool"],type:"number",input:{tag:"input",type:"number",classname:"-form-input"},_buildInput:function(){this.$input.attr("min",0).css("max-width","65px"),this.$tool.append(this.$input)}}),t.add("class","tool.segment",{mixins:["tool"],type:"segment",input:{tag:"input",type:"hidden",classname:"-form-input"},setValue:function(t){this.$segment.find("."+this.prefix+"-form-segment-item").removeClass("active"),this.$segment.find("[data-segment="+t+"]").addClass("active"),this.$input.val(t)},_buildInput:function(){this.$segment=this.dom("<div>").addClass(this.prefix+"-form-segment");var t,e,i=this.obj.segments;for(t in i)i.hasOwnProperty(t)&&((e=this.dom("<span>").addClass(this.prefix+"-form-segment-item")).attr("data-segment",t).on("click",this._catchSegment.bind(this)),Object.prototype.hasOwnProperty.call(i[t],"icon")?e.html(i[t].icon):e.addClass(this.prefix+"-icon-"+i[t].prefix+"-"+t),this.$segment.append(e));this.$segment.append(this.$input),this.$tool.append(this.$segment)},_catchSegment:function(t){t.preventDefault(),t.stopPropagation();var t=this.dom(t.target).closest("."+this.prefix+"-form-segment-item"),e=t.attr("data-segment");this.$segment.find("."+this.prefix+"-form-segment-item").removeClass("active"),t.addClass("active"),this.$input.val(e),this.app.api(this.setter,this.popup)}}),t.add("class","tool.select",{mixins:["tool"],type:"select",input:{tag:"select",classname:"-form-select"},_buildInput:function(){for(var t in this.obj.options){var e;this.obj.options.hasOwnProperty(t)&&((e=this.dom("<option>")).val(t),e.html(this.lang.parse(this.obj.options[t])),this.$input.append(e))}this.$tool.append(this.$input)}}),t.add("class","tool.textarea",{mixins:["tool"],type:"textarea",input:{tag:"textarea",classname:"-form-textarea"},setFocus:function(){this.$input.focus(),this.$input.get().setSelectionRange(0,0),this.$input.scrollTop(0)},_buildInput:function(){this._has("rows")&&this.$input.attr("rows",this._get("rows")),this.$input.attr("data-gramm_editor",!1),this.$tool.append(this.$input)}}),t.add("class","tool.upload",{mixins:["tool"],type:"upload",input:{tag:"input",type:"hidden",classname:"-form-input"},setValue:function(t){t=t||"",this.upload&&this.upload.setImage(t),this.$input.val(t)},_buildInput:function(){this.$tool.append(this.$input),this._buildUpload()},_buildUpload:function(){this.$upload=this.dom("<input>").attr("type","file"),this.$tool.append(this.$upload);var t={};this._has("trigger")&&this._get("trigger")&&(t={instance:this,method:"trigger"}),this.upload=this.app.create("upload",this.$upload,this.obj.upload,t)}}),t.add("block","block.paragraph",{mixins:["block"],type:"paragraph",editable:!0,toolbar:{add:{title:"## buttons.add ##",command:"addbar.popup"},format:{title:"## buttons.format ##",command:"format.popup"},alignment:{title:"## buttons.align ##",command:"block.popup",observer:"block.observe"},bold:{title:"## buttons.bold ##",command:"inline.set",params:{tag:"b"}},italic:{title:"## buttons.italic ##",command:"inline.set",params:{tag:"i"}},deleted:{title:"## buttons.deleted ##",command:"inline.set",params:{tag:"del"}},link:{title:"## buttons.link ##",command:"link.popup"}},control:{trash:{title:"## buttons.delete ##",command:"block.remove"},duplicate:{title:"## buttons.duplicate ##",command:"block.duplicate"}},create:function(){return this.dom("<p>")},handleEnter:function(t,e,i){if(t.preventDefault(),this.isEmpty()||this.isCaretEnd()){t=this.app.block.create();if(this.opts.clean.enter||(t=this.duplicateEmpty()).getBlock().removeAttr("id"),!this.opts.clean.enterinline){var s=this.app.selection.getInline();if(s){for(var n,a,o=this.app.element.getAllInlines(s),r=0;r<o.length;r++)"A"!==o[r].tagName&&(0===r?((n=o[r].cloneNode()).removeAttribute("id"),n.innerHTML=""):((a=o[r].cloneNode()).removeAttribute("id"),a.innerHTML="",n.appendChild(a)));n&&(t=this.app.block.create(n.outerHTML))}}t.isEmpty()&&t.getBlock().html(this.app.utils.createInvisibleChar()),this.insert({instance:t,position:"after",caret:"start",remove:!1})}else this.isCaretStart()?this.insert({instance:this.duplicateEmpty(),position:"before"}):(s=this.getBlock(),t=this.app.element.split(s),this.app.block.set(t,"start"));return!0}}),t.add("block","block.text",{mixins:["block"],type:"text",editable:!0,toolbar:{add:{title:"## buttons.add ##",command:"addbar.popup"}
1,format:{title:"## buttons.format ##",command:"format.popup"},alignment:{title:"## buttons.align ##",command:"block.popup",observer:"block.observe"},bold:{title:"## buttons.bold ##",command:"inline.set",params:{tag:"b"}},italic:{title:"## buttons.italic ##",command:"inline.set",params:{tag:"i"}},deleted:{title:"## buttons.deleted ##",command:"inline.set",params:{tag:"del"}},link:{title:"## buttons.link ##",command:"link.popup"}},control:{trash:{title:"## buttons.delete ##",command:"block.remove"},duplicate:{title:"## buttons.duplicate ##",command:"block.duplicate"}},create:function(){return this.dom("<div>").addClass(this.opts.text.classname)},handleEnter:function(t,e,i){return t.preventDefault(),this.app.insertion.insertBreakline(),!0}}),t.add("block","block.address",{mixins:["block"],type:"address",editable:!0,toolbar:{add:{title:"## buttons.add ##",command:"addbar.popup"},format:{title:"## buttons.format ##",command:"format.popup"},alignment:{title:"## buttons.align ##",command:"block.popup",observer:"block.observe"},bold:{title:"## buttons.bold ##",command:"inline.set",params:{tag:"b"}},italic:{title:"## buttons.italic ##",command:"inline.set",params:{tag:"i"}},deleted:{title:"## buttons.deleted ##",command:"inline.set",params:{tag:"del"}},link:{title:"## buttons.link ##",command:"link.popup"}},control:{trash:{title:"## buttons.delete ##",command:"block.remove"},duplicate:{title:"## buttons.duplicate ##",command:"block.duplicate"}},create:function(){return this.dom("<address>")},handleEnter:function(t,e,i){if(t.preventDefault(),this.isEmpty()||this.isCaretEnd()){var t=this.getBlock(),s=t.children(),n=s.length,a=s.eq(n-1),s=s.eq(n-2),n=t.html().trim();if(-1!==(n=this.app.utils.removeInvisibleChars(n)).search(/<br\s?\/?>$/))return s.remove(),a.remove(),void this.insertEmpty({position:"after",caret:"start"})}return this.app.insertion.insertBreakline(),!0}}),t.add("block","block.cell",{mixins:["block"],type:"cell",editable:!0,toolbar:{table:{title:"## blocks.table ##",command:"table.add",observer:"table.observe"},alignment:{title:"## buttons.align ##",command:"block.popup",observer:"block.observe"},bold:{title:"## buttons.bold ##",command:"inline.set",params:{tag:"b"}},italic:{title:"## buttons.italic ##",command:"inline.set",params:{tag:"i"}},deleted:{title:"## buttons.deleted ##",command:"inline.set",params:{tag:"del"}},link:{title:"## buttons.link ##",command:"link.popup"},tune:{command:"table.cellSetting",title:"## buttons.settings ##"}},create:function(){return this.dom("<td>")},getNextCell:function(){var t,e=this.getNext();return e||(t=this.getParent("row"))&&(t=t.getNextRow())&&(e=t.getChildFirst("cell")),e},getPrevCell:function(){var t,e=this.getPrev();return e||(t=this.getParent("row"))&&(t=t.getPrevRow())&&(e=t.getChildLast("cell")),e},getWidth:function(){var t=this.$block.attr("width");return t||""},getNowrap:function(){return"nowrap"===this.$block.css("white-space")},setWidth:function(e){this._eachCell(function(t){""===e?t.removeAttr("width"):(e=-1!==e.search("%")?e:e.replace("px",""),t.attr("width",e))})},setNowrap:function(e){this._eachCell(function(t){e=e?"nowrap":"",t.css("white-space",e)})},handleArrow:function(t,e,i){var s,n;return i.is("up-left")&&this.isCaretStart()?(t.preventDefault(),(n=this.getPrevCell())?this.app.block.set(n,"end"):(s=this.getParent("table"),this.app.block.set(s)),!0):i.is("down-right")&&this.isCaretEnd()?(t.preventDefault(),(n=this.getNextCell())?this.app.block.set(n,"start"):(s=this.getParent("table"),this.app.block.set(s)),!0):void 0},handleTab:function(t,e,i){t.preventDefault();var t=this.getNextCell();return t?this.app.block.set(t,"start"):(t=this.getParent("table"),this.app.block.set(t)),!0},handleEnter:function(t,e,i){return t.preventDefault(),this.app.insertion.insertBreakline(),!0},_eachCell:function(e){var i=0,t=this.$block.closest("table");this.$block.closest("tr").find("td, th").each(function(t,e){t.get()===this.$block.get()&&(i=e)}.bind(this)),t.find("tr").each(function(t){t=t.find("td, th").get(i),t=this.dom(t);e(t)}.bind(this))}}),t.add("block","block.code",{mixins:["block"],type:"code",editable:!0,toolbar:{add:{title:"## buttons.add ##",command:"addbar.popup"}},control:{trash:{title:"## buttons.delete ##",command:"block.remove"},duplicate:{title:"## buttons.duplicate ##",command:"block.duplicate"}},create:function(){return this.dom(this.opts.code.template)},build:function(){this._buildCaption(),this._buildItems("figcaption","figcaption")}
1,handleArrow:function(t,e,i){if(i.is("down-right")&&this.isCaretEnd())return(i=this.getNext())?this.app.block.set(i,"start"):this.app.insertion.insertEmptyBlock({position:"after",caret:"start"}),!0},handleTab:function(t,e,i){t.preventDefault();t=this.opts.code.spaces,t=document.createTextNode(Array(t+1).join(" "));return this.app.insertion.insertNode(t,"end"),!0},handleEnter:function(t,e,i){t.preventDefault();t=this.$block.html().search(/\n$/);return this.isCaretEnd()&&-1===t?this.app.insertion.insertNewline("after",!0):this.app.insertion.insertNewline(),!0}}),t.add("block","block.column",{mixins:["block"],type:"column",nested:!0,emptiable:!0,toolbar:{alignment:{title:"## buttons.align ##",command:"block.popup",observer:"block.observe"}},create:function(){return this.dom("<div>")}}),t.add("block","block.dlist",{mixins:["block"],type:"dlist",editable:!0,toolbar:{add:{title:"## buttons.add ##",command:"addbar.popup"},format:{title:"## buttons.format ##",command:"format.popup"},alignment:{title:"## buttons.align ##",command:"block.popup",observer:"block.observe"},bold:{title:"## buttons.bold ##",command:"inline.set",params:{tag:"b"}},italic:{title:"## buttons.italic ##",command:"inline.set",params:{tag:"i"}},deleted:{title:"## buttons.deleted ##",command:"inline.set",params:{tag:"del"}},link:{title:"## buttons.link ##",command:"link.popup"}},control:{trash:{title:"## buttons.delete ##",command:"block.remove"},duplicate:{title:"## buttons.duplicate ##",command:"block.duplicate"}},create:function(){return this.dom("<dl>")},getPlainText:function(i){var s="",t=this.$block.find("dt, dd"),n=t.length;return t.each(function(t,e){e=e!==n&&i?"<br>":"";s+=t.html()+e}),s},setEmpty:function(){this.$block.html("");var t=this.dom("<dt>");this.$block.append(t),this.app.caret.set(t,"start")},isEmpty:function(){var t=this.$block.html(),t=this._cleanEmpty(t),e=this.$block.find("dt, dd");return 0===e.length?""===(t=t.trim()):1===e.length&&(t=e.eq(0).html(),""===(t=this._cleanEmpty(t)))},handleEnter:function(t,e,i){if(t.preventDefault(),this.isEmpty()||this.isCaretEnd()){var t=this.app.selection.getBlock(),s=this.dom(t),n=t.tagName.toLowerCase(),a=this.app.content.isEmptyHtml(t.innerHTML);if("dt"===n&&a)return s.remove(),this.insertEmpty({position:"after",caret:"start"}),!0;a="dt"===n?this.dom("<dd>"):this.dom("<dt>"),this.dom(t).after(a),this.app.caret.set(a,"start")}else{if(this.isCaretStart())return!0;this.app.insertion.insertBreakline()}return!0}}),t.add("block","block.embed",{mixins:["block"],type:"embed",parser:{unparse:function(t){var e,i=decodeURI(t.attr("data-embed-code")),s=this.opts.embed.responsive.split(" ").join("."),s=t.find("."+s),n=t.find("figcaption");0!==n.length&&(e=n.clone(),n.remove()),(0===s.length?t:s).html(i),e&&t.append(e),t.removeAttr("data-embed-code")}},toolbar:{add:{title:"## buttons.add ##",command:"addbar.popup"},outset:{title:"## buttons.outset ##",command:"block.popup",observer:"block.observe"},embed:{title:"## blocks.embed ##",command:"embed.popup",observer:"embed.observe"}},control:{trash:{title:"## buttons.delete ##",command:"block.remove"},duplicate:{title:"## buttons.duplicate ##",command:"block.duplicate"}},create:function(){return this.dom("<figure>")},build:function(){this._buildCaption(),this._buildItems("figcaption","figcaption"),this._buildEmbedCode()},addResponsive:function(){var t=this.dom("<div>").addClass(this.opts.embed.responsive),e=this.$block.find("figcaption"),i=e.clone(),s=this.getEmbedCode();e.remove(),t.html(s),this.$block.html("").append(t),0!==i.length&&(this.app.create("block.figcaption",i),this.$block.append(i)),this._buildEmbedCode()},removeResponsive:function(){this.$block.find(this._getEmbedClass()).unwrap()},getEmbedCode:function(){return decodeURI(this.$block.attr("data-embed-code"))},isResponsive:function(){return 0!==this.$block.find(this._getEmbedClass()).length},_buildEmbedCode:function(){var t=this.$block.clone(),t=(t.find(this._getEmbedClass()).unwrap(),t.find("figcaption").remove(),t.html().trim());this.$block.attr("data-embed-code",encodeURI(t))},_getEmbedClass:function(){return"."+this.opts.embed.responsive.replace(/ +/g,".")}}),t.add("block","block.figcaption",{mixins:["block"],type:"figcaption",editable:!0,toolbar:{alignment:{title:"## buttons.align ##",command:"block.popup",observer:"block.observe"},bold:{title:"## buttons.bold ##",command:"inline.set",params:{tag:"b"}},italic:{title:"## buttons.italic ##",command:"inline.set",params:{tag:"i"}},deleted:{title:"## buttons.deleted ##",command:"inline.set",params:{tag:"del"}},link:{title:"## buttons.link ##",command:"link.popup"}},create:function(){return this.dom("<figcaption>")},getFigure:function(){return this.$block.closest("figure").dataget("instance")}
1,handleArrow:function(t,e,i){if(i.is("up-left")&&this.isCaretStart()||i.is("down-right")&&this.isCaretEnd())return t.preventDefault(),i=this.getFigure(),this.app.block.set(i),!0},handleTab:function(t,e,i){t.preventDefault();t=this.getFigure();return this.app.block.set(t),!0},handleEnter:function(t,e,i){return t.preventDefault(),this.isEmpty()||this.isCaretEnd()||this.isCaretStart()||this.app.insertion.insertBreakline(),!0}}),t.add("block","block.grid",{mixins:["block"],type:"grid",nested:!0,parser:{unparse:function(t){t.removeClass(this.prefix+"-grid-overlay")}},toolbar:{add:{title:"## buttons.add ##",command:"addbar.popup"},valign:{title:"## buttons.valign ##",command:"block.popup",observer:"block.observe"}},control:{trash:{title:"## buttons.delete ##",command:"block.remove"},duplicate:{title:"## buttons.duplicate ##",command:"block.duplicate"}},create:function(){var t=this.dom("<div>").addClass(this.opts.grid.classname);return""!==this.opts.grid.classes&&t.addClass(this.opts.grid.classes),t},build:function(){this._buildOverlay()},_buildOverlay:function(){this.opts.grid&&this.opts.grid.overlay&&this.$block.addClass(this.prefix+"-grid-overlay")}}),t.add("block","block.heading",{mixins:["block"],type:"heading",editable:!0,toolbar:{add:{title:"## buttons.add ##",command:"addbar.popup"},format:{title:"## buttons.format ##",command:"format.popup"},alignment:{title:"## buttons.align ##",command:"block.popup",observer:"block.observe"},bold:{title:"## buttons.bold ##",command:"inline.set",params:{tag:"b"}},italic:{title:"## buttons.italic ##",command:"inline.set",params:{tag:"i"}},deleted:{title:"## buttons.deleted ##",command:"inline.set",params:{tag:"del"}},link:{title:"## buttons.link ##",command:"link.popup"}},control:{trash:{title:"## buttons.delete ##",command:"block.remove"},duplicate:{title:"## buttons.duplicate ##",command:"block.duplicate"}},create:function(){return this.dom("<h2>")},getTitle:function(){var t=this.lang.get("headings"),e=this.getTag(),i=this.$block.attr("data-title");return void 0!==t[e]?t[e]:i},handleEnter:function(t,e,i){return t.preventDefault(),this.isEmpty()||this.isCaretEnd()?this.insertEmpty({position:"after",caret:"start",remove:!1}):this.isCaretStart()?this.insert({instance:this.duplicateEmpty(),position:"before"}):(t=this.getBlock(),t=this.app.element.split(t),this.app.block.set(t,"start")),!0}}),t.add("block","block.image",{mixins:["block"],type:"image",toolbar:{add:{title:"## buttons.add ##",command:"addbar.popup"},outset:{title:"## buttons.outset ##",command:"block.popup",observer:"block.observe"},image:{title:"## blocks.image ##",command:"image.popup",observer:"image.observe"}},control:{trash:{title:"## buttons.delete ##",command:"block.remove"},duplicate:{title:"## buttons.duplicate ##",command:"block.duplicate"}},create:function(){return this.dom("<"+this.opts.image.tag+">")},build:function(){this._buildCaption(),this._buildItems("figcaption","figcaption"),this.data={alt:{getter:"getAlt",setter:"setAlt"},width:{getter:"getWidth",setter:"setWidth"},link:{getter:"getLinkUrl",setter:"setLinkUrl"},target:{getter:"getTarget",setter:"setTarget"},caption:{getter:"getCaption",setter:"setCaption"}}},getImage:function(){return this.$block.find("img").eq(0)},getSrc:function(){return this.getImage().attr("src")},getId:function(){return this.getImage().attr("data-image")},getLink:function(){var t=this.getImage().parent();return t="A"===t.get().tagName&&t},getWidth:function(){var t=this.getImage(),e=t.css("width"),t=t.attr("width");return e=t&&-1!==t.search(/%/)?t:e},getAlt:function(){var t=this.getImage().attr("alt");return t||""},getLinkUrl:function(){var t=this.getLink();return t?t.attr("href"):""},getTarget:function(){var t=this.getLink();return t?t.attr("target"):this.opts.image.newtab},setWidth:function(t){var e,i,s,n=this.getImage();""===(t=t.trim())?n.removeAttr("width"):(e=(s=-1!==t.search(/%/))?t:parseInt(t),i=n.width()/n.height(),s?(n.removeAttr("height"),n.attr({width:e})):(s=Math.round(e/i),n.attr({width:e,height:s}))),n.css({width:t,"max-width":t}),this.app.broadcast("image.width",{image:n,width:t})},setAlt:function(t){var e=this.getImage();t=t.replace(/"/g,"'"),e.attr("alt",t)},setTarget:function(t){var e=this.getLink();e&&(t?e.attr("target","_blank"):e.removeAttr("target"))}
1,setLinkUrl:function(t){if(i=this.getLink()){if(""===t)return this.removeLink(),void this.app.broadcast("image.unlink",{instance:this});i.attr("href",t)}else if(!i){if(""===t)return;var e=this.getImage(),i=this.dom("<a>");e.wrap(i),i.attr("href",t)}this.app.broadcast("image.link",{instance:this,link:i})},setImage:function(t){var e=this.getImage();e.attr("src",t.url),Object.prototype.hasOwnProperty.call(t,"id")&&e.attr("data-image",t.id),Object.prototype.hasOwnProperty.call(t,"2x")&&e.attr("srcset",t["2x"]+" 2x"),e.one("load",this.app.editor.adjustHeight.bind(this.app.editor))},removeLink:function(){var t=this.getLink();t&&t.unwrap()}}),t.add("block","block.layer",{mixins:["block"],type:"layer",nested:!0,emptiable:!0,toolbar:{add:{title:"## buttons.add ##",command:"addbar.popup"}},control:{trash:{title:"## buttons.delete ##",command:"block.remove"},duplicate:{title:"## buttons.duplicate ##",command:"block.duplicate"}},create:function(){return this.dom(this.opts.layer.template)},getTitle:function(){return this.$block.attr("data-title")||this._getNameByTag()}}),t.add("block","block.line",{mixins:["block"],type:"line",toolbar:{add:{title:"## buttons.add ##",command:"addbar.popup"}},control:{trash:{title:"## buttons.delete ##",command:"block.remove"},duplicate:{title:"## buttons.duplicate ##",command:"block.duplicate"}},create:function(){return this.dom("<hr>")}}),t.add("block","block.list",{mixins:["block"],type:"list",editable:!0,toolbar:{add:{title:"## buttons.add ##",command:"addbar.popup"},format:{title:"## buttons.format ##",command:"format.popup"},alignment:{title:"## buttons.align ##",command:"block.popup",observer:"block.observe"},bold:{title:"## buttons.bold ##",command:"inline.set",params:{tag:"b"}},italic:{title:"## buttons.italic ##",command:"inline.set",params:{tag:"i"}},deleted:{title:"## buttons.deleted ##",command:"inline.set",params:{tag:"del"}},outdent:{title:"## buttons.outdent ##",command:"list.outdent"},indent:{title:"## buttons.indent ##",command:"list.indent"},link:{title:"## buttons.link ##",command:"link.popup"}},control:{trash:{title:"## buttons.delete ##",command:"block.remove"},duplicate:{title:"## buttons.duplicate ##",command:"block.duplicate"}},create:function(){return this.dom("<ul>")},unparse:function(t){this.app.content.unfixListMargin(t)},setEmpty:function(){this.$block.html("");var t=this.dom("<li>");this.$block.append(t),this.app.caret.set(t,"start")},isEmpty:function(){var t=this.$block.html(),t=this._cleanEmpty(t),e=this.$block.find("li");return 0===e.length?""===(t=t.trim()):1===e.length&&(t=e.eq(0).html(),""===(t=this._cleanEmpty(t)))},handleTab:function(t,e,i){var s=this.app.selection.getBlock(),s=this.app.caret.is(s,"start");if(this.isCaretStart()||this.isCaretEnd()){var n=this.getNext();if(n)return t.preventDefault(),this.app.block.set(n,"start"),!0}else if(!this.opts.tab.spaces||s)return t.preventDefault(),this.app.list.indent(),!0},handleEnter:function(t,e,i){var s,n,a,o,r;if(t.preventDefault(),this.isEmpty()||this.isCaretEnd()){if(s=this.app.selection.getBlock(),n=this.dom(s),o=this.app.content.isEmptyHtml(s.innerHTML))return n.remove(),this.insertEmpty({position:"after",caret:"start"}),!0;r=this.dom("<li>"),this.app.element.cloneAttrs(s,r),this.dom(s).after(r),this.app.caret.set(r,"start")}else this.isCaretStart()?(r=this.dom("<li>"),s=this.app.selection.getBlock(),this.app.element.cloneAttrs(s,r),this.dom(s).before(r)):(s=this.app.selection.getBlock(),n=this.dom(s),o=this.app.content.isEmptyHtml(s.innerHTML),t=this.app.caret.is(s,"start"),a=this.app.caret.is(s,"end",["ul","ol"]),r=this.dom("<li>"),this.app.element.cloneAttrs(s,r),o?(n.after(r),this.app.caret.set(r,"start")):t?n.before(r):a?(0!==(o=n.find("ul, ol").first()).length&&(r.append(this.app.utils.createInvisibleChar()),r.append(o)),n.after(r),this.app.caret.set(r,"start")):(t=this.app.element.split(s),this.app.caret.set(r=t,"start")));return this.app.broadcast("list.item",{element:r}),!0}}),t.add("block","block.noneditable",{mixins:["block"],type:"noneditable",toolbar:{add:{title:"## buttons.add ##",command:"addbar.popup"}},control:{trash:{title:"## buttons.delete ##",command:"block.remove"},duplicate:{title:"## buttons.duplicate ##",command:"block.duplicate"}},create:function(){return this.dom("<div>").addClass(this.opts.noneditable.classname)}}),t.add("block","block.quote",{mixins:["block"],type:"quote",toolbar:{add:{title:"## buttons.add ##",command:"addbar.popup"}},control:{trash:{title:"## buttons.delete ##",command:"block.remove"},duplicate:{title:"## buttons.duplicate ##",command:"block.duplicate"}},create:function(){return this.dom(this.opts.quote.template)},build:function(){this._buildCaption(),this._buildItems("p","quoteitem"),this._buildItems("figcaption","figcaption")}}),t.add("block","block.quoteitem",{mixins:["block"],type:"quoteitem",editable:!0,toolbar:{alignment:{title:"## buttons.align ##",command:"block.popup",observer:"block.observe"},bold:{title:"## buttons.bold ##",command:"inline.set",params:{tag:"b"}},italic:{title:"## buttons.italic ##",command:"inline.set",params:{tag:"i"}},deleted:{title:"## buttons.deleted ##",command:"inline.set",params:{tag:"del"}},link:{title:"## buttons.link ##",command:"link.popup"}},create:function(){return this.dom("<p>")},getBlockquote:function(){return this.$block.closest("blockquote")}
1,handleArrow:function(t,e,i){var s,n=this.getBlockquote();if(0!==n.length)return s=this.app.caret.is(n,"start"),n=this.app.caret.is(n,"end"),i.is("up-left")&&s||i.is("down-right")&&n?(t.preventDefault(),s=this.getParent("quote"),this.app.block.set(s),!0):void 0},handleTab:function(t,e,i){t.preventDefault();var t=this.getNext();return t?this.app.block.set(t,"start"):(t=this.getParent("quote"),this.app.block.set(t)),!0},handleEnter:function(t,e,i){t.preventDefault();var t=this.app.create("block.quoteitem");return this.isEmpty()||this.isCaretEnd()?this.insert({instance:t,position:"after",caret:"start"}):this.isCaretStart()?this.insert({instance:t,position:"before"}):(t=this.getBlock(),t=this.app.element.split(t),this.app.block.set(t,"start")),!0}}),t.add("block","block.row",{mixins:["block"],type:"row",toolbar:{table:{title:"## blocks.table ##",command:"table.add",observer:"table.observe"}},create:function(){return this.dom("<tr>")},getNextRow:function(){var t=this.getNext(),e=this.$block.parent();return t=t||"TABLE"===e.get().tagName?t:e.nextElement().find("tr").first().dataget("instance")},getPrevRow:function(){var t=this.getPrev(),e=this.$block.parent();return t=t||"TABLE"===e.get().tagName?t:e.prevElement().find("tr").last().dataget("instance")},handleDelete:function(t,e,i){return t.preventDefault(),!0},handleArrow:function(t,e,i){return t.preventDefault(),i.is("up-left")?(t=this.getParent("table"),this.app.block.set(t)):(i=this.getChildFirst("cell"),this.app.block.set(i,"start")),!0},handleTab:function(t,e,i){t.preventDefault();var t=this.getNextRow();return t?this.app.block.set(t):(t=this.getParent("table"),this.app.block.set(t)),!0},handleEnter:function(t,e,i){return t.preventDefault(),!0}}),t.add("block","block.table",{mixins:["block"],type:"table",toolbar:{add:{title:"## buttons.add ##",command:"addbar.popup"},table:{title:"## blocks.table ##",command:"table.add",observer:"table.observe"}},control:{trash:{title:"## buttons.delete ##",command:"block.remove"},duplicate:{title:"## buttons.duplicate ##",command:"block.duplicate"}},create:function(){return this.dom(this.opts.table.template)},build:function(){this._buildItems("tr","row"),this._buildItems("td, th","cell")},getFirstCell:function(){var t=this.$block.find("th, td").first();if(0!==t.length)return t.dataget("instance")}}),t.add("block","block.variable",{mixins:["block"],type:"variable",editable:!1,inline:!0,toolbar:{add:{title:"## buttons.add ##",command:"addbar.popup"}},create:function(){return this.dom("<span>").addClass(this.opts.variable.classname)},build:function(){this.$block.addClass(this.opts.variable.classname)}}),t.add("block","block.form",{mixins:["block"],type:"form",create:function(){return this.dom("<form>")},toolbar:{add:{title:"## buttons.add ##",command:"addbar.popup"}},control:{trash:{command:"block.remove",title:"## buttons.delete ##"},duplicate:{command:"block.duplicate",title:"## buttons.duplicate ##"}}}),t.add("block","block.card",{mixins:["block"],type:"card",editable:!0,toolbar:{add:{title:"## buttons.add ##",command:"addbar.popup"},bold:{title:"## buttons.bold ##",command:"inline.set",params:{tag:"b"}},italic:{title:"## buttons.italic ##",command:"inline.set",params:{tag:"i"}},deleted:{title:"## buttons.deleted ##",command:"inline.set",params:{tag:"del"}},link:{title:"## buttons.link ##",command:"link.popup"},image:{title:"## buttons.settings ##",command:"image.editCard",observer:"block.observeCard"}},control:{trash:{title:"## buttons.delete ##",command:"block.remove"},duplicate:{title:"## buttons.duplicate ##",command:"block.duplicate"}},create:function(){return this.dom(this.opts.card.template)},build:function(){this.data={alt:{getter:"getAlt",setter:"setAlt"}}},hasImage:function(){return 0!==this.$block.find("img").length},getImage:function(){return this.$block.find("img").eq(0)},getAlt:function(){var t=this.getImage().attr("alt");return t||""},setAlt:function(t){this.getImage().attr("alt",t)},setImage:function(t){var e=this.getImage();e.attr("src",t.url),Object.prototype.hasOwnProperty.call(t,"id")&&e.attr("data-image",t.id),e.one("load",this.app.editor.adjustHeight.bind(this.app.editor))}
1,handleEnter:function(t,e,i){return t.preventDefault(),this.app.insertion.insertBreakline(),!0}}),window.ArticleEditor=t,window.addEventListener("load",function(){t("[data-article-editor]")}),"object"==typeof module&&module.exports&&(module.exports=t,module.exports.ArticleEditor=t)}();

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.