"classList"in document.createElement("_")||!function(a){"use strict";if("Element"in a){var b="classList",c="prototype",d=a.Element[c],e=Object,f=String[c].trim||function(){return this.replace(/^\s+|\s+$/g,"")},g=Array[c].indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(b in this&&this[b]===a)return b;return-1},h=function(a,b){this.name=a,this.code=DOMException[a],this.message=b},i=function(a,b){if(""===b)throw new h("SYNTAX_ERR","An invalid or illegal string was specified");if(/\s/.test(b))throw new h("INVALID_CHARACTER_ERR","String contains an invalid character");return g.call(a,b)},j=function(a){for(var b=f.call(a.getAttribute("class")||""),c=b?b.split(/\s+/):[],d=0,e=c.length;e>d;d++)this.push(c[d]);this._updateClassName=function(){a.setAttribute("class",this.toString())}},k=j[c]=[],l=function(){return new j(this)};if(h[c]=Error[c],k.item=function(a){return this[a]||null},k.contains=function(a){return a+="",-1!==i(this,a)},k.add=function(){var a,b=arguments,c=0,d=b.length,e=!1;do a=b[c]+"",-1===i(this,a)&&(this.push(a),e=!0);while(++ci;i++)e+=String.fromCharCode(f[i]);c.push(e)}else if("Blob"===b(a)||"File"===b(a)){if(!g)throw new h("NOT_READABLE_ERR");var k=new g;c.push(k.readAsBinaryString(a))}else a instanceof d?"base64"===a.encoding&&p?c.push(p(a.data)):"URI"===a.encoding?c.push(decodeURIComponent(a.data)):"raw"===a.encoding&&c.push(a.data):("string"!=typeof a&&(a+=""),c.push(unescape(encodeURIComponent(a))))},e.getBlob=function(a){return arguments.length||(a=null),new d(this.data.join(""),a,"raw")},e.toString=function(){return"[object BlobBuilder]"},f.slice=function(a,b,c){var e=arguments.length;return 3>e&&(c=null),new d(this.data.slice(a,e>1?b:this.data.length),c,this.encoding)},f.toString=function(){return"[object Blob]"},f.close=function(){this.size=0,delete this.data},c}(a);a.Blob=function(a,b){var d=b?b.type||"":"",e=new c;if(a)for(var f=0,g=a.length;g>f;f++)e.append(Uint8Array&&a[f]instanceof Uint8Array?a[f].buffer:a[f]);var h=e.getBlob(d);return!h.slice&&h.webkitSlice&&(h.slice=h.webkitSlice),h};var d=Object.getPrototypeOf||function(a){return a.__proto__};a.Blob.prototype=d(new a.Blob)}("undefined"!=typeof self&&self||"undefined"!=typeof window&&window||this.content||this),function(a,b){"use strict";"object"==typeof module?module.exports=b:"function"==typeof define&&define.amd?define(function(){return b}):a.MediumEditor=b}(this,function(){"use strict";function a(a,b){return this.init(a,b)}var b;!function(a){function c(b,c,d){d||(d=a);try{for(var e=0;e=0,keyCode:{BACKSPACE:8,TAB:9,ENTER:13,ESCAPE:27,SPACE:32,DELETE:46},isMetaCtrlKey:function(a){return this.isMac&&a.metaKey||!this.isMac&&a.ctrlKey?!0:!1},parentElements:["p","h1","h2","h3","h4","h5","h6","blockquote","pre"],extend:function(){var a=[!0].concat(Array.prototype.slice.call(arguments));return d.apply(this,a)},defaults:function(){var a=[!1].concat(Array.prototype.slice.call(arguments));return d.apply(this,a)},derives:function(a,b){function c(){}var e=b.prototype;return c.prototype=a.prototype,b.prototype=new c,b.prototype.constructor=a,b.prototype=d(!1,b.prototype,e),b},findAdjacentTextNodeWithContent:function(a,b,c){var d,e=!1,f=c.createNodeIterator(a,NodeFilter.SHOW_TEXT,null,!1);for(d=f.nextNode();d;){if(d===b)e=!0;else if(e&&3===d.nodeType&&d.nodeValue&&d.nodeValue.trim().length>0)break;d=f.nextNode()}return d},isDescendant:function(a,b,c){if(!a||!b)return!1;if(c&&a===b)return!0;for(var d=b.parentNode;null!==d;){if(d===a)return!0;d=d.parentNode}return!1},isElement:function(a){return!(!a||1!==a.nodeType)},now:Date.now,throttle:function(a,b){var c,d,e,f=50,g=null,h=0,i=function(){h=Date.now(),g=null,e=a.apply(c,d),g||(c=d=null)};return b||0===b||(b=f),function(){var f=Date.now(),j=b-(f-h);return c=this,d=arguments,0>=j||j>b?(g&&(clearTimeout(g),g=null),h=f,e=a.apply(c,d),g||(c=d=null)):g||(g=setTimeout(i,j)),e}},traverseUp:function(a,b){if(!a)return!1;do{if(1===a.nodeType){if(b(a))return a;if(a.getAttribute("data-medium-element"))return!1}a=a.parentNode}while(a);return!1},htmlEntities:function(a){return String(a).replace(/&/g,"&").replace(//g,">").replace(/"/g,""")},insertHTMLCommand:function(a,b){var c,d,e,f,g,h,i;if(a.queryCommandSupported("insertHTML"))try{return a.execCommand("insertHTML",!1,b)}catch(j){}if(c=a.defaultView.getSelection(),c.getRangeAt&&c.rangeCount){if(d=c.getRangeAt(0),i=d.commonAncestorContainer,3===i.nodeType&&i.nodeValue===d.toString()||3!==i.nodeType&&i.innerHTML===d.toString()){for(;i.parentNode&&1===i.parentNode.childNodes.length&&!i.parentNode.getAttribute("data-medium-element");)i=i.parentNode;d.selectNode(i)}for(d.deleteContents(),e=a.createElement("div"),e.innerHTML=b,f=a.createDocumentFragment();e.firstChild;)g=e.firstChild,h=f.appendChild(g);d.insertNode(f),h&&(d=d.cloneRange(),d.setStartAfter(h),d.collapse(!0),c.removeAllRanges(),c.addRange(d))}},getSelectionRange:function(a){var b=a.getSelection();return 0===b.rangeCount?null:b.getRangeAt(0)},getSelectionStart:function(a){var b=a.getSelection().anchorNode,c=b&&3===b.nodeType?b.parentNode:b;return c},getSelectionData:function(a){var b;for(a&&a.tagName&&(b=a.tagName.toLowerCase());a&&-1===this.parentElements.indexOf(b);)a=a.parentNode,a&&a.tagName&&(b=a.tagName.toLowerCase());return{el:a,tagName:b}},execFormatBlock:function(a,b){var c=this.getSelectionData(this.getSelectionStart(a));if("blockquote"===b&&c.el&&"blockquote"===c.el.parentNode.tagName.toLowerCase())return a.execCommand("outdent",!1,null);if(c.tagName===b&&(b="p"),this.isIE){if("blockquote"===b)return a.execCommand("indent",!1,b);b="<"+b+">"}return a.execCommand("formatBlock",!1,b)},setTargetBlank:function(a){var b;if("a"===a.tagName.toLowerCase())a.target="_blank";else for(a=a.getElementsByTagName("a"),b=0;bB",contentFA:'',key:"b"},italic:{name:"italic",action:"italic",aria:"italic",tagNames:["i","em"],style:{prop:"font-style",value:"italic"},useQueryState:!0,contentDefault:"I",contentFA:'',key:"i"},underline:{name:"underline",action:"underline",aria:"underline",tagNames:["u"],style:{prop:"text-decoration",value:"underline"},useQueryState:!0,contentDefault:"U",contentFA:'',key:"u"},strikethrough:{name:"strikethrough",action:"strikethrough",aria:"strike through",tagNames:["strike"],style:{prop:"text-decoration",value:"line-through"},useQueryState:!0,contentDefault:"A",contentFA:''},superscript:{name:"superscript",action:"superscript",aria:"superscript",tagNames:["sup"],contentDefault:"x1",contentFA:''},subscript:{name:"subscript",action:"subscript",aria:"subscript",tagNames:["sub"],contentDefault:"x1",contentFA:''},image:{name:"image",action:"image",aria:"image",tagNames:["img"],contentDefault:"image",contentFA:''},quote:{name:"quote",action:"append-blockquote",aria:"blockquote",tagNames:["blockquote"],contentDefault:"“",contentFA:''},orderedlist:{name:"orderedlist",action:"insertorderedlist",aria:"ordered list",tagNames:["ol"],useQueryState:!0,contentDefault:"1.",contentFA:''},unorderedlist:{name:"unorderedlist",action:"insertunorderedlist",aria:"unordered list",tagNames:["ul"],useQueryState:!0,contentDefault:"•",contentFA:''},pre:{name:"pre",action:"append-pre",aria:"preformatted text",tagNames:["pre"],contentDefault:"0101",contentFA:''},indent:{name:"indent",action:"indent",aria:"indent",tagNames:[],contentDefault:"→",contentFA:''},outdent:{name:"outdent",action:"outdent",aria:"outdent",tagNames:[],contentDefault:"←",contentFA:''},justifyCenter:{name:"justifyCenter",action:"justifyCenter",aria:"center justify",tagNames:[],style:{prop:"text-align",value:"center"},contentDefault:"C",contentFA:''},justifyFull:{name:"justifyFull",action:"justifyFull",aria:"full justify",tagNames:[],style:{prop:"text-align",value:"justify"},contentDefault:"J",contentFA:''},justifyLeft:{name:"justifyLeft",action:"justifyLeft",aria:"left justify",tagNames:[],style:{prop:"text-align",value:"left"},contentDefault:"L",contentFA:''},justifyRight:{name:"justifyRight",action:"justifyRight",aria:"right justify",tagNames:[],style:{prop:"text-align",value:"right"},contentDefault:"R",contentFA:''},header1:{name:"header1",action:function(a){return"append-"+a.firstHeader},aria:function(a){return a.firstHeader},tagNames:function(a){return[a.firstHeader]},contentDefault:"H1"},header2:{name:"header2",action:function(a){return"append-"+a.secondHeader},aria:function(a){return a.secondHeader},tagNames:function(a){return[a.secondHeader]},contentDefault:"H2"},removeFormat:{name:"removeFormat",aria:"remove formatting",action:"removeFormat",contentDefault:"X",contentFA:''}}}();var d;!function(){d={allowMultiParagraphSelection:!0,anchorInputPlaceholder:"Paste or type a link",anchorInputCheckboxLabel:"Open in new window",anchorPreviewHideDelay:500,buttons:["bold","italic","underline","anchor","header1","header2","quote"],buttonLabels:!1,checkLinkFormat:!1,delay:0,diffLeft:0,diffTop:-10,disableReturn:!1,disableDoubleReturn:!1,disableToolbar:!1,disableAnchorPreview:!1,disableEditing:!1,disablePlaceholders:!1,toolbarAlign:"center",elementsContainer:!1,imageDragging:!0,standardizeSelectionStart:!1,contentWindow:window,ownerDocument:document,firstHeader:"h3",placeholder:"Type your text",secondHeader:"h4",targetBlank:!1,anchorTarget:!1,anchorButton:!1,anchorButtonClass:"btn",extensions:{},activeButtonClass:"medium-editor-button-active",firstButtonClass:"medium-editor-button-first",lastButtonClass:"medium-editor-button-last",spellcheck:!0,paste:{forcePlainText:!0,cleanPastedHTML:!1,cleanAttrs:["class","style","dir"],cleanTags:["meta"]}}}();var e;!function(){e=function(a){b.extend(this,a)},e.extend=function(a){var c,d=this;c=a&&a.hasOwnProperty("constructor")?a.constructor:function(){return d.apply(this,arguments)},b.extend(c,d);var e=function(){this.constructor=c};return e.prototype=d.prototype,c.prototype=new e,a&&b.extend(c.prototype,a),c},e.prototype={init:function(){},parent:!1,base:null,name:null,checkState:null,getButton:null,queryCommandState:null,isActive:null,isAlreadyApplied:null,setActive:null,setInactive:null,onHide:null}}();var f;!function(){f={findMatchingSelectionParent:function(a,c){var d,e,f=c.getSelection();return 0===f.rangeCount?!1:(d=f.getRangeAt(0),e=d.commonAncestorContainer,b.traverseUp(e,a))},getSelectionElement:function(a){return this.findMatchingSelectionParent(function(a){return a.getAttribute("data-medium-element")},a)},selectionInContentEditableFalse:function(a){return this.findMatchingSelectionParent(function(a){return a&&"#text"!==a.nodeName&&"false"===a.getAttribute("contenteditable")},a)},getSelectionHtml:function(){var a,b,c,d="",e=this.options.contentWindow.getSelection();if(e.rangeCount){for(c=this.options.ownerDocument.createElement("div"),a=0,b=e.rangeCount;b>a;a+=1)c.appendChild(e.getRangeAt(a).cloneContents());d=c.innerHTML}return d},getCaretOffsets:function(a,b){var c,d;return b||(b=window.getSelection().getRangeAt(0)),c=b.cloneRange(),d=b.cloneRange(),c.selectNodeContents(a),c.setEnd(b.endContainer,b.endOffset),d.selectNodeContents(a),d.setStart(b.endContainer,b.endOffset),{left:c.toString().length,right:d.toString().length}},rangeSelectsSingleNode:function(a){var b=a.startContainer;return b===a.endContainer&&b.hasChildNodes()&&a.endOffset===a.startOffset+1},getSelectedParentElement:function(a){var b=null;return b=this.rangeSelectsSingleNode(a)&&3!==a.startContainer.childNodes[a.startOffset].nodeType?a.startContainer.childNodes[a.startOffset]:3===a.startContainer.nodeType?a.startContainer.parentNode:a.startContainer},getSelectedElements:function(a){var b,c,d,e=a.getSelection();if(!e.rangeCount||!e.getRangeAt(0).commonAncestorContainer)return[];if(b=e.getRangeAt(0),3===b.commonAncestorContainer.nodeType){for(c=[],d=b.commonAncestorContainer;d.parentNode&&1===d.parentNode.childNodes.length;)c.push(d.parentNode),d=d.parentNode;return c}return[].filter.call(b.commonAncestorContainer.getElementsByTagName("*"),function(a){return"function"==typeof e.containsNode?e.containsNode(a,!0):!0})},selectNode:function(a,b){var c=b.createRange(),d=b.getSelection();c.selectNodeContents(a),d.removeAllRanges(),d.addRange(c)}}}();var g;!function(){g=function(a){this.base=a,this.options=this.base.options,this.events=[],this.customEvents={},this.listeners={}},g.prototype={attachDOMEvent:function(a,b,c,d){a.addEventListener(b,c,d),this.events.push([a,b,c,d])},detachDOMEvent:function(a,b,c,d){var e,f=this.indexOfListener(a,b,c,d);-1!==f&&(e=this.events.splice(f,1)[0],e[0].removeEventListener(e[1],e[2],e[3]))},indexOfListener:function(a,b,c,d){var e,f,g;for(e=0,f=this.events.length;f>e;e+=1)if(g=this.events[e],g[0]===a&&g[1]===b&&g[2]===c&&g[3]===d)return e;return-1},detachAllDOMEvents:function(){for(var a=this.events.pop();a;)a[0].removeEventListener(a[1],a[2],a[3]),a=this.events.pop()},attachCustomEvent:function(a,b){this.setupListener(a),this.listeners[a]&&(this.customEvents[a]||(this.customEvents[a]=[]),this.customEvents[a].push(b))},detachCustomEvent:function(a,b){var c=this.indexOfCustomListener(a,b);-1!==c&&this.customEvents[a].splice(c,1)},indexOfCustomListener:function(a,b){return this.customEvents[a]&&this.customEvents[a].length?this.customEvents[a].indexOf(b):-1},detachAllCustomEvents:function(){this.customEvents={}},triggerCustomEvent:function(a,b,c){this.customEvents[a]&&this.customEvents[a].forEach(function(a){a(b,c)})},setupListener:function(a){if(!this.listeners[a])switch(a){case"externalInteraction":this.attachDOMEvent(this.options.ownerDocument.body,"mousedown",this.handleBodyMousedown.bind(this),!0),this.attachDOMEvent(this.options.ownerDocument.body,"click",this.handleBodyClick.bind(this),!0),this.attachDOMEvent(this.options.ownerDocument.body,"focus",this.handleBodyFocus.bind(this),!0),this.listeners[a]=!0;break;case"blur":this.setupListener("externalInteraction"),this.listeners[a]=!0;break;case"focus":this.setupListener("externalInteraction"),this.listeners[a]=!0;break;case"editableClick":this.base.elements.forEach(function(a){this.attachDOMEvent(a,"click",this.handleClick.bind(this))}.bind(this)),this.listeners[a]=!0;break;case"editableBlur":this.base.elements.forEach(function(a){this.attachDOMEvent(a,"blur",this.handleBlur.bind(this))}.bind(this)),this.listeners[a]=!0;break;case"editableKeypress":this.base.elements.forEach(function(a){this.attachDOMEvent(a,"keypress",this.handleKeypress.bind(this))}.bind(this)),this.listeners[a]=!0;break;case"editableKeyup":this.base.elements.forEach(function(a){this.attachDOMEvent(a,"keyup",this.handleKeyup.bind(this))}.bind(this)),this.listeners[a]=!0;break;case"editableKeydown":this.base.elements.forEach(function(a){this.attachDOMEvent(a,"keydown",this.handleKeydown.bind(this))}.bind(this)),this.listeners[a]=!0;break;case"editableKeydownEnter":this.setupListener("editableKeydown"),this.listeners[a]=!0;break;case"editableKeydownTab":this.setupListener("editableKeydown"),this.listeners[a]=!0;break;case"editableKeydownDelete":this.setupListener("editableKeydown"),this.listeners[a]=!0;break;case"editableMouseover":this.base.elements.forEach(function(a){this.attachDOMEvent(a,"mouseover",this.handleMouseover.bind(this))},this),this.listeners[a]=!0;break;case"editableDrag":this.base.elements.forEach(function(a){this.attachDOMEvent(a,"dragover",this.handleDragging.bind(this)),this.attachDOMEvent(a,"dragleave",this.handleDragging.bind(this))},this),this.listeners[a]=!0;break;case"editableDrop":this.base.elements.forEach(function(a){this.attachDOMEvent(a,"drop",this.handleDrop.bind(this))},this),this.listeners[a]=!0;break;case"editablePaste":this.base.elements.forEach(function(a){this.attachDOMEvent(a,"paste",this.handlePaste.bind(this))},this),this.listeners[a]=!0}},focusElement:function(a){a.focus(),this.updateFocus(a,{target:a,type:"focus"})},updateFocus:function(a,c){var d,e,f=this.base.toolbar?this.base.toolbar.getToolbarElement():null,g=this.base.getExtensionByName("anchor-preview"),h=g&&g.getPreviewElement?g.getPreviewElement():null;this.base.elements.some(function(a){return!d&&a.getAttribute("data-medium-focused")&&(d=a),!!d},this),d&&"click"===c.type&&this.lastMousedownTarget&&(b.isDescendant(d,this.lastMousedownTarget,!0)||b.isDescendant(f,this.lastMousedownTarget,!0)||b.isDescendant(h,this.lastMousedownTarget,!0))&&(e=d),e||this.base.elements.some(function(c){return!e&&b.isDescendant(c,a,!0)&&(e=c),!!e},this);var i=!b.isDescendant(d,a,!0)&&!b.isDescendant(f,a,!0)&&!b.isDescendant(h,a,!0);e!==d&&(d&&i&&(d.removeAttribute("data-medium-focused"),this.triggerCustomEvent("blur",c,d)),e&&(e.setAttribute("data-medium-focused",!0),this.triggerCustomEvent("focus",c,e))),i&&this.triggerCustomEvent("externalInteraction",c)},handleBodyClick:function(a){this.updateFocus(a.target,a)},handleBodyFocus:function(a){this.updateFocus(a.target,a)},handleBodyMousedown:function(a){this.lastMousedownTarget=a.target},handleClick:function(a){this.triggerCustomEvent("editableClick",a,a.currentTarget)},handleBlur:function(a){this.triggerCustomEvent("editableBlur",a,a.currentTarget)},handleKeypress:function(a){this.triggerCustomEvent("editableKeypress",a,a.currentTarget)},handleKeyup:function(a){this.triggerCustomEvent("editableKeyup",a,a.currentTarget)},handleMouseover:function(a){this.triggerCustomEvent("editableMouseover",a,a.currentTarget)},handleDragging:function(a){this.triggerCustomEvent("editableDrag",a,a.currentTarget)},handleDrop:function(a){this.triggerCustomEvent("editableDrop",a,a.currentTarget)},handlePaste:function(a){this.triggerCustomEvent("editablePaste",a,a.currentTarget)},handleKeydown:function(a){switch(this.triggerCustomEvent("editableKeydown",a,a.currentTarget),a.which){case b.keyCode.ENTER:this.triggerCustomEvent("editableKeydownEnter",a,a.currentTarget);break;case b.keyCode.TAB:this.triggerCustomEvent("editableKeydownTab",a,a.currentTarget);break;case b.keyCode.DELETE:case b.keyCode.BACKSPACE:this.triggerCustomEvent("editableKeydownDelete",a,a.currentTarget)}}}}();var h;!function(){h=function(a,b){this.options=a,this.name=a.name,this.init(b)},h.prototype={init:function(a){this.base=a,this.button=this.createButton(),this.base.on(this.button,"click",this.handleClick.bind(this)),this.options.key&&this.base.subscribe("editableKeydown",this.handleKeydown.bind(this))},getButton:function(){return this.button},getAction:function(){return"function"==typeof this.options.action?this.options.action(this.base.options):this.options.action},getAria:function(){return"function"==typeof this.options.aria?this.options.aria(this.base.options):this.options.aria},getTagNames:function(){return"function"==typeof this.options.tagNames?this.options.tagNames(this.base.options):this.options.tagNames},createButton:function(){var a=this.base.options.ownerDocument.createElement("button"),b=this.options.contentDefault,c=this.getAria();return a.classList.add("medium-editor-action"),a.classList.add("medium-editor-action-"+this.name),a.setAttribute("data-action",this.getAction()),c&&(a.setAttribute("title",c),a.setAttribute("aria-label",c)),this.base.options.buttonLabels&&("fontawesome"===this.base.options.buttonLabels&&this.options.contentFA?b=this.options.contentFA:"object"==typeof this.base.options.buttonLabels&&this.base.options.buttonLabels[this.name]&&(b=this.base.options.buttonLabels[this.options.name])),a.innerHTML=b,a},handleKeydown:function(a){var c,d=String.fromCharCode(a.which||a.keyCode).toLowerCase();this.options.key===d&&b.isMetaCtrlKey(a)&&(a.preventDefault(),a.stopPropagation(),c=this.getAction(),c&&this.base.execAction(c))},handleClick:function(a){a.preventDefault(),a.stopPropagation();var b=this.getAction();b&&this.base.execAction(b)},isActive:function(){return this.button.classList.contains(this.base.options.activeButtonClass)},setInactive:function(){this.button.classList.remove(this.base.options.activeButtonClass),delete this.knownState},setActive:function(){this.button.classList.add(this.base.options.activeButtonClass),delete this.knownState},queryCommandState:function(){var a=null;return this.options.useQueryState&&(a=this.base.queryCommandState(this.getAction())),a},isAlreadyApplied:function(a){var b,c,d=!1,e=this.getTagNames();return this.knownState===!1||this.knownState===!0?this.knownState:(e&&e.length>0&&a.tagName&&(d=-1!==e.indexOf(a.tagName.toLowerCase())),!d&&this.options.style&&(b=this.options.style.value.split("|"),c=this.base.options.contentWindow.getComputedStyle(a,null).getPropertyValue(this.options.style.prop),b.forEach(function(a){this.knownState||(d=-1!==c.indexOf(a),(d||"text-decoration"!==this.options.style.prop)&&(this.knownState=d))},this)),d)}}}();var i;!function(){function a(){return[[new RegExp(/<[^>]*docs-internal-guid[^>]*>/gi),""],[new RegExp(/<\/b>(
]*>)?$/gi),""],[new RegExp(/\s+<\/span>/g)," "],[new RegExp(/
/g),"
"],[new RegExp(/]*(font-style:italic;font-weight:bold|font-weight:bold;font-style:italic)[^>]*>/gi),''],[new RegExp(/]*font-style:italic[^>]*>/gi),''],[new RegExp(/]*font-weight:bold[^>]*>/gi),''],[new RegExp(/<(\/?)(i|b|a)>/gi),"<$1$2>"],[new RegExp(/<a(?:(?!href).)+href=(?:"|”|“|"|“|”)(((?!"|”|“|"|“|”).)*)(?:"|”|“|"|“|”)(?:(?!>).)*>/gi),''],[new RegExp(/<\/p>\n+/gi),"
"],[new RegExp(/\n+/gi),""]]}i=e.extend({forcePlainText:!0,cleanPastedHTML:!1,cleanReplacements:[],cleanAttrs:["class","style","dir"],cleanTags:["meta"],window:window,document:document,targetBlank:!1,disableReturn:!1,parent:!0,init:function(){(this.forcePlainText||this.cleanPastedHTML)&&this.base.subscribe("editablePaste",this.handlePaste.bind(this))},handlePaste:function(a,c){var d,e,f,g,h="",i="text/html",j="text/plain";if(this.window.clipboardData&&void 0===a.clipboardData&&(a.clipboardData=this.window.clipboardData,i="Text",j="Text"),a.clipboardData&&a.clipboardData.getData&&!a.defaultPrevented){if(a.preventDefault(),f=a.clipboardData.getData(i),g=a.clipboardData.getData(j),f||(f=g),this.cleanPastedHTML&&f)return this.cleanPaste(f);if(this.disableReturn||c.getAttribute("data-disable-return"))h=b.htmlEntities(g);else if(d=g.split(/[\r\n]+/g),d.length>1)for(e=0;e"+b.htmlEntities(d[e])+"
");else h=b.htmlEntities(d[0]);b.insertHTMLCommand(this.document,h)}},cleanPaste:function(c){var d,e,g,h=f.getSelectionElement(this.window),i=/
"),this.pasteHTML("
"+e.join("
")+"
");try{this.document.execCommand("insertText",!1,"\n")}catch(k){}for(e=h.querySelectorAll("a,p,div,br"),d=0;d"+d.innerHTML+"":e.innerHTML=d.innerHTML,d.parentNode.replaceChild(e,d);for(f=a.querySelectorAll("span"),c=0;c#",contentFA:'',key:"k"},this.name="anchor",this.hasForm=!0}a.prototype={formSaveLabel:"✓",formCloseLabel:"×",handleClick:function(a){a.preventDefault(),a.stopPropagation();var c=f.getSelectedParentElement(b.getSelectionRange(this.base.options.ownerDocument));return c.tagName&&"a"===c.tagName.toLowerCase()?this.base.execAction("unlink"):(this.isDisplayed()||this.showForm(),!1)},handleKeydown:function(a){var c=String.fromCharCode(a.which||a.keyCode).toLowerCase();this.options.key===c&&b.isMetaCtrlKey(a)&&(a.preventDefault(),a.stopPropagation(),this.handleClick(a))},getForm:function(){return this.form||(this.form=this.createForm()),this.form},getTemplate:function(){var a=[''];return a.push('',"fontawesome"===this.base.options.buttonLabels?'':this.formSaveLabel,""),a.push('',"fontawesome"===this.base.options.buttonLabels?'':this.formCloseLabel,""),this.base.options.anchorTarget&&a.push('',""),this.base.options.anchorButton&&a.push('',""),a.join("")},isDisplayed:function(){return"block"===this.getForm().style.display},hideForm:function(){this.getForm().style.display="none",
this.getInput().value=""},showForm:function(a){var b=this.getInput();this.base.saveSelection(),this.base.hideToolbarDefaultActions(),this.getForm().style.display="block",this.base.setToolbarPosition(),b.value=a||"",b.focus()},deactivate:function(){return this.form?(this.form.parentNode&&this.form.parentNode.removeChild(this.form),void delete this.form):!1},getFormOpts:function(){var a=this.getForm().querySelector(".medium-editor-toolbar-anchor-target"),b=this.getForm().querySelector(".medium-editor-toolbar-anchor-button"),c={url:this.getInput().value};return this.base.options.checkLinkFormat&&(c.url=this.checkLinkFormat(c.url)),a&&a.checked?c.target="_blank":c.target="_self",b&&b.checked&&(c.buttonClass=this.base.options.anchorButtonClass),c},doFormSave:function(){var a=this.getFormOpts();this.completeFormSave(a)},completeFormSave:function(a){this.base.restoreSelection(),this.base.createLink(a),this.base.checkSelection()},checkLinkFormat:function(a){var b=/^(https?|ftps?|rtmpt?):\/\/|mailto:/;return(b.test(a)?"":"http://")+a},doFormCancel:function(){this.base.restoreSelection(),this.base.checkSelection()},attachFormEvents:function(a){var b=a.querySelector(".medium-editor-toolbar-close"),c=a.querySelector(".medium-editor-toolbar-save"),d=a.querySelector(".medium-editor-toolbar-input");this.base.on(a,"click",this.handleFormClick.bind(this)),this.base.on(d,"keyup",this.handleTextboxKeyup.bind(this)),this.base.on(b,"click",this.handleCloseClick.bind(this)),this.base.on(c,"click",this.handleSaveClick.bind(this),!0)},createForm:function(){var a=this.base.options.ownerDocument,b=a.createElement("div");return b.className="medium-editor-toolbar-form",b.id="medium-editor-toolbar-form-anchor-"+this.base.id,b.innerHTML=this.getTemplate(),this.attachFormEvents(b),b},getInput:function(){return this.getForm().querySelector("input.medium-editor-toolbar-input")},handleTextboxKeyup:function(a){return a.keyCode===b.keyCode.ENTER?(a.preventDefault(),void this.doFormSave()):void(a.keyCode===b.keyCode.ESCAPE&&(a.preventDefault(),this.doFormCancel()))},handleFormClick:function(a){a.stopPropagation()},handleSaveClick:function(a){a.preventDefault(),this.doFormSave()},handleCloseClick:function(a){a.preventDefault(),this.doFormCancel()}},j=b.derives(h,a)}();var k;!function(){k=function(){this.parent=!0,this.name="anchor-preview"},k.prototype={previewValueSelector:"a",init:function(a){this.base=a,this.anchorPreview=this.createPreview(),this.base.options.elementsContainer.appendChild(this.anchorPreview),this.attachToEditables()},getPreviewElement:function(){return this.anchorPreview},createPreview:function(){var a=this.base.options.ownerDocument.createElement("div");return a.id="medium-editor-anchor-preview-"+this.base.id,a.className="medium-editor-anchor-preview",a.innerHTML=this.getTemplate(),this.base.on(a,"click",this.handleClick.bind(this)),a},getTemplate:function(){return''},deactivate:function(){this.anchorPreview&&(this.anchorPreview.parentNode&&this.anchorPreview.parentNode.removeChild(this.anchorPreview),delete this.anchorPreview)},hidePreview:function(){this.anchorPreview.classList.remove("medium-editor-anchor-preview-active"),this.activeAnchor=null},showPreview:function(a){return this.anchorPreview.classList.contains("medium-editor-anchor-preview-active")||a.getAttribute("data-disable-preview")?!0:(this.previewValueSelector&&(this.anchorPreview.querySelector(this.previewValueSelector).textContent=a.attributes.href.value,this.anchorPreview.querySelector(this.previewValueSelector).href=a.attributes.href.value),this.anchorPreview.classList.add("medium-toolbar-arrow-over"),this.anchorPreview.classList.remove("medium-toolbar-arrow-under"),this.anchorPreview.classList.contains("medium-editor-anchor-preview-active")||this.anchorPreview.classList.add("medium-editor-anchor-preview-active"),this.activeAnchor=a,this.positionPreview(),this.attachPreviewHandlers(),this)},positionPreview:function(){var a,b,c=this.anchorPreview.offsetHeight,d=this.activeAnchor.getBoundingClientRect(),e=(d.left+d.right)/2;a=this.anchorPreview.offsetWidth/2,b=this.base.options.diffLeft-a,this.anchorPreview.style.top=Math.round(c+d.bottom-this.base.options.diffTop+this.base.options.contentWindow.pageYOffset-this.anchorPreview.offsetHeight)+"px",a>e?this.anchorPreview.style.left=b+a+"px":this.base.options.contentWindow.innerWidth-ethis.base.options.anchorPreviewHideDelay&&this.detachPreviewHandlers()},detachPreviewHandlers:function(){clearInterval(this.intervalTimer),this.instanceHandlePreviewMouseover&&(this.base.off(this.anchorPreview,"mouseover",this.instanceHandlePreviewMouseover),this.base.off(this.anchorPreview,"mouseout",this.instanceHandlePreviewMouseout),this.activeAnchor&&(this.base.off(this.activeAnchor,"mouseover",this.instanceHandlePreviewMouseover),this.base.off(this.activeAnchor,"mouseout",this.instanceHandlePreviewMouseout))),this.hidePreview(),this.hovering=this.instanceHandlePreviewMouseover=this.instanceHandlePreviewMouseout=null},attachPreviewHandlers:function(){this.lastOver=(new Date).getTime(),this.hovering=!0,this.instanceHandlePreviewMouseover=this.handlePreviewMouseover.bind(this),this.instanceHandlePreviewMouseout=this.handlePreviewMouseout.bind(this),this.intervalTimer=setInterval(this.updatePreview.bind(this),200),this.base.on(this.anchorPreview,"mouseover",this.instanceHandlePreviewMouseover),this.base.on(this.anchorPreview,"mouseout",this.instanceHandlePreviewMouseout),this.base.on(this.activeAnchor,"mouseover",this.instanceHandlePreviewMouseover),this.base.on(this.activeAnchor,"mouseout",this.instanceHandlePreviewMouseout)}}}();var l;!function(){function a(){this.parent=!0,this.options={name:"fontsize",action:"fontSize",aria:"increase/decrease font size",contentDefault:"±",contentFA:''},this.name="fontsize",this.hasForm=!0}a.prototype={handleClick:function(a){if(a.preventDefault(),a.stopPropagation(),!this.isDisplayed()){var b=this.base.options.ownerDocument.queryCommandValue("fontSize")+"";this.showForm(b)}return!1},getForm:function(){return this.form||(this.form=this.createForm()),this.form},isDisplayed:function(){return"block"===this.getForm().style.display},hideForm:function(){this.getForm().style.display="none",this.getInput().value=""},showForm:function(a){var b=this.getInput();this.base.saveSelection(),this.base.hideToolbarDefaultActions(),this.getForm().style.display="block",this.base.setToolbarPosition(),b.value=a||"",b.focus()},deactivate:function(){return this.form?(this.form.parentNode&&this.form.parentNode.removeChild(this.form),void delete this.form):!1},doFormSave:function(){this.base.restoreSelection(),this.base.checkSelection()},doFormCancel:function(){this.base.restoreSelection(),this.clearFontSize(),this.base.checkSelection()},createForm:function(){var a=this.base.options.ownerDocument,b=a.createElement("div"),c=a.createElement("input"),d=a.createElement("a"),e=a.createElement("a");return b.className="medium-editor-toolbar-form",b.id="medium-editor-toolbar-form-fontsize-"+this.base.id,this.base.on(b,"click",this.handleFormClick.bind(this)),c.setAttribute("type","range"),c.setAttribute("min","1"),c.setAttribute("max","7"),c.className="medium-editor-toolbar-input",b.appendChild(c),this.base.on(c,"change",this.handleSliderChange.bind(this)),e.setAttribute("href","#"),e.className="medium-editor-toobar-save",e.innerHTML="fontawesome"===this.base.options.buttonLabels?'':"✓",b.appendChild(e),this.base.on(e,"click",this.handleSaveClick.bind(this),!0),d.setAttribute("href","#"),d.className="medium-editor-toobar-close",d.innerHTML="fontawesome"===this.base.options.buttonLabels?'':"×",b.appendChild(d),this.base.on(d,"click",this.handleCloseClick.bind(this)),b},getInput:function(){return this.getForm().querySelector("input.medium-editor-toolbar-input")},clearFontSize:function(){f.getSelectedElements(this.base.options.ownerDocument).forEach(function(a){"FONT"===a.tagName&&a.hasAttribute("size")&&a.removeAttribute("size")})},handleSliderChange:function(){var a=this.getInput().value;"4"===a?this.clearFontSize():this.base.execAction("fontSize",{size:a})},handleFormClick:function(a){a.stopPropagation()},handleSaveClick:function(a){a.preventDefault(),this.doFormSave()},handleCloseClick:function(a){a.preventDefault(),this.doFormCancel()}},l=b.derives(h,a)}();var m;!function(){m=function(a){this.base=a,this.options=a.options,this.initThrottledMethods()},m.prototype={createToolbar:function(){var a=this.base.options.ownerDocument.createElement("div");return a.id="medium-editor-toolbar-"+this.base.id,a.className="medium-editor-toolbar",this.options.staticToolbar?a.className+=" static-toolbar":a.className+=" stalker-toolbar",a.appendChild(this.createToolbarButtons()),this.base.commands.forEach(function(b){b.hasForm&&a.appendChild(b.getForm())}),this.attachEventHandlers(),a},createToolbarButtons:function(){var a,c,d,e,f=this.base.options.ownerDocument.createElement("ul");return f.id="medium-editor-toolbar-actions"+this.base.id,f.className="medium-editor-toolbar-actions clearfix",f.style.display="block",this.base.options.buttons.forEach(function(d){e=this.base.getExtensionByName(d),"function"==typeof e.getButton&&(c=e.getButton(this.base),a=this.base.options.ownerDocument.createElement("li"),b.isElement(c)?a.appendChild(c):a.innerHTML=c,f.appendChild(a))}.bind(this)),d=f.querySelectorAll("button"),d.length>0&&(d[0].classList.add(this.options.firstButtonClass),d[d.length-1].classList.add(this.options.lastButtonClass)),f},deactivate:function(){this.toolbar&&(this.toolbar.parentNode&&this.toolbar.parentNode.removeChild(this.toolbar),delete this.toolbar)},getToolbarElement:function(){return this.toolbar||(this.toolbar=this.createToolbar()),this.toolbar},getToolbarActionsElement:function(){return this.getToolbarElement().querySelector(".medium-editor-toolbar-actions")},initThrottledMethods:function(){this.throttledPositionToolbar=b.throttle(function(){this.base.isActive&&this.positionToolbarIfShown()}.bind(this))},attachEventHandlers:function(){this.base.subscribe("blur",this.handleBlur.bind(this)),this.base.subscribe("focus",this.handleFocus.bind(this)),this.base.subscribe("editableClick",this.handleEditableClick.bind(this)),this.base.subscribe("editableKeyup",this.handleEditableKeyup.bind(this)),this.base.on(this.options.ownerDocument.documentElement,"mouseup",this.handleDocumentMouseup.bind(this)),this.options.staticToolbar&&this.options.stickyToolbar&&this.base.on(this.options.contentWindow,"scroll",this.handleWindowScroll.bind(this),!0),this.base.on(this.options.contentWindow,"resize",this.handleWindowResize.bind(this))},handleWindowScroll:function(){this.positionToolbarIfShown()},handleWindowResize:function(){this.throttledPositionToolbar()},handleDocumentMouseup:function(a){return a&&a.target&&b.isDescendant(this.getToolbarElement(),a.target)?!1:void this.checkState()},handleEditableClick:function(){setTimeout(function(){this.checkState()}.bind(this),0)},handleEditableKeyup:function(){this.checkState()},handleBlur:function(){clearTimeout(this.hideTimeout),clearTimeout(this.delayShowTimeout),this.hideTimeout=setTimeout(function(){this.hideToolbar()}.bind(this),1)},handleFocus:function(){this.checkState()},isDisplayed:function(){return this.getToolbarElement().classList.contains("medium-editor-toolbar-active")},showToolbar:function(){clearTimeout(this.hideTimeout),this.isDisplayed()||(this.getToolbarElement().classList.add("medium-editor-toolbar-active"),"function"==typeof this.options.onShowToolbar&&this.options.onShowToolbar())},hideToolbar:function(){this.isDisplayed()&&(this.base.commands.forEach(function(a){"function"==typeof a.onHide&&a.onHide()}),this.getToolbarElement().classList.remove("medium-editor-toolbar-active"),"function"==typeof this.options.onHideToolbar&&this.options.onHideToolbar())},isToolbarDefaultActionsDisplayed:function(){return"block"===this.getToolbarActionsElement().style.display},hideToolbarDefaultActions:function(){this.isToolbarDefaultActionsDisplayed()&&(this.getToolbarActionsElement().style.display="none")},showToolbarDefaultActions:function(){this.hideExtensionForms(),this.isToolbarDefaultActionsDisplayed()||(this.getToolbarActionsElement().style.display="block"),this.delayShowTimeout=this.base.delay(function(){this.showToolbar()}.bind(this))},hideExtensionForms:function(){this.base.commands.forEach(function(a){a.hasForm&&a.isDisplayed()&&a.hideForm()})},multipleBlockElementsSelected:function(){var a=f.getSelectionHtml.call(this).replace(/<[\S]+><\/[\S]+>/gim,""),b=a.match(/<(p|h[1-6]|blockquote)[^>]*>/g);return!!b&&b.length>1},modifySelection:function(){var a=this.options.contentWindow.getSelection(),c=a.getRangeAt(0);if(this.options.standardizeSelectionStart&&c.startContainer.nodeValue&&c.startOffset===c.startContainer.nodeValue.length){var d=b.findAdjacentTextNodeWithContent(f.getSelectionElement(this.options.contentWindow),c.startContainer,this.options.ownerDocument);if(d){for(var e=0;0===d.nodeValue.substr(e,1).trim().length;)e+=1;var g=this.options.ownerDocument.createRange();g.setStart(d,e),g.setEnd(c.endContainer,c.endOffset),a.removeAllRanges(),a.addRange(g),c=g}}},checkState:function(){if(!this.base.preventSelectionUpdates){if(!this.getFocusedElement()||f.selectionInContentEditableFalse(this.options.contentWindow))return void this.hideToolbar();var a=f.getSelectionElement(this.options.contentWindow);if(!a||-1===this.base.elements.indexOf(a)||a.getAttribute("data-disable-toolbar"))return void this.hideToolbar();if(this.options.updateOnEmptySelection&&this.options.staticToolbar)return void this.showAndUpdateToolbar();""===this.options.contentWindow.getSelection().toString().trim()||this.options.allowMultiParagraphSelection===!1&&this.multipleBlockElementsSelected()?this.hideToolbar():this.showAndUpdateToolbar()}},getFocusedElement:function(){for(var a=0;ag+a.offsetHeight-i?(e.style.top=g+a.offsetHeight-i+"px",e.classList.remove("sticky-toolbar")):c>g-i?(e.classList.add("sticky-toolbar"),e.style.top="0px"):(e.classList.remove("sticky-toolbar"),e.style.top=g-i+"px"):e.style.top=g-i+"px","left"===this.options.toolbarAlign?b=f.left:"center"===this.options.toolbarAlign?b=h-k:"right"===this.options.toolbarAlign&&(b=f.right-j),0>b?b=0:b+j>d&&(b=d-Math.ceil(j)-1),e.style.left=b+"px"},positionToolbar:function(a){this.getToolbarElement().style.left="0";var b=this.options.contentWindow.innerWidth,c=a.getRangeAt(0),d=c.getBoundingClientRect(),e=(d.left+d.right)/2,f=this.getToolbarElement(),g=f.offsetHeight,h=f.offsetWidth,i=h/2,j=50,k=this.options.diffLeft-i;d.tope?f.style.left=k+i+"px":i>b-e?f.style.left=b+k-i+"px":f.style.left=k+e+"px"}}}();var n;!function(){n=function(a){this.base=a,this.initPlaceholders(),this.attachEventHandlers()},n.prototype={initPlaceholders:function(){this.base.elements.forEach(function(a){this.updatePlaceholder(a)},this)},showPlaceholder:function(a){a&&a.classList.add("medium-editor-placeholder")},hidePlaceholder:function(a){a&&a.classList.remove("medium-editor-placeholder")},updatePlaceholder:function(a){a.querySelector("img")||a.querySelector("blockquote")||""!==a.textContent.replace(/^\s+|\s+$/g,"")?this.hidePlaceholder(a):this.showPlaceholder(a)},attachEventHandlers:function(){this.base.subscribe("blur",this.handleExternalInteraction.bind(this)),this.base.subscribe("editableBlur",this.handleBlur.bind(this)),this.base.subscribe("editableClick",this.handleHidePlaceholderEvent.bind(this)),this.base.subscribe("editableKeypress",this.handleHidePlaceholderEvent.bind(this)),this.base.subscribe("editablePaste",this.handleHidePlaceholderEvent.bind(this))},handleHidePlaceholderEvent:function(a,b){this.hidePlaceholder(b)},handleBlur:function(a,b){this.updatePlaceholder(b)},handleExternalInteraction:function(){this.initPlaceholders()}}}();var o;return function(){o={paste:i}}(),function(){function i(a,c){if(this.options.disableReturn||c.getAttribute("data-disable-return"))a.preventDefault();else if(this.options.disableDoubleReturn||c.getAttribute("data-disable-double-return")){var d=b.getSelectionStart(this.options.ownerDocument);d&&""===d.textContent.trim()&&a.preventDefault()}}function p(a){var c=b.getSelectionStart(this.options.ownerDocument),d=c&&c.tagName.toLowerCase();"pre"===d&&(a.preventDefault(),b.insertHTMLCommand(this.options.ownerDocument," ")),b.isListItem(c)&&(a.preventDefault(),a.shiftKey?this.options.ownerDocument.execCommand("outdent",!1,null):this.options.ownerDocument.execCommand("indent",!1,null))}function q(a){var c,d,e,g=b.getSelectionStart(this.options.ownerDocument),h=g.tagName.toLowerCase(),i=/^(\s+|
)?$/i,j=/h\d/i;(a.which===b.keyCode.BACKSPACE||a.which===b.keyCode.ENTER)&&g.previousElementSibling&&j.test(h)&&0===f.getCaretOffsets(g).left?a.which===b.keyCode.BACKSPACE&&i.test(g.previousElementSibling.innerHTML)?(g.previousElementSibling.parentNode.removeChild(g.previousElementSibling),a.preventDefault()):a.which===b.keyCode.ENTER&&(e=this.options.ownerDocument.createElement("p"),e.innerHTML="
",g.previousElementSibling.parentNode.insertBefore(e,g),a.preventDefault()):a.which===b.keyCode.DELETE&&g.nextElementSibling&&g.previousElementSibling&&!j.test(h)&&i.test(g.innerHTML)&&j.test(g.nextElementSibling.tagName)?(c=this.options.ownerDocument.createRange(),d=this.options.ownerDocument.getSelection(),c.setStart(g.nextElementSibling,0),c.collapse(!0),d.removeAllRanges(),d.addRange(c),g.previousElementSibling.parentNode.removeChild(g),a.preventDefault()):a.which!==b.keyCode.BACKSPACE||"li"!==h||!i.test(g.innerHTML)||g.previousElementSibling||g.parentElement.previousElementSibling||"li"!==g.nextElementSibling.tagName.toLowerCase()||(e=this.options.ownerDocument.createElement("p"),e.innerHTML="
",g.parentElement.parentElement.insertBefore(e,g.parentElement),c=this.options.ownerDocument.createRange(),d=this.options.ownerDocument.getSelection(),c.setStart(e,0),c.collapse(!0),d.removeAllRanges(),d.addRange(c),g.parentElement.removeChild(g),a.preventDefault())}function r(a){var b="medium-editor-dragover";a.preventDefault(),a.dataTransfer.dropEffect="copy","dragover"===a.type?a.target.classList.add(b):"dragleave"===a.type&&a.target.classList.remove(b)}function s(a){var c,d="medium-editor-dragover";a.preventDefault(),a.stopPropagation(),a.dataTransfer.files&&(c=Array.prototype.slice.call(a.dataTransfer.files,0),c.some(function(a){if(a.type.match("image")){var c,d;c=new FileReader,c.readAsDataURL(a),d="medium-img-"+ +new Date,b.insertHTMLCommand(this.options.ownerDocument,''),c.onload=function(){var a=this.options.ownerDocument.getElementById(d);a&&(a.removeAttribute("id"),a.removeAttribute("class"),a.src=c.result)}.bind(this)}}.bind(this))),a.target.classList.remove(d)}function t(a){var c,d=b.getSelectionStart(this.options.ownerDocument);d&&(d.getAttribute("data-medium-element")&&0===d.children.length&&this.options.ownerDocument.execCommand("formatBlock",!1,"p"),a.which!==b.keyCode.ENTER||b.isListItem(d)||(c=d.tagName.toLowerCase(),"a"===c?this.options.ownerDocument.execCommand("unlink",!1,null):a.shiftKey||/h\d/.test(c)||this.options.ownerDocument.execCommand("formatBlock",!1,"p")))}function u(a){a||(a=[]),"string"==typeof a&&(a=this.options.ownerDocument.querySelectorAll(a)),b.isElement(a)&&(a=[a]);var c=Array.prototype.slice.apply(a);this.elements=[],c.forEach(function(a){this.elements.push("textarea"===a.tagName.toLowerCase()?x.call(this,a):a)},this)}function v(a,b,c){return a.parent&&(a.base=c),"function"==typeof a.init&&a.init(c),a.name||(a.name=b),a}function w(){var a,b=!1;if(this.options.disableAnchorPreview)return!1;if(this.options.extensions["anchor-preview"])return!1;if(this.options.disableToolbar)return!1;for(a=0;a0&&(a=f.getRangeAt(0),c=a.cloneRange(),this.elements.some(function(c,d){return c===a.startContainer||b.isDescendant(c,a.startContainer)?(g=d,!0):!1}),g>-1&&(c.selectNodeContents(this.elements[g]),c.setEnd(a.startContainer,a.startOffset),d=c.toString().length,e={start:d,end:d+a.toString().length,editableElementIndex:g})),null!==e&&0===e.editableElementIndex&&delete e.editableElementIndex,e},saveSelection:function(){this.selectionState=this.exportSelection()},importSelection:function(a){if(a){var b,c,d,e,f=void 0===a.editableElementIndex?0:a.editableElementIndex,g={
editableElementIndex:f,start:a.start,end:a.end},h=this.elements[g.editableElementIndex],i=0,j=this.options.ownerDocument.createRange(),k=[h],l=!1,m=!1;for(j.setStart(h,0),j.collapse(!0),b=k.pop();!m&&b;){if(3===b.nodeType)e=i+b.length,!l&&g.start>=i&&g.start<=e&&(j.setStart(b,g.start-i),l=!0),l&&g.end>=i&&g.end<=e&&(j.setEnd(b,g.end-i),m=!0),i=e;else for(c=b.childNodes.length-1;c>=0;)k.push(b.childNodes[c]),c-=1;m||(b=k.pop())}d=this.options.contentWindow.getSelection(),d.removeAllRanges(),d.addRange(j)}},restoreSelection:function(){this.importSelection(this.selectionState)},createLink:function(a){var c,d;if(a.url&&a.url.trim().length>0&&(this.options.ownerDocument.execCommand("createLink",!1,a.url),(this.options.targetBlank||"_blank"===a.target)&&b.setTargetBlank(b.getSelectionStart(this.options.ownerDocument)),a.buttonClass&&b.addClassToAnchors(b.getSelectionStart(this.options.ownerDocument),a.buttonClass)),this.options.targetBlank||"_blank"===a.target||a.buttonClass)for(c=this.options.ownerDocument.createEvent("HTMLEvents"),c.initEvent("input",!0,!0,this.options.contentWindow),d=0;d