Socket
Socket
Sign inDemoInstall

medium-editor

Package Overview
Dependencies
Maintainers
3
Versions
125
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

medium-editor - npm Package Compare versions

Comparing version 4.3.0 to 4.4.0

2

bower.json
{
"name": "medium-editor",
"version": "4.3.0",
"version": "4.4.0",
"homepage": "http://daviferreira.github.io/medium-editor/",

@@ -5,0 +5,0 @@ "authors": [

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

4.4.0 / 2015-04-11
==================
* Expose smart 'blur' and 'focus' events which account for toolbar interaction
* Expose selectElement method for selecting text and updating toolbar
* Fix always wrapping pasted text in a <p> tag
4.3.0 / 2015-04-10
==================
* Add override options for pasteHTML and cleanPaste

@@ -3,0 +11,0 @@ * Support overriding of scss theme variables

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

"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(++c<d);e&&this._updateClassName()},k.remove=function(){var a,b,c=arguments,d=0,e=c.length,f=!1;do for(a=c[d]+"",b=i(this,a);-1!==b;)this.splice(b,1),f=!0,b=i(this,a);while(++d<e);f&&this._updateClassName()},k.toggle=function(a,b){a+="";var c=this.contains(a),d=c?b!==!0&&"remove":b!==!1&&"add";return d&&this[d](a),b===!0||b===!1?b:!c},k.toString=function(){return this.join(" ")},e.defineProperty){var m={get:l,enumerable:!0,configurable:!0};try{e.defineProperty(d,b,m)}catch(n){-2146823252===n.number&&(m.enumerable=!1,e.defineProperty(d,b,m))}}else e[c].__defineGetter__&&d.__defineGetter__(b,l)}}(self),function(a){"use strict";if(a.URL=a.URL||a.webkitURL,a.Blob&&a.URL)try{return void new Blob}catch(b){}var c=a.BlobBuilder||a.WebKitBlobBuilder||a.MozBlobBuilder||function(a){var b=function(a){return Object.prototype.toString.call(a).match(/^\[object\s(.*)\]$/)[1]},c=function(){this.data=[]},d=function(a,b,c){this.data=a,this.size=a.length,this.type=b,this.encoding=c},e=c.prototype,f=d.prototype,g=a.FileReaderSync,h=function(a){this.code=this[this.name=a]},i="NOT_FOUND_ERR SECURITY_ERR ABORT_ERR NOT_READABLE_ERR ENCODING_ERR NO_MODIFICATION_ALLOWED_ERR INVALID_STATE_ERR SYNTAX_ERR".split(" "),j=i.length,k=a.URL||a.webkitURL||a,l=k.createObjectURL,m=k.revokeObjectURL,n=k,o=a.btoa,p=a.atob,q=a.ArrayBuffer,r=a.Uint8Array,s=/^[\w-]+:\/*\[?[\w\.:-]+\]?(?::[0-9]+)?/;for(d.fake=f.fake=!0;j--;)h.prototype[i[j]]=j+1;return k.createObjectURL||(n=a.URL=function(a){var b,c=document.createElementNS("http://www.w3.org/1999/xhtml","a");return c.href=a,"origin"in c||("data:"===c.protocol.toLowerCase()?c.origin=null:(b=a.match(s),c.origin=b&&b[1])),c}),n.createObjectURL=function(a){var b,c=a.type;return null===c&&(c="application/octet-stream"),a instanceof d?(b="data:"+c,"base64"===a.encoding?b+";base64,"+a.data:"URI"===a.encoding?b+","+decodeURIComponent(a.data):o?b+";base64,"+o(a.data):b+","+encodeURIComponent(a.data)):l?l.call(k,a):void 0},n.revokeObjectURL=function(a){"data:"!==a.substring(0,5)&&m&&m.call(k,a)},e.append=function(a){var c=this.data;if(r&&(a instanceof q||a instanceof r)){for(var e="",f=new r(a),i=0,j=f.length;j>i;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<b.length;e++){var f=b[e];if(!(f in d)){if(!c)return;d[f]={}}d=d[f]}return d}catch(g){}}function d(a,b){var c,d=Array.prototype.slice.call(arguments,2);b=b||{};for(var e=0;e<d.length;e++){var f=d[e];if(f)for(c in f)f.hasOwnProperty(c)&&"undefined"!=typeof f[c]&&(a||b.hasOwnProperty(c)===!1)&&(b[c]=f[c])}return b}b={isIE:"Microsoft Internet Explorer"===navigator.appName||"Netscape"===navigator.appName&&null!==new RegExp("Trident/.*rv:([0-9]{1,}[.0-9]{0,})").exec(navigator.userAgent),keyCode:{BACKSPACE:8,TAB:9,ENTER:13,ESCAPE:27,SPACE:32,DELETE:46},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){if(!a||!b)return!1;for(var c=b.parentNode;null!==c;){if(c===a)return!0;c=c.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){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,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")},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;b<a.length;b+=1)a[b].target="_blank"},addClassToAnchors:function(a,b){var c,d,e=b.split(" ");if("a"===a.tagName.toLowerCase())for(d=0;d<e.length;d+=1)a.classList.add(e[d]);else for(a=a.getElementsByTagName("a"),c=0;c<a.length;c+=1)for(d=0;d<e.length;d+=1)a[c].classList.add(e[d])},isListItem:function(a){if(!a)return!1;if("li"===a.tagName.toLowerCase())return!0;for(var b=a.parentNode,c=b.tagName.toLowerCase();-1===this.parentElements.indexOf(c)&&"div"!==c;){if("li"===c)return!0;if(b=b.parentNode,!b||!b.tagName)return!1;c=b.tagName.toLowerCase()}return!1},cleanListDOM:function(a){if("li"===a.tagName.toLowerCase()){var b=a.parentElement;"p"===b.parentElement.tagName.toLowerCase()&&this.unwrapElement(b.parentElement)}},unwrapElement:function(a){var b,c=a.parentNode,d=a.firstChild;do b=d.nextSibling,c.insertBefore(d,a),d=b;while(d);c.removeChild(a)},warn:function(){void 0!==a.console&&console.warn.apply(console,arguments)},deprecated:function(a,c,d){var e=a+" is deprecated, please use "+c+" instead.";d&&(e+=" Will be removed in "+d),b.warn(e)},deprecatedMethod:function(a,c,d,e){b.deprecated(a,c,e),"function"==typeof this[c]&&this[c].apply(this,d)},cleanupAttrs:function(a,b){b.forEach(function(b){a.removeAttribute(b)})},cleanupTags:function(a,b){b.forEach(function(b){a.tagName.toLowerCase()===b&&a.parentNode.removeChild(a)})},setObject:function(a,b,d){var e=a.split("."),f=e.pop(),g=c(e,!0,d);return g&&f?g[f]=b:void 0},getObject:function(a,b,d){return c(a?a.split("."):[],b,d)}}}(window);var c;!function(){c={bold:{name:"bold",action:"bold",aria:"bold",tagNames:["b","strong"],style:{prop:"font-weight",value:"700|bold"},useQueryState:!0,contentDefault:"<b>B</b>",contentFA:'<i class="fa fa-bold"></i>',key:"b"},italic:{name:"italic",action:"italic",aria:"italic",tagNames:["i","em"],style:{prop:"font-style",value:"italic"},useQueryState:!0,contentDefault:"<b><i>I</i></b>",contentFA:'<i class="fa fa-italic"></i>',key:"i"},underline:{name:"underline",action:"underline",aria:"underline",tagNames:["u"],style:{prop:"text-decoration",value:"underline"},useQueryState:!0,contentDefault:"<b><u>U</u></b>",contentFA:'<i class="fa fa-underline"></i>',key:"u"},strikethrough:{name:"strikethrough",action:"strikethrough",aria:"strike through",tagNames:["strike"],style:{prop:"text-decoration",value:"line-through"},useQueryState:!0,contentDefault:"<s>A</s>",contentFA:'<i class="fa fa-strikethrough"></i>'},superscript:{name:"superscript",action:"superscript",aria:"superscript",tagNames:["sup"],contentDefault:"<b>x<sup>1</sup></b>",contentFA:'<i class="fa fa-superscript"></i>'},subscript:{name:"subscript",action:"subscript",aria:"subscript",tagNames:["sub"],contentDefault:"<b>x<sub>1</sub></b>",contentFA:'<i class="fa fa-subscript"></i>'},image:{name:"image",action:"image",aria:"image",tagNames:["img"],contentDefault:"<b>image</b>",contentFA:'<i class="fa fa-picture-o"></i>'},quote:{name:"quote",action:"append-blockquote",aria:"blockquote",tagNames:["blockquote"],contentDefault:"<b>&ldquo;</b>",contentFA:'<i class="fa fa-quote-right"></i>'},orderedlist:{name:"orderedlist",action:"insertorderedlist",aria:"ordered list",tagNames:["ol"],useQueryState:!0,contentDefault:"<b>1.</b>",contentFA:'<i class="fa fa-list-ol"></i>'},unorderedlist:{name:"unorderedlist",action:"insertunorderedlist",aria:"unordered list",tagNames:["ul"],useQueryState:!0,contentDefault:"<b>&bull;</b>",contentFA:'<i class="fa fa-list-ul"></i>'},pre:{name:"pre",action:"append-pre",aria:"preformatted text",tagNames:["pre"],contentDefault:"<b>0101</b>",contentFA:'<i class="fa fa-code fa-lg"></i>'},indent:{name:"indent",action:"indent",aria:"indent",tagNames:[],contentDefault:"<b>&rarr;</b>",contentFA:'<i class="fa fa-indent"></i>'},outdent:{name:"outdent",action:"outdent",aria:"outdent",tagNames:[],contentDefault:"<b>&larr;</b>",contentFA:'<i class="fa fa-outdent"></i>'},justifyCenter:{name:"justifyCenter",action:"justifyCenter",aria:"center justify",tagNames:[],style:{prop:"text-align",value:"center"},contentDefault:"<b>C</b>",contentFA:'<i class="fa fa-align-center"></i>'},justifyFull:{name:"justifyFull",action:"justifyFull",aria:"full justify",tagNames:[],style:{prop:"text-align",value:"justify"},contentDefault:"<b>J</b>",contentFA:'<i class="fa fa-align-justify"></i>'},justifyLeft:{name:"justifyLeft",action:"justifyLeft",aria:"left justify",tagNames:[],style:{prop:"text-align",value:"left"},contentDefault:"<b>L</b>",contentFA:'<i class="fa fa-align-left"></i>'},justifyRight:{name:"justifyRight",action:"justifyRight",aria:"right justify",tagNames:[],style:{prop:"text-align",value:"right"},contentDefault:"<b>R</b>",contentFA:'<i class="fa fa-align-right"></i>'},header1:{name:"header1",action:function(a){return"append-"+a.firstHeader},aria:function(a){return a.firstHeader},tagNames:function(a){return[a.firstHeader]},contentDefault:"<b>H1</b>"},header2:{name:"header2",action:function(a){return"append-"+a.secondHeader},aria:function(a){return a.secondHeader},tagNames:function(a){return[a.secondHeader]},contentDefault:"<b>H2</b>"},removeFormat:{name:"removeFormat",aria:"remove formatting",action:"removeFormat",contentDefault:"<b>X</b>",contentFA:'<i class="fa fa-eraser"></i>'}}}();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",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(){}}}();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}}}();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))},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,"click",this.handleInteraction.bind(this),!0),this.attachDOMEvent(this.options.ownerDocument.body,"focus",this.handleInteraction.bind(this),!0),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"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}},handleInteraction:function(a){var c,d=!1,e=this.options.contentWindow.getSelection(),g=this.base.toolbar?this.base.toolbar.getToolbarElement():null,h=this.base.getExtensionByName("anchor-preview"),i=h&&h.getPreviewElement?h.getPreviewElement():null,j=e.isCollapsed?null:f.getSelectedParentElement(e.getRangeAt(0));for(c=0;c<this.base.elements.length;c+=1)if(this.base.elements[c]===a.target||b.isDescendant(this.base.elements[c],a.target)||b.isDescendant(this.base.elements[c],j)){d=!0;break}d||g&&(g===a.target||b.isDescendant(g,a.target))||i&&(i===a.target||b.isDescendant(i,a.target))||this.triggerCustomEvent("externalInteraction",a)},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)},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;return a.classList.add("medium-editor-action"),a.classList.add("medium-editor-action-"+this.name),a.setAttribute("data-action",this.getAction()),a.setAttribute("aria-label",this.getAria()),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 b,c;(a.ctrlKey||a.metaKey)&&(b=String.fromCharCode(a.which||a.keyCode).toLowerCase(),this.options.key===b&&(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>(<br[^>]*>)?$/gi),""],[new RegExp(/<span class="Apple-converted-space">\s+<\/span>/g)," "],[new RegExp(/<br class="Apple-interchange-newline">/g),"<br>"],[new RegExp(/<span[^>]*(font-style:italic;font-weight:bold|font-weight:bold;font-style:italic)[^>]*>/gi),'<span class="replace-with italic bold">'],[new RegExp(/<span[^>]*font-style:italic[^>]*>/gi),'<span class="replace-with italic">'],[new RegExp(/<span[^>]*font-weight:bold[^>]*>/gi),'<span class="replace-with bold">'],[new RegExp(/&lt;(\/?)(i|b|a)&gt;/gi),"<$1$2>"],[new RegExp(/&lt;a\s+href=(&quot;|&rdquo;|&ldquo;|“|”)([^&]+)(&quot;|&rdquo;|&ldquo;|“|”)&gt;/gi),'<a href="$2">'],[new RegExp(/<\/p>\n+/gi),"</p>"],[new RegExp(/\n+<p/gi),"<p"],[new RegExp(/<\/?o:[a-z]*>/gi),""]]}i=function(a,b){this.base=a,this.options=b,(this.options.forcePlainText||this.options.cleanPastedHTML)&&this.base.subscribe("editablePaste",this.handlePaste.bind(this))},i.prototype={handlePaste:function(a,c){var d,e,f="",g="text/html",h="text/plain";if(this.options.contentWindow.clipboardData&&void 0===a.clipboardData&&(a.clipboardData=this.options.contentWindow.clipboardData,g="Text",h="Text"),a.clipboardData&&a.clipboardData.getData&&!a.defaultPrevented){if(a.preventDefault(),this.options.cleanPastedHTML&&a.clipboardData.getData(g))return this.cleanPaste(a.clipboardData.getData(g));if(this.options.disableReturn||c.getAttribute("data-disable-return"))f=b.htmlEntities(a.clipboardData.getData(h)),b.insertHTMLCommand(this.options.ownerDocument,f);else{for(d=a.clipboardData.getData(h).split(/[\r\n]/g),e=0;e<d.length;e+=1)""!==d[e]&&(f+="<p>"+b.htmlEntities(d[e])+"</p>");b.insertHTMLCommand(this.options.ownerDocument,f)}}},cleanPaste:function(c){var d,e,g,h=f.getSelectionElement(this.options.contentWindow),i=/<p|<br|<div/.test(c),j=a().concat(this.options.cleanReplacements||[]);for(d=0;d<j.length;d+=1)c=c.replace(j[d][0],j[d][1]);if(i){e=c.split("<br><br>"),this.pasteHTML("<p>"+e.join("</p><p>")+"</p>");try{this.options.ownerDocument.execCommand("insertText",!1,"\n")}catch(k){}for(e=h.querySelectorAll("a,p,div,br"),d=0;d<e.length;d+=1)switch(g=e[d],g.innerHTML=g.innerHTML.replace(/\n/gi," "),g.tagName.toLowerCase()){case"a":this.options.targetBlank&&b.setTargetBlank(g);break;case"p":case"div":this.filterCommonBlocks(g);break;case"br":this.filterLineBreak(g)}}else this.pasteHTML(c)},pasteHTML:function(a,c){c=b.defaults({},c,this.options);var d,e,f,g,h=this.options.ownerDocument.createDocumentFragment();for(h.appendChild(this.options.ownerDocument.createElement("body")),g=h.querySelector("body"),g.innerHTML=a,this.cleanupSpans(g),d=g.querySelectorAll("*"),f=0;f<d.length;f+=1)e=d[f],b.cleanupAttrs(e,c.cleanAttrs),b.cleanupTags(e,c.cleanTags);b.insertHTMLCommand(this.options.ownerDocument,g.innerHTML.replace(/&nbsp;/g," "))},isCommonBlock:function(a){return a&&("p"===a.tagName.toLowerCase()||"div"===a.tagName.toLowerCase())},filterCommonBlocks:function(a){/^\s*$/.test(a.textContent)&&a.parentNode&&a.parentNode.removeChild(a)},filterLineBreak:function(a){this.isCommonBlock(a.previousElementSibling)?this.removeWithParent(a):!this.isCommonBlock(a.parentNode)||a.parentNode.firstChild!==a&&a.parentNode.lastChild!==a?a.parentNode&&1===a.parentNode.childElementCount&&""===a.parentNode.textContent&&this.removeWithParent(a):this.removeWithParent(a)},removeWithParent:function(a){a&&a.parentNode&&(a.parentNode.parentNode&&1===a.parentNode.childElementCount?a.parentNode.parentNode.removeChild(a.parentNode):a.parentNode.removeChild(a))},cleanupSpans:function(a){var c,d,e,f=a.querySelectorAll(".replace-with"),g=function(a){return a&&"#text"!==a.nodeName&&"false"===a.getAttribute("contenteditable")};for(c=0;c<f.length;c+=1)d=f[c],e=this.options.ownerDocument.createElement(d.classList.contains("bold")?"b":"i"),e.innerHTML=d.classList.contains("bold")&&d.classList.contains("italic")?"<i>"+d.innerHTML+"</i>":d.innerHTML,d.parentNode.replaceChild(e,d);for(f=a.querySelectorAll("span"),c=0;c<f.length;c+=1){if(d=f[c],b.traverseUp(d,g))return!1;/^\s*$/.test()?d.parentNode.removeChild(d):d.parentNode.replaceChild(this.options.ownerDocument.createTextNode(d.textContent),d)}}}}();var j;!function(){function a(){this.parent=!0,this.options={name:"anchor",action:"createLink",aria:"link",tagNames:["a"],contentDefault:"<b>#</b>",contentFA:'<i class="fa fa-link"></i>'},this.name="anchor",this.hasForm=!0}a.prototype={formSaveLabel:"&#10003;",formCloseLabel:"&times;",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)},getForm:function(){return this.form||(this.form=this.createForm()),this.form},getTemplate:function(){var a=['<input type="text" class="medium-editor-toolbar-input" placeholder="',this.base.options.anchorInputPlaceholder,'">'];return a.push('<a href="#" class="medium-editor-toolbar-save">',"fontawesome"===this.base.options.buttonLabels?'<i class="fa fa-check"></i>':this.formSaveLabel,"</a>"),a.push('<a href="#" class="medium-editor-toolbar-close">',"fontawesome"===this.base.options.buttonLabels?'<i class="fa fa-times"></i>':this.formCloseLabel,"</a>"),this.base.options.anchorTarget&&a.push('<input type="checkbox" class="medium-editor-toolbar-anchor-target">',"<label>",this.base.options.anchorInputCheckboxLabel,"</label>"),this.base.options.anchorButton&&a.push('<input type="checkbox" class="medium-editor-toolbar-anchor-button">',"<label>Button</label>"),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)),c.target=a&&a.checked?"_blank":"_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:"i",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'<div class="medium-editor-toolbar-anchor-preview" id="medium-editor-toolbar-anchor-preview"> <i class="medium-editor-toolbar-anchor-preview-inner"></i></div>'},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.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=40,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",this.anchorPreview.style.left=a>e?b+a+"px":this.base.options.contentWindow.innerWidth-e<a?this.base.options.contentWindow.innerWidth+b-a+"px":b+e+"px"},attachToEditables:function(){this.base.subscribe("editableMouseover",this.handleEditableMouseover.bind(this))},handleClick:function(){var a,b,c=this.base.getExtensionByName("anchor"),d=this.activeAnchor;c&&d&&(a=this.base.options.ownerDocument.createRange(),a.selectNodeContents(this.activeAnchor),b=this.base.options.contentWindow.getSelection(),b.removeAllRanges(),b.addRange(a),this.base.delay(function(){d&&(c.showForm(d.attributes.href.value),d=null)}.bind(this))),this.hidePreview()},handleAnchorMouseout:function(){this.anchorToPreview=null,this.base.off(this.activeAnchor,"mouseout",this.instance_handleAnchorMouseout),this.instance_handleAnchorMouseout=null},handleEditableMouseover:function(a){if(a.target&&"a"===a.target.tagName.toLowerCase()){if(!/href=["']\S+["']/.test(a.target.outerHTML)||/href=["']#\S+["']/.test(a.target.outerHTML))return!0;if(this.base.toolbar&&this.base.toolbar.isDisplayed())return!0;this.activeAnchor&&this.activeAnchor!==a.target&&this.detachPreviewHandlers(),this.anchorToPreview=a.target,this.instance_handleAnchorMouseout=this.handleAnchorMouseout.bind(this),this.base.on(this.anchorToPreview,"mouseout",this.instance_handleAnchorMouseout),this.base.delay(function(){this.anchorToPreview&&this.showPreview(this.anchorToPreview)}.bind(this))}},handlePreviewMouseover:function(){this.lastOver=(new Date).getTime(),this.hovering=!0},handlePreviewMouseout:function(a){a.relatedTarget&&/anchor-preview/.test(a.relatedTarget.className)||(this.hovering=!1)},updatePreview:function(){if(this.hovering)return!0;var a=(new Date).getTime()-this.lastOver;a>this.base.options.anchorPreviewHideDelay&&this.detachPreviewHandlers()},detachPreviewHandlers:function(){clearInterval(this.interval_timer),this.instance_handlePreviewMouseover&&(this.base.off(this.anchorPreview,"mouseover",this.instance_handlePreviewMouseover),this.base.off(this.anchorPreview,"mouseout",this.instance_handlePreviewMouseout),this.activeAnchor&&(this.base.off(this.activeAnchor,"mouseover",this.instance_handlePreviewMouseover),this.base.off(this.activeAnchor,"mouseout",this.instance_handlePreviewMouseout))),this.hidePreview(),this.hovering=this.instance_handlePreviewMouseover=this.instance_handlePreviewMouseout=null},attachPreviewHandlers:function(){this.lastOver=(new Date).getTime(),this.hovering=!0,this.instance_handlePreviewMouseover=this.handlePreviewMouseover.bind(this),this.instance_handlePreviewMouseout=this.handlePreviewMouseout.bind(this),this.interval_timer=setInterval(this.updatePreview.bind(this),200),this.base.on(this.anchorPreview,"mouseover",this.instance_handlePreviewMouseover),this.base.on(this.anchorPreview,"mouseout",this.instance_handlePreviewMouseout),this.base.on(this.activeAnchor,"mouseover",this.instance_handlePreviewMouseover),this.base.on(this.activeAnchor,"mouseout",this.instance_handlePreviewMouseout)}}}();var l;!function(){l=function(a){this.base=a,this.options=a.options,this.initThrottledMethods()},l.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",a.className+=this.options.staticToolbar?" static-toolbar":" stalker-toolbar",a.appendChild(this.createToolbarButtons()),this.base.commands.forEach(function(b){b.hasForm&&a.appendChild(b.getForm())}),this.attachEventHandlers(),this.base.subscribe("externalInteraction",this.handleBlur.bind(this)),a},createToolbarButtons:function(){var a,c,d,e=this.base.options.ownerDocument.createElement("ul");return e.id="medium-editor-toolbar-actions"+this.base.id,e.className="medium-editor-toolbar-actions clearfix",e.style.display="block",this.base.commands.forEach(function(d){"function"==typeof d.getButton&&(c=d.getButton(this.base),a=this.base.options.ownerDocument.createElement("li"),b.isElement(c)?a.appendChild(c):a.innerHTML=c,e.appendChild(a))}.bind(this)),d=e.querySelectorAll("button"),d.length>0&&(d[0].classList.add(this.options.firstButtonClass),d[d.length-1].classList.add(this.options.lastButtonClass)),e},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.on(this.options.ownerDocument.documentElement,"mousedown",this.handleDocumentMousedown.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)),this.base.elements.forEach(function(a){this.base.on(a,"click",this.handleEditableClick.bind(this)),this.base.on(a,"keyup",this.handleEditableKeyup.bind(this)),this.base.on(a,"blur",this.handleEditableBlur.bind(this))},this)},handleWindowScroll:function(){this.positionToolbarIfShown()},handleWindowResize:function(){this.throttledPositionToolbar()},handleDocumentMousedown:function(a){this.lastMousedownTarget=a.target},handleDocumentMouseup:function(a){return this.lastMousedownTarget=null,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()},handleEditableBlur:function(a){var c=!1,d=a&&a.relatedTarget?a.relatedTarget:this.lastMousedownTarget;return b.isDescendant(this.getToolbarElement(),d)?!1:(d&&(this.base.elements.forEach(function(a){c=c||b.isDescendant(a,d)||d===a},this),c||this.options.contentWindow.getSelection().removeAllRanges()),void this.checkState())},handleBlur:function(){setTimeout(function(){this.hideToolbar()}.bind(this),0)},isDisplayed:function(){return this.getToolbarElement().classList.contains("medium-editor-toolbar-active")},showToolbar:function(){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.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},checkSelectionElement:function(a,c){var d,e,g,h=0,i=a.getRangeAt(0);if(this.options.standardizeSelectionStart&&i.startContainer.nodeValue&&i.startOffset===i.startContainer.nodeValue.length&&(e=b.findAdjacentTextNodeWithContent(f.getSelectionElement(this.options.contentWindow),i.startContainer,this.options.ownerDocument))){for(h=0;0===e.nodeValue.substr(h,1).trim().length;)h+=1;g=this.options.ownerDocument.createRange(),g.setStart(e,h),g.setEnd(i.endContainer,i.endOffset),a.removeAllRanges(),a.addRange(g),i=g}for(d=0;d<this.base.elements.length;d+=1)if(this.base.elements[d]===c)return void this.showAndUpdateToolbar();this.options.staticToolbar||this.hideToolbar()},checkState:function(){var a,b;this.base.preventSelectionUpdates||(a=this.options.contentWindow.getSelection(),!this.options.updateOnEmptySelection&&""===a.toString().trim()||this.options.allowMultiParagraphSelection===!1&&this.multipleBlockElementsSelected()||f.selectionInContentEditableFalse(this.options.contentWindow)?this.options.staticToolbar?this.showAndUpdateToolbar():this.hideToolbar():(b=f.getSelectionElement(this.options.contentWindow),!b||b.getAttribute("data-disable-toolbar")?this.options.staticToolbar||this.hideToolbar():this.checkSelectionElement(a,b)))},showAndUpdateToolbar:function(){this.setToolbarButtonStates(),this.showToolbarDefaultActions(),this.setToolbarPosition()},setToolbarButtonStates:function(){this.base.commands.forEach(function(a){"function"==typeof a.isActive&&a.setInactive()}.bind(this)),this.checkActiveButtons()},checkActiveButtons:function(){var a,c=[],d=null,e=b.getSelectionRange(this.options.ownerDocument),g=function(b){"function"==typeof b.checkState?b.checkState(a):"function"==typeof b.isActive&&"function"==typeof b.isAlreadyApplied&&!b.isActive()&&b.isAlreadyApplied(a)&&b.setActive()};if(e)for(a=f.getSelectedParentElement(e),this.base.commands.forEach(function(a){return"function"==typeof a.queryCommandState&&(d=a.queryCommandState(),null!==d)?void(d&&a.setActive()):void c.push(a)});void 0!==a.tagName&&-1===b.parentElements.indexOf(a.tagName.toLowerCase)&&(c.forEach(g),-1===this.base.elements.indexOf(a));)a=a.parentNode},positionToolbarIfShown:function(){this.isDisplayed()&&this.setToolbarPosition()},setToolbarPosition:function(){var a,b=f.getSelectionElement(this.options.contentWindow),c=this.options.contentWindow.getSelection();return b&&this.options.contentWindow.getSelection().focusNode?-1===this.base.elements.indexOf(b)?this:(this.options.staticToolbar?(this.showToolbar(),this.positionStaticToolbar(b)):c.isCollapsed||(this.showToolbar(),this.positionToolbar(c)),a=this.base.getExtensionByName("anchor-preview"),void(a&&"function"==typeof a.hidePreview&&a.hidePreview())):this},positionStaticToolbar:function(a){this.getToolbarElement().style.left="0";var b,c=this.options.ownerDocument.documentElement&&this.options.ownerDocument.documentElement.scrollTop||this.options.ownerDocument.body.scrollTop,d=this.options.contentWindow.innerWidth,e=this.getToolbarElement(),f=a.getBoundingClientRect(),g=f.top+c,h=f.left+f.width/2,i=e.offsetHeight,j=e.offsetWidth,k=j/2;this.options.stickyToolbar?c>g+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-j),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.top<j?(f.classList.add("medium-toolbar-arrow-over"),f.classList.remove("medium-toolbar-arrow-under"),f.style.top=j+d.bottom-this.options.diffTop+this.options.contentWindow.pageYOffset-g+"px"):(f.classList.add("medium-toolbar-arrow-under"),f.classList.remove("medium-toolbar-arrow-over"),f.style.top=d.top+this.options.diffTop+this.options.contentWindow.pageYOffset-g+"px"),f.style.left=i>e?k+i+"px":i>b-e?b+k-i+"px":k+e+"px"}}}();var m;!function(){m=function(a){this.base=a,this.initPlaceholders(),this.attachEventHandlers()},m.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("externalInteraction",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 n;return function(){n={}}(),function(){function o(a,c){if(this.options.disableReturn||c.getAttribute("data-disable-return"))a.preventDefault();else if(this.options.disableDoubleReturn||this.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+|<br\/?>)?$/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="<br>",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="<br>",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,'<img class="medium-image-loading" id="'+d+'" />'),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]),this.elements=Array.prototype.slice.apply(a)}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;a<this.elements.length;a+=1)if(!this.elements[a].getAttribute("data-disable-toolbar")){b=!0;break}return b}function x(a){var b=this.options.ownerDocument.createElement("div"),c=+new Date,d=this.elements[a];return b.className=d.className,b.id=c,b.innerHTML=d.value,d.classList.add("medium-editor-hidden"),d.parentNode.insertBefore(b,d),this.on(b,"input",function(){d.value=this.serialize()[c].value}.bind(this)),b}function y(){var a,b=!1;for(a=0;a<this.elements.length;a+=1)this.options.disableEditing||this.elements[a].getAttribute("data-disable-editing")||("textarea"===this.elements[a].tagName.toLowerCase()&&(this.elements[a]=x.call(this,a)),this.elements[a].setAttribute("contentEditable",!0)),this.elements[a].getAttribute("data-placeholder")||this.elements[a].setAttribute("data-placeholder",this.options.placeholder),this.elements[a].setAttribute("data-medium-element",!0),this.elements[a].setAttribute("role","textbox"),this.elements[a].setAttribute("aria-multiline",!0),this.options.disableToolbar||this.elements[a].getAttribute("data-disable-toolbar")||(b=!0);!this.toolbar&&b&&(this.toolbar=new l(this),this.options.elementsContainer.appendChild(this.toolbar.getToolbarElement()))}function z(){var a;if(this.subscribe("editableKeydownTab",p.bind(this)),this.subscribe("editableKeydownDelete",q.bind(this)),this.subscribe("editableKeydownEnter",q.bind(this)),this.options.disableReturn||this.options.disableDoubleReturn)this.subscribe("editableKeydownEnter",o.bind(this));else for(a=0;a<this.elements.length;a+=1)if(this.elements[a].getAttribute("data-disable-return")||this.elements[a].getAttribute("data-disable-double-return")){this.subscribe("editableKeydownEnter",o.bind(this));break}this.options.disableReturn||this.elements.forEach(function(a){a.getAttribute("data-disable-return")||this.on(a,"keyup",t.bind(this))},this),this.options.imageDragging&&(this.subscribe("editableDrag",r.bind(this)),this.subscribe("editableDrop",s.bind(this)))}function A(){var a=b.extend({},this.options.paste,{forcePlainText:this.options.forcePlainText,cleanPastedHtml:this.options.cleanPastedHtml,disableReturn:this.options.disableReturn,targetBlank:this.options.targetBlank,contentWindow:this.options.contentWindow,ownerDocument:this.options.ownerDocument});this.pasteHandler=new i(this,a)}function B(){var a,b,d=this.options.buttons,e=this.options.extensions;this.commands=[],d.forEach(function(b){e[b]?(a=v(e[b],b,this),this.commands.push(a)):"anchor"===b?(a=v(new j,b,this),this.commands.push(a)):c.hasOwnProperty(b)&&(a=new h(c[b],this),this.commands.push(a))},this);for(b in e)e.hasOwnProperty(b)&&-1===d.indexOf(b)&&(a=v(e[b],b,this));w.call(this)&&this.commands.push(v(new k,"anchor-preview",this))}function C(a,c){c&&[["forcePlainText","paste.forcePlainText"],["cleanPastedHtml","paste.cleanPastedHtml"]].forEach(function(a){c.hasOwnProperty(a[0])&&void 0!==c[a[0]]&&b.deprecated(a[0],a[1])});var d=["paste"],e=b.extend({},c);return d.forEach(function(c){e[c]=e[c]?b.defaults({},e[c],a[c]):a[c]}),b.defaults(e,a)}function D(a,c){var d,e=/^append-(.+)$/gi;return d=e.exec(a),d?b.execFormatBlock(this.options.ownerDocument,d[1]):"createLink"===a?this.createLink(c):"image"===a?this.options.ownerDocument.execCommand("insertImage",!1,this.options.contentWindow.getSelection()):this.options.ownerDocument.execCommand(a,!1,null)}a.statics={ButtonsData:c,DefaultButton:h,AnchorExtension:j,Toolbar:l,AnchorPreview:k},a.Extension=e,a.extensions=n,a.util=b,a.selection=f,a.prototype={defaults:d,init:function(a,b){var c=1;if(this.options=C.call(this,this.defaults,b),u.call(this,a),0!==this.elements.length){for(this.options.elementsContainer||(this.options.elementsContainer=this.options.ownerDocument.body);this.options.elementsContainer.querySelector("#medium-editor-toolbar-"+c);)c+=1;return this.id=c,this.setup()}},setup:function(){this.isActive||(this.events=new g(this),this.isActive=!0,B.call(this),y.call(this),z.call(this),A.call(this),this.options.disablePlaceholders||(this.placeholders=new m(this)))},destroy:function(){if(this.isActive){var a;for(this.isActive=!1,void 0!==this.toolbar&&(this.toolbar.deactivate(),delete this.toolbar),a=0;a<this.elements.length;a+=1)this.elements[a].removeAttribute("contentEditable"),this.elements[a].removeAttribute("data-medium-element");this.commands.forEach(function(a){"function"==typeof a.deactivate&&a.deactivate()},this),this.events.detachAllDOMEvents()}},on:function(a,b,c,d){this.events.attachDOMEvent(a,b,c,d)},off:function(a,b,c,d){this.events.detachDOMEvent(a,b,c,d)},subscribe:function(a,b){this.events.attachCustomEvent(a,b)},delay:function(a){var b=this;setTimeout(function(){b.isActive&&a()},this.options.delay)},serialize:function(){var a,b,c={};for(a=0;a<this.elements.length;a+=1)b=""!==this.elements[a].id?this.elements[a].id:"element-"+a,c[b]={value:this.elements[a].innerHTML.trim()};return c},getExtensionByName:function(a){var b;return this.commands&&this.commands.length&&this.commands.some(function(c){return c.name===a?(b=c,!0):!1}),b},callExtensions:function(a){if(!(arguments.length<1)){var b,c,d=Array.prototype.slice.call(arguments,1);for(c in this.options.extensions)this.options.extensions.hasOwnProperty(c)&&(b=this.options.extensions[c],void 0!==b[a]&&b[a].apply(b,d));return this}},stopSelectionUpdates:function(){this.preventSelectionUpdates=!0},startSelectionUpdates:function(){this.preventSelectionUpdates=!1},checkSelection:function(){return this.toolbar&&this.toolbar.checkState(),this},queryCommandState:function(a){var b,c=/^full-(.+)$/gi,d=null;b=c.exec(a),b&&(a=b[1]);try{d=this.options.ownerDocument.queryCommandState(a)}catch(e){d=null}return d},execAction:function(a,c){var d,e,f=/^full-(.+)$/gi;return d=f.exec(a),d?(this.saveSelection(),this.selectAllContents(),e=D.call(this,d[1],c),this.restoreSelection()):e=D.call(this,a,c),("insertunorderedlist"===a||"insertorderedlist"===a)&&b.cleanListDOM(this.getSelectedParentElement()),this.checkSelection(),e},getSelectedParentElement:function(a){return void 0===a&&(a=this.options.contentWindow.getSelection().getRangeAt(0)),f.getSelectedParentElement(a)},hideToolbarDefaultActions:function(){return this.toolbar&&this.toolbar.hideToolbarDefaultActions(),this},setToolbarPosition:function(){this.toolbar&&this.toolbar.setToolbarPosition()},selectAllContents:function(){var a=this.options.ownerDocument.createRange(),b=this.options.contentWindow.getSelection(),c=f.getSelectionElement(this.options.contentWindow);if(c){for(;1===c.children.length;)c=c.children[0];a.selectNodeContents(c),b.removeAllRanges(),b.addRange(a)}},saveSelection:function(){this.selectionState=null;var a,c,d,e=this.options.contentWindow.getSelection(),f=-1;e.rangeCount>0&&(a=e.getRangeAt(0),c=a.cloneRange(),this.elements.some(function(c,d){return c===a.startContainer||b.isDescendant(c,a.startContainer)?(f=d,!0):!1}),f>-1&&(c.selectNodeContents(this.elements[f]),c.setEnd(a.startContainer,a.startOffset),d=c.toString().length,this.selectionState={start:d,end:d+a.toString().length,editableElementIndex:f}))},restoreSelection:function(){if(this.selectionState){var a,b,c,d,e=this.elements[this.selectionState.editableElementIndex],f=0,g=this.options.ownerDocument.createRange(),h=[e],i=!1,j=!1;for(g.setStart(e,0),g.collapse(!0),a=h.pop();!j&&a;){if(3===a.nodeType)d=f+a.length,!i&&this.selectionState.start>=f&&this.selectionState.start<=d&&(g.setStart(a,this.selectionState.start-f),i=!0),i&&this.selectionState.end>=f&&this.selectionState.end<=d&&(g.setEnd(a,this.selectionState.end-f),j=!0),f=d;else for(b=a.childNodes.length-1;b>=0;)h.push(a.childNodes[b]),b-=1;j||(a=h.pop())}c=this.options.contentWindow.getSelection(),c.removeAllRanges(),c.addRange(g)}},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<this.elements.length;d+=1)this.elements[d].dispatchEvent(c)},activate:function(){b.deprecatedMethod.call(this,"activate","setup",arguments)},deactivate:function(){b.deprecatedMethod.call(this,"deactivate","destroy",arguments)},cleanPaste:function(a){this.pasteHandler.cleanPaste(a)},pasteHTML:function(a,b){this.pasteHandler.pasteHTML(a,b)}}}(),a.version=function(a,b,c){return{major:parseInt(a,10),minor:parseInt(b,10),revision:parseInt(c,10),toString:function(){return[a,b,c].join(".")}}}.apply(this,{version:"4.3.0"}.version.split(".")),a}());
"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(++c<d);e&&this._updateClassName()},k.remove=function(){var a,b,c=arguments,d=0,e=c.length,f=!1;do for(a=c[d]+"",b=i(this,a);-1!==b;)this.splice(b,1),f=!0,b=i(this,a);while(++d<e);f&&this._updateClassName()},k.toggle=function(a,b){a+="";var c=this.contains(a),d=c?b!==!0&&"remove":b!==!1&&"add";return d&&this[d](a),b===!0||b===!1?b:!c},k.toString=function(){return this.join(" ")},e.defineProperty){var m={get:l,enumerable:!0,configurable:!0};try{e.defineProperty(d,b,m)}catch(n){-2146823252===n.number&&(m.enumerable=!1,e.defineProperty(d,b,m))}}else e[c].__defineGetter__&&d.__defineGetter__(b,l)}}(self),function(a){"use strict";if(a.URL=a.URL||a.webkitURL,a.Blob&&a.URL)try{return void new Blob}catch(b){}var c=a.BlobBuilder||a.WebKitBlobBuilder||a.MozBlobBuilder||function(a){var b=function(a){return Object.prototype.toString.call(a).match(/^\[object\s(.*)\]$/)[1]},c=function(){this.data=[]},d=function(a,b,c){this.data=a,this.size=a.length,this.type=b,this.encoding=c},e=c.prototype,f=d.prototype,g=a.FileReaderSync,h=function(a){this.code=this[this.name=a]},i="NOT_FOUND_ERR SECURITY_ERR ABORT_ERR NOT_READABLE_ERR ENCODING_ERR NO_MODIFICATION_ALLOWED_ERR INVALID_STATE_ERR SYNTAX_ERR".split(" "),j=i.length,k=a.URL||a.webkitURL||a,l=k.createObjectURL,m=k.revokeObjectURL,n=k,o=a.btoa,p=a.atob,q=a.ArrayBuffer,r=a.Uint8Array,s=/^[\w-]+:\/*\[?[\w\.:-]+\]?(?::[0-9]+)?/;for(d.fake=f.fake=!0;j--;)h.prototype[i[j]]=j+1;return k.createObjectURL||(n=a.URL=function(a){var b,c=document.createElementNS("http://www.w3.org/1999/xhtml","a");return c.href=a,"origin"in c||("data:"===c.protocol.toLowerCase()?c.origin=null:(b=a.match(s),c.origin=b&&b[1])),c}),n.createObjectURL=function(a){var b,c=a.type;return null===c&&(c="application/octet-stream"),a instanceof d?(b="data:"+c,"base64"===a.encoding?b+";base64,"+a.data:"URI"===a.encoding?b+","+decodeURIComponent(a.data):o?b+";base64,"+o(a.data):b+","+encodeURIComponent(a.data)):l?l.call(k,a):void 0},n.revokeObjectURL=function(a){"data:"!==a.substring(0,5)&&m&&m.call(k,a)},e.append=function(a){var c=this.data;if(r&&(a instanceof q||a instanceof r)){for(var e="",f=new r(a),i=0,j=f.length;j>i;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<b.length;e++){var f=b[e];if(!(f in d)){if(!c)return;d[f]={}}d=d[f]}return d}catch(g){}}function d(a,b){var c,d=Array.prototype.slice.call(arguments,2);b=b||{};for(var e=0;e<d.length;e++){var f=d[e];if(f)for(c in f)f.hasOwnProperty(c)&&"undefined"!=typeof f[c]&&(a||b.hasOwnProperty(c)===!1)&&(b[c]=f[c])}return b}b={isIE:"Microsoft Internet Explorer"===navigator.appName||"Netscape"===navigator.appName&&null!==new RegExp("Trident/.*rv:([0-9]{1,}[.0-9]{0,})").exec(navigator.userAgent),keyCode:{BACKSPACE:8,TAB:9,ENTER:13,ESCAPE:27,SPACE:32,DELETE:46},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){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,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")},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;b<a.length;b+=1)a[b].target="_blank"},addClassToAnchors:function(a,b){var c,d,e=b.split(" ");if("a"===a.tagName.toLowerCase())for(d=0;d<e.length;d+=1)a.classList.add(e[d]);else for(a=a.getElementsByTagName("a"),c=0;c<a.length;c+=1)for(d=0;d<e.length;d+=1)a[c].classList.add(e[d])},isListItem:function(a){if(!a)return!1;if("li"===a.tagName.toLowerCase())return!0;for(var b=a.parentNode,c=b.tagName.toLowerCase();-1===this.parentElements.indexOf(c)&&"div"!==c;){if("li"===c)return!0;if(b=b.parentNode,!b||!b.tagName)return!1;c=b.tagName.toLowerCase()}return!1},cleanListDOM:function(a){if("li"===a.tagName.toLowerCase()){var b=a.parentElement;"p"===b.parentElement.tagName.toLowerCase()&&this.unwrapElement(b.parentElement)}},unwrapElement:function(a){var b,c=a.parentNode,d=a.firstChild;do b=d.nextSibling,c.insertBefore(d,a),d=b;while(d);c.removeChild(a)},warn:function(){void 0!==a.console&&console.warn.apply(console,arguments)},deprecated:function(a,c,d){var e=a+" is deprecated, please use "+c+" instead.";d&&(e+=" Will be removed in "+d),b.warn(e)},deprecatedMethod:function(a,c,d,e){b.deprecated(a,c,e),"function"==typeof this[c]&&this[c].apply(this,d)},cleanupAttrs:function(a,b){b.forEach(function(b){a.removeAttribute(b)})},cleanupTags:function(a,b){b.forEach(function(b){a.tagName.toLowerCase()===b&&a.parentNode.removeChild(a)})},setObject:function(a,b,d){var e=a.split("."),f=e.pop(),g=c(e,!0,d);return g&&f?g[f]=b:void 0},getObject:function(a,b,d){return c(a?a.split("."):[],b,d)}}}(window);var c;!function(){c={bold:{name:"bold",action:"bold",aria:"bold",tagNames:["b","strong"],style:{prop:"font-weight",value:"700|bold"},useQueryState:!0,contentDefault:"<b>B</b>",contentFA:'<i class="fa fa-bold"></i>',key:"b"},italic:{name:"italic",action:"italic",aria:"italic",tagNames:["i","em"],style:{prop:"font-style",value:"italic"},useQueryState:!0,contentDefault:"<b><i>I</i></b>",contentFA:'<i class="fa fa-italic"></i>',key:"i"},underline:{name:"underline",action:"underline",aria:"underline",tagNames:["u"],style:{prop:"text-decoration",value:"underline"},useQueryState:!0,contentDefault:"<b><u>U</u></b>",contentFA:'<i class="fa fa-underline"></i>',key:"u"},strikethrough:{name:"strikethrough",action:"strikethrough",aria:"strike through",tagNames:["strike"],style:{prop:"text-decoration",value:"line-through"},useQueryState:!0,contentDefault:"<s>A</s>",contentFA:'<i class="fa fa-strikethrough"></i>'},superscript:{name:"superscript",action:"superscript",aria:"superscript",tagNames:["sup"],contentDefault:"<b>x<sup>1</sup></b>",contentFA:'<i class="fa fa-superscript"></i>'},subscript:{name:"subscript",action:"subscript",aria:"subscript",tagNames:["sub"],contentDefault:"<b>x<sub>1</sub></b>",contentFA:'<i class="fa fa-subscript"></i>'},image:{name:"image",action:"image",aria:"image",tagNames:["img"],contentDefault:"<b>image</b>",contentFA:'<i class="fa fa-picture-o"></i>'},quote:{name:"quote",action:"append-blockquote",aria:"blockquote",tagNames:["blockquote"],contentDefault:"<b>&ldquo;</b>",contentFA:'<i class="fa fa-quote-right"></i>'},orderedlist:{name:"orderedlist",action:"insertorderedlist",aria:"ordered list",tagNames:["ol"],useQueryState:!0,contentDefault:"<b>1.</b>",contentFA:'<i class="fa fa-list-ol"></i>'},unorderedlist:{name:"unorderedlist",action:"insertunorderedlist",aria:"unordered list",tagNames:["ul"],useQueryState:!0,contentDefault:"<b>&bull;</b>",contentFA:'<i class="fa fa-list-ul"></i>'},pre:{name:"pre",action:"append-pre",aria:"preformatted text",tagNames:["pre"],contentDefault:"<b>0101</b>",contentFA:'<i class="fa fa-code fa-lg"></i>'},indent:{name:"indent",action:"indent",aria:"indent",tagNames:[],contentDefault:"<b>&rarr;</b>",contentFA:'<i class="fa fa-indent"></i>'},outdent:{name:"outdent",action:"outdent",aria:"outdent",tagNames:[],contentDefault:"<b>&larr;</b>",contentFA:'<i class="fa fa-outdent"></i>'},justifyCenter:{name:"justifyCenter",action:"justifyCenter",aria:"center justify",tagNames:[],style:{prop:"text-align",value:"center"},contentDefault:"<b>C</b>",contentFA:'<i class="fa fa-align-center"></i>'},justifyFull:{name:"justifyFull",action:"justifyFull",aria:"full justify",tagNames:[],style:{prop:"text-align",value:"justify"},contentDefault:"<b>J</b>",contentFA:'<i class="fa fa-align-justify"></i>'},justifyLeft:{name:"justifyLeft",action:"justifyLeft",aria:"left justify",tagNames:[],style:{prop:"text-align",value:"left"},contentDefault:"<b>L</b>",contentFA:'<i class="fa fa-align-left"></i>'},justifyRight:{name:"justifyRight",action:"justifyRight",aria:"right justify",tagNames:[],style:{prop:"text-align",value:"right"},contentDefault:"<b>R</b>",contentFA:'<i class="fa fa-align-right"></i>'},header1:{name:"header1",action:function(a){return"append-"+a.firstHeader},aria:function(a){return a.firstHeader},tagNames:function(a){return[a.firstHeader]},contentDefault:"<b>H1</b>"},header2:{name:"header2",action:function(a){return"append-"+a.secondHeader},aria:function(a){return a.secondHeader},tagNames:function(a){return[a.secondHeader]},contentDefault:"<b>H2</b>"},removeFormat:{name:"removeFormat",aria:"remove formatting",action:"removeFormat",contentDefault:"<b>X</b>",contentFA:'<i class="fa fa-eraser"></i>'}}}();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",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(){}}}();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},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))},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,"click",this.handleInteraction.bind(this),!0),this.attachDOMEvent(this.options.ownerDocument.body,"focus",this.handleInteraction.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"})},handleInteraction:function(a){this.updateFocus(a.target,a)},updateFocus:function(a,c){var d,e,g=this.options.contentWindow.getSelection(),h=this.base.toolbar?this.base.toolbar.getToolbarElement():null,i=this.base.getExtensionByName("anchor-preview"),j=i&&i.getPreviewElement?i.getPreviewElement():null,k=g.isCollapsed?null:f.getSelectedParentElement(g.getRangeAt(0));this.base.elements.some(function(c){return!d&&c.getAttribute("data-medium-focused")&&(d=c),e||!b.isDescendant(c,a,!0)&&!b.isDescendant(c,k)||(e=c),!!d&&!!e},this);var l=!b.isDescendant(d,a,!0)&&!b.isDescendant(h,a,!0)&&!b.isDescendant(j,a,!0);e!==d&&(d&&l&&(d.removeAttribute("data-medium-focused"),this.triggerCustomEvent("blur",c,d)),e&&(e.setAttribute("data-medium-focused",!0),this.triggerCustomEvent("focus",c,e))),l&&this.triggerCustomEvent("externalInteraction",c)},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;return a.classList.add("medium-editor-action"),a.classList.add("medium-editor-action-"+this.name),a.setAttribute("data-action",this.getAction()),a.setAttribute("aria-label",this.getAria()),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 b,c;(a.ctrlKey||a.metaKey)&&(b=String.fromCharCode(a.which||a.keyCode).toLowerCase(),this.options.key===b&&(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>(<br[^>]*>)?$/gi),""],[new RegExp(/<span class="Apple-converted-space">\s+<\/span>/g)," "],[new RegExp(/<br class="Apple-interchange-newline">/g),"<br>"],[new RegExp(/<span[^>]*(font-style:italic;font-weight:bold|font-weight:bold;font-style:italic)[^>]*>/gi),'<span class="replace-with italic bold">'],[new RegExp(/<span[^>]*font-style:italic[^>]*>/gi),'<span class="replace-with italic">'],[new RegExp(/<span[^>]*font-weight:bold[^>]*>/gi),'<span class="replace-with bold">'],[new RegExp(/&lt;(\/?)(i|b|a)&gt;/gi),"<$1$2>"],[new RegExp(/&lt;a\s+href=(&quot;|&rdquo;|&ldquo;|“|”)([^&]+)(&quot;|&rdquo;|&ldquo;|“|”)&gt;/gi),'<a href="$2">'],[new RegExp(/<\/p>\n+/gi),"</p>"],[new RegExp(/\n+<p/gi),"<p"],[new RegExp(/<\/?o:[a-z]*>/gi),""]]}i=function(a,b){this.base=a,this.options=b,(this.options.forcePlainText||this.options.cleanPastedHTML)&&this.base.subscribe("editablePaste",this.handlePaste.bind(this))},i.prototype={handlePaste:function(a,c){var d,e,f="",g="text/html",h="text/plain";if(this.options.contentWindow.clipboardData&&void 0===a.clipboardData&&(a.clipboardData=this.options.contentWindow.clipboardData,g="Text",h="Text"),a.clipboardData&&a.clipboardData.getData&&!a.defaultPrevented){if(a.preventDefault(),this.options.cleanPastedHTML&&a.clipboardData.getData(g))return this.cleanPaste(a.clipboardData.getData(g));if(this.options.disableReturn||c.getAttribute("data-disable-return"))f=b.htmlEntities(a.clipboardData.getData(h));else if(d=a.clipboardData.getData(h).split(/[\r\n]+/g),d.length>1)for(e=0;e<d.length;e+=1)""!==d[e]&&(f+="<p>"+b.htmlEntities(d[e])+"</p>");else f=b.htmlEntities(d[0]);b.insertHTMLCommand(this.options.ownerDocument,f)}},cleanPaste:function(c){var d,e,g,h=f.getSelectionElement(this.options.contentWindow),i=/<p|<br|<div/.test(c),j=a().concat(this.options.cleanReplacements||[]);for(d=0;d<j.length;d+=1)c=c.replace(j[d][0],j[d][1]);if(i){e=c.split("<br><br>"),this.pasteHTML("<p>"+e.join("</p><p>")+"</p>");try{this.options.ownerDocument.execCommand("insertText",!1,"\n")}catch(k){}for(e=h.querySelectorAll("a,p,div,br"),d=0;d<e.length;d+=1)switch(g=e[d],g.innerHTML=g.innerHTML.replace(/\n/gi," "),g.tagName.toLowerCase()){case"a":this.options.targetBlank&&b.setTargetBlank(g);break;case"p":case"div":this.filterCommonBlocks(g);break;case"br":this.filterLineBreak(g)}}else this.pasteHTML(c)},pasteHTML:function(a,c){c=b.defaults({},c,this.options);var d,e,f,g,h=this.options.ownerDocument.createDocumentFragment();for(h.appendChild(this.options.ownerDocument.createElement("body")),g=h.querySelector("body"),g.innerHTML=a,this.cleanupSpans(g),d=g.querySelectorAll("*"),f=0;f<d.length;f+=1)e=d[f],b.cleanupAttrs(e,c.cleanAttrs),b.cleanupTags(e,c.cleanTags);b.insertHTMLCommand(this.options.ownerDocument,g.innerHTML.replace(/&nbsp;/g," "))},isCommonBlock:function(a){return a&&("p"===a.tagName.toLowerCase()||"div"===a.tagName.toLowerCase())},filterCommonBlocks:function(a){/^\s*$/.test(a.textContent)&&a.parentNode&&a.parentNode.removeChild(a)},filterLineBreak:function(a){this.isCommonBlock(a.previousElementSibling)?this.removeWithParent(a):!this.isCommonBlock(a.parentNode)||a.parentNode.firstChild!==a&&a.parentNode.lastChild!==a?a.parentNode&&1===a.parentNode.childElementCount&&""===a.parentNode.textContent&&this.removeWithParent(a):this.removeWithParent(a)},removeWithParent:function(a){a&&a.parentNode&&(a.parentNode.parentNode&&1===a.parentNode.childElementCount?a.parentNode.parentNode.removeChild(a.parentNode):a.parentNode.removeChild(a))},cleanupSpans:function(a){var c,d,e,f=a.querySelectorAll(".replace-with"),g=function(a){return a&&"#text"!==a.nodeName&&"false"===a.getAttribute("contenteditable")};for(c=0;c<f.length;c+=1)d=f[c],e=this.options.ownerDocument.createElement(d.classList.contains("bold")?"b":"i"),e.innerHTML=d.classList.contains("bold")&&d.classList.contains("italic")?"<i>"+d.innerHTML+"</i>":d.innerHTML,d.parentNode.replaceChild(e,d);for(f=a.querySelectorAll("span"),c=0;c<f.length;c+=1){if(d=f[c],b.traverseUp(d,g))return!1;/^\s*$/.test()?d.parentNode.removeChild(d):d.parentNode.replaceChild(this.options.ownerDocument.createTextNode(d.textContent),d)}}}}();var j;!function(){function a(){this.parent=!0,this.options={name:"anchor",action:"createLink",aria:"link",tagNames:["a"],contentDefault:"<b>#</b>",contentFA:'<i class="fa fa-link"></i>'},this.name="anchor",this.hasForm=!0}a.prototype={formSaveLabel:"&#10003;",formCloseLabel:"&times;",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)},getForm:function(){return this.form||(this.form=this.createForm()),this.form},getTemplate:function(){var a=['<input type="text" class="medium-editor-toolbar-input" placeholder="',this.base.options.anchorInputPlaceholder,'">'];return a.push('<a href="#" class="medium-editor-toolbar-save">',"fontawesome"===this.base.options.buttonLabels?'<i class="fa fa-check"></i>':this.formSaveLabel,"</a>"),a.push('<a href="#" class="medium-editor-toolbar-close">',"fontawesome"===this.base.options.buttonLabels?'<i class="fa fa-times"></i>':this.formCloseLabel,"</a>"),this.base.options.anchorTarget&&a.push('<input type="checkbox" class="medium-editor-toolbar-anchor-target">',"<label>",this.base.options.anchorInputCheckboxLabel,"</label>"),this.base.options.anchorButton&&a.push('<input type="checkbox" class="medium-editor-toolbar-anchor-button">',"<label>Button</label>"),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)),c.target=a&&a.checked?"_blank":"_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:"i",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'<div class="medium-editor-toolbar-anchor-preview" id="medium-editor-toolbar-anchor-preview"> <i class="medium-editor-toolbar-anchor-preview-inner"></i></div>'},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.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=40,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",this.anchorPreview.style.left=a>e?b+a+"px":this.base.options.contentWindow.innerWidth-e<a?this.base.options.contentWindow.innerWidth+b-a+"px":b+e+"px"},attachToEditables:function(){this.base.subscribe("editableMouseover",this.handleEditableMouseover.bind(this))},handleClick:function(){var a=this.base.getExtensionByName("anchor"),b=this.activeAnchor;a&&b&&(this.base.selectElement(this.activeAnchor),this.base.delay(function(){b&&(a.showForm(b.attributes.href.value),b=null)}.bind(this))),this.hidePreview()},handleAnchorMouseout:function(){this.anchorToPreview=null,this.base.off(this.activeAnchor,"mouseout",this.instance_handleAnchorMouseout),this.instance_handleAnchorMouseout=null},handleEditableMouseover:function(a){if(a.target&&"a"===a.target.tagName.toLowerCase()){if(!/href=["']\S+["']/.test(a.target.outerHTML)||/href=["']#\S+["']/.test(a.target.outerHTML))return!0;if(this.base.toolbar&&this.base.toolbar.isDisplayed())return!0;this.activeAnchor&&this.activeAnchor!==a.target&&this.detachPreviewHandlers(),this.anchorToPreview=a.target,this.instance_handleAnchorMouseout=this.handleAnchorMouseout.bind(this),this.base.on(this.anchorToPreview,"mouseout",this.instance_handleAnchorMouseout),this.base.delay(function(){this.anchorToPreview&&this.showPreview(this.anchorToPreview)}.bind(this))}},handlePreviewMouseover:function(){this.lastOver=(new Date).getTime(),this.hovering=!0},handlePreviewMouseout:function(a){a.relatedTarget&&/anchor-preview/.test(a.relatedTarget.className)||(this.hovering=!1)},updatePreview:function(){if(this.hovering)return!0;var a=(new Date).getTime()-this.lastOver;a>this.base.options.anchorPreviewHideDelay&&this.detachPreviewHandlers()},detachPreviewHandlers:function(){clearInterval(this.interval_timer),this.instance_handlePreviewMouseover&&(this.base.off(this.anchorPreview,"mouseover",this.instance_handlePreviewMouseover),this.base.off(this.anchorPreview,"mouseout",this.instance_handlePreviewMouseout),this.activeAnchor&&(this.base.off(this.activeAnchor,"mouseover",this.instance_handlePreviewMouseover),this.base.off(this.activeAnchor,"mouseout",this.instance_handlePreviewMouseout))),this.hidePreview(),this.hovering=this.instance_handlePreviewMouseover=this.instance_handlePreviewMouseout=null},attachPreviewHandlers:function(){this.lastOver=(new Date).getTime(),this.hovering=!0,this.instance_handlePreviewMouseover=this.handlePreviewMouseover.bind(this),this.instance_handlePreviewMouseout=this.handlePreviewMouseout.bind(this),this.interval_timer=setInterval(this.updatePreview.bind(this),200),this.base.on(this.anchorPreview,"mouseover",this.instance_handlePreviewMouseover),this.base.on(this.anchorPreview,"mouseout",this.instance_handlePreviewMouseout),this.base.on(this.activeAnchor,"mouseover",this.instance_handlePreviewMouseover),this.base.on(this.activeAnchor,"mouseout",this.instance_handlePreviewMouseout)}}}();var l;!function(){l=function(a){this.base=a,this.options=a.options,this.initThrottledMethods()},l.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",a.className+=this.options.staticToolbar?" static-toolbar":" 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=this.base.options.ownerDocument.createElement("ul");return e.id="medium-editor-toolbar-actions"+this.base.id,e.className="medium-editor-toolbar-actions clearfix",e.style.display="block",this.base.commands.forEach(function(d){"function"==typeof d.getButton&&(c=d.getButton(this.base),a=this.base.options.ownerDocument.createElement("li"),b.isElement(c)?a.appendChild(c):a.innerHTML=c,e.appendChild(a))}.bind(this)),d=e.querySelectorAll("button"),d.length>0&&(d[0].classList.add(this.options.firstButtonClass),d[d.length-1].classList.add(this.options.lastButtonClass)),e},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),this.hideTimeout=setTimeout(function(){this.hideToolbar()}.bind(this),0)},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.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;a<this.base.elements.length;a+=1)if(this.base.elements[a].getAttribute("data-medium-focused"))return this.base.elements[a];return null},showAndUpdateToolbar:function(){this.modifySelection(),this.setToolbarButtonStates(),this.showToolbarDefaultActions(),this.setToolbarPosition()},setToolbarButtonStates:function(){this.base.commands.forEach(function(a){"function"==typeof a.isActive&&a.setInactive()}.bind(this)),this.checkActiveButtons()},checkActiveButtons:function(){var a,c=[],d=null,e=b.getSelectionRange(this.options.ownerDocument),g=function(b){"function"==typeof b.checkState?b.checkState(a):"function"==typeof b.isActive&&"function"==typeof b.isAlreadyApplied&&!b.isActive()&&b.isAlreadyApplied(a)&&b.setActive()};if(e)for(a=f.getSelectedParentElement(e),this.base.commands.forEach(function(a){return"function"==typeof a.queryCommandState&&(d=a.queryCommandState(),null!==d)?void(d&&a.setActive()):void c.push(a)});void 0!==a.tagName&&-1===b.parentElements.indexOf(a.tagName.toLowerCase)&&(c.forEach(g),-1===this.base.elements.indexOf(a));)a=a.parentNode},positionToolbarIfShown:function(){this.isDisplayed()&&this.setToolbarPosition()},setToolbarPosition:function(){var a,b=this.getFocusedElement(),c=this.options.contentWindow.getSelection();return b?(this.options.staticToolbar?(this.showToolbar(),this.positionStaticToolbar(b)):c.isCollapsed||(this.showToolbar(),this.positionToolbar(c)),a=this.base.getExtensionByName("anchor-preview"),void(a&&"function"==typeof a.hidePreview&&a.hidePreview())):this},positionStaticToolbar:function(a){this.getToolbarElement().style.left="0";var b,c=this.options.ownerDocument.documentElement&&this.options.ownerDocument.documentElement.scrollTop||this.options.ownerDocument.body.scrollTop,d=this.options.contentWindow.innerWidth,e=this.getToolbarElement(),f=a.getBoundingClientRect(),g=f.top+c,h=f.left+f.width/2,i=e.offsetHeight,j=e.offsetWidth,k=j/2;this.options.stickyToolbar?c>g+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.top<j?(f.classList.add("medium-toolbar-arrow-over"),f.classList.remove("medium-toolbar-arrow-under"),f.style.top=j+d.bottom-this.options.diffTop+this.options.contentWindow.pageYOffset-g+"px"):(f.classList.add("medium-toolbar-arrow-under"),f.classList.remove("medium-toolbar-arrow-over"),f.style.top=d.top+this.options.diffTop+this.options.contentWindow.pageYOffset-g+"px"),f.style.left=i>e?k+i+"px":i>b-e?b+k-i+"px":k+e+"px"}}}();var m;!function(){m=function(a){this.base=a,this.initPlaceholders(),this.attachEventHandlers()},m.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 n;return function(){n={}}(),function(){function o(a,c){if(this.options.disableReturn||c.getAttribute("data-disable-return"))a.preventDefault();else if(this.options.disableDoubleReturn||this.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+|<br\/?>)?$/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="<br>",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="<br>",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,'<img class="medium-image-loading" id="'+d+'" />'),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]),this.elements=Array.prototype.slice.apply(a)}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;a<this.elements.length;a+=1)if(!this.elements[a].getAttribute("data-disable-toolbar")){b=!0;break}return b}function x(a){var b=this.options.ownerDocument.createElement("div"),c=+new Date,d=this.elements[a];return b.className=d.className,b.id=c,b.innerHTML=d.value,d.classList.add("medium-editor-hidden"),d.parentNode.insertBefore(b,d),this.on(b,"input",function(){d.value=this.serialize()[c].value}.bind(this)),b}function y(){var a,b=!1;for(a=0;a<this.elements.length;a+=1)this.options.disableEditing||this.elements[a].getAttribute("data-disable-editing")||("textarea"===this.elements[a].tagName.toLowerCase()&&(this.elements[a]=x.call(this,a)),this.elements[a].setAttribute("contentEditable",!0)),this.elements[a].getAttribute("data-placeholder")||this.elements[a].setAttribute("data-placeholder",this.options.placeholder),this.elements[a].setAttribute("data-medium-element",!0),this.elements[a].setAttribute("role","textbox"),this.elements[a].setAttribute("aria-multiline",!0),this.options.disableToolbar||this.elements[a].getAttribute("data-disable-toolbar")||(b=!0);!this.toolbar&&b&&(this.toolbar=new l(this),this.options.elementsContainer.appendChild(this.toolbar.getToolbarElement()))}function z(){var a;if(this.subscribe("editableKeydownTab",p.bind(this)),this.subscribe("editableKeydownDelete",q.bind(this)),this.subscribe("editableKeydownEnter",q.bind(this)),this.options.disableReturn||this.options.disableDoubleReturn)this.subscribe("editableKeydownEnter",o.bind(this));else for(a=0;a<this.elements.length;a+=1)if(this.elements[a].getAttribute("data-disable-return")||this.elements[a].getAttribute("data-disable-double-return")){this.subscribe("editableKeydownEnter",o.bind(this));break}this.options.disableReturn||this.elements.forEach(function(a){a.getAttribute("data-disable-return")||this.on(a,"keyup",t.bind(this))},this),this.options.imageDragging&&(this.subscribe("editableDrag",r.bind(this)),this.subscribe("editableDrop",s.bind(this)))}function A(){var a=b.extend({},this.options.paste,{forcePlainText:this.options.forcePlainText,cleanPastedHtml:this.options.cleanPastedHtml,disableReturn:this.options.disableReturn,targetBlank:this.options.targetBlank,contentWindow:this.options.contentWindow,ownerDocument:this.options.ownerDocument});this.pasteHandler=new i(this,a)}function B(){var a,b,d=this.options.buttons,e=this.options.extensions;this.commands=[],d.forEach(function(b){e[b]?(a=v(e[b],b,this),this.commands.push(a)):"anchor"===b?(a=v(new j,b,this),this.commands.push(a)):c.hasOwnProperty(b)&&(a=new h(c[b],this),this.commands.push(a))},this);for(b in e)e.hasOwnProperty(b)&&-1===d.indexOf(b)&&(a=v(e[b],b,this));w.call(this)&&this.commands.push(v(new k,"anchor-preview",this))}function C(a,c){c&&[["forcePlainText","paste.forcePlainText"],["cleanPastedHtml","paste.cleanPastedHtml"]].forEach(function(a){c.hasOwnProperty(a[0])&&void 0!==c[a[0]]&&b.deprecated(a[0],a[1])});var d=["paste"],e=b.extend({},c);return d.forEach(function(c){e[c]=e[c]?b.defaults({},e[c],a[c]):a[c]}),b.defaults(e,a)}function D(a,c){var d,e=/^append-(.+)$/gi;return d=e.exec(a),d?b.execFormatBlock(this.options.ownerDocument,d[1]):"createLink"===a?this.createLink(c):"image"===a?this.options.ownerDocument.execCommand("insertImage",!1,this.options.contentWindow.getSelection()):this.options.ownerDocument.execCommand(a,!1,null)}a.statics={ButtonsData:c,DefaultButton:h,AnchorExtension:j,Toolbar:l,AnchorPreview:k},a.Extension=e,a.extensions=n,a.util=b,a.selection=f,a.prototype={defaults:d,init:function(a,b){var c=1;if(this.options=C.call(this,this.defaults,b),u.call(this,a),0!==this.elements.length){for(this.options.elementsContainer||(this.options.elementsContainer=this.options.ownerDocument.body);this.options.elementsContainer.querySelector("#medium-editor-toolbar-"+c);)c+=1;return this.id=c,this.setup()}},setup:function(){this.isActive||(this.events=new g(this),this.isActive=!0,B.call(this),y.call(this),z.call(this),A.call(this),this.options.disablePlaceholders||(this.placeholders=new m(this)))},destroy:function(){if(this.isActive){var a;for(this.isActive=!1,void 0!==this.toolbar&&(this.toolbar.deactivate(),delete this.toolbar),a=0;a<this.elements.length;a+=1)this.elements[a].removeAttribute("contentEditable"),this.elements[a].removeAttribute("data-medium-element");this.commands.forEach(function(a){"function"==typeof a.deactivate&&a.deactivate()},this),this.events.detachAllDOMEvents()}},on:function(a,b,c,d){this.events.attachDOMEvent(a,b,c,d)},off:function(a,b,c,d){this.events.detachDOMEvent(a,b,c,d)},subscribe:function(a,b){this.events.attachCustomEvent(a,b)},delay:function(a){var b=this;return setTimeout(function(){b.isActive&&a()},this.options.delay)},serialize:function(){var a,b,c={};for(a=0;a<this.elements.length;a+=1)b=""!==this.elements[a].id?this.elements[a].id:"element-"+a,c[b]={value:this.elements[a].innerHTML.trim()};return c},getExtensionByName:function(a){var b;return this.commands&&this.commands.length&&this.commands.some(function(c){return c.name===a?(b=c,!0):!1}),b},callExtensions:function(a){if(!(arguments.length<1)){var b,c,d=Array.prototype.slice.call(arguments,1);for(c in this.options.extensions)this.options.extensions.hasOwnProperty(c)&&(b=this.options.extensions[c],void 0!==b[a]&&b[a].apply(b,d));return this}},stopSelectionUpdates:function(){this.preventSelectionUpdates=!0},startSelectionUpdates:function(){this.preventSelectionUpdates=!1},checkSelection:function(){return this.toolbar&&this.toolbar.checkState(),this},queryCommandState:function(a){var b,c=/^full-(.+)$/gi,d=null;b=c.exec(a),b&&(a=b[1]);try{d=this.options.ownerDocument.queryCommandState(a)}catch(e){d=null}return d},execAction:function(a,c){var d,e,f=/^full-(.+)$/gi;return d=f.exec(a),d?(this.saveSelection(),this.selectAllContents(),e=D.call(this,d[1],c),this.restoreSelection()):e=D.call(this,a,c),("insertunorderedlist"===a||"insertorderedlist"===a)&&b.cleanListDOM(this.getSelectedParentElement()),this.checkSelection(),e},getSelectedParentElement:function(a){return void 0===a&&(a=this.options.contentWindow.getSelection().getRangeAt(0)),f.getSelectedParentElement(a)},hideToolbarDefaultActions:function(){return this.toolbar&&this.toolbar.hideToolbarDefaultActions(),this},setToolbarPosition:function(){this.toolbar&&this.toolbar.setToolbarPosition()},selectAllContents:function(){var a=f.getSelectionElement(this.options.contentWindow);if(a){for(;1===a.children.length;)a=a.children[0];this.selectElement(a)}},selectElement:function(a){f.selectNode(a,this.options.ownerDocument);var b=f.getSelectionElement(this.options.contentWindow);b&&this.events.focusElement(b)},saveSelection:function(){this.selectionState=null;var a,c,d,e=this.options.contentWindow.getSelection(),f=-1;e.rangeCount>0&&(a=e.getRangeAt(0),c=a.cloneRange(),this.elements.some(function(c,d){return c===a.startContainer||b.isDescendant(c,a.startContainer)?(f=d,!0):!1}),f>-1&&(c.selectNodeContents(this.elements[f]),c.setEnd(a.startContainer,a.startOffset),d=c.toString().length,this.selectionState={start:d,end:d+a.toString().length,editableElementIndex:f}))},restoreSelection:function(){if(this.selectionState){var a,b,c,d,e=this.elements[this.selectionState.editableElementIndex],f=0,g=this.options.ownerDocument.createRange(),h=[e],i=!1,j=!1;for(g.setStart(e,0),g.collapse(!0),a=h.pop();!j&&a;){if(3===a.nodeType)d=f+a.length,!i&&this.selectionState.start>=f&&this.selectionState.start<=d&&(g.setStart(a,this.selectionState.start-f),i=!0),i&&this.selectionState.end>=f&&this.selectionState.end<=d&&(g.setEnd(a,this.selectionState.end-f),j=!0),f=d;else for(b=a.childNodes.length-1;b>=0;)h.push(a.childNodes[b]),b-=1;j||(a=h.pop())}c=this.options.contentWindow.getSelection(),c.removeAllRanges(),c.addRange(g)}},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<this.elements.length;d+=1)this.elements[d].dispatchEvent(c)},activate:function(){b.deprecatedMethod.call(this,"activate","setup",arguments)},deactivate:function(){b.deprecatedMethod.call(this,"deactivate","destroy",arguments)},cleanPaste:function(a){this.pasteHandler.cleanPaste(a)},pasteHTML:function(a,b){this.pasteHandler.pasteHTML(a,b)}}}(),a.version=function(a,b,c){return{major:parseInt(a,10),minor:parseInt(b,10),revision:parseInt(c,10),toString:function(){return[a,b,c].join(".")}}}.apply(this,{version:"4.4.0"}.version.split(".")),a}());
{
"name": "medium-editor",
"version": "4.3.0",
"version": "4.4.0",
"author": "Davi Ferreira <hi@daviferreira.com>",

@@ -5,0 +5,0 @@ "contributors": [

@@ -203,2 +203,3 @@ # MediumEditor

* __.getExtensionByName(name)__: get a reference to an extension with the specified name
* __.selectElement(element)__: change selection to be a specific element and update the toolbar to reflect the selection

@@ -205,0 +206,0 @@ ## Capturing DOM changes

@@ -57,6 +57,5 @@ /*global MediumEditor, describe, it, expect, spyOn,

sel.addRange(nextRange);
fireEvent(document.documentElement, 'mouseup');
fireEvent(document.getElementById('another-element'), 'click');
jasmine.clock().tick(200);
expect(editor.toolbar.hideToolbar).toHaveBeenCalled();
});

@@ -63,0 +62,0 @@

/*global MediumEditor, describe, it, expect, spyOn,
afterEach, beforeEach, selectElementContents,
jasmine, fireEvent, tearDown,
jasmine, fireEvent, tearDown, Util,
selectElementContentsAndFire */

@@ -52,2 +52,20 @@

describe('Anchor Form', function () {
it('should not hide the toolbar when mouseup fires inside the anchor form', function () {
var editor = new MediumEditor('.editor'),
anchorExtension = editor.getExtensionByName('anchor');
selectElementContentsAndFire(editor.elements[0]);
var button = editor.toolbar.getToolbarElement().querySelector('[data-action="createLink"]');
fireEvent(button, 'click');
expect(editor.toolbar.isDisplayed()).toBe(true);
expect(anchorExtension.isDisplayed()).toBe(true);
fireEvent(anchorExtension.getInput(), 'mouseup');
expect(editor.toolbar.isDisplayed()).toBe(true);
expect(anchorExtension.isDisplayed()).toBe(true);
});
});
describe('Link Creation', function () {

@@ -66,6 +84,7 @@ it('should create a link when user presses enter', function () {

fireEvent(input, 'keyup', {
keyCode: 13
keyCode: Util.keyCode.ENTER
});
expect(editor.createLink).toHaveBeenCalled();
});
it('shouldn\'t create a link when user presses enter without value', function () {

@@ -83,3 +102,3 @@ spyOn(MediumEditor.prototype, 'createLink').and.callThrough();

fireEvent(input, 'keyup', {
keyCode: 13
keyCode: Util.keyCode.ENTER
});

@@ -180,3 +199,3 @@ expect(editor.elements[0].querySelector('a')).toBeNull();

fireEvent(input, 'keyup', {
keyCode: 13
keyCode: Util.keyCode.ENTER
});

@@ -205,3 +224,3 @@ opts = {

selectElementContents(editor.elements[0]);
selectElementContentsAndFire(editor.elements[0]);
button = editor.toolbar.getToolbarElement().querySelector('[data-action="createLink"]');

@@ -215,2 +234,3 @@ cancel = anchorExtension.getForm().querySelector('a.medium-editor-toolbar-close');

});
it('should close the link form when user presses escape', function () {

@@ -220,7 +240,7 @@ var editor = new MediumEditor('.editor'),

selectElementContents(editor.elements[0]);
selectElementContentsAndFire(editor.elements[0]);
fireEvent(editor.toolbar.getToolbarElement().querySelector('[data-action="createLink"]'), 'click');
expect(anchorExtension.isDisplayed()).toBe(true);
fireEvent(anchorExtension.getInput(), 'keyup', {
keyCode: 27
keyCode: Util.keyCode.ESCAPE
});

@@ -227,0 +247,0 @@ expect(anchorExtension.isDisplayed()).toBe(false);

@@ -242,3 +242,3 @@ /*global MediumEditor, describe, it, expect, spyOn,

this.el.innerHTML = '<strong>lorem ipsum</strong>';
selectElementContentsAndFire(editor.elements[0]);
selectElementContentsAndFire(editor.elements[0], { eventToFire: 'mouseup' });
expect(button.classList.contains('medium-editor-button-active')).toBe(true);

@@ -308,3 +308,3 @@ });

this.el.innerHTML = '<em>lorem ipsum</em>';
selectElementContentsAndFire(editor.elements[0]);
selectElementContentsAndFire(editor.elements[0], { eventToFire: 'mouseup' });
expect(button.classList.contains('medium-editor-button-active')).toBe(true);

@@ -492,3 +492,3 @@ });

selectElementContentsAndFire(document.getElementById('span-lorem'));
selectElementContentsAndFire(document.getElementById('span-lorem'), { eventToFire: 'mouseup' });
expect(button.classList.contains('medium-editor-button-active')).toBe(false);

@@ -632,3 +632,3 @@ });

// Second paragraph should have justifyLeft activated
selectElementContentsAndFire(document.getElementById('justify-para-two'));
selectElementContentsAndFire(document.getElementById('justify-para-two'), { eventToFire: 'mouseup' });
expect(leftButton.classList.contains('medium-editor-button-active')).toBe(true);

@@ -647,3 +647,3 @@ expect(rightButton.classList.contains('medium-editor-button-active')).toBe(false);

// Third paragraph should have justifyRight activated
selectElementContentsAndFire(document.getElementById('justify-para-three'));
selectElementContentsAndFire(document.getElementById('justify-para-three'), { eventToFire: 'mouseup' });
expect(leftButton.classList.contains('medium-editor-button-active')).toBe(false);

@@ -662,3 +662,3 @@ expect(rightButton.classList.contains('medium-editor-button-active')).toBe(true);

// Fourth paragraph should have justifyCenter activated
selectElementContentsAndFire(document.getElementById('justify-para-four'));
selectElementContentsAndFire(document.getElementById('justify-para-four'), { eventToFire: 'mouseup' });
expect(leftButton.classList.contains('medium-editor-button-active')).toBe(false);

@@ -671,3 +671,3 @@ expect(rightButton.classList.contains('medium-editor-button-active')).toBe(false);

fireEvent(rightButton, 'click');
selectElementContentsAndFire(document.getElementById('justify-para-four'));
selectElementContentsAndFire(document.getElementById('justify-para-four'), { eventToFire: 'mouseup' });
expect(leftButton.classList.contains('medium-editor-button-active')).toBe(false);

@@ -679,3 +679,3 @@ expect(rightButton.classList.contains('medium-editor-button-active')).toBe(true);

// Fifth paragraph should have justifyFull activated
selectElementContentsAndFire(document.getElementById('justify-para-five'));
selectElementContentsAndFire(document.getElementById('justify-para-five'), { eventToFire: 'mouseup' });
expect(leftButton.classList.contains('medium-editor-button-active')).toBe(false);

@@ -731,7 +731,7 @@ expect(rightButton.classList.contains('medium-editor-button-active')).toBe(false);

selectElementContentsAndFire(editor.elements[0].querySelector('h3'));
selectElementContentsAndFire(editor.elements[0].querySelector('h3'), { eventToFire: 'mouseup' });
expect(buttonOne.classList.contains('medium-editor-button-active')).toBe(true);
expect(buttonTwo.classList.contains('medium-editor-button-active')).toBe(false);
selectElementContentsAndFire(editor.elements[0].querySelector('h4'));
selectElementContentsAndFire(editor.elements[0].querySelector('h4'), { eventToFire: 'mouseup' });
expect(buttonOne.classList.contains('medium-editor-button-active')).toBe(false);

@@ -758,7 +758,7 @@ expect(buttonTwo.classList.contains('medium-editor-button-active')).toBe(true);

selectElementContentsAndFire(editor.elements[0].querySelector('h3'));
selectElementContentsAndFire(editor.elements[0].querySelector('h3'), { eventToFire: 'mouseup' });
expect(buttonOne.classList.contains('medium-editor-button-active')).toBe(false);
expect(buttonTwo.classList.contains('medium-editor-button-active')).toBe(false);
selectElementContentsAndFire(editor.elements[0].querySelector('h5'));
selectElementContentsAndFire(editor.elements[0].querySelector('h5'), { eventToFire: 'mouseup' });
expect(buttonOne.classList.contains('medium-editor-button-active')).toBe(false);

@@ -765,0 +765,0 @@ expect(buttonTwo.classList.contains('medium-editor-button-active')).toBe(true);

@@ -32,3 +32,3 @@ /*global MediumEditor, describe, it, expect, afterEach,

paste: '><img src="x" onerror="alert(\'xss\')">',
output: '<p>&gt;&lt;img src="x" onerror="alert(\'xss\')"&gt;</p>'
output: '<span id="editor-inner">&gt;&lt;img src="x" onerror="alert(\'xss\')"&gt;</span>'
};

@@ -53,3 +53,3 @@

range = document.createRange();
range.selectNodeContents(editorEl);
range.selectNodeContents(editorEl.firstChild);
sel.removeAllRanges();

@@ -56,0 +56,0 @@ sel.addRange(range);

@@ -59,2 +59,4 @@ /*global atob, unescape, Uint8Array, Blob*/

evt.currentTarget = element;
if (options.keyCode) {

@@ -123,3 +125,3 @@ evt.keyCode = options.keyCode;

selectElementContents(el, options);
fireEvent(el, options.eventToFire || 'mouseup');
fireEvent(el, options.eventToFire || 'focus');
}

@@ -126,0 +128,0 @@

@@ -55,2 +55,23 @@ /*global MediumEditor, describe, it, expect, spyOn,

output: "<b>Bold,</b> <i>italic,</i> <b><i>bold and italic</i></b>, and <a href=\"http://en.wikipedia.org/wiki/Link_\\(The_Legend_of_Zelda\\)\">a link</a>\\."
}],
textTests = [
{
source: "Text single word",
paste: "supercalifragilisticexpalidocious",
output: '<div id="editor-inner">supercalifragilisticexpalidocious</div>'
},
{
source: "Text single word with leading/trailing space",
paste: " supercalifragilisticexpalidocious ",
output: '<div id="editor-inner"> supercalifragilisticexpalidocious </div>'
},
{
source: "Text multi-word with no line breaks",
paste: "Their relationship consisted in discussing if it existed",
output: '<div id="editor-inner">Their relationship consisted in discussing if it existed</div>'
},
{
source: 'Text with multiple line breaks',
paste: 'Only one thing made him happy\nAnd now that it was gone\nEverything made him happy\r\n',
output: '<div id="editor-inner"><p>Only one thing made him happy</p><p>And now that it was gone</p><p>Everything made him happy</p></div>'
}

@@ -228,2 +249,44 @@ ];

});
describe('text', function () {
it('handlePaste should handle text with/without linebreaks', function () {
var range, i,
editorEl = this.el,
sel = window.getSelection(),
editor = new MediumEditor('.editor', {
delay: 200,
disableReturn: false
}),
// mock event with clipboardData API
// test requires creating a function, so can't loop or jslint balks
evt = {
pasteText: null,
preventDefault: function () {
return;
},
clipboardData: {
getData: function () {
// do we need to return different results for the different types? text/plain, text/html
return this.pasteText;
}
}
};
for (i = 0; i < textTests.length; i += 1) {
editorEl.innerHTML = '<div id="editor-inner">&nbsp</div>';
range = document.createRange();
range.selectNodeContents(editorEl.firstChild);
sel.removeAllRanges();
sel.addRange(range);
evt.clipboardData.pasteText = textTests[i].paste;
editor.pasteHandler.handlePaste(evt, editorEl);
jasmine.clock().tick(100);
expect(editorEl.innerHTML).toEqual(textTests[i].output);
}
});
});
});

@@ -63,2 +63,4 @@ /*global MediumEditor, describe, it, expect,

var editor = new MediumEditor('.editor');
editor.elements[0].focus();
fireEvent(editor.elements[0], 'focus');
expect(editor.elements[0].className).not.toContain('medium-editor-placeholder');

@@ -65,0 +67,0 @@ editor.elements[0].innerHTML = '';

@@ -35,3 +35,3 @@ /*global MediumEditor, describe, it, expect,

var editor = new MediumEditor('.editor');
spyOn(MediumEditor.statics.Toolbar.prototype, 'setToolbarPosition');
spyOn(editor.toolbar, 'setToolbarPosition').and.callThrough();
fireEvent(window, 'resize');

@@ -52,3 +52,3 @@ jasmine.clock().tick(1);

spyOn(MediumEditor.statics.Toolbar.prototype, 'setToolbarPosition');
spyOn(editor.toolbar, 'setToolbarPosition').and.callThrough();
for (totalTicks = 0; totalTicks < tickTime; totalTicks += 10) {

@@ -55,0 +55,0 @@ fireEvent(window, 'resize');

@@ -92,5 +92,5 @@ /*global MediumEditor, describe, it, expect, spyOn,

});
selectElementContentsAndFire(document.getElementById('p-one'));
selectElementContentsAndFire(document.getElementById('p-one'), { eventToFire: 'focus' });
expect(editor.toolbar.getToolbarElement().classList.contains('medium-editor-toolbar-active')).toBe(true);
selectElementContentsAndFire(this.el);
selectElementContentsAndFire(this.el, { eventToFire: 'mouseup' });
expect(editor.toolbar.getToolbarElement().classList.contains('medium-editor-toolbar-active')).toBe(false);

@@ -119,7 +119,8 @@ });

it('should update button states when updateOnEmptySelection is true and the selection is empty', function () {
it('should update button states for static toolbar when updateOnEmptySelection is true and the selection is empty', function () {
spyOn(MediumEditor.statics.Toolbar.prototype, 'setToolbarButtonStates').and.callThrough();
var editor = new MediumEditor('.editor', {
updateOnEmptySelection: true
updateOnEmptySelection: true,
staticToolbar: true
});

@@ -126,0 +127,0 @@

@@ -83,3 +83,3 @@ /*global MediumEditor, describe, it, expect, spyOn,

editor.startSelectionUpdates();
selectElementContentsAndFire(document.getElementById('bold_dolorTwo'));
selectElementContentsAndFire(document.getElementById('bold_dolorTwo'), { eventToFire: 'mouseup' });

@@ -107,3 +107,3 @@ jasmine.clock().tick(51);

selectElementContentsAndFire(this.el);
selectElementContentsAndFire(this.el, { eventToFire: 'focus' });

@@ -142,10 +142,10 @@ expect(editor.toolbar.getToolbarElement().classList.contains('medium-editor-toolbar-active')).toBe(true);

placeCursorInsideElement(this.el.firstChild, 'This is my text'.length);
fireEvent(document.documentElement, 'mousedown', {
target: document.body
fireEvent(this.el.parentNode, 'click', {
target: this.el.parentNode,
currentTarget: this.el
});
fireEvent(this.el, 'blur', {
relatedTarget: document.createElement('div')
});
jasmine.clock().tick(1);
expect(editor.toolbar.getToolbarElement().classList.contains('medium-editor-toolbar-active')).toBe(false);
expect(window.getSelection().anchorNode).toBe(null);
expect(this.el.getAttribute('medium-editor-focused')).not.toBeTruthy();
});

@@ -160,3 +160,3 @@

selectElementContents(this.el.querySelector('b'));
selectElementContentsAndFire(this.el.querySelector('b'));
window.getSelection().removeAllRanges();

@@ -166,15 +166,5 @@ editor.checkSelection();

expect(editor.toolbar.getToolbarElement().classList.contains('medium-editor-toolbar-active')).toBe(true);
expect(editor.toolbar.getToolbarElement().querySelector('[data-action="bold"]').classList.contains('medium-editor-button-active')).toBe(false);
expect(editor.toolbar.getToolbarElement().querySelector('[data-action="bold"]').classList.contains('medium-editor-button-active')).toBe(true);
});
it('should update toolbar position when user clicks on medium editor element', function () {
var editor = new MediumEditor('.editor', {
staticToolbar: true
});
spyOn(MediumEditor.statics.Toolbar.prototype, 'setToolbarPosition').and.callThrough();
fireEvent(editor.elements[0], 'click');
jasmine.clock().tick(1); // checkSelection delay
expect(editor.toolbar.setToolbarPosition).toHaveBeenCalled();
});
it('should show and update toolbar buttons when staticToolbar and updateOnEmptySelection options are set to true', function () {

@@ -188,3 +178,3 @@ this.el.innerHTML = '<b>lorem ipsum</b>';

selectElementContents(this.el.querySelector('b'));
selectElementContentsAndFire(this.el.querySelector('b'));
window.getSelection().getRangeAt(0).collapse(false);

@@ -211,3 +201,7 @@ editor.checkSelection();

selectElementContentsAndFire(document.getElementById('editor-span-1'));
selectElementContents(document.getElementById('editor-span-1'));
fireEvent(this.el, 'focus', {
target: this.el,
relatedTarget: elTwo
});

@@ -219,3 +213,3 @@ jasmine.clock().tick(1); // checkSelection delay

selectElementContentsAndFire(document.getElementById('editor-span-2'));
selectElementContents(document.getElementById('editor-span-2'));
fireEvent(elTwo, 'focus', {

@@ -317,4 +311,3 @@ target: elTwo,

expect(editor.toolbar.getToolbarElement().style.display).toBe('');
selectElementContents(this.el);
editor.checkSelection();
selectElementContentsAndFire(this.el, { eventToFire: 'focus'});

@@ -321,0 +314,0 @@ expect(editor.toolbar.getToolbarElement().classList.contains('medium-editor-toolbar-active')).toBe(true);

@@ -560,3 +560,3 @@ /*global FileReader, Util, ButtonsData, DefaultButton,

var self = this;
setTimeout(function () {
return setTimeout(function () {
if (self.isActive) {

@@ -715,5 +715,3 @@ fn();

selectAllContents: function () {
var range = this.options.ownerDocument.createRange(),
sel = this.options.contentWindow.getSelection(),
currNode = Selection.getSelectionElement(this.options.contentWindow);
var currNode = Selection.getSelectionElement(this.options.contentWindow);

@@ -726,8 +724,15 @@ if (currNode) {

range.selectNodeContents(currNode);
sel.removeAllRanges();
sel.addRange(range);
this.selectElement(currNode);
}
},
selectElement: function (element) {
Selection.selectNode(element, this.options.ownerDocument);
var selElement = Selection.getSelectionElement(this.options.contentWindow);
if (selElement) {
this.events.focusElement(selElement);
}
},
// http://stackoverflow.com/questions/17678843/cant-restore-selection-after-html-modify-even-if-its-the-same-html

@@ -734,0 +739,0 @@ // Tim Down

@@ -82,3 +82,3 @@ /*global Util, Selection */

case 'externalInteraction':
// Detecting when focus is lost
// Detecting when user has interacted with elements outside of MediumEditor
this.attachDOMEvent(this.options.ownerDocument.body, 'click', this.handleInteraction.bind(this), true);

@@ -88,2 +88,12 @@ this.attachDOMEvent(this.options.ownerDocument.body, 'focus', this.handleInteraction.bind(this), true);

break;
case 'blur':
// Detecting when focus is lost
this.setupListener('externalInteraction');
this.listeners[name] = true;
break;
case 'focus':
// Detecting when focus moves into some part of MediumEditor
this.setupListener('externalInteraction');
this.listeners[name] = true;
break;
case 'editableClick':

@@ -110,2 +120,9 @@ // Detecting click in the contenteditables

break;
case 'editableKeyup':
// Detecting keyup in the contenteditables
this.base.elements.forEach(function (element) {
this.attachDOMEvent(element, 'keyup', this.handleKeyup.bind(this));
}.bind(this));
this.listeners[name] = true;
break;
case 'editableKeydown':

@@ -165,5 +182,13 @@ // Detecting keydown on the contenteditables

focusElement: function (element) {
element.focus();
this.updateFocus(element, { target: element, type: 'focus' });
},
handleInteraction: function (event) {
var isDescendantOfEditorElements = false,
selection = this.options.contentWindow.getSelection(),
this.updateFocus(event.target, event);
},
updateFocus: function (target, eventObj) {
var selection = this.options.contentWindow.getSelection(),
toolbarEl = this.base.toolbar ? this.base.toolbar.getToolbarElement() : null,

@@ -175,20 +200,48 @@ anchorPreview = this.base.getExtensionByName('anchor-preview'),

Selection.getSelectedParentElement(selection.getRangeAt(0)),
i;
focused,
toFocus;
// This control was introduced also to avoid the toolbar
// to disapper when selecting from right to left and
// the selection ends at the beginning of the text.
for (i = 0; i < this.base.elements.length; i += 1) {
if (this.base.elements[i] === event.target ||
Util.isDescendant(this.base.elements[i], event.target) ||
Util.isDescendant(this.base.elements[i], selRange)) {
isDescendantOfEditorElements = true;
break;
this.base.elements.some(function (element) {
// Find the element that has focus
if (!focused && element.getAttribute('data-medium-focused')) {
focused = element;
}
// Find the element that is receiving focus
if (!toFocus &&
// target is part of an editor element
(Util.isDescendant(element, target, true) ||
// introduced also to avoid the toolbar to disapper when selecting from right to left and the selection ends at the beginning of the text.
Util.isDescendant(element, selRange))) {
toFocus = element;
}
// bail if we found both focused and toFocus elements
return !!focused && !!toFocus;
}, this);
// Check if the target is external (not part of the editor, toolbar, or anchorpreview)
var externalEvent = !Util.isDescendant(focused, target, true) &&
!Util.isDescendant(toolbarEl, target, true) &&
!Util.isDescendant(previewEl, target, true);
if (toFocus !== focused) {
// If element has focus, and focus is going outside of editor
// Don't blur focused element if clicking on editor, toolbar, or anchorpreview
if (focused && externalEvent) {
// Trigger blur on the editable that has lost focus
focused.removeAttribute('data-medium-focused');
this.triggerCustomEvent('blur', eventObj, focused);
}
// If focus is going into an editor element
if (toFocus) {
// Trigger focus on the editable that now has focus
toFocus.setAttribute('data-medium-focused', true);
this.triggerCustomEvent('focus', eventObj, toFocus);
}
}
// If it's not part of the editor, toolbar, or anchor preview
if (!isDescendantOfEditorElements &&
(!toolbarEl || (toolbarEl !== event.target && !Util.isDescendant(toolbarEl, event.target))) &&
(!previewEl || (previewEl !== event.target && !Util.isDescendant(previewEl, event.target)))) {
this.triggerCustomEvent('externalInteraction', event);
if (externalEvent) {
this.triggerCustomEvent('externalInteraction', eventObj);
}

@@ -209,2 +262,6 @@ },

handleKeyup: function (event) {
this.triggerCustomEvent('editableKeyup', event, event.currentTarget);
},
handleMouseover: function (event) {

@@ -211,0 +268,0 @@ this.triggerCustomEvent('editableMouseover', event, event.currentTarget);

@@ -111,14 +111,8 @@ var AnchorPreview;

handleClick: function () {
var range,
sel,
anchorExtension = this.base.getExtensionByName('anchor'),
var anchorExtension = this.base.getExtensionByName('anchor'),
activeAnchor = this.activeAnchor;
if (anchorExtension && activeAnchor) {
range = this.base.options.ownerDocument.createRange();
range.selectNodeContents(this.activeAnchor);
this.base.selectElement(this.activeAnchor);
sel = this.base.options.contentWindow.getSelection();
sel.removeAllRanges();
sel.addRange(range);
// Using setTimeout + options.delay because:

@@ -125,0 +119,0 @@ // We may actually be displaying the anchor form, which should be controlled by options.delay

@@ -105,13 +105,17 @@ /*global Util, Selection*/

if (!(this.options.disableReturn || element.getAttribute('data-disable-return'))) {
paragraphs = event.clipboardData.getData(dataFormatPlain).split(/[\r\n]/g);
for (p = 0; p < paragraphs.length; p += 1) {
if (paragraphs[p] !== '') {
html += '<p>' + Util.htmlEntities(paragraphs[p]) + '</p>';
paragraphs = event.clipboardData.getData(dataFormatPlain).split(/[\r\n]+/g);
// If there are no \r\n in data, don't wrap in <p>
if (paragraphs.length > 1) {
for (p = 0; p < paragraphs.length; p += 1) {
if (paragraphs[p] !== '') {
html += '<p>' + Util.htmlEntities(paragraphs[p]) + '</p>';
}
}
} else {
html = Util.htmlEntities(paragraphs[0]);
}
Util.insertHTMLCommand(this.options.ownerDocument, html);
} else {
html = Util.htmlEntities(event.clipboardData.getData(dataFormatPlain));
Util.insertHTMLCommand(this.options.ownerDocument, html);
}
Util.insertHTMLCommand(this.options.ownerDocument, html);
}

@@ -118,0 +122,0 @@ },

@@ -45,3 +45,3 @@ var Placeholders;

// Custom events
this.base.subscribe('externalInteraction', this.handleExternalInteraction.bind(this));
this.base.subscribe('blur', this.handleExternalInteraction.bind(this));

@@ -48,0 +48,0 @@ // Check placeholder on blur

@@ -98,4 +98,13 @@ /*global Util */

return selectedParentElement;
},
selectNode: function (node, doc) {
var range = doc.createRange(),
sel = doc.getSelection();
range.selectNodeContents(node);
sel.removeAllRanges();
sel.addRange(range);
}
};
}());

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

/*global Util, Selection*/
/*global Util, Selection */

@@ -40,3 +40,2 @@ var Toolbar;

this.attachEventHandlers();
this.base.subscribe('externalInteraction', this.handleBlur.bind(this));

@@ -115,3 +114,11 @@ return toolbar;

attachEventHandlers: function () {
this.base.on(this.options.ownerDocument.documentElement, 'mousedown', this.handleDocumentMousedown.bind(this));
// MediumEditor custom events for when user beings and ends interaction with a contenteditable and its elements
this.base.subscribe('blur', this.handleBlur.bind(this));
this.base.subscribe('focus', this.handleFocus.bind(this));
// Updating the state of the toolbar as things change
this.base.subscribe('editableClick', this.handleEditableClick.bind(this));
this.base.subscribe('editableKeyup', this.handleEditableKeyup.bind(this));
// Handle mouseup on document for updating the selection in the toolbar

@@ -128,14 +135,2 @@ this.base.on(this.options.ownerDocument.documentElement, 'mouseup', this.handleDocumentMouseup.bind(this));

this.base.on(this.options.contentWindow, 'resize', this.handleWindowResize.bind(this));
// Handlers for each contentedtiable element
this.base.elements.forEach(function (element) {
// Attach click handler to each contenteditable element
this.base.on(element, 'click', this.handleEditableClick.bind(this));
// Attach keyup handler to each contenteditable element
this.base.on(element, 'keyup', this.handleEditableKeyup.bind(this));
// Attach blur handler to each contenteditable element
this.base.on(element, 'blur', this.handleEditableBlur.bind(this));
}, this);
},

@@ -151,8 +146,3 @@

handleDocumentMousedown: function (event) {
this.lastMousedownTarget = event.target;
},
handleDocumentMouseup: function (event) {
this.lastMousedownTarget = null;
// Do not trigger checkState when mouseup fires over the toolbar

@@ -179,32 +169,7 @@ if (event &&

handleEditableBlur: function (event) {
var isRelatedTargetOwnedByThisEditor = false,
relatedTarget = (event && event.relatedTarget) ? event.relatedTarget : this.lastMousedownTarget;
// Do not trigger checkState when blurring the editable area and clicking into the toolbar
if (Util.isDescendant(this.getToolbarElement(), relatedTarget)) {
return false;
}
if (relatedTarget) {
// Remove all selections before checking state. This is necessary to avoid issues with
// standardizeSelectionStart 'canceling' the blur event by moving the selection (in Chrome only).
// In Safari, when you click on a non-button element outside of the contenteditable, the selection
// is already nulled out by the browser at this point, but remained set in Chrome, Firefox, and IE11.
// This change will effectively normalize all browsers' behavior to be the same as Safari.
this.base.elements.forEach(function (el) {
isRelatedTargetOwnedByThisEditor = isRelatedTargetOwnedByThisEditor || Util.isDescendant(el, relatedTarget) ||
relatedTarget === el;
}, this);
// We only remove all the ranges if the user clicked outside the contenteditables managed by this
// medium-editor instance. Otherwise keep the ranges if they are set, we need the range to be present
// for various things done by the toolbar to work.
if (!isRelatedTargetOwnedByThisEditor) {
this.options.contentWindow.getSelection().removeAllRanges();
}
}
this.checkState();
},
handleBlur: function () {
clearTimeout(this.hideTimeout);
handleBlur: function () {
// Delay the call to hideToolbar to handle bug with multiple editors on the page at once
setTimeout(function () {
this.hideTimeout = setTimeout(function () {
this.hideToolbar();

@@ -214,2 +179,6 @@ }.bind(this), 0);

handleFocus: function () {
this.checkState();
},
// Hiding/showing toolbar

@@ -222,2 +191,3 @@

showToolbar: function () {
clearTimeout(this.hideTimeout);
if (!this.isDisplayed()) {

@@ -291,10 +261,5 @@ this.getToolbarElement().classList.add('medium-editor-toolbar-active');

// TODO: selection and selectionRange should be properties of the
// Selection object
checkSelectionElement: function (newSelection, selectionElement) {
var i,
adjacentNode,
offset = 0,
newRange,
selectionRange = newSelection.getRangeAt(0);
modifySelection: function () {
var selection = this.options.contentWindow.getSelection(),
selectionRange = selection.getRangeAt(0);

@@ -320,53 +285,55 @@ /*

(selectionRange.startOffset === selectionRange.startContainer.nodeValue.length)) {
adjacentNode = Util.findAdjacentTextNodeWithContent(Selection.getSelectionElement(this.options.contentWindow), selectionRange.startContainer, this.options.ownerDocument);
var adjacentNode = Util.findAdjacentTextNodeWithContent(Selection.getSelectionElement(this.options.contentWindow), selectionRange.startContainer, this.options.ownerDocument);
if (adjacentNode) {
offset = 0;
var offset = 0;
while (adjacentNode.nodeValue.substr(offset, 1).trim().length === 0) {
offset = offset + 1;
}
newRange = this.options.ownerDocument.createRange();
var newRange = this.options.ownerDocument.createRange();
newRange.setStart(adjacentNode, offset);
newRange.setEnd(selectionRange.endContainer, selectionRange.endOffset);
newSelection.removeAllRanges();
newSelection.addRange(newRange);
selection.removeAllRanges();
selection.addRange(newRange);
selectionRange = newRange;
}
}
for (i = 0; i < this.base.elements.length; i += 1) {
if (this.base.elements[i] === selectionElement) {
this.showAndUpdateToolbar();
return;
}
}
if (!this.options.staticToolbar) {
this.hideToolbar();
}
},
checkState: function () {
var newSelection,
selectionElement;
if (!this.base.preventSelectionUpdates) {
newSelection = this.options.contentWindow.getSelection();
if ((!this.options.updateOnEmptySelection && newSelection.toString().trim() === '') ||
(this.options.allowMultiParagraphSelection === false && this.multipleBlockElementsSelected()) ||
// If no editable has focus OR selection is inside contenteditable = false
// hide toolbar
if (!this.getFocusedElement() ||
Selection.selectionInContentEditableFalse(this.options.contentWindow)) {
if (!this.options.staticToolbar) {
this.hideToolbar();
} else {
this.showAndUpdateToolbar();
}
this.hideToolbar();
return;
}
// If there's no selection element, selection element doesn't belong to this editor
// or toolbar is disabled for this selection element
// hide toolbar
var selectionElement = Selection.getSelectionElement(this.options.contentWindow);
if (!selectionElement ||
this.base.elements.indexOf(selectionElement) === -1 ||
selectionElement.getAttribute('data-disable-toolbar')) {
this.hideToolbar();
return;
}
// Now we know there's a focused editable with a selection
// If the updateOnEmptySelection option is true, show the toolbar
if (this.options.updateOnEmptySelection && this.options.staticToolbar) {
this.showAndUpdateToolbar();
return;
}
// If we don't have a "valid" selection -> hide toolbar
if (this.options.contentWindow.getSelection().toString().trim() === '' ||
(this.options.allowMultiParagraphSelection === false && this.multipleBlockElementsSelected())) {
this.hideToolbar();
} else {
selectionElement = Selection.getSelectionElement(this.options.contentWindow);
if (!selectionElement || selectionElement.getAttribute('data-disable-toolbar')) {
if (!this.options.staticToolbar) {
this.hideToolbar();
}
} else {
this.checkSelectionElement(newSelection, selectionElement);
}
this.showAndUpdateToolbar();
}

@@ -376,5 +343,15 @@ }

getFocusedElement: function () {
for (var i = 0; i < this.base.elements.length; i += 1) {
if (this.base.elements[i].getAttribute('data-medium-focused')) {
return this.base.elements[i];
}
}
return null;
},
// Updating the toolbar
showAndUpdateToolbar: function () {
this.modifySelection();
this.setToolbarButtonStates();

@@ -455,3 +432,3 @@ this.showToolbarDefaultActions();

setToolbarPosition: function () {
var container = Selection.getSelectionElement(this.options.contentWindow),
var container = this.getFocusedElement(),
selection = this.options.contentWindow.getSelection(),

@@ -461,11 +438,6 @@ anchorPreview;

// If there isn't a valid selection, bail
if (!container || !this.options.contentWindow.getSelection().focusNode) {
if (!container) {
return this;
}
// If the container isn't part of this medium-editor instance, bail
if (this.base.elements.indexOf(container) === -1) {
return this;
}
if (this.options.staticToolbar) {

@@ -534,3 +506,3 @@ this.showToolbar();

} else if ((targetLeft + toolbarWidth) > windowWidth) {
targetLeft = windowWidth - toolbarWidth;
targetLeft = (windowWidth - Math.ceil(toolbarWidth) - 1);
}

@@ -537,0 +509,0 @@

@@ -119,6 +119,9 @@ /*global NodeFilter, console*/

isDescendant: function isDescendant(parent, child) {
isDescendant: function isDescendant(parent, child, checkEquality) {
if (!parent || !child) {
return false;
}
if (checkEquality && parent === child) {
return true;
}
var node = child.parentNode;

@@ -125,0 +128,0 @@ while (node !== null) {

@@ -14,3 +14,3 @@

// grunt-bump looks for this:
"version": "4.3.0"
"version": "4.4.0"
}).version.split("."));

Sorry, the diff of this file is not supported yet

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

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc