Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

medium-editor

Package Overview
Dependencies
Maintainers
1
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 2.0.0 to 2.1.0

spec/delay.spec.js

2

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

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

@@ -0,1 +1,14 @@

2.1.0 / 2015-01-27
==================
* Handles ESC key in link editor
* Standardizes usage of setTimeout for UX delays vs debouncing vs deferring
* Adds an optional onShowToolbar method
* Supports enabling/disabling checkSelection updates externally
* Standardizes where in the DOM a range begins
* Adds ARIA role information
* Fixes off() not removing any event listeners
* Misc minor bug fixes and improvements
2.0.0 / 2015-01-06

@@ -2,0 +15,0 @@ ==================

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

function MediumEditor(a,b){"use strict";return this.init(a,b)}"object"==typeof module?module.exports=MediumEditor:"function"==typeof define&&define.amd&&define(function(){"use strict";return MediumEditor}),function(a,b){"use strict";function c(a,b){var c;if(void 0===a)return b;for(c in b)b.hasOwnProperty(c)&&a.hasOwnProperty(c)===!1&&(a[c]=b[c]);return a}function d(a,b){for(var c=b.parentNode;null!==c;){if(c===a)return!0;c=c.parentNode}return!1}function e(){var a,b,c,d=this.options.contentWindow.getSelection();if(d.getRangeAt&&d.rangeCount){for(c=[],a=0,b=d.rangeCount;b>a;a+=1)c.push(d.getRangeAt(a));return c}return null}function f(a){var b,c,d=this.options.contentWindow.getSelection();if(a)for(d.removeAllRanges(),b=0,c=a.length;c>b;b+=1)d.addRange(a[b])}function g(){var a=this.options.ownerDocument.getSelection().anchorNode,b=a&&3===a.nodeType?a.parentNode:a;return b}function h(){var a,b,c,d,e="";if(void 0!==this.options.contentWindow.getSelection){if(b=this.options.contentWindow.getSelection(),b.rangeCount){for(d=this.options.ownerDocument.createElement("div"),a=0,c=b.rangeCount;c>a;a+=1)d.appendChild(b.getRangeAt(a).cloneContents());e=d.innerHTML}}else void 0!==this.options.ownerDocument.selection&&"Text"===this.options.ownerDocument.selection.type&&(e=this.options.ownerDocument.selection.createRange().htmlText);return e}function i(a){return!(!a||1!==a.nodeType)}function j(b,c){var d,e,f,g,h,i;if(b.queryCommandSupported("insertHTML"))return b.execCommand("insertHTML",!1,c);if(d=a.getSelection(),d.getRangeAt&&d.rangeCount){for(e=d.getRangeAt(0),e.deleteContents(),f=b.createElement("div"),f.innerHTML=c,g=b.createDocumentFragment();f.firstChild;)h=f.firstChild,i=g.appendChild(h);e.insertNode(g),i&&(e=e.cloneRange(),e.setStartAfter(i),e.collapse(!0),d.removeAllRanges(),d.addRange(e))}}MediumEditor.prototype={defaults:{allowMultiParagraphSelection:!0,anchorInputPlaceholder:"Paste or type a link",anchorPreviewHideDelay:500,buttons:["bold","italic","underline","anchor","header1","header2","quote"],buttonLabels:!1,checkLinkFormat:!1,cleanPastedHTML:!1,delay:0,diffLeft:0,diffTop:-10,disableReturn:!1,disableDoubleReturn:!1,disableToolbar:!1,disableEditing:!1,disableAnchorForm:!1,disablePlaceholders:!1,elementsContainer:!1,contentWindow:a,ownerDocument:b,firstHeader:"h3",forcePlainText:!0,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"},isIE:"Microsoft Internet Explorer"===navigator.appName||"Netscape"===navigator.appName&&null!==new RegExp("Trident/.*rv:([0-9]{1,}[.0-9]{0,})").exec(navigator.userAgent),init:function(a,d){var e=1;if(this.options=c(d,this.defaults),this.setElementSelection(a),0!==this.elements.length){for(this.parentElements=["p","h1","h2","h3","h4","h5","h6","blockquote","pre"],this.options.elementsContainer||(this.options.elementsContainer=b.body);this.options.elementsContainer.querySelector("#medium-editor-toolbar-"+e);)e+=1;return this.id=e,this.setup()}},setup:function(){this.events=[],this.isActive=!0,this.initElements().bindSelect().bindPaste().setPlaceholders().bindElementActions().bindWindowActions().passInstance()},on:function(a,b,c,d){a.addEventListener(b,c,d),this.events.push([a,b,c,d])},off:function(a,b,c,d){var e,f=this.events.indexOf([a,b,c,d]);-1!==f&&(e=this.events.splice(f,1),e[0].removeEventListener(e[1],e[2],e[3]))},removeAllEvents:function(){for(var a=this.events.pop();a;)a[0].removeEventListener(a[1],a[2],a[3]),a=this.events.pop()},initElements:function(){this.updateElementList();var a,b=!1;for(a=0;a<this.elements.length;a+=1)this.options.disableEditing||this.elements[a].getAttribute("data-disable-editing")||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.bindParagraphCreation(a),this.options.disableToolbar||this.elements[a].getAttribute("data-disable-toolbar")||(b=!0);return b&&this.initToolbar().bindButtons().bindAnchorForm().bindAnchorPreview(),this},setElementSelection:function(a){this.elementSelection=a,this.updateElementList()},updateElementList:function(){this.elements="string"==typeof this.elementSelection?this.options.ownerDocument.querySelectorAll(this.elementSelection):this.elementSelection,1===this.elements.nodeType&&(this.elements=[this.elements])},bindBlur:function(){var a,c=this,e=function(b){b.target===c.toolbar||b.target===c.elements[0]||d(c.elements[0],b.target)||d(c.toolbar,b.target)||d(c.anchorPreview,b.target)||(c.options.disablePlaceholders||c.placeholderWrapper(c.elements[0],b),clearTimeout(a),a=setTimeout(function(){c.keepToolbarAlive||c.hideToolbarActions()},200))};return this.on(b.body,"click",e,!0),this.on(b.body,"focus",e,!0),this},bindKeypress:function(a){if(this.options.disablePlaceholders)return this;var b=this;return this.on(this.elements[a],"keypress",function(a){b.placeholderWrapper(this,a)}),this},bindClick:function(a){var b=this;return this.on(this.elements[a],"click",function(){b.options.disablePlaceholders||this.classList.remove("medium-editor-placeholder"),b.options.staticToolbar&&b.setToolbarPosition()}),this},bindElementActions:function(){var a;for(a=0;a<this.elements.length;a+=1)this.options.disablePlaceholders||this.activatePlaceholder(this.elements[a]),this.bindReturn(a).bindTab(a).bindBlur(a).bindClick(a).bindKeypress(a);return this},activatePlaceholder:function(a){a.querySelector("img")||a.querySelector("blockquote")||""!==a.textContent.replace(/^\s+|\s+$/g,"")||a.classList.add("medium-editor-placeholder")},placeholderWrapper:function(a,b){a.classList.remove("medium-editor-placeholder"),"keypress"!==b.type&&this.activatePlaceholder(a)},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},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))}},passInstance:function(){var a,b,c=this;for(b in c.options.extensions)c.options.extensions.hasOwnProperty(b)&&(a=c.options.extensions[b],a.parent&&(a.base=c));return c},bindParagraphCreation:function(a){var c=this;return this.on(this.elements[a],"keypress",function(a){var d,e;32===a.which&&(d=g.call(c),e=d.tagName.toLowerCase(),"a"===e&&b.execCommand("unlink",!1,null))}),this.on(this.elements[a],"keyup",function(a){var d,e,f=g.call(c);f&&f.getAttribute("data-medium-element")&&0===f.children.length&&!c.options.disableReturn&&!f.getAttribute("data-disable-return")&&b.execCommand("formatBlock",!1,"p"),13===a.which&&(f=g.call(c),d=f.tagName.toLowerCase(),e=c.getSelectionElement(),c.options.disableReturn||e.getAttribute("data-disable-return")||"li"===d||c.isListItemChild(f)||(a.shiftKey||b.execCommand("formatBlock",!1,"p"),"a"===d&&b.execCommand("unlink",!1,null)))}),this},isListItemChild:function(a){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},bindReturn:function(a){var b=this;return this.on(this.elements[a],"keypress",function(a){if(13===a.which)if(b.options.disableReturn||this.getAttribute("data-disable-return"))a.preventDefault();else if(b.options.disableDoubleReturn||this.getAttribute("data-disable-double-return")){var c=g.call(b);c&&"\n"===c.textContent&&a.preventDefault()}}),this},bindTab:function(a){var c=this;return this.on(this.elements[a],"keydown",function(a){if(9===a.which){var d=g.call(c).tagName.toLowerCase();"pre"===d&&(a.preventDefault(),b.execCommand("insertHtml",null," ")),"li"===d&&(a.preventDefault(),a.shiftKey?b.execCommand("outdent",a):b.execCommand("indent",a))}}),this},buttonTemplate:function(a){var b=this.getButtonLabels(this.options.buttonLabels),c={bold:'<button class="medium-editor-action medium-editor-action-bold" data-action="bold" data-element="b">'+b.bold+"</button>",italic:'<button class="medium-editor-action medium-editor-action-italic" data-action="italic" data-element="i">'+b.italic+"</button>",underline:'<button class="medium-editor-action medium-editor-action-underline" data-action="underline" data-element="u">'+b.underline+"</button>",strikethrough:'<button class="medium-editor-action medium-editor-action-strikethrough" data-action="strikethrough" data-element="strike">'+b.strikethrough+"</button>",superscript:'<button class="medium-editor-action medium-editor-action-superscript" data-action="superscript" data-element="sup">'+b.superscript+"</button>",subscript:'<button class="medium-editor-action medium-editor-action-subscript" data-action="subscript" data-element="sub">'+b.subscript+"</button>",anchor:'<button class="medium-editor-action medium-editor-action-anchor" data-action="anchor" data-element="a">'+b.anchor+"</button>",image:'<button class="medium-editor-action medium-editor-action-image" data-action="image" data-element="img">'+b.image+"</button>",header1:'<button class="medium-editor-action medium-editor-action-header1" data-action="append-'+this.options.firstHeader+'" data-element="'+this.options.firstHeader+'">'+b.header1+"</button>",header2:'<button class="medium-editor-action medium-editor-action-header2" data-action="append-'+this.options.secondHeader+'" data-element="'+this.options.secondHeader+'">'+b.header2+"</button>",quote:'<button class="medium-editor-action medium-editor-action-quote" data-action="append-blockquote" data-element="blockquote">'+b.quote+"</button>",orderedlist:'<button class="medium-editor-action medium-editor-action-orderedlist" data-action="insertorderedlist" data-element="ol">'+b.orderedlist+"</button>",unorderedlist:'<button class="medium-editor-action medium-editor-action-unorderedlist" data-action="insertunorderedlist" data-element="ul">'+b.unorderedlist+"</button>",pre:'<button class="medium-editor-action medium-editor-action-pre" data-action="append-pre" data-element="pre">'+b.pre+"</button>",indent:'<button class="medium-editor-action medium-editor-action-indent" data-action="indent" data-element="ul">'+b.indent+"</button>",outdent:'<button class="medium-editor-action medium-editor-action-outdent" data-action="outdent" data-element="ul">'+b.outdent+"</button>",justifyCenter:'<button class="medium-editor-action medium-editor-action-justifyCenter" data-action="justifyCenter" data-element="">'+b.justifyCenter+"</button>",justifyFull:'<button class="medium-editor-action medium-editor-action-justifyFull" data-action="justifyFull" data-element="">'+b.justifyFull+"</button>",justifyLeft:'<button class="medium-editor-action medium-editor-action-justifyLeft" data-action="justifyLeft" data-element="">'+b.justifyLeft+"</button>",justifyRight:'<button class="medium-editor-action medium-editor-action-justifyRight" data-action="justifyRight" data-element="">'+b.justifyRight+"</button>"};return c[a]||!1},getButtonLabels:function(a){var b,c,d={bold:"<b>B</b>",italic:"<b><i>I</i></b>",underline:"<b><u>U</u></b>",strikethrough:"<s>A</s>",superscript:"<b>x<sup>1</sup></b>",subscript:"<b>x<sub>1</sub></b>",anchor:"<b>#</b>",image:"<b>image</b>",header1:"<b>H1</b>",header2:"<b>H2</b>",quote:"<b>&ldquo;</b>",orderedlist:"<b>1.</b>",unorderedlist:"<b>&bull;</b>",pre:"<b>0101</b>",indent:"<b>&rarr;</b>",outdent:"<b>&larr;</b>",justifyCenter:"<b>C</b>",justifyFull:"<b>J</b>",justifyLeft:"<b>L</b>",justifyRight:"<b>R</b>"};if("fontawesome"===a?b={bold:'<i class="fa fa-bold"></i>',italic:'<i class="fa fa-italic"></i>',underline:'<i class="fa fa-underline"></i>',strikethrough:'<i class="fa fa-strikethrough"></i>',superscript:'<i class="fa fa-superscript"></i>',subscript:'<i class="fa fa-subscript"></i>',anchor:'<i class="fa fa-link"></i>',image:'<i class="fa fa-picture-o"></i>',quote:'<i class="fa fa-quote-right"></i>',orderedlist:'<i class="fa fa-list-ol"></i>',unorderedlist:'<i class="fa fa-list-ul"></i>',pre:'<i class="fa fa-code fa-lg"></i>',indent:'<i class="fa fa-indent"></i>',outdent:'<i class="fa fa-outdent"></i>',justifyCenter:'<i class="fa fa-align-center"></i>',justifyFull:'<i class="fa fa-align-justify"></i>',justifyLeft:'<i class="fa fa-align-left"></i>',justifyRight:'<i class="fa fa-align-right"></i>'}:"object"==typeof a&&(b=a),"object"==typeof b)for(c in b)b.hasOwnProperty(c)&&(d[c]=b[c]);return d},initToolbar:function(){return this.toolbar?this:(this.toolbar=this.createToolbar(),this.keepToolbarAlive=!1,this.toolbarActions=this.toolbar.querySelector(".medium-editor-toolbar-actions"),this.anchorPreview=this.createAnchorPreview(),this.options.disableAnchorForm||(this.anchorForm=this.toolbar.querySelector(".medium-editor-toolbar-form-anchor"),this.anchorInput=this.anchorForm.querySelector("input.medium-editor-toolbar-anchor-input"),this.anchorTarget=this.anchorForm.querySelector("input.medium-editor-toolbar-anchor-target"),this.anchorButton=this.anchorForm.querySelector("input.medium-editor-toolbar-anchor-button")),this)},createToolbar:function(){var a=b.createElement("div");return a.id="medium-editor-toolbar-"+this.id,a.className="medium-editor-toolbar",a.className+=this.options.staticToolbar?" static-toolbar":" stalker-toolbar",a.appendChild(this.toolbarButtons()),this.options.disableAnchorForm||a.appendChild(this.toolbarFormAnchor()),this.options.elementsContainer.appendChild(a),a},toolbarButtons:function(){var a,c,d,e,f=this.options.buttons,g=b.createElement("ul");for(g.id="medium-editor-toolbar-actions"+this.id,g.className="medium-editor-toolbar-actions clearfix",c=0;c<f.length;c+=1)this.options.extensions.hasOwnProperty(f[c])?(e=this.options.extensions[f[c]],d=void 0!==e.getButton?e.getButton():null):d=this.buttonTemplate(f[c]),d&&(a=b.createElement("li"),i(d)?a.appendChild(d):a.innerHTML=d,g.appendChild(a));return g},toolbarFormAnchor:function(){var a=b.createElement("div"),c=b.createElement("input"),d=b.createElement("label"),e=b.createElement("input"),f=b.createElement("label"),g=b.createElement("input"),h=b.createElement("a"),i=b.createElement("a");return h.setAttribute("href","#"),h.className="medium-editor-toobar-anchor-close",h.innerHTML="&times;",i.setAttribute("href","#"),i.className="medium-editor-toobar-anchor-save",i.innerHTML="&#10003;",c.setAttribute("type","text"),c.className="medium-editor-toolbar-anchor-input",c.setAttribute("placeholder",this.options.anchorInputPlaceholder),e.setAttribute("type","checkbox"),e.className="medium-editor-toolbar-anchor-target",d.innerHTML="Open in New Window?",d.insertBefore(e,d.firstChild),g.setAttribute("type","checkbox"),g.className="medium-editor-toolbar-anchor-button",f.innerHTML="Button",f.insertBefore(g,f.firstChild),a.className="medium-editor-toolbar-form-anchor",a.id="medium-editor-toolbar-form-anchor-"+this.id,a.appendChild(c),a.appendChild(i),a.appendChild(h),this.options.anchorTarget&&a.appendChild(d),this.options.anchorButton&&a.appendChild(f),a},bindSelect:function(){var a,c=this,d="";for(this.checkSelectionWrapper=function(a){return!c.options.disableAnchorForm&&a&&c.clickingIntoArchorForm(a)?!1:(clearTimeout(d),void(d=setTimeout(function(){c.checkSelection()},c.options.delay)))},this.on(b.documentElement,"mouseup",this.checkSelectionWrapper),a=0;a<this.elements.length;a+=1)this.on(this.elements[a],"keyup",this.checkSelectionWrapper),this.on(this.elements[a],"blur",this.checkSelectionWrapper),this.on(this.elements[a],"click",this.checkSelectionWrapper);return this},checkSelection:function(){var a,b;return this.keepToolbarAlive===!0||this.options.disableToolbar||(a=this.options.contentWindow.getSelection(),!this.options.updateOnEmptySelection&&""===a.toString().trim()||this.options.allowMultiParagraphSelection===!1&&this.hasMultiParagraphs()||this.selectionInContentEditableFalse()?this.options.staticToolbar?this.anchorForm&&"block"===this.anchorForm.style.display&&(this.setToolbarButtonStates(),this.showToolbarActions()):this.hideToolbarActions():(b=this.getSelectionElement(),!b||b.getAttribute("data-disable-toolbar")?this.options.staticToolbar||this.hideToolbarActions():this.checkSelectionElement(a,b))),this},clickingIntoArchorForm:function(a){var b=this;return a.type&&"blur"===a.type.toLowerCase()&&a.relatedTarget&&a.relatedTarget===b.anchorInput?!0:!1},hasMultiParagraphs:function(){var a=h.call(this).replace(/<[\S]+><\/[\S]+>/gim,""),b=a.match(/<(p|h[0-6]|blockquote)>([\s\S]*?)<\/(p|h[0-6]|blockquote)>/g);return b?b.length:0},checkSelectionElement:function(a,b){var c;for(this.selection=a,this.selectionRange=this.selection.getRangeAt(0),c=0;c<this.elements.length;c+=1)if(this.elements[c]===b)return void this.setToolbarButtonStates().setToolbarPosition().showToolbarActions();this.options.staticToolbar||this.hideToolbarActions()},findMatchingSelectionParent:function(a){var b,c,d=this.options.contentWindow.getSelection();if(0===d.rangeCount)return!1;b=d.getRangeAt(0),c=b.commonAncestorContainer;do{if(1===c.nodeType){if(a(c))return c;if(c.getAttribute("data-medium-element"))return!1}c=c.parentNode}while(c);return!1},getSelectionElement:function(){return this.findMatchingSelectionParent(function(a){return a.getAttribute("data-medium-element")})},selectionInContentEditableFalse:function(){return this.findMatchingSelectionParent(function(a){return a&&"#text"!==a.nodeName&&"false"===a.getAttribute("contenteditable")})},setToolbarPosition:function(){var c,d,e,f=b.documentElement&&b.documentElement.scrollTop||b.body.scrollTop,g=this.elements[0],h=g.getBoundingClientRect(),i=h.top+f,j=50,k=a.getSelection(),l=this.options.diffLeft-this.toolbar.offsetWidth/2,m=this.toolbar.offsetWidth/2;return null===k.focusNode?this:(this.toolbar.classList.add("medium-editor-toolbar-active"),this.options.staticToolbar?(this.options.stickyToolbar?f>i+this.elements[0].offsetHeight-this.toolbar.offsetHeight?this.toolbar.style.top=i+this.elements[0].offsetHeight+"px":f>i-this.toolbar.offsetHeight?(this.toolbar.classList.add("sticky-toolbar"),this.toolbar.style.top="0px"):(this.toolbar.classList.remove("sticky-toolbar"),this.toolbar.style.top=i-this.toolbar.offsetHeight+"px"):this.toolbar.style.top=i-this.toolbar.offsetHeight+"px",this.toolbar.style.left=h.left+"px"):k.isCollapsed||(c=k.getRangeAt(0),d=c.getBoundingClientRect(),e=(d.left+d.right)/2,d.top<j?(this.toolbar.classList.add("medium-toolbar-arrow-over"),this.toolbar.classList.remove("medium-toolbar-arrow-under"),this.toolbar.style.top=j+d.bottom-this.options.diffTop+this.options.contentWindow.pageYOffset-this.toolbar.offsetHeight+"px"):(this.toolbar.classList.add("medium-toolbar-arrow-under"),this.toolbar.classList.remove("medium-toolbar-arrow-over"),this.toolbar.style.top=d.top+this.options.diffTop+this.options.contentWindow.pageYOffset-this.toolbar.offsetHeight+"px"),this.toolbar.style.left=m>e?l+m+"px":this.options.contentWindow.innerWidth-e<m?this.options.contentWindow.innerWidth+l-m+"px":l+e+"px"),this.hideAnchorPreview(),this)},setToolbarButtonStates:function(){var a,b=this.toolbarActions.querySelectorAll("button");for(a=0;a<b.length;a+=1)b[a].classList.remove(this.options.activeButtonClass);return this.checkActiveButtons(),this},checkActiveButtons:function(){for(var a=Array.prototype.slice.call(this.elements),b=this.getSelectedParentElement();void 0!==b.tagName&&-1===this.parentElements.indexOf(b.tagName.toLowerCase)&&(this.activateButton(b.tagName.toLowerCase()),this.callExtensions("checkState",b),-1===a.indexOf(b));)b=b.parentNode},activateButton:function(a){var b=this.toolbar.querySelector('[data-element="'+a+'"]');null!==b&&-1===b.className.indexOf(this.options.activeButtonClass)&&(b.className+=" "+this.options.activeButtonClass)},bindButtons:function(){var a,b=this.toolbar.querySelectorAll("button"),c=this,d=function(a){a.preventDefault(),a.stopPropagation(),void 0===c.selection&&c.checkSelection(),this.className.indexOf(c.options.activeButtonClass)>-1?this.classList.remove(c.options.activeButtonClass):this.className+=" "+c.options.activeButtonClass,this.hasAttribute("data-action")&&c.execAction(this.getAttribute("data-action"),a)};for(a=0;a<b.length;a+=1)this.on(b[a],"click",d);return this.setFirstAndLastItems(b),this},setFirstAndLastItems:function(a){return a.length>0&&(a[0].className+=" "+this.options.firstButtonClass,a[a.length-1].className+=" "+this.options.lastButtonClass),this},execAction:function(a,b){a.indexOf("append-")>-1?(this.execFormatBlock(a.replace("append-","")),this.setToolbarPosition(),this.setToolbarButtonStates()):"anchor"===a?this.options.disableAnchorForm||this.triggerAnchorAction(b):"image"===a?this.options.ownerDocument.execCommand("insertImage",!1,this.options.contentWindow.getSelection()):(this.options.ownerDocument.execCommand(a,!1,null),this.setToolbarPosition())},rangeSelectsSingleNode:function(a){var b=a.startContainer;return b===a.endContainer&&b.hasChildNodes()&&a.endOffset===a.startOffset+1},getSelectedParentElement:function(){var a=null,b=this.selectionRange;return a=this.rangeSelectsSingleNode(b)?b.startContainer.childNodes[b.startOffset]:3===b.startContainer.nodeType?b.startContainer.parentNode:b.startContainer},triggerAnchorAction:function(){var a=this.getSelectedParentElement();return a.tagName&&"a"===a.tagName.toLowerCase()?this.options.ownerDocument.execCommand("unlink",!1,null):this.anchorForm&&("block"===this.anchorForm.style.display?this.showToolbarActions():this.showAnchorForm()),this},execFormatBlock:function(a){var b=this.getSelectionData(this.selection.anchorNode);if("blockquote"===a&&b.el&&"blockquote"===b.el.parentNode.tagName.toLowerCase())return this.options.ownerDocument.execCommand("outdent",!1,null);if(b.tagName===a&&(a="p"),this.isIE){if("blockquote"===a)return this.options.ownerDocument.execCommand("indent",!1,a);a="<"+a+">"}return this.options.ownerDocument.execCommand("formatBlock",!1,a)},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}},getFirstChild:function(a){for(var b=a.firstChild;null!==b&&1!==b.nodeType;)b=b.nextSibling;return b},hideToolbarActions:function(){this.keepToolbarAlive=!1,void 0!==this.toolbar&&this.toolbar.classList.contains("medium-editor-toolbar-active")&&(this.toolbar.classList.remove("medium-editor-toolbar-active"),this.onHideToolbar&&this.onHideToolbar())},showToolbarActions:function(){var a,b=this;this.anchorForm&&(this.anchorForm.style.display="none"),this.toolbarActions.style.display="block",this.keepToolbarAlive=!1,clearTimeout(a),a=setTimeout(function(){b.toolbar&&!b.toolbar.classList.contains("medium-editor-toolbar-active")&&b.toolbar.classList.add("medium-editor-toolbar-active")},100)},saveSelection:function(){this.savedSelection=e.call(this)},restoreSelection:function(){f.call(this,this.savedSelection)},showAnchorForm:function(a){this.anchorForm&&(this.toolbarActions.style.display="none",this.saveSelection(),this.anchorForm.style.display="block",this.setToolbarPosition(),this.keepToolbarAlive=!0,this.anchorInput.focus(),this.anchorInput.value=a||"")},bindAnchorForm:function(){if(!this.anchorForm)return this;var a=this.anchorForm.querySelector("a.medium-editor-toobar-anchor-close"),b=this.anchorForm.querySelector("a.medium-editor-toobar-anchor-save"),c=this;return this.on(this.anchorForm,"click",function(a){a.stopPropagation(),c.keepToolbarAlive=!0}),this.on(this.anchorInput,"keyup",function(a){var b,d=null;13===a.keyCode&&(a.preventDefault(),b=c.options.anchorTarget&&c.anchorTarget.checked?"_blank":"_self",c.options.anchorButton&&c.anchorButton.checked&&(d=c.options.anchorButtonClass),c.createLink(this,b,d))}),this.on(b,"click",function(a){var b,d=null;a.preventDefault(),b=c.options.anchorTarget&&c.anchorTarget.checked?"_blank":"_self",c.options.anchorButton&&c.anchorButton.checked&&(d=c.options.anchorButtonClass),c.createLink(c.anchorInput,b,d)},!0),this.on(this.anchorInput,"click",function(a){a.stopPropagation(),c.keepToolbarAlive=!0}),this.on(this.options.ownerDocument.body,"click",function(a){a.target===c.anchorForm||d(c.anchorForm,a.target)||d(c.toolbarActions,a.target)||(c.keepToolbarAlive=!1,c.checkSelection())},!0),this.on(this.options.ownerDocument.body,"focus",function(a){a.target===c.anchorForm||d(c.anchorForm,a.target)||d(c.toolbarActions,a.target)||(c.keepToolbarAlive=!1,c.checkSelection())},!0),this.on(a,"click",function(a){a.preventDefault(),c.showToolbarActions(),f.call(c,c.savedSelection)}),this},hideAnchorPreview:function(){this.anchorPreview.classList.remove("medium-editor-anchor-preview-active")},showAnchorPreview:function(a){if(this.anchorPreview.classList.contains("medium-editor-anchor-preview-active")||a.getAttribute("data-disable-preview"))return!0;var b,c,d,e=this,f=40,g=a.getBoundingClientRect(),h=(g.left+g.right)/2;return e.anchorPreview.querySelector("i").textContent=a.href,b=e.anchorPreview.offsetWidth/2,c=e.options.diffLeft-b,clearTimeout(d),d=setTimeout(function(){e.anchorPreview&&!e.anchorPreview.classList.contains("medium-editor-anchor-preview-active")&&e.anchorPreview.classList.add("medium-editor-anchor-preview-active")},100),e.observeAnchorPreview(a),e.anchorPreview.classList.add("medium-toolbar-arrow-over"),e.anchorPreview.classList.remove("medium-toolbar-arrow-under"),e.anchorPreview.style.top=Math.round(f+g.bottom-e.options.diffTop+this.options.contentWindow.pageYOffset-e.anchorPreview.offsetHeight)+"px",e.anchorPreview.style.left=b>h?c+b+"px":this.options.contentWindow.innerWidth-h<b?this.options.contentWindow.innerWidth+c-b+"px":c+h+"px",this},observeAnchorPreview:function(a){var b=this,c=(new Date).getTime(),d=!0,e=function(){c=(new Date).getTime(),d=!0},f=function(a){a.relatedTarget&&/anchor-preview/.test(a.relatedTarget.className)||(d=!1)},g=setInterval(function(){if(d)return!0;var h=(new Date).getTime()-c;h>b.options.anchorPreviewHideDelay&&(b.hideAnchorPreview(),clearInterval(g),b.off(b.anchorPreview,"mouseover",e),b.off(b.anchorPreview,"mouseout",f),b.off(a,"mouseover",e),b.off(a,"mouseout",f))},200);this.on(b.anchorPreview,"mouseover",e),this.on(b.anchorPreview,"mouseout",f),this.on(a,"mouseover",e),this.on(a,"mouseout",f)},createAnchorPreview:function(){var a=this,b=this.options.ownerDocument.createElement("div");return b.id="medium-editor-anchor-preview-"+this.id,b.className="medium-editor-anchor-preview",b.innerHTML=this.anchorPreviewTemplate(),this.options.elementsContainer.appendChild(b),this.on(b,"click",function(){a.anchorPreviewClickHandler()}),b},anchorPreviewTemplate: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>'},anchorPreviewClickHandler:function(){if(!this.options.disableAnchorForm&&this.activeAnchor){var a=this,b=this.options.ownerDocument.createRange(),c=this.options.contentWindow.getSelection();b.selectNodeContents(a.activeAnchor),c.removeAllRanges(),c.addRange(b),setTimeout(function(){a.activeAnchor&&a.showAnchorForm(a.activeAnchor.href),a.keepToolbarAlive=!1},100+a.options.delay)}this.hideAnchorPreview()},editorAnchorObserver:function(a){var b=this,c=!0,d=function(){c=!1,b.off(b.activeAnchor,"mouseout",d)};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.toolbar.classList.contains("medium-editor-toolbar-active"))return!0;this.activeAnchor=a.target,this.on(this.activeAnchor,"mouseout",d),setTimeout(function(){c&&b.showAnchorPreview(a.target)},b.options.delay)}},bindAnchorPreview:function(){var a,b=this;for(this.editorAnchorObserverWrapper=function(a){b.editorAnchorObserver(a)},a=0;a<this.elements.length;a+=1)this.on(this.elements[a],"mouseover",this.editorAnchorObserverWrapper);return this},checkLinkFormat:function(a){var b=/^(https?|ftps?|rtmpt?):\/\/|mailto:/;return(b.test(a)?"":"http://")+a},setTargetBlank:function(a){var b;if(a=a||g.call(this),"a"===a.tagName.toLowerCase())a.target="_blank";else for(a=a.getElementsByTagName("a"),b=0;b<a.length;b+=1)a[b].target="_blank"},setButtonClass:function(a){var b,c,d=g.call(this),e=a.split(" ");if("a"===d.tagName.toLowerCase())for(c=0;c<e.length;c+=1)d.classList.add(e[c]);else for(d=d.getElementsByTagName("a"),b=0;b<d.length;b+=1)for(c=0;c<e.length;c+=1)d[b].classList.add(e[c])},createLink:function(a,b,c){var d,e;if(0===a.value.trim().length)return void this.hideToolbarActions();if(f.call(this,this.savedSelection),this.options.checkLinkFormat&&(a.value=this.checkLinkFormat(a.value)),this.options.ownerDocument.execCommand("createLink",!1,a.value),(this.options.targetBlank||"_blank"===b)&&this.setTargetBlank(),c&&this.setButtonClass(c),this.options.targetBlank||"_blank"===b||c)for(e=this.options.ownerDocument.createEvent("HTMLEvents"),e.initEvent("input",!0,!0,this.options.contentWindow),d=0;d<this.elements.length;d+=1)this.elements[d].dispatchEvent(e);this.checkSelection(),this.showToolbarActions(),a.value=""},bindWindowActions:function(){var b,c=this;return this.windowResizeHandler=function(){clearTimeout(b),b=setTimeout(function(){c.toolbar&&c.toolbar.classList.contains("medium-editor-toolbar-active")&&c.setToolbarPosition()},100)},this.options.staticToolbar&&this.options.stickyToolbar&&this.on(a,"scroll",function(){c.toolbar&&c.toolbar.classList.contains("medium-editor-toolbar-active")&&c.setToolbarPosition()},!0),this.on(this.options.contentWindow,"resize",this.windowResizeHandler),this},activate:function(){this.isActive||this.setup()},deactivate:function(){var a;if(this.isActive){for(this.isActive=!1,void 0!==this.toolbar&&(this.options.elementsContainer.removeChild(this.anchorPreview),this.options.elementsContainer.removeChild(this.toolbar),delete this.toolbar,delete this.anchorPreview),a=0;a<this.elements.length;a+=1)this.elements[a].removeAttribute("contentEditable"),this.elements[a].removeAttribute("data-medium-element");this.removeAllEvents()}},htmlEntities:function(a){return String(a).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")},bindPaste:function(){var b,c=this;for(this.pasteWrapper=function(b){var d,e,f="",g="text/html",h="text/plain";if(this.classList.remove("medium-editor-placeholder"),!c.options.forcePlainText&&!c.options.cleanPastedHTML)return this;if(a.clipboardData&&void 0===b.clipboardData&&(b.clipboardData=a.clipboardData,g="Text",h="Text"),b.clipboardData&&b.clipboardData.getData&&!b.defaultPrevented){if(b.preventDefault(),c.options.cleanPastedHTML&&b.clipboardData.getData(g))return c.cleanPaste(b.clipboardData.getData(g));if(c.options.disableReturn||this.getAttribute("data-disable-return"))f=c.htmlEntities(b.clipboardData.getData(h)),j(c.options.ownerDocument,f);else{for(d=b.clipboardData.getData(h).split(/[\r\n]/g),e=0;e<d.length;e+=1)""!==d[e]&&(f+=navigator.userAgent.match(/firefox/i)&&0===e?c.htmlEntities(d[e]):"<p>"+c.htmlEntities(d[e])+"</p>");j(c.options.ownerDocument,f)}}},b=0;b<this.elements.length;b+=1)this.on(this.elements[b],"paste",this.pasteWrapper);return this},setPlaceholders:function(){if(this.options.disablePlaceholders)return this;var a,b=function(a){a.querySelector("img")||a.querySelector("blockquote")||""!==a.textContent.replace(/^\s+|\s+$/g,"")||a.classList.add("medium-editor-placeholder")},c=function(a){this.classList.remove("medium-editor-placeholder"),"keypress"!==a.type&&b(this)};for(a=0;a<this.elements.length;a+=1)b(this.elements[a]),this.on(this.elements[a],"blur",c),this.on(this.elements[a],"keypress",c);return this},cleanPaste:function(a){var b,c,d,e=this.getSelectionElement(),f=/<p|<br|<div/.test(a),g=[[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">']];
for(b=0;b<g.length;b+=1)a=a.replace(g[b][0],g[b][1]);if(f)for(c=a.split("<br><br>"),this.pasteHTML("<p>"+c.join("</p><p>")+"</p>"),this.options.ownerDocument.execCommand("insertText",!1,"\n"),c=e.querySelectorAll("a,p,div,br"),b=0;b<c.length;b+=1)switch(d=c[b],d.tagName.toLowerCase()){case"a":this.options.targetBlank&&this.setTargetBlank(d);break;case"p":case"div":this.filterCommonBlocks(d);break;case"br":this.filterLineBreak(d)}else this.pasteHTML(a)},pasteHTML:function(a){var b,c,d,e,f=this.options.ownerDocument.createDocumentFragment();for(f.appendChild(this.options.ownerDocument.createElement("body")),e=f.querySelector("body"),e.innerHTML=a,this.cleanupSpans(e),b=e.querySelectorAll("*"),d=0;d<b.length;d+=1)c=b[d],c.removeAttribute("class"),c.removeAttribute("style"),c.removeAttribute("dir"),"meta"===c.tagName.toLowerCase()&&c.parentNode.removeChild(c);this.options.ownerDocument.execCommand("insertHTML",!1,e.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.removeChild(a)},filterLineBreak:function(a){this.isCommonBlock(a.previousElementSibling)?a.parentNode.removeChild(a):!this.isCommonBlock(a.parentNode)||a.parentNode.firstChild!==a&&a.parentNode.lastChild!==a?1===a.parentNode.childElementCount&&this.removeWithParent(a):a.parentNode.removeChild(a)},removeWithParent:function(a){a&&a.parentNode&&(a.parentNode.parentNode&&1===a.parentNode.childElementCount?a.parentNode.parentNode.removeChild(a.parentNode):a.parentNode.removeChild(a.parentNode))},cleanupSpans:function(a){var b,c,d,e=a.querySelectorAll(".replace-with");for(b=0;b<e.length;b+=1)c=e[b],d=this.options.ownerDocument.createElement(c.classList.contains("bold")?"b":"i"),d.innerHTML=c.classList.contains("bold")&&c.classList.contains("italic")?"<i>"+c.innerHTML+"</i>":c.innerHTML,c.parentNode.replaceChild(d,c);for(e=a.querySelectorAll("span"),b=0;b<e.length;b+=1)c=e[b],/^\s*$/.test()?c.parentNode.removeChild(c):c.parentNode.replaceChild(this.options.ownerDocument.createTextNode(c.textContent),c)}}}(window,document);
function MediumEditor(a,b){"use strict";return this.init(a,b)}"object"==typeof module?module.exports=MediumEditor:"function"==typeof define&&define.amd&&define(function(){"use strict";return MediumEditor}),function(a,b){"use strict";function c(a,b){var c;if(void 0===a)return b;for(c in b)b.hasOwnProperty(c)&&a.hasOwnProperty(c)===!1&&(a[c]=b[c]);return a}function d(a,b){var c,d,e,f,g=50,h=null,i=0;return b||0===b||(b=g),f=function(){i=m(),h=null,e=a.apply(c,d),h||(c=d=null)},function(){var g=m(),j=b-(g-i);return c=this,d=arguments,0>=j||j>b?(clearTimeout(h),h=null,i=g,e=a.apply(c,d),h||(c=d=null)):h||(h=setTimeout(f,j)),e}}function e(a,b){for(var c=b.parentNode;null!==c;){if(c===a)return!0;c=c.parentNode}return!1}function f(a,b,c){var d,e=!1,f=c.createNodeIterator(a,NodeFilter.SHOW_TEXT);for(d=f.nextNode();d;){if(d===b)e=!0;else if(e&&3===d.nodeType&&d.nodeValue.length>0)break;d=f.nextNode()}return d}function g(){var a,b,c,d=this.options.contentWindow.getSelection();if(d.getRangeAt&&d.rangeCount){for(c=[],a=0,b=d.rangeCount;b>a;a+=1)c.push(d.getRangeAt(a));return c}return null}function h(a){var b,c,d=this.options.contentWindow.getSelection();if(a)for(d.removeAllRanges(),b=0,c=a.length;c>b;b+=1)d.addRange(a[b])}function i(){var a=this.options.ownerDocument.getSelection().anchorNode,b=a&&3===a.nodeType?a.parentNode:a;return b}function j(){var a,b,c,d,e="";if(void 0!==this.options.contentWindow.getSelection){if(b=this.options.contentWindow.getSelection(),b.rangeCount){for(d=this.options.ownerDocument.createElement("div"),a=0,c=b.rangeCount;c>a;a+=1)d.appendChild(b.getRangeAt(a).cloneContents());e=d.innerHTML}}else void 0!==this.options.ownerDocument.selection&&"Text"===this.options.ownerDocument.selection.type&&(e=this.options.ownerDocument.selection.createRange().htmlText);return e}function k(a){return!(!a||1!==a.nodeType)}function l(b,c){var d,e,f,g,h,i;if(b.queryCommandSupported("insertHTML"))return b.execCommand("insertHTML",!1,c);if(d=a.getSelection(),d.getRangeAt&&d.rangeCount){for(e=d.getRangeAt(0),e.deleteContents(),f=b.createElement("div"),f.innerHTML=c,g=b.createDocumentFragment();f.firstChild;)h=f.firstChild,i=g.appendChild(h);e.insertNode(g),i&&(e=e.cloneRange(),e.setStartAfter(i),e.collapse(!0),d.removeAllRanges(),d.addRange(e))}}var m=Date.now||function(){return(new Date).getTime()};MediumEditor.prototype={defaults:{allowMultiParagraphSelection:!0,anchorInputPlaceholder:"Paste or type a link",anchorPreviewHideDelay:500,buttons:["bold","italic","underline","anchor","header1","header2","quote"],buttonLabels:!1,checkLinkFormat:!1,cleanPastedHTML:!1,delay:0,diffLeft:0,diffTop:-10,disableReturn:!1,disableDoubleReturn:!1,disableToolbar:!1,disableEditing:!1,disableAnchorForm:!1,disablePlaceholders:!1,elementsContainer:!1,standardizeSelectionStart:!1,contentWindow:a,ownerDocument:b,firstHeader:"h3",forcePlainText:!0,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"},isIE:"Microsoft Internet Explorer"===navigator.appName||"Netscape"===navigator.appName&&null!==new RegExp("Trident/.*rv:([0-9]{1,}[.0-9]{0,})").exec(navigator.userAgent),init:function(a,b){var d=1;if(this.options=c(b,this.defaults),this.setElementSelection(a),0!==this.elements.length){for(this.parentElements=["p","h1","h2","h3","h4","h5","h6","blockquote","pre"],this.options.elementsContainer||(this.options.elementsContainer=this.options.ownerDocument.body);this.options.elementsContainer.querySelector("#medium-editor-toolbar-"+d);)d+=1;return this.id=d,this.setup()}},setup:function(){this.events=[],this.isActive=!0,this.initThrottledMethods().initElements().bindSelect().bindPaste().setPlaceholders().bindElementActions().bindWindowActions().passInstance()},on:function(a,b,c,d){a.addEventListener(b,c,d),this.events.push([a,b,c,d])},off: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},delay:function(a){var b=this;setTimeout(function(){b.isActive&&a()},this.options.delay)},removeAllEvents:function(){for(var a=this.events.pop();a;)a[0].removeEventListener(a[1],a[2],a[3]),a=this.events.pop()},initThrottledMethods:function(){var a=this;return this.handleResize=d(function(){a.isActive&&a.positionToolbarIfShown()}),this.handleBlur=d(function(){a.isActive&&!a.keepToolbarAlive&&a.hideToolbarActions()}),this},initElements:function(){var a,b=!1;for(a=0;a<this.elements.length;a+=1)this.options.disableEditing||this.elements[a].getAttribute("data-disable-editing")||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.bindParagraphCreation(a),this.options.disableToolbar||this.elements[a].getAttribute("data-disable-toolbar")||(b=!0);return b&&this.initToolbar().bindButtons().bindAnchorForm().bindAnchorPreview(),this},setElementSelection:function(a){a||(a=[]),"string"==typeof a&&(a=this.options.ownerDocument.querySelectorAll(a)),k(a)&&(a=[a]),this.elements=Array.prototype.slice.apply(a)},bindBlur:function(){var a=this,b=function(b){b.target===a.toolbar||b.target===a.elements[0]||e(a.elements[0],b.target)||e(a.toolbar,b.target)||e(a.anchorPreview,b.target)||(a.options.disablePlaceholders||a.placeholderWrapper(b,a.elements[0]),a.handleBlur())};return this.on(this.options.ownerDocument.body,"click",b,!0),this.on(this.options.ownerDocument.body,"focus",b,!0),this},bindClick:function(a){var b=this;return this.on(this.elements[a],"click",function(){b.options.disablePlaceholders||this.classList.remove("medium-editor-placeholder"),b.options.staticToolbar&&b.setToolbarPosition()}),this},bindElementActions:function(){var a;for(a=0;a<this.elements.length;a+=1)this.options.disablePlaceholders||this.activatePlaceholder(this.elements[a]),this.bindReturn(a).bindTab(a).bindBlur(a).bindClick(a);return this},activatePlaceholder:function(a){a.querySelector("img")||a.querySelector("blockquote")||""!==a.textContent.replace(/^\s+|\s+$/g,"")||a.classList.add("medium-editor-placeholder")},placeholderWrapper:function(a,b){b=b||a.target,b.classList.remove("medium-editor-placeholder"),"keypress"!==a.type&&this.activatePlaceholder(b)},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},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))}},passInstance:function(){var a,b,c=this;for(b in c.options.extensions)c.options.extensions.hasOwnProperty(b)&&(a=c.options.extensions[b],a.parent&&(a.base=c));return c},bindParagraphCreation:function(a){var b=this;return this.on(this.elements[a],"keypress",function(a){var c,d;32===a.which&&(c=i.call(b),d=c.tagName.toLowerCase(),"a"===d&&b.options.ownerDocument.execCommand("unlink",!1,null))}),this.on(this.elements[a],"keyup",function(a){var c,d,e=i.call(b);e&&e.getAttribute("data-medium-element")&&0===e.children.length&&!b.options.disableReturn&&!e.getAttribute("data-disable-return")&&b.options.ownerDocument.execCommand("formatBlock",!1,"p"),13===a.which&&(e=i.call(b),c=e.tagName.toLowerCase(),d=b.getSelectionElement(),b.options.disableReturn||d.getAttribute("data-disable-return")||"li"===c||b.isListItemChild(e)||(a.shiftKey||b.options.ownerDocument.execCommand("formatBlock",!1,"p"),"a"===c&&b.options.ownerDocument.execCommand("unlink",!1,null)))}),this},isListItemChild:function(a){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},bindReturn:function(a){var b=this;return this.on(this.elements[a],"keypress",function(a){if(13===a.which)if(b.options.disableReturn||this.getAttribute("data-disable-return"))a.preventDefault();else if(b.options.disableDoubleReturn||this.getAttribute("data-disable-double-return")){var c=i.call(b);c&&"\n"===c.textContent&&a.preventDefault()}}),this},bindTab:function(a){var b=this;return this.on(this.elements[a],"keydown",function(a){if(9===a.which){var c=i.call(b).tagName.toLowerCase();"pre"===c&&(a.preventDefault(),b.options.ownerDocument.execCommand("insertHtml",null," ")),"li"===c&&(a.preventDefault(),a.shiftKey?b.options.ownerDocument.execCommand("outdent",a):b.options.ownerDocument.execCommand("indent",a))}}),this},buttonTemplate:function(a){var b=this.getButtonLabels(this.options.buttonLabels),c={bold:'<button class="medium-editor-action medium-editor-action-bold" data-action="bold" data-element="b" aria-label="bold">'+b.bold+"</button>",italic:'<button class="medium-editor-action medium-editor-action-italic" data-action="italic" data-element="i" aria-label="italic">'+b.italic+"</button>",underline:'<button class="medium-editor-action medium-editor-action-underline" data-action="underline" data-element="u" aria-label="underline">'+b.underline+"</button>",strikethrough:'<button class="medium-editor-action medium-editor-action-strikethrough" data-action="strikethrough" data-element="strike" aria-label="strike through">'+b.strikethrough+"</button>",superscript:'<button class="medium-editor-action medium-editor-action-superscript" data-action="superscript" data-element="sup" aria-label="superscript">'+b.superscript+"</button>",subscript:'<button class="medium-editor-action medium-editor-action-subscript" data-action="subscript" data-element="sub" aria-label="subscript">'+b.subscript+"</button>",anchor:'<button class="medium-editor-action medium-editor-action-anchor" data-action="anchor" data-element="a" aria-label="link">'+b.anchor+"</button>",image:'<button class="medium-editor-action medium-editor-action-image" data-action="image" data-element="img" aria-label="image">'+b.image+"</button>",header1:'<button class="medium-editor-action medium-editor-action-header1" data-action="append-'+this.options.firstHeader+'" data-element="'+this.options.firstHeader+'" aria-label="h1">'+b.header1+"</button>",header2:'<button class="medium-editor-action medium-editor-action-header2" data-action="append-'+this.options.secondHeader+'" data-element="'+this.options.secondHeader+' "aria-label="h2">'+b.header2+"</button>",quote:'<button class="medium-editor-action medium-editor-action-quote" data-action="append-blockquote" data-element="blockquote" aria-label="blockquote">'+b.quote+"</button>",orderedlist:'<button class="medium-editor-action medium-editor-action-orderedlist" data-action="insertorderedlist" data-element="ol" aria-label="ordered list">'+b.orderedlist+"</button>",unorderedlist:'<button class="medium-editor-action medium-editor-action-unorderedlist" data-action="insertunorderedlist" data-element="ul" aria-label="unordered list">'+b.unorderedlist+"</button>",pre:'<button class="medium-editor-action medium-editor-action-pre" data-action="append-pre" data-element="pre" aria-label="preformatted text">'+b.pre+"</button>",indent:'<button class="medium-editor-action medium-editor-action-indent" data-action="indent" data-element="ul" aria-label="indent">'+b.indent+"</button>",outdent:'<button class="medium-editor-action medium-editor-action-outdent" data-action="outdent" data-element="ul" aria-label="outdent">'+b.outdent+"</button>",justifyCenter:'<button class="medium-editor-action medium-editor-action-justifyCenter" data-action="justifyCenter" data-element="" aria-label="center justify">'+b.justifyCenter+"</button>",justifyFull:'<button class="medium-editor-action medium-editor-action-justifyFull" data-action="justifyFull" data-element="" aria-label="full justify">'+b.justifyFull+"</button>",justifyLeft:'<button class="medium-editor-action medium-editor-action-justifyLeft" data-action="justifyLeft" data-element="" aria-label="left justify">'+b.justifyLeft+"</button>",justifyRight:'<button class="medium-editor-action medium-editor-action-justifyRight" data-action="justifyRight" data-element="" aria-label="right justify">'+b.justifyRight+"</button>"};return c[a]||!1},getButtonLabels:function(a){var b,c,d={bold:"<b>B</b>",italic:"<b><i>I</i></b>",underline:"<b><u>U</u></b>",strikethrough:"<s>A</s>",superscript:"<b>x<sup>1</sup></b>",subscript:"<b>x<sub>1</sub></b>",anchor:"<b>#</b>",image:"<b>image</b>",header1:"<b>H1</b>",header2:"<b>H2</b>",quote:"<b>&ldquo;</b>",orderedlist:"<b>1.</b>",unorderedlist:"<b>&bull;</b>",pre:"<b>0101</b>",indent:"<b>&rarr;</b>",outdent:"<b>&larr;</b>",justifyCenter:"<b>C</b>",justifyFull:"<b>J</b>",justifyLeft:"<b>L</b>",justifyRight:"<b>R</b>"};if("fontawesome"===a?b={bold:'<i class="fa fa-bold"></i>',italic:'<i class="fa fa-italic"></i>',underline:'<i class="fa fa-underline"></i>',strikethrough:'<i class="fa fa-strikethrough"></i>',superscript:'<i class="fa fa-superscript"></i>',subscript:'<i class="fa fa-subscript"></i>',anchor:'<i class="fa fa-link"></i>',image:'<i class="fa fa-picture-o"></i>',quote:'<i class="fa fa-quote-right"></i>',orderedlist:'<i class="fa fa-list-ol"></i>',unorderedlist:'<i class="fa fa-list-ul"></i>',pre:'<i class="fa fa-code fa-lg"></i>',indent:'<i class="fa fa-indent"></i>',outdent:'<i class="fa fa-outdent"></i>',justifyCenter:'<i class="fa fa-align-center"></i>',justifyFull:'<i class="fa fa-align-justify"></i>',justifyLeft:'<i class="fa fa-align-left"></i>',justifyRight:'<i class="fa fa-align-right"></i>'}:"object"==typeof a&&(b=a),"object"==typeof b)for(c in b)b.hasOwnProperty(c)&&(d[c]=b[c]);return d},initToolbar:function(){return this.toolbar?this:(this.toolbar=this.createToolbar(),this.keepToolbarAlive=!1,this.toolbarActions=this.toolbar.querySelector(".medium-editor-toolbar-actions"),this.anchorPreview=this.createAnchorPreview(),this.options.disableAnchorForm||(this.anchorForm=this.toolbar.querySelector(".medium-editor-toolbar-form-anchor"),this.anchorInput=this.anchorForm.querySelector("input.medium-editor-toolbar-anchor-input"),this.anchorTarget=this.anchorForm.querySelector("input.medium-editor-toolbar-anchor-target"),this.anchorButton=this.anchorForm.querySelector("input.medium-editor-toolbar-anchor-button")),this)},createToolbar:function(){var a=this.options.ownerDocument.createElement("div");return a.id="medium-editor-toolbar-"+this.id,a.className="medium-editor-toolbar",a.className+=this.options.staticToolbar?" static-toolbar":" stalker-toolbar",a.appendChild(this.toolbarButtons()),this.options.disableAnchorForm||a.appendChild(this.toolbarFormAnchor()),this.options.elementsContainer.appendChild(a),a},toolbarButtons:function(){var a,b,c,d,e=this.options.buttons,f=this.options.ownerDocument.createElement("ul");for(f.id="medium-editor-toolbar-actions"+this.id,f.className="medium-editor-toolbar-actions clearfix",b=0;b<e.length;b+=1)this.options.extensions.hasOwnProperty(e[b])?(d=this.options.extensions[e[b]],c=void 0!==d.getButton?d.getButton(this):null):c=this.buttonTemplate(e[b]),c&&(a=this.options.ownerDocument.createElement("li"),k(c)?a.appendChild(c):a.innerHTML=c,f.appendChild(a));return f},toolbarFormAnchor:function(){var a=this.options.ownerDocument.createElement("div"),b=this.options.ownerDocument.createElement("input"),c=this.options.ownerDocument.createElement("label"),d=this.options.ownerDocument.createElement("input"),e=this.options.ownerDocument.createElement("label"),f=this.options.ownerDocument.createElement("input"),g=this.options.ownerDocument.createElement("a"),h=this.options.ownerDocument.createElement("a");return g.setAttribute("href","#"),g.className="medium-editor-toobar-anchor-close",g.innerHTML="&times;",h.setAttribute("href","#"),h.className="medium-editor-toobar-anchor-save",h.innerHTML="&#10003;",b.setAttribute("type","text"),b.className="medium-editor-toolbar-anchor-input",b.setAttribute("placeholder",this.options.anchorInputPlaceholder),d.setAttribute("type","checkbox"),d.className="medium-editor-toolbar-anchor-target",c.innerHTML="Open in New Window?",c.insertBefore(d,c.firstChild),f.setAttribute("type","checkbox"),f.className="medium-editor-toolbar-anchor-button",e.innerHTML="Button",e.insertBefore(f,e.firstChild),a.className="medium-editor-toolbar-form-anchor",a.id="medium-editor-toolbar-form-anchor-"+this.id,a.appendChild(b),a.appendChild(h),a.appendChild(g),this.options.anchorTarget&&a.appendChild(c),this.options.anchorButton&&a.appendChild(e),a},bindSelect:function(){var a,b=this;for(this.checkSelectionWrapper=function(a){return!b.options.disableAnchorForm&&a&&b.clickingIntoArchorForm(a)?!1:void b.checkSelection()},this.on(this.options.ownerDocument.documentElement,"mouseup",this.checkSelectionWrapper),a=0;a<this.elements.length;a+=1)this.on(this.elements[a],"keyup",this.checkSelectionWrapper),this.on(this.elements[a],"blur",this.checkSelectionWrapper),this.on(this.elements[a],"click",this.checkSelectionWrapper);return this},stopSelectionUpdates:function(){this.preventSelectionUpdates=!0},startSelectionUpdates:function(){this.preventSelectionUpdates=!1},checkSelection:function(){var a,b;return this.preventSelectionUpdates||this.keepToolbarAlive===!0||this.options.disableToolbar||(a=this.options.contentWindow.getSelection(),!this.options.updateOnEmptySelection&&""===a.toString().trim()||this.options.allowMultiParagraphSelection===!1&&this.hasMultiParagraphs()||this.selectionInContentEditableFalse()?this.options.staticToolbar?this.anchorForm&&"block"===this.anchorForm.style.display&&(this.setToolbarButtonStates(),this.showToolbarActions()):this.hideToolbarActions():(b=this.getSelectionElement(),!b||b.getAttribute("data-disable-toolbar")?this.options.staticToolbar||this.hideToolbarActions():this.checkSelectionElement(a,b))),this},clickingIntoArchorForm:function(a){var b=this;return a.type&&"blur"===a.type.toLowerCase()&&a.relatedTarget&&a.relatedTarget===b.anchorInput?!0:!1},hasMultiParagraphs:function(){var a=j.call(this).replace(/<[\S]+><\/[\S]+>/gim,""),b=a.match(/<(p|h[0-6]|blockquote)>([\s\S]*?)<\/(p|h[0-6]|blockquote)>/g);return b?b.length:0},checkSelectionElement:function(a,b){var c,d,e,g=0;if(this.selection=a,this.selectionRange=this.selection.getRangeAt(0),this.options.standardizeSelectionStart&&this.selectionRange.startOffset===this.selectionRange.startContainer.nodeValue.length&&(d=f(this.getSelectionElement(),this.selectionRange.startContainer,this.options.ownerDocument))){for(g=0;0===d.nodeValue.substr(g,1).trim().length;)g+=1;e=this.options.ownerDocument.createRange(),e.setStart(d,g),e.setEnd(this.selectionRange.endContainer,this.selectionRange.endOffset),this.selection.removeAllRanges(),this.selection.addRange(e),this.selectionRange=e}for(c=0;c<this.elements.length;c+=1)if(this.elements[c]===b)return void this.setToolbarButtonStates().setToolbarPosition().showToolbarActions();this.options.staticToolbar||this.hideToolbarActions()},findMatchingSelectionParent:function(a){var b,c,d=this.options.contentWindow.getSelection();if(0===d.rangeCount)return!1;b=d.getRangeAt(0),c=b.commonAncestorContainer;do{if(1===c.nodeType){if(a(c))return c;if(c.getAttribute("data-medium-element"))return!1}c=c.parentNode}while(c);return!1},getSelectionElement:function(){return this.findMatchingSelectionParent(function(a){return a.getAttribute("data-medium-element")})},selectionInContentEditableFalse:function(){return this.findMatchingSelectionParent(function(a){return a&&"#text"!==a.nodeName&&"false"===a.getAttribute("contenteditable")})},setToolbarPosition:function(){var a,b,c,d=this.options.ownerDocument.documentElement&&this.options.ownerDocument.documentElement.scrollTop||this.options.ownerDocument.body.scrollTop,e=this.elements[0],f=e.getBoundingClientRect(),g=f.top+d,h=50,i=this.options.contentWindow.getSelection(),j=this.options.diffLeft-this.toolbar.offsetWidth/2,k=this.toolbar.offsetWidth/2;return null===i.focusNode?this:(this.showToolbar(),this.options.staticToolbar?(this.options.stickyToolbar?d>g+this.elements[0].offsetHeight-this.toolbar.offsetHeight?this.toolbar.style.top=g+this.elements[0].offsetHeight+"px":d>g-this.toolbar.offsetHeight?(this.toolbar.classList.add("sticky-toolbar"),this.toolbar.style.top="0px"):(this.toolbar.classList.remove("sticky-toolbar"),this.toolbar.style.top=g-this.toolbar.offsetHeight+"px"):this.toolbar.style.top=g-this.toolbar.offsetHeight+"px",this.toolbar.style.left=f.left+"px"):i.isCollapsed||(a=i.getRangeAt(0),b=a.getBoundingClientRect(),c=(b.left+b.right)/2,b.top<h?(this.toolbar.classList.add("medium-toolbar-arrow-over"),this.toolbar.classList.remove("medium-toolbar-arrow-under"),this.toolbar.style.top=h+b.bottom-this.options.diffTop+this.options.contentWindow.pageYOffset-this.toolbar.offsetHeight+"px"):(this.toolbar.classList.add("medium-toolbar-arrow-under"),this.toolbar.classList.remove("medium-toolbar-arrow-over"),this.toolbar.style.top=b.top+this.options.diffTop+this.options.contentWindow.pageYOffset-this.toolbar.offsetHeight+"px"),this.toolbar.style.left=k>c?j+k+"px":this.options.contentWindow.innerWidth-c<k?this.options.contentWindow.innerWidth+j-k+"px":j+c+"px"),this.hideAnchorPreview(),this)},setToolbarButtonStates:function(){var a,b=this.toolbarActions.querySelectorAll("button");for(a=0;a<b.length;a+=1)b[a].classList.remove(this.options.activeButtonClass);return this.checkActiveButtons(),this},checkActiveButtons:function(){for(var a=Array.prototype.slice.call(this.elements),b=this.getSelectedParentElement();void 0!==b.tagName&&-1===this.parentElements.indexOf(b.tagName.toLowerCase)&&(this.activateButton(b.tagName.toLowerCase()),this.callExtensions("checkState",b),-1===a.indexOf(b));)b=b.parentNode},activateButton:function(a){var b=this.toolbar.querySelector('[data-element="'+a+'"]');null!==b&&-1===b.className.indexOf(this.options.activeButtonClass)&&(b.className+=" "+this.options.activeButtonClass)},bindButtons:function(){var a,b=this.toolbar.querySelectorAll("button"),c=this,d=function(a){a.preventDefault(),a.stopPropagation(),void 0===c.selection&&c.checkSelection(),this.className.indexOf(c.options.activeButtonClass)>-1?this.classList.remove(c.options.activeButtonClass):this.className+=" "+c.options.activeButtonClass,this.hasAttribute("data-action")&&c.execAction(this.getAttribute("data-action"),a)};for(a=0;a<b.length;a+=1)this.on(b[a],"click",d);return this.setFirstAndLastItems(b),this},setFirstAndLastItems:function(a){return a.length>0&&(a[0].className+=" "+this.options.firstButtonClass,a[a.length-1].className+=" "+this.options.lastButtonClass),this},execAction:function(a,b){a.indexOf("append-")>-1?(this.execFormatBlock(a.replace("append-","")),this.setToolbarPosition(),this.setToolbarButtonStates()):"anchor"===a?this.options.disableAnchorForm||this.triggerAnchorAction(b):"image"===a?this.options.ownerDocument.execCommand("insertImage",!1,this.options.contentWindow.getSelection()):(this.options.ownerDocument.execCommand(a,!1,null),this.setToolbarPosition())},rangeSelectsSingleNode:function(a){var b=a.startContainer;return b===a.endContainer&&b.hasChildNodes()&&a.endOffset===a.startOffset+1},getSelectedParentElement:function(){var a=null,b=this.selectionRange;return a=this.rangeSelectsSingleNode(b)?b.startContainer.childNodes[b.startOffset]:3===b.startContainer.nodeType?b.startContainer.parentNode:b.startContainer},triggerAnchorAction:function(){var a=this.getSelectedParentElement();return a.tagName&&"a"===a.tagName.toLowerCase()?this.options.ownerDocument.execCommand("unlink",!1,null):this.anchorForm&&("block"===this.anchorForm.style.display?this.showToolbarActions():this.showAnchorForm()),this},execFormatBlock:function(a){var b=this.getSelectionData(this.selection.anchorNode);if("blockquote"===a&&b.el&&"blockquote"===b.el.parentNode.tagName.toLowerCase())return this.options.ownerDocument.execCommand("outdent",!1,null);if(b.tagName===a&&(a="p"),this.isIE){if("blockquote"===a)return this.options.ownerDocument.execCommand("indent",!1,a);a="<"+a+">"}return this.options.ownerDocument.execCommand("formatBlock",!1,a)},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}},getFirstChild:function(a){for(var b=a.firstChild;null!==b&&1!==b.nodeType;)b=b.nextSibling;return b},isToolbarShown:function(){return this.toolbar&&this.toolbar.classList.contains("medium-editor-toolbar-active")},showToolbar:function(){this.toolbar&&!this.isToolbarShown()&&(this.toolbar.classList.add("medium-editor-toolbar-active"),this.onShowToolbar&&this.onShowToolbar())},hideToolbar:function(){this.isToolbarShown()&&(this.toolbar.classList.remove("medium-editor-toolbar-active"),this.onHideToolbar&&this.onHideToolbar())},hideToolbarActions:function(){this.keepToolbarAlive=!1,this.hideToolbar()},showToolbarActions:function(){var a=this;this.anchorForm&&(this.anchorForm.style.display="none"),this.toolbarActions.style.display="block",this.keepToolbarAlive=!1,this.delay(function(){a.showToolbar()})},saveSelection:function(){this.savedSelection=g.call(this)},restoreSelection:function(){h.call(this,this.savedSelection)},showAnchorForm:function(a){this.anchorForm&&(this.toolbarActions.style.display="none",this.saveSelection(),this.anchorForm.style.display="block",this.setToolbarPosition(),this.keepToolbarAlive=!0,this.anchorInput.focus(),this.anchorInput.value=a||"")},bindAnchorForm:function(){if(!this.anchorForm)return this;var a=this.anchorForm.querySelector("a.medium-editor-toobar-anchor-close"),b=this.anchorForm.querySelector("a.medium-editor-toobar-anchor-save"),c=this;return this.on(this.anchorForm,"click",function(a){a.stopPropagation(),c.keepToolbarAlive=!0}),this.on(this.anchorInput,"keyup",function(a){var b,d=null;13===a.keyCode?(a.preventDefault(),b=c.options.anchorTarget&&c.anchorTarget.checked?"_blank":"_self",c.options.anchorButton&&c.anchorButton.checked&&(d=c.options.anchorButtonClass),c.createLink(this,b,d)):27===a.keyCode&&(a.preventDefault(),c.showToolbarActions(),h.call(c,c.savedSelection))}),this.on(b,"click",function(a){var b,d=null;a.preventDefault(),b=c.options.anchorTarget&&c.anchorTarget.checked?"_blank":"_self",c.options.anchorButton&&c.anchorButton.checked&&(d=c.options.anchorButtonClass),c.createLink(c.anchorInput,b,d)},!0),this.on(this.anchorInput,"click",function(a){a.stopPropagation(),c.keepToolbarAlive=!0}),this.on(this.options.ownerDocument.body,"click",function(a){a.target===c.anchorForm||e(c.anchorForm,a.target)||e(c.toolbarActions,a.target)||(c.keepToolbarAlive=!1,c.checkSelection())},!0),this.on(this.options.ownerDocument.body,"focus",function(a){a.target===c.anchorForm||e(c.anchorForm,a.target)||e(c.toolbarActions,a.target)||(c.keepToolbarAlive=!1,c.checkSelection())},!0),this.on(a,"click",function(a){a.preventDefault(),c.showToolbarActions(),h.call(c,c.savedSelection)}),this},hideAnchorPreview:function(){this.anchorPreview.classList.remove("medium-editor-anchor-preview-active")},showAnchorPreview:function(a){if(this.anchorPreview.classList.contains("medium-editor-anchor-preview-active")||a.getAttribute("data-disable-preview"))return!0;var b,c,d=this,e=40,f=a.getBoundingClientRect(),g=(f.left+f.right)/2;return d.anchorPreview.querySelector("i").textContent=a.href,b=d.anchorPreview.offsetWidth/2,c=d.options.diffLeft-b,d.observeAnchorPreview(a),d.anchorPreview.classList.add("medium-toolbar-arrow-over"),d.anchorPreview.classList.remove("medium-toolbar-arrow-under"),d.anchorPreview.style.top=Math.round(e+f.bottom-d.options.diffTop+this.options.contentWindow.pageYOffset-d.anchorPreview.offsetHeight)+"px",d.anchorPreview.style.left=b>g?c+b+"px":this.options.contentWindow.innerWidth-g<b?this.options.contentWindow.innerWidth+c-b+"px":c+g+"px",this.anchorPreview&&!this.anchorPreview.classList.contains("medium-editor-anchor-preview-active")&&this.anchorPreview.classList.add("medium-editor-anchor-preview-active"),this},observeAnchorPreview:function(a){var b=this,c=(new Date).getTime(),d=!0,e=function(){c=(new Date).getTime(),d=!0},f=function(a){a.relatedTarget&&/anchor-preview/.test(a.relatedTarget.className)||(d=!1)},g=setInterval(function(){if(d)return!0;var h=(new Date).getTime()-c;h>b.options.anchorPreviewHideDelay&&(b.hideAnchorPreview(),clearInterval(g),b.off(b.anchorPreview,"mouseover",e),b.off(b.anchorPreview,"mouseout",f),b.off(a,"mouseover",e),b.off(a,"mouseout",f))},200);this.on(b.anchorPreview,"mouseover",e),this.on(b.anchorPreview,"mouseout",f),this.on(a,"mouseover",e),this.on(a,"mouseout",f)},createAnchorPreview:function(){var a=this,b=this.options.ownerDocument.createElement("div");return b.id="medium-editor-anchor-preview-"+this.id,b.className="medium-editor-anchor-preview",b.innerHTML=this.anchorPreviewTemplate(),this.options.elementsContainer.appendChild(b),this.on(b,"click",function(){a.anchorPreviewClickHandler()}),b},anchorPreviewTemplate: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>'},anchorPreviewClickHandler:function(){if(!this.options.disableAnchorForm&&this.activeAnchor){var a=this,b=this.options.ownerDocument.createRange(),c=this.options.contentWindow.getSelection();b.selectNodeContents(a.activeAnchor),c.removeAllRanges(),c.addRange(b),this.delay(function(){a.activeAnchor&&a.showAnchorForm(a.activeAnchor.href),a.keepToolbarAlive=!1})}this.hideAnchorPreview()},editorAnchorObserver:function(a){var b=this,c=!0,d=function(){c=!1,b.off(b.activeAnchor,"mouseout",d)};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.isToolbarShown())return!0;this.activeAnchor=a.target,this.on(this.activeAnchor,"mouseout",d),this.delay(function(){c&&b.showAnchorPreview(a.target)})}},bindAnchorPreview:function(){var a,b=this;for(this.editorAnchorObserverWrapper=function(a){b.editorAnchorObserver(a)},a=0;a<this.elements.length;a+=1)this.on(this.elements[a],"mouseover",this.editorAnchorObserverWrapper);return this},checkLinkFormat:function(a){var b=/^(https?|ftps?|rtmpt?):\/\/|mailto:/;return(b.test(a)?"":"http://")+a},setTargetBlank:function(a){var b;if(a=a||i.call(this),"a"===a.tagName.toLowerCase())a.target="_blank";else for(a=a.getElementsByTagName("a"),b=0;b<a.length;b+=1)a[b].target="_blank"},setButtonClass:function(a){var b,c,d=i.call(this),e=a.split(" ");if("a"===d.tagName.toLowerCase())for(c=0;c<e.length;c+=1)d.classList.add(e[c]);else for(d=d.getElementsByTagName("a"),b=0;b<d.length;b+=1)for(c=0;c<e.length;c+=1)d[b].classList.add(e[c])},createLink:function(a,b,c){var d,e;if(0===a.value.trim().length)return void this.hideToolbarActions();if(h.call(this,this.savedSelection),this.options.checkLinkFormat&&(a.value=this.checkLinkFormat(a.value)),this.options.ownerDocument.execCommand("createLink",!1,a.value),(this.options.targetBlank||"_blank"===b)&&this.setTargetBlank(),c&&this.setButtonClass(c),this.options.targetBlank||"_blank"===b||c)for(e=this.options.ownerDocument.createEvent("HTMLEvents"),e.initEvent("input",!0,!0,this.options.contentWindow),d=0;d<this.elements.length;d+=1)this.elements[d].dispatchEvent(e);this.checkSelection(),this.showToolbarActions(),a.value=""},positionToolbarIfShown:function(){this.isToolbarShown()&&this.setToolbarPosition()},bindWindowActions:function(){var a=this;return this.options.staticToolbar&&this.options.stickyToolbar&&this.on(this.options.contentWindow,"scroll",function(){a.positionToolbarIfShown()
},!0),this.on(this.options.contentWindow,"resize",function(){a.handleResize()}),this},activate:function(){this.isActive||this.setup()},deactivate:function(){var a;if(this.isActive){for(this.isActive=!1,void 0!==this.toolbar&&(this.options.elementsContainer.removeChild(this.anchorPreview),this.options.elementsContainer.removeChild(this.toolbar),delete this.toolbar,delete this.anchorPreview),a=0;a<this.elements.length;a+=1)this.elements[a].removeAttribute("contentEditable"),this.elements[a].removeAttribute("data-medium-element");this.removeAllEvents()}},htmlEntities:function(a){return String(a).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")},bindPaste:function(){var a,b=this;for(this.pasteWrapper=function(a){var c,d,e="",f="text/html",g="text/plain";if(this.classList.remove("medium-editor-placeholder"),!b.options.forcePlainText&&!b.options.cleanPastedHTML)return this;if(b.options.contentWindow.clipboardData&&void 0===a.clipboardData&&(a.clipboardData=b.options.contentWindow.clipboardData,f="Text",g="Text"),a.clipboardData&&a.clipboardData.getData&&!a.defaultPrevented){if(a.preventDefault(),b.options.cleanPastedHTML&&a.clipboardData.getData(f))return b.cleanPaste(a.clipboardData.getData(f));if(b.options.disableReturn||this.getAttribute("data-disable-return"))e=b.htmlEntities(a.clipboardData.getData(g)),l(b.options.ownerDocument,e);else{for(c=a.clipboardData.getData(g).split(/[\r\n]/g),d=0;d<c.length;d+=1)""!==c[d]&&(e+=navigator.userAgent.match(/firefox/i)&&0===d?b.htmlEntities(c[d]):"<p>"+b.htmlEntities(c[d])+"</p>");l(b.options.ownerDocument,e)}}},a=0;a<this.elements.length;a+=1)this.on(this.elements[a],"paste",this.pasteWrapper);return this},setPlaceholders:function(){return!this.options.disablePlaceholders&&this.elements&&this.elements.length&&this.elements.forEach(function(a){this.activatePlaceholder(a),this.on(a,"blur",this.placeholderWrapper.bind(this)),this.on(a,"keypress",this.placeholderWrapper.bind(this))}.bind(this)),this},cleanPaste:function(a){var b,c,d,e=this.getSelectionElement(),f=/<p|<br|<div/.test(a),g=[[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">']];for(b=0;b<g.length;b+=1)a=a.replace(g[b][0],g[b][1]);if(f)for(c=a.split("<br><br>"),this.pasteHTML("<p>"+c.join("</p><p>")+"</p>"),this.options.ownerDocument.execCommand("insertText",!1,"\n"),c=e.querySelectorAll("a,p,div,br"),b=0;b<c.length;b+=1)switch(d=c[b],d.tagName.toLowerCase()){case"a":this.options.targetBlank&&this.setTargetBlank(d);break;case"p":case"div":this.filterCommonBlocks(d);break;case"br":this.filterLineBreak(d)}else this.pasteHTML(a)},pasteHTML:function(a){var b,c,d,e,f=this.options.ownerDocument.createDocumentFragment();for(f.appendChild(this.options.ownerDocument.createElement("body")),e=f.querySelector("body"),e.innerHTML=a,this.cleanupSpans(e),b=e.querySelectorAll("*"),d=0;d<b.length;d+=1)c=b[d],c.removeAttribute("class"),c.removeAttribute("style"),c.removeAttribute("dir"),"meta"===c.tagName.toLowerCase()&&c.parentNode.removeChild(c);this.options.ownerDocument.execCommand("insertHTML",!1,e.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.removeChild(a)},filterLineBreak:function(a){this.isCommonBlock(a.previousElementSibling)?a.parentNode.removeChild(a):!this.isCommonBlock(a.parentNode)||a.parentNode.firstChild!==a&&a.parentNode.lastChild!==a?1===a.parentNode.childElementCount&&this.removeWithParent(a):a.parentNode.removeChild(a)},removeWithParent:function(a){a&&a.parentNode&&(a.parentNode.parentNode&&1===a.parentNode.childElementCount?a.parentNode.parentNode.removeChild(a.parentNode):a.parentNode.removeChild(a.parentNode))},cleanupSpans:function(a){var b,c,d,e=a.querySelectorAll(".replace-with");for(b=0;b<e.length;b+=1)c=e[b],d=this.options.ownerDocument.createElement(c.classList.contains("bold")?"b":"i"),d.innerHTML=c.classList.contains("bold")&&c.classList.contains("italic")?"<i>"+c.innerHTML+"</i>":c.innerHTML,c.parentNode.replaceChild(d,c);for(e=a.querySelectorAll("span"),b=0;b<e.length;b+=1)c=e[b],/^\s*$/.test()?c.parentNode.removeChild(c):c.parentNode.replaceChild(this.options.ownerDocument.createTextNode(c.textContent),c)}}}(window,document);
{
"name": "medium-editor",
"version": "2.0.0",
"version": "2.1.0",
"author": "Davi Ferreira <hi@daviferreira.com>",

@@ -5,0 +5,0 @@ "description": "Medium.com WYSIWYG editor clone.",

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

* __secondHeader__: HTML tag to be used as second header. Default: h4
* __standardizeSelectionStart__: Standardizes how the beginning of a range is decided between browsers whenever the selected text is analyzed for updating toolbar buttons status

@@ -81,2 +82,3 @@ ### Toolbar options

* __lastButtonClass__: CSS class added to the last button in the toolbar. Default: 'medium-editor-button-last'
* __onShowToolbar__: optional callback that will be called each time the toolbar is actually shown for this instance of medium-editor.
* __onHideToolbar__: optional callback that will be called each time the toolbar is actually hidden for this instance of medium-editor.

@@ -304,84 +306,88 @@ * __staticToolbar__: enable/disable the toolbar always displaying in the same location relative to the medium-editor element. Default: false

project : medium-editor
repo age : 1 year, 7 months
active : 206 days
commits : 694
files : 59
repo age : 1 year, 8 months
active : 217 days
commits : 730
files : 61
authors :
478 Davi Ferreira 68.9%
20 Maxime de Visscher 2.9%
18 Andy Yaco-Mink 2.6%
9 Noah Chase 1.3%
8 Jarl Gunnar T. Flaten 1.2%
8 Seif 1.2%
8 Derek Odegard 1.2%
8 Pedro Nasser 1.2%
7 Aidan Threadgold 1.0%
7 Alfonso (the fonz) de la Osa 1.0%
7 OmniaGM 1.0%
6 Pascal 0.9%
6 Dayjo 0.9%
5 Nate Mielnik 0.7%
5 Raul Matei 0.7%
5 Martin Thurau 0.7%
4 Sebastian Zuchmanski 0.6%
4 minikomi 0.6%
3 Troels Knak-Nielsen 0.4%
3 Pavel Linkesch 0.4%
3 Dmitri Cherniak 0.4%
3 ʞuıɯ-oɔɐʎ ʎpuɐ 0.4%
3 Andrew Hubbs 0.4%
3 Nikita Korotaev 0.4%
3 arol 0.4%
2 Son Tran-Nguyen 0.3%
2 Alexander Hofbauer 0.3%
2 Ethan Turkeltaub 0.3%
2 Jacob Magnusson 0.3%
2 Jeremy 0.3%
2 Joel 0.3%
2 jj 0.3%
2 mako 0.3%
1 Max 0.1%
1 Maxime De Visscher 0.1%
1 Johann Troendle 0.1%
1 Michael Kay 0.1%
1 Moore Adam 0.1%
1 Jeff Welch 0.1%
1 Nic Malan 0.1%
1 Nick Semenkovich 0.1%
1 Jack Parker 0.1%
1 Ionică Bizău 0.1%
1 Noah Paessel 0.1%
1 IndieSquidge 0.1%
1 Harshil Shah 0.1%
1 Patrick Kempff 0.1%
1 Diana Liao 0.1%
1 Denis Gorbachev 0.1%
1 Peleg Rosenthal 0.1%
1 Randson Oliveira 0.1%
1 David Hellsing 0.1%
1 Richard Park 0.1%
1 Robert Koritnik 0.1%
1 Sarah Squire 0.1%
1 Scott Carleton 0.1%
1 David Collien 0.1%
1 Dave Jarvis 0.1%
1 Adam Mulligan 0.1%
1 Søren Torp Petersen 0.1%
1 Tom MacWright 0.1%
1 Cenk Dölek 0.1%
1 Carlos Alexandre Fuechter 0.1%
1 happyaccidents 0.1%
1 zzjin 0.1%
1 Alberto Gasparin 0.1%
1 mako yass 0.1%
1 mbrookes 0.1%
1 Bitdeli Chef 0.1%
1 muescha 0.1%
1 shaohua 0.1%
1 t_kjaergaard 0.1%
1 typify 0.1%
1 valentinnew 0.1%
1 waffleio 0.1%
1 Mark Kraemer 0.1%
1 Maxime Dantec 0.1%
497 Davi Ferreira 68.1%
20 Maxime de Visscher 2.7%
18 Andy Yaco-Mink 2.5%
15 Nate Mielnik 2.1%
9 Noah Chase 1.2%
8 Derek Odegard 1.1%
8 Jarl Gunnar T. Flaten 1.1%
8 Pedro Nasser 1.1%
8 Seif 1.1%
7 Aidan Threadgold 1.0%
7 Alfonso (the fonz) de la Osa 1.0%
7 OmniaGM 1.0%
6 Dayjo 0.8%
6 Pascal 0.8%
5 Martin Thurau 0.7%
5 Raul Matei 0.7%
4 Sebastian Zuchmanski 0.5%
4 minikomi 0.5%
3 Andrew Hubbs 0.4%
3 Brian Reavis 0.4%
3 Dmitri Cherniak 0.4%
3 Nikita Korotaev 0.4%
3 Pavel Linkesch 0.4%
3 Troels Knak-Nielsen 0.4%
3 arol 0.4%
3 ʞuıɯ-oɔɐʎ ʎpuɐ 0.4%
2 Alexander Hofbauer 0.3%
2 Ethan Turkeltaub 0.3%
2 Jacob Magnusson 0.3%
2 Jeremy 0.3%
2 Joel 0.3%
2 Karl Sander 0.3%
2 Son Tran-Nguyen 0.3%
2 jj 0.3%
2 mako 0.3%
1 Adam Mulligan 0.1%
1 Alberto Gasparin 0.1%
1 Bitdeli Chef 0.1%
1 Carlos Alexandre Fuechter 0.1%
1 Cenk Dölek 0.1%
1 Dave Jarvis 0.1%
1 David Collien 0.1%
1 David Hellsing 0.1%
1 Denis Gorbachev 0.1%
1 Diana Liao 0.1%
1 Harshil Shah 0.1%
1 IndieSquidge 0.1%
1 Ionică Bizău 0.1%
1 Jack Parker 0.1%
1 Jeff Bellsey 0.1%
1 Jeff Welch 0.1%
1 Johann Troendle 0.1%
1 Mark Kraemer 0.1%
1 Max 0.1%
1 Maxime Dantec 0.1%
1 Maxime De Visscher 0.1%
1 Michael Kay 0.1%
1 Moore Adam 0.1%
1 Nic Malan 0.1%
1 Nick Semenkovich 0.1%
1 Noah Paessel 0.1%
1 Patrick Cavanaugh 0.1%
1 Patrick Kempff 0.1%
1 Peleg Rosenthal 0.1%
1 Randson Oliveira 0.1%
1 Richard Park 0.1%
1 Robert Koritnik 0.1%
1 Sarah Squire 0.1%
1 Scott Carleton 0.1%
1 Søren Torp Petersen 0.1%
1 Tom MacWright 0.1%
1 happyaccidents 0.1%
1 mako yass 0.1%
1 mbrookes 0.1%
1 muescha 0.1%
1 shaohua 0.1%
1 t_kjaergaard 0.1%
1 typify 0.1%
1 valentinnew 0.1%
1 waffleio 0.1%
1 zzjin 0.1%
```

@@ -388,0 +394,0 @@

@@ -65,2 +65,27 @@ /*global MediumEditor, describe, it, expect, spyOn, jasmine, fireEvent,

it('should abort any pending throttled event handlers', function () {
var editor, triggerEvents;
editor = new MediumEditor('.editor', {delay: 5});
triggerEvents = function() {
fireEvent(window, 'resize', null, false);
fireEvent(document.body, 'click', null, false, document.body);
fireEvent(document.body, 'blur', null, false);
};
// fire event (handler executed immediately)
triggerEvents();
jasmine.clock().tick(1);
// fire event again (handler delayed because of throttle)
triggerEvents();
spyOn(editor, 'positionToolbarIfShown').and.callThrough(); // via: handleResize
spyOn(editor, 'hideToolbarActions').and.callThrough(); // via: handleBlur
editor.deactivate();
jasmine.clock().tick(1000); // arbitrary – must be longer than THROTTLE_INTERVAL
expect(editor.positionToolbarIfShown).not.toHaveBeenCalled();
expect(editor.hideToolbarActions).not.toHaveBeenCalled();
});
// regression test for https://github.com/daviferreira/medium-editor/issues/197

@@ -67,0 +92,0 @@ it('should not crash when deactivated immediately after a mouse click', function () {

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

});
it('should set element role attribute to textbox', function () {
var editor = new MediumEditor('.editor');
expect(editor.elements.length).toBe(1);
expect(this.el.getAttribute('role')).toEqual('textbox');
});
it('should set element aria multiline attribute to true', function () {
var editor = new MediumEditor('.editor');
expect(editor.elements.length).toBe(1);
expect(this.el.getAttribute('aria-multiline')).toEqual('true');
});
});
});

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

editor = new MediumEditor(elements);
expect(editor.elements).toBe(elements);
expect(editor.elements.length).toEqual(elements.length);
});

@@ -61,2 +61,27 @@

});
it('should always initalize elements as an Array', function() {
var nodeList = document.querySelectorAll('span'),
node = document.querySelector('span'),
editor = new MediumEditor(nodeList);
// nodeList is a NodeList, similar to an array but not of the same type
expect(editor.elements.length).toEqual(nodeList.length);
expect(typeof editor.elements).not.toBe(typeof nodeList);
editor.deactivate();
editor = new MediumEditor('span');
expect(editor.elements.length).toEqual(nodeList.length);
editor.deactivate();
editor = new MediumEditor(node);
expect(editor.elements.length).toEqual(1);
expect(editor.elements[0]).toBe(node);
editor.deactivate();
editor = new MediumEditor();
expect(editor.elements).not.toBe(null);
expect(editor.elements.length).toBe(0);
editor.deactivate();
});
});

@@ -88,2 +113,3 @@

elementsContainer: document.body,
standardizeSelectionStart: false,
contentWindow: window,

@@ -90,0 +116,0 @@ ownerDocument: document,

/*global MediumEditor, describe, it, expect, spyOn,
afterEach, beforeEach, selectElementContents, runs,
fireEvent, waitsFor, tearDown, xit */
fireEvent, waitsFor, tearDown, xit, jasmine */

@@ -12,2 +12,5 @@ describe('Toolbar TestCase', function () {

document.body.appendChild(this.el);
this.elTwo = document.createElement('div');
this.elTwo.id = 'editor-div-two';
document.body.appendChild(this.elTwo);
});

@@ -38,2 +41,19 @@

it('should call the onShowToolbar callback if set', function () {
this.el.innerHTML = 'specOnShowToolbarTest';
var editor = new MediumEditor('.editor');
editor.onShowToolbar = function() {};
spyOn(editor, 'onShowToolbar').and.callThrough();
jasmine.clock().install();
try {
selectElementContents(this.el);
editor.checkSelection();
jasmine.clock().tick(501);
expect(editor.toolbar.classList.contains('medium-editor-toolbar-active')).toBe(true);
expect(editor.onShowToolbar).toHaveBeenCalled();
} finally {
jasmine.clock().uninstall();
}
});
it('should not create an anchor form element if disableAnchorForm is set to true', function() {

@@ -68,2 +88,11 @@ expect(document.querySelectorAll('.medium-editor-toolbar-form-anchor').length).toBe(0);

describe('Disable', function () {
beforeEach(function () {
jasmine.clock().install();
});
afterEach(function () {
jasmine.clock().uninstall();
});
it('should not show the toolbar on elements when option disableToolbar is set to true', function () {

@@ -104,3 +133,3 @@ var editor = new MediumEditor('.editor', {

it('should not display toolbar when selected text within an element with contenteditable="false"', function (done) {
it('should not display toolbar when selected text within an element with contenteditable="false"', function () {
var element = document.createElement('div'),

@@ -118,10 +147,41 @@ editor = null;

setTimeout(function(){
expect(editor.toolbar.classList.contains('medium-editor-toolbar-active')).toBe(false);
done();
}, 500);
jasmine.clock().tick(51);
expect(editor.toolbar.classList.contains('medium-editor-toolbar-active')).toBe(false);
});
it('should enable bold button in toolbar when bold text is selected', function() {
var editor = null;
this.el.innerHTML = 'lorem ipsum <b><div id="cef_el">dolor</div></b>';
editor = new MediumEditor(document.querySelectorAll('.editor'), { delay: 0 });
selectElementContents(document.getElementById('cef_el'));
editor.checkSelection();
jasmine.clock().tick(51);
expect(editor.toolbar.querySelector('button[data-action="bold"]').classList.contains('medium-editor-button-active')).toBe(true);
});
it('should not activate buttons in toolbar when stopSelectionUpdates has been called, but should activate buttons after startSelectionUpdates is called', function() {
var editor = null;
this.el.innerHTML = 'lorem ipsum <b><div id="cef_el">dolor</div></b>';
editor = new MediumEditor(document.querySelectorAll('.editor'), { delay: 0 });
selectElementContents(document.getElementById('cef_el'));
editor.stopSelectionUpdates();
editor.checkSelection();
jasmine.clock().tick(51);
expect(editor.toolbar.querySelector('button[data-action="bold"]').classList.contains('medium-editor-button-active')).toBe(false);
editor.startSelectionUpdates();
editor.checkSelection();
jasmine.clock().tick(51);
expect(editor.toolbar.querySelector('button[data-action="bold"]').classList.contains('medium-editor-button-active')).toBe(true);
});
it('should call onHideToolbar when toolbar is hidden', function () {

@@ -140,2 +200,30 @@ var editor = new MediumEditor('.editor');

it('should hide the toolbar for one medium-editor instance when another medium-editor instance shows its toolbar', function() {
var editorOne,
editorTwo;
this.el.innerHTML = '<span id="editor-span-1">lorem ipsum</span>';
this.elTwo.innerHTML = '<span id="editor-span-2">lorem ipsum</span>';
editorOne = new MediumEditor('.editor', { updateOnEmptySelection: true, delay: 0, staticToolbar: true });
editorTwo = new MediumEditor('#editor-div-two', { updateOnEmptySelection: true, delay: 0, staticToolbar: true });
selectElementContents(document.getElementById('editor-span-1'));
fireEvent(editorOne.elements[0], 'focus');
jasmine.clock().tick(51);
expect(editorOne.toolbar.classList.contains('medium-editor-toolbar-active')).toBe(true);
expect(editorTwo.toolbar.classList.contains('medium-editor-toolbar-active')).toBe(false);
fireEvent(editorOne.elements[0], 'blur');
selectElementContents(document.getElementById('editor-span-2'));
fireEvent(editorTwo.elements[0], 'focus');
jasmine.clock().tick(51);
expect(editorOne.toolbar.classList.contains('medium-editor-toolbar-active')).toBe(false);
expect(editorTwo.toolbar.classList.contains('medium-editor-toolbar-active')).toBe(true);
});
// jasmine 2.0 changed async tests, runs no longer exists

@@ -142,0 +230,0 @@ xit('should show the toolbar if it\'s text are selected even though one or more elements that has a data attr of disable-toolbar', function () {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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

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