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

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 2.1.3 to 2.2.0

2

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

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

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

2.2.0 / 2015-02-05
==================
* Fix bug in getSelectedParentElement + Fix tests in browsers
* Fall back to shimmed insertHTML in cases where firefox throws
when calling insertHTML
* Prevent "Argument not optional" error
* Prevent infinite loop after findAdjacentTextNodeWithContent
* Remove cleanups from contenteditable false areas
* Firefox fix: Don't modify value of input before calling execCommand()
* Fix selection issue for clean pasted html test case in firefox
* Add image drag and drop support
2.1.3 / 2015-01-31

@@ -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){var c,d,e,f,g=50,h=null,i=0;return b||0===b||(b=g),f=function(){i=n(),h=null,e=a.apply(c,d),h||(c=d=null)},function(){var g=n(),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&&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(b,c){var d,e;return c||(c=a.getSelection().getRangeAt(0)),d=c.cloneRange(),e=c.cloneRange(),d.selectNodeContents(b),d.setEnd(c.endContainer,c.endOffset),e.selectNodeContents(b),e.setStart(c.endContainer,c.endOffset),{left:d.toString().length,right:e.toString().length}}function l(a){return!(!a||1!==a.nodeType)}function m(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 n=Date.now||function(){return(new Date).getTime()};MediumEditor.prototype={defaults:{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,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()},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.passInstance().callExtensions("init").initToolbar().bindButtons().bindAnchorForm().bindAnchorPreview(),this},setElementSelection:function(a){a||(a=[]),"string"==typeof a&&(a=this.options.ownerDocument.querySelectorAll(a)),l(a)&&(a=[a]),this.elements=Array.prototype.slice.apply(a)},bindBlur:function(){var a=this,b=function(b){var c,d=!1;for(c=0;c<a.elements.length;c+=1)if(e(a.elements[c],b.target)){d=!0;break}b.target===a.toolbar||-1!==a.elements.indexOf(b.target)||d||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).bindKeydown(a).bindBlur().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));return this}},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||/h\d/.test(c)||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},bindKeydown: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))}else(8===a.which||46===a.which||13===a.which)&&b.onBlockModifier(a)}),this},onBlockModifier:function(c){var d,e,f,g=i.call(this),h=g.tagName.toLowerCase(),j=/^(\s+|<br\/?>)?$/i,l=/h\d/i;(8===c.which||13===c.which)&&g.previousElementSibling&&l.test(h)&&0===k(g).left?8===c.which&&j.test(g.previousElementSibling.innerHTML)?(g.previousElementSibling.parentNode.removeChild(g.previousElementSibling),c.preventDefault()):13===c.which&&(f=this.options.ownerDocument.createElement("p"),f.innerHTML="<br>",g.previousElementSibling.parentNode.insertBefore(f,g),c.preventDefault()):46===c.which&&g.nextElementSibling&&g.previousElementSibling&&!l.test(h)&&j.test(g.innerHTML)&&l.test(g.nextElementSibling.tagName)&&(d=b.createRange(),e=a.getSelection(),d.setStart(g.nextElementSibling,0),d.collapse(!0),e.removeAllRanges(),e.addRange(d),g.previousElementSibling.parentNode.removeChild(g),c.preventDefault())},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.addExtensionForms(),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"),this.anchorInput=this.anchorForm.querySelector("input.medium-editor-toolbar-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,d.hasForm&&c.setAttribute("data-form","medium-editor-toolbar-form-"+e[b]+"-"+this.id)):c=this.buttonTemplate(e[b]),c&&(a=this.options.ownerDocument.createElement("li"),l(c)?a.appendChild(c):a.innerHTML=c,f.appendChild(a));return f},addExtensionForms:function(){var a,b,c,d,e=this.options.extensions;for(b in e)e.hasOwnProperty(b)&&(a=e[b],a.hasForm&&(c=void 0!==a.getForm?a.getForm():null),c&&(d="medium-editor-toolbar-form-"+b+"-"+this.id,c.className="medium-editor-toolbar-form",c.id=d,a.getForm().id=d,this.toolbar.appendChild(c)))},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-close",g.innerHTML="&times;",h.setAttribute("href","#"),h.className="medium-editor-toobar-save",h.innerHTML="&#10003;",b.setAttribute("type","text"),b.className="medium-editor-toolbar-input",b.setAttribute("placeholder",this.options.anchorInputPlaceholder),d.setAttribute("type","checkbox"),d.className="medium-editor-toolbar-anchor-target",c.innerHTML=this.options.anchorInputCheckboxLabel,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",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.startContainer.nodeValue&&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,l=f.left+f.width/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=this.options.toolbarAlign?"left"===this.options.toolbarAlign?f.left+"px":"center"===this.options.toolbarAlign?l-k+"px":f.right-this.toolbar.offsetWidth+"px":l-k+"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),this.hasAttribute("data-form")&&c.showForm(this.getAttribute("data-form"),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())},showForm:function(a){this.toolbarActions.style.display="none",this.saveSelection();var c=b.getElementById(a);c.style.display="block",this.setToolbarPosition(),this.keepToolbarAlive=!0},hideForm:function(a){var c=b.getElementById(a.id);c.style.display="none",this.showToolbarActions(),this.setToolbarPosition(),h.call(this,this.savedSelection)},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-close"),b=this.anchorForm.querySelector("a.medium-editor-toobar-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)),m(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>");m(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);
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=n(),h=null,e=a.apply(c,d),h||(c=d=null)},function(){var g=n(),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,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}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(b,c){var d,e;return c||(c=a.getSelection().getRangeAt(0)),d=c.cloneRange(),e=c.cloneRange(),d.selectNodeContents(b),d.setEnd(c.endContainer,c.endOffset),e.selectNodeContents(b),e.setStart(c.endContainer,c.endOffset),{left:d.toString().length,right:e.toString().length}}function l(a){return!(!a||1!==a.nodeType)}function m(b,c){var d,e,f,g,h,i;if(b.queryCommandSupported("insertHTML"))try{return b.execCommand("insertHTML",!1,c)}catch(j){}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 n=Date.now||function(){return(new Date).getTime()};MediumEditor.prototype={defaults:{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,cleanPastedHTML:!1,delay:0,diffLeft:0,diffTop:-10,disableReturn:!1,disableDoubleReturn:!1,disableToolbar:!1,disableEditing:!1,disableAnchorForm:!1,disablePlaceholders:!1,elementsContainer:!1,imageDragging:!0,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().bindDragDrop().bindPaste().setPlaceholders().bindElementActions().bindWindowActions()},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.passInstance().callExtensions("init").initToolbar().bindButtons().bindAnchorForm().bindAnchorPreview(),this},setElementSelection:function(a){a||(a=[]),"string"==typeof a&&(a=this.options.ownerDocument.querySelectorAll(a)),l(a)&&(a=[a]),this.elements=Array.prototype.slice.apply(a)},bindBlur:function(){var a=this,b=function(b){var c,d=!1;for(c=0;c<a.elements.length;c+=1)if(e(a.elements[c],b.target)){d=!0;break}b.target===a.toolbar||-1!==a.elements.indexOf(b.target)||d||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).bindKeydown(a).bindBlur().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));return this}},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||/h\d/.test(c)||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},bindKeydown: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))}else(8===a.which||46===a.which||13===a.which)&&b.onBlockModifier(a)}),this},onBlockModifier:function(c){var d,e,f,g=i.call(this),h=g.tagName.toLowerCase(),j=/^(\s+|<br\/?>)?$/i,l=/h\d/i;(8===c.which||13===c.which)&&g.previousElementSibling&&l.test(h)&&0===k(g).left?8===c.which&&j.test(g.previousElementSibling.innerHTML)?(g.previousElementSibling.parentNode.removeChild(g.previousElementSibling),c.preventDefault()):13===c.which&&(f=this.options.ownerDocument.createElement("p"),f.innerHTML="<br>",g.previousElementSibling.parentNode.insertBefore(f,g),c.preventDefault()):46===c.which&&g.nextElementSibling&&g.previousElementSibling&&!l.test(h)&&j.test(g.innerHTML)&&l.test(g.nextElementSibling.tagName)&&(d=b.createRange(),e=a.getSelection(),d.setStart(g.nextElementSibling,0),d.collapse(!0),e.removeAllRanges(),e.addRange(d),g.previousElementSibling.parentNode.removeChild(g),c.preventDefault())},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.addExtensionForms(),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"),this.anchorInput=this.anchorForm.querySelector("input.medium-editor-toolbar-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,d.hasForm&&c.setAttribute("data-form","medium-editor-toolbar-form-"+e[b]+"-"+this.id)):c=this.buttonTemplate(e[b]),c&&(a=this.options.ownerDocument.createElement("li"),l(c)?a.appendChild(c):a.innerHTML=c,f.appendChild(a));return f},addExtensionForms:function(){var a,b,c,d,e=this.options.extensions;for(b in e)e.hasOwnProperty(b)&&(a=e[b],a.hasForm&&(c=void 0!==a.getForm?a.getForm():null),c&&(d="medium-editor-toolbar-form-"+b+"-"+this.id,c.className="medium-editor-toolbar-form",c.id=d,a.getForm().id=d,this.toolbar.appendChild(c)))},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-close",g.innerHTML="&times;",h.setAttribute("href","#"),h.className="medium-editor-toobar-save",h.innerHTML="&#10003;",b.setAttribute("type","text"),b.className="medium-editor-toolbar-input",b.setAttribute("placeholder",this.options.anchorInputPlaceholder),d.setAttribute("type","checkbox"),d.className="medium-editor-toolbar-anchor-target",c.innerHTML=this.options.anchorInputCheckboxLabel,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",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},bindDragDrop:function(){var a,c,d,e,f,g=this;if(g.options.imageDragging){for(c="medium-editor-dragover",d=function(a){a.preventDefault(),a.dataTransfer.dropEffect="copy","dragover"===a.type?this.classList.add(c):this.classList.remove(c)},e=function(a){var d;a.preventDefault(),a.stopPropagation(),d=Array.prototype.slice.call(a.dataTransfer.files,0),d.some(function(a){if(a.type.match("image")){var c,d;c=new FileReader,c.readAsDataURL(a),d="medium-img-"+ +new Date,m(g.options.ownerDocument,'<img class="medium-image-loading" id="'+d+'" />'),c.onload=function(){var a=b.getElementById(d);a&&(a.removeAttribute("id"),a.removeAttribute("class"),a.src=c.result)}}}),this.classList.remove(c)},a=0;a<this.elements.length;a+=1)f=this.elements[a],this.on(f,"dragover",d),this.on(f,"dragleave",d),this.on(f,"drop",e);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.startContainer.nodeValue&&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()},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},findMatchingSelectionParent:function(a){var b,c,d=this.options.contentWindow.getSelection();return 0===d.rangeCount?!1:(b=d.getRangeAt(0),c=b.commonAncestorContainer,this.traverseUp(c,a))},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,l=f.left+f.width/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=this.options.toolbarAlign?"left"===this.options.toolbarAlign?f.left+"px":"center"===this.options.toolbarAlign?l-k+"px":f.right-this.toolbar.offsetWidth+"px":l-k+"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),this.hasAttribute("data-form")&&c.showForm(this.getAttribute("data-form"),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())},showForm:function(a){this.toolbarActions.style.display="none",this.saveSelection();var c=b.getElementById(a);c.style.display="block",this.setToolbarPosition(),this.keepToolbarAlive=!0},hideForm:function(a){var c=b.getElementById(a.id);c.style.display="none",this.showToolbarActions(),this.setToolbarPosition(),h.call(this,this.savedSelection)},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)&&3!==b.startContainer.childNodes[b.startOffset].nodeType?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-close"),b=this.anchorForm.querySelector("a.medium-editor-toobar-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(this.createLinkInternal(a.value,b,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=""},createLinkInternal:function(a,b,c){return a&&0!==a.trim().length?(h.call(this,this.savedSelection),this.options.checkLinkFormat&&(a=this.checkLinkFormat(a)),this.options.ownerDocument.execCommand("createLink",!1,a),(this.options.targetBlank||"_blank"===b)&&this.setTargetBlank(),void(c&&this.setButtonClass(c))):void this.hideToolbarActions()},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)),m(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+="<p>"+b.htmlEntities(c[d])+"</p>");m(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);m(this.options.ownerDocument,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"),f=function(a){return a&&"#text"!==a.nodeName&&"false"===a.getAttribute("contenteditable")};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){if(c=e[b],this.traverseUp(c,f))return!1;/^\s*$/.test()?c.parentNode.removeChild(c):c.parentNode.replaceChild(this.options.ownerDocument.createTextNode(c.textContent),c)}}}}(window,document);
{
"name": "medium-editor",
"version": "2.1.3",
"version": "2.2.0",
"author": "Davi Ferreira <hi@daviferreira.com>",

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

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

* __forcePlainText__: Forces pasting as plain text. Default: true
* __imageDragging--: Allows image drag and drop into the editor. Default: true
* __placeholder__: Defines the default placeholder for empty contenteditables when __disablePlaceholders__ is not set to true. You can overwrite it by setting a data-placeholder attribute on your elements. Default: 'Type your text'

@@ -291,3 +292,3 @@ * __secondHeader__: HTML tag to be used as second header. Default: h4

if(this.base.options.buttonLabels === 'fontawesome'){
this.button.innerHTML = '<i class="fa fa-table"></i>';
this.button.innerHTML = '<i class="fa fa-table"></i>';
}

@@ -368,3 +369,3 @@ this.button.onclick = this.onClick.bind(this);

headerCol.innerHTML = '...';
headerRow.appendChild(headerCol);
headerRow.appendChild(headerCol);
}

@@ -379,3 +380,3 @@

bodyCol.innerHTML = '...';
bodyRow.appendChild(bodyCol);
bodyRow.appendChild(bodyCol);
}

@@ -440,4 +441,2 @@ body.appendChild(bodyRow);

[![Stories in Ready](https://badge.waffle.io/daviferreira/medium-editor.png)](https://waffle.io/daviferreira/medium-editor)
1. Fork it

@@ -456,22 +455,23 @@ 2. Create your feature branch (`git checkout -b my-new-feature`)

repo age : 1 year, 8 months
active : 217 days
commits : 730
files : 61
active : 233 days
commits : 804
files : 62
authors :
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%
520 Davi Ferreira 64.7%
30 Andy Yaco-Mink 3.7%
30 Nate Mielnik 3.7%
20 Maxime de Visscher 2.5%
18 Noah Chase 2.2%
8 Derek Odegard 1.0%
8 Jarl Gunnar T. Flaten 1.0%
8 Pedro Nasser 1.0%
8 Seif 1.0%
7 Aidan Threadgold 0.9%
7 Alfonso (the fonz) de la Osa 0.9%
7 Charl Gottschalk 0.9%
7 OmniaGM 0.9%
6 Dayjo 0.7%
6 Pascal 0.7%
5 Martin Thurau 0.6%
5 Raul Matei 0.6%
4 Sebastian Zuchmanski 0.5%

@@ -482,3 +482,5 @@ 4 minikomi 0.5%

3 Dmitri Cherniak 0.4%
3 Javier Marín 0.4%
3 Nikita Korotaev 0.4%
3 Patrick Cavanaugh 0.4%
3 Pavel Linkesch 0.4%

@@ -488,14 +490,16 @@ 3 Troels Knak-Nielsen 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%
2 Alexander Hofbauer 0.2%
2 Ethan Turkeltaub 0.2%
2 Jacob Magnusson 0.2%
2 Jeremy 0.2%
2 Joel 0.2%
2 Karl Sander 0.2%
2 Son Tran-Nguyen 0.2%
2 jj 0.2%
2 mako 0.2%
1 Adam Mulligan 0.1%
1 Alberto Gasparin 0.1%
1 Bitdeli Chef 0.1%
1 Brooke McKim 0.1%
1 Bruno Peres 0.1%
1 Carlos Alexandre Fuechter 0.1%

@@ -508,2 +512,3 @@ 1 Cenk Dölek 0.1%

1 Diana Liao 0.1%
1 Enrico Berti 0.1%
1 Harshil Shah 0.1%

@@ -525,3 +530,2 @@ 1 IndieSquidge 0.1%

1 Noah Paessel 0.1%
1 Patrick Cavanaugh 0.1%
1 Patrick Kempff 0.1%

@@ -528,0 +532,0 @@ 1 Peleg Rosenthal 0.1%

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

@@ -112,9 +112,7 @@ describe('Activate/Deactivate TestCase', function () {

selectElementContents(editor.elements[0]);
fireEvent(editor.elements[0], 'click');
selectElementContentsAndFire(editor.elements[0], { eventToFire: 'click' });
jasmine.clock().tick(51);
expect(editor.hideToolbarActions).not.toHaveBeenCalled();
selectElementContents(editor.elements[1]);
fireEvent(editor.elements[1], 'click');
selectElementContentsAndFire(editor.elements[1], { eventToFire: 'click' });
jasmine.clock().tick(51);

@@ -124,3 +122,3 @@ expect(editor.hideToolbarActions).not.toHaveBeenCalled();

selectElementContents(editor.elements[2]);
fireEvent(editor.elements[2], 'click');
selectElementContentsAndFire(editor.elements[2], { eventToFire: 'click' });
jasmine.clock().tick(51);

@@ -148,4 +146,5 @@ expect(editor.hideToolbarActions).not.toHaveBeenCalled();

jasmine.clock().tick(501);
expect(true).toBe(true);
});
});
});

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

}),
sel = window.getSelection();
sel = window.getSelection(),
nextRange;

@@ -52,4 +53,6 @@ // show preview

spyOn(MediumEditor.prototype, 'hideToolbarActions').and.callThrough();
nextRange = document.createRange();
nextRange.selectNodeContents(document.getElementById('another-element'));
sel.removeAllRanges();
sel.addRange(document.createRange().selectNodeContents(document.getElementById('another-element')));
sel.addRange(nextRange);
fireEvent(document.documentElement, 'mouseup');

@@ -56,0 +59,0 @@ jasmine.clock().tick(200);

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

@@ -26,4 +27,3 @@ describe('Anchor Button TestCase', function () {

editor = new MediumEditor('.editor');
selectElementContents(editor.elements[0]);
fireEvent(editor.elements[0], 'mouseup');
selectElementContentsAndFire(editor.elements[0]);
jasmine.clock().tick(1);

@@ -41,4 +41,3 @@ button = editor.toolbar.querySelector('[data-element="a"]');

editor = new MediumEditor('.editor');
selectElementContents(editor.elements[0]);
fireEvent(editor.elements[0], 'mouseup');
selectElementContentsAndFire(editor.elements[0]);
jasmine.clock().tick(1);

@@ -58,4 +57,3 @@ button = editor.toolbar.querySelector('[data-element="a"]');

editor = new MediumEditor('.editor');
selectElementContents(editor.elements[0]);
fireEvent(editor.elements[0], 'mouseup');
selectElementContentsAndFire(editor.elements[0]);
jasmine.clock().tick(1);

@@ -102,7 +100,7 @@ button = editor.toolbar.querySelector('[data-element="a"]');

checkLinkFormat: true
}),
input = editor.anchorForm.querySelector('input');
selectElementContents(editor.elements[0]);
input.value = 'test.com';
editor.createLink(input);
});
selectElementContentsAndFire(editor.elements[0]);
editor.showAnchorForm('test.com');
fireEvent(editor.anchorForm.querySelector('a.medium-editor-toobar-save'), 'click');
expect(editor.elements[0].querySelector('a').href).toBe('http://test.com/');

@@ -114,7 +112,7 @@ });

}),
input = editor.anchorForm.querySelector('input'),
validUrl = 'mailto:test.com';
selectElementContents(editor.elements[0]);
input.value = validUrl;
editor.createLink(input);
selectElementContentsAndFire(editor.elements[0]);
editor.showAnchorForm(validUrl);
fireEvent(editor.anchorForm.querySelector('a.medium-editor-toobar-save'), 'click');
expect(editor.elements[0].querySelector('a').href).toBe(validUrl);

@@ -125,7 +123,7 @@ });

targetBlank: true
}),
input = editor.anchorForm.querySelector('input');
selectElementContents(editor.elements[0]);
input.value = 'http://test.com';
editor.createLink(input);
});
selectElementContentsAndFire(editor.elements[0]);
editor.showAnchorForm('http://test.com');
fireEvent(editor.anchorForm.querySelector('a.medium-editor-toobar-save'), 'click');
expect(editor.elements[0].querySelector('a').target).toBe('_blank');

@@ -156,11 +154,2 @@ });

expect(editor.createLink).toHaveBeenCalledWith(input, '_self', 'btn btn-default');
});
it('should set class when respective option is set to true and checkbox is checked', function () {
var editor = new MediumEditor('.editor'),
input = editor.anchorForm.querySelector('input');
selectElementContents(editor.elements[0]);
input.value = 'http://test.com';
editor.createLink(input, '_blank', 'btn btn-default');
expect(editor.elements[0].querySelector('a').classList.contains('btn')).toBe(true);

@@ -167,0 +156,0 @@ expect(editor.elements[0].querySelector('a').classList.contains('btn-default')).toBe(true);

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

@@ -32,4 +33,3 @@ describe('Buttons TestCase', function () {

this.el.innerHTML = '<b>lorem ipsum</b>';
selectElementContents(editor.elements[0]);
fireEvent(editor.elements[0], 'mouseup');
selectElementContentsAndFire(editor.elements[0]);
jasmine.clock().tick(1);

@@ -49,4 +49,3 @@ button = editor.toolbar.querySelector('[data-element="b"]');

editor = new MediumEditor('.editor');
selectElementContents(editor.elements[0]);
fireEvent(editor.elements[0], 'mouseup');
selectElementContentsAndFire(editor.elements[0]);
jasmine.clock().tick(1);

@@ -62,4 +61,3 @@ button = editor.toolbar.querySelector('[data-element="b"]');

editor = new MediumEditor('.editor');
selectElementContents(editor.elements[0]);
fireEvent(editor.elements[0], 'mouseup');
selectElementContentsAndFire(editor.elements[0]);
jasmine.clock().tick(1);

@@ -76,4 +74,3 @@ button = editor.toolbar.querySelector('[data-element="b"]');

editor = new MediumEditor('.editor');
selectElementContents(editor.elements[0]);
fireEvent(editor.elements[0], 'mouseup');
selectElementContentsAndFire(editor.elements[0]);
jasmine.clock().tick(1);

@@ -90,4 +87,3 @@ button = editor.toolbar.querySelector('[data-element="b"]');

editor = new MediumEditor('.editor');
selectElementContents(editor.elements[0]);
fireEvent(editor.elements[0], 'mouseup');
selectElementContentsAndFire(editor.elements[0]);
jasmine.clock().tick(1);

@@ -103,4 +99,3 @@ button = editor.toolbar.querySelector('[data-element="b"]');

editor = new MediumEditor('.editor');
selectElementContents(editor.elements[0]);
fireEvent(editor.elements[0], 'mouseup');
selectElementContentsAndFire(editor.elements[0]);
jasmine.clock().tick(1);

@@ -110,3 +105,4 @@ button = editor.toolbar.querySelector('[data-element="i"]');

expect(document.execCommand).toHaveBeenCalled();
expect(this.el.innerHTML).toBe('<i>lorem ipsum</i>');
// IE won't generate an `<i>` tag here. it generates an `<em>`:
expect(this.el.innerHTML).toMatch(/(<i>|<em>)lorem ipsum(<\/i>|<\/em>)/);
});

@@ -118,4 +114,3 @@

editor = new MediumEditor('.editor');
selectElementContents(editor.elements[0]);
fireEvent(editor.elements[0], 'mouseup');
selectElementContentsAndFire(editor.elements[0]);
jasmine.clock().tick(1);

@@ -131,4 +126,3 @@ button = editor.toolbar.querySelector('[data-element="b"]');

editor = new MediumEditor('.editor');
selectElementContents(editor.elements[0]);
fireEvent(editor.elements[0], 'mouseup');
selectElementContentsAndFire(editor.elements[0]);
jasmine.clock().tick(1);

@@ -150,4 +144,3 @@ button = editor.toolbar.querySelector('[data-element="a"]');

editor = new MediumEditor('.editor');
selectElementContents(editor.elements[0]);
fireEvent(editor.elements[0], 'mouseup');
selectElementContentsAndFire(editor.elements[0]);
jasmine.clock().tick(1);

@@ -163,8 +156,10 @@ button = editor.toolbar.querySelector('[data-element="h3"]');

editor = new MediumEditor('.editor');
selectElementContents(editor.elements[0]);
fireEvent(editor.elements[0], 'mouseup');
selectElementContentsAndFire(editor.elements[0]);
jasmine.clock().tick(1);
button = editor.toolbar.querySelector('[data-element="h3"]');
fireEvent(button, 'click');
expect(this.el.innerHTML).toBe('<h3><b>lorem ipsum</b></h3>');
// depending on the styling you have,
// IE might strip the <b> out when it applies the H3 here.
// so, make the <b> match optional in the output:
expect(this.el.innerHTML).toMatch(/<h3>(<b>)?lorem ipsum(<\/b>)?<\/h3>/);
});

@@ -176,4 +171,3 @@

editor = new MediumEditor('.editor');
selectElementContents(editor.elements[0]);
fireEvent(editor.elements[0], 'mouseup');
selectElementContentsAndFire(editor.elements[0].firstChild);
jasmine.clock().tick(1);

@@ -180,0 +174,0 @@ button = editor.toolbar.querySelector('[data-element="h3"]');

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

@@ -23,5 +24,4 @@ describe('Clean pasted HTML', function () {

it('Multi-line rich-text pastes', function () {
var i, range,
var i,
editorEl = this.el,
sel = window.getSelection(),
editor = new MediumEditor('.editor', {

@@ -55,6 +55,3 @@ delay: 200,

range = document.createRange();
range.selectNodeContents(document.getElementById('editor-inner'));
sel.removeAllRanges();
sel.addRange(range);
selectElementContentsAndFire(editorEl);

@@ -69,5 +66,4 @@ editor.cleanPaste(tests[i].paste);

it('Inline rich-text pastes', function () {
var i, range,
var i,
editorEl = this.el,
sel = window.getSelection(),
editor = new MediumEditor('.editor', {

@@ -94,12 +90,15 @@ delay: 200,

// move caret to editor
editorEl.innerHTML = 'Before <span id="editor-inner">&nbsp</span> after.';
editorEl.innerHTML = 'Before&nbsp;<span id="editor-inner">&nbsp;</span>&nbsp;after.';
range = document.createRange();
range.selectNodeContents(document.getElementById('editor-inner'));
sel.removeAllRanges();
sel.addRange(range);
selectElementContents(document.getElementById('editor-inner'));
editor.cleanPaste(tests[i].paste);
jasmine.clock().tick(100);
expect(editorEl.innerHTML).toEqual('Before&nbsp;' + tests[i].output + '&nbsp;after.');
if (editorEl.innerHTML.indexOf('<span id="editor-inner">') !== -1) {
// Firefox and IE: doing an insertHTML while this <span> is selected results in the html being inserted inside of the span
expect(editorEl.innerHTML).toEqual('Before&nbsp;<span id="editor-inner">' + tests[i].output + '</span>&nbsp;after.');
} else {
// Chrome, Safari, and our test suite: doing an insertHTML while this <span> is selected results in the span being replaced completely
expect(editorEl.innerHTML).toEqual('Before&nbsp;' + tests[i].output + '&nbsp;after.');
}
}

@@ -106,0 +105,0 @@

@@ -25,2 +25,3 @@ /*global MediumEditor, describe, it, expect, spyOn, jasmine, fireEvent,

el = document.createElement('div');
el = document.body.appendChild(el);
spy = jasmine.createSpy('handler');

@@ -27,0 +28,0 @@ editor = new MediumEditor('.editor');

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

range = document.createRange();
range.selectNodeContents(document.getElementById('editor-inner'));
range.selectNodeContents(editorEl);
sel.removeAllRanges();

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

@@ -26,2 +26,8 @@ function fireEvent (element, event, keyCode, ctrlKey, target, relatedTarget) {

function selectElementContentsAndFire(el, options) {
options = options || {};
selectElementContents(el, options);
fireEvent(el, options.eventToFire || 'mouseup');
}
function selectElementContents(el, options) {

@@ -28,0 +34,0 @@ options = options || {};

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

elementsContainer: document.body,
imageDragging: true,
standardizeSelectionStart: false,

@@ -115,0 +116,0 @@ contentWindow: window,

@@ -66,13 +66,27 @@ /*global MediumEditor, describe, it, expect, spyOn,

/*jslint regexp: true*/
function validatePlaceholderContent(element, expectedValue) {
var placeholder = window.getComputedStyle(element, ':after').getPropertyValue('content'),
regex = /^attr\(([^\)]+)\)$/g,
match = regex.exec(placeholder);
if (match) {
// In firefox, getComputedStyle().getPropertyValue('content') can return attr() instead of what attr() evaluates to
expect(match[1]).toEqual('data-placeholder');
} else {
expect(placeholder).toEqual("'" + expectedValue + "'");
}
}
/*jslint regexp: false*/
it('should add the default placeholder text when data-placeholder is not present', function () {
var editor = new MediumEditor('.editor'),
placeholder = window.getComputedStyle(editor.elements[0], ':after').getPropertyValue('content');
expect(placeholder).toEqual("'" + editor.options.placeholder + "'");
var editor = new MediumEditor('.editor');
validatePlaceholderContent(editor.elements[0], editor.options.placeholder);
});
it('should use the data-placeholder when it is present', function () {
this.el.setAttribute('data-placeholder', 'Custom placeholder');
var editor = new MediumEditor('.editor'),
placeholder = window.getComputedStyle(editor.elements[0], ':after').getPropertyValue('content');
expect(placeholder).toEqual("'Custom placeholder'");
var editor,
placeholderText = 'Custom placeholder';
this.el.setAttribute('data-placeholder', placeholderText);
editor = new MediumEditor('.editor');
validatePlaceholderContent(editor.elements[0], placeholderText);
});

@@ -79,0 +93,0 @@

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

@@ -24,4 +24,3 @@

var editor = new MediumEditor('.editor');
selectElementContents(editor.elements[0]);
fireEvent(editor.elements[0], 'mouseup');
selectElementContentsAndFire(editor.elements[0]);
jasmine.clock().tick(101);

@@ -33,2 +32,3 @@ expect(editor.toolbar.className.indexOf('active') > -1).toBe(true);

expect(editor.setToolbarPosition).toHaveBeenCalled();
editor.deactivate();
});

@@ -35,0 +35,0 @@

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

@@ -13,2 +14,3 @@ describe('Selection TestCase', function () {

document.body.appendChild(this.el);
jasmine.clock().install();
});

@@ -23,3 +25,2 @@

it('should check for selection on mouseup event', function () {
jasmine.clock().install();
spyOn(MediumEditor.prototype, 'checkSelection');

@@ -33,3 +34,2 @@ var editor = new MediumEditor('.editor');

it('should check for selection on keyup', function () {
jasmine.clock().install();
spyOn(MediumEditor.prototype, 'checkSelection');

@@ -68,6 +68,4 @@ var editor = new MediumEditor('.editor');

var editor = new MediumEditor('.editor');
jasmine.clock().install();
expect(editor.toolbar.classList.contains('medium-editor-toolbar-active')).toBe(false);
selectElementContents(this.el);
editor.checkSelection();
selectElementContentsAndFire(this.el);
jasmine.clock().tick(501);

@@ -82,4 +80,4 @@ expect(editor.toolbar.classList.contains('medium-editor-toolbar-active')).toBe(true);

var editor = new MediumEditor('.editor');
selectElementContents(this.el);
editor.checkSelection();
selectElementContentsAndFire(this.el);
jasmine.clock().tick(51);
expect(editor.setToolbarPosition).toHaveBeenCalled();

@@ -97,4 +95,4 @@ expect(editor.setToolbarButtonStates).toHaveBeenCalled();

selectElementContents(this.el, { collapse: 'toStart' });
editor.checkSelection();
selectElementContentsAndFire(this.el, { collapse: 'toStart' });
jasmine.clock().tick(51);

@@ -101,0 +99,0 @@ expect(editor.setToolbarButtonStates).toHaveBeenCalled();

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

@@ -12,5 +13,2 @@ 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);
});

@@ -48,5 +46,4 @@

try {
selectElementContents(this.el);
editor.checkSelection();
jasmine.clock().tick(501);
selectElementContentsAndFire(this.el);
jasmine.clock().tick(51);
expect(editor.toolbar.classList.contains('medium-editor-toolbar-active')).toBe(true);

@@ -76,2 +73,91 @@ expect(editor.onShowToolbar).toHaveBeenCalled();

describe('Toolbars', function () {
beforeEach(function () {
jasmine.clock().install();
});
afterEach(function () {
jasmine.clock().uninstall();
});
it('should enable bold button in toolbar when bold text is selected', function () {
var editor = null,
newElement = document.createElement('div');
newElement.id = 'editor-for-toolbar-test';
newElement.innerHTML = 'lorem ipsum <b><div id="bold_dolorOne">dolor</div></b>';
document.body.appendChild(newElement);
editor = new MediumEditor(document.getElementById('editor-for-toolbar-test'), { delay: 0 });
selectElementContentsAndFire(document.getElementById('bold_dolorOne'));
selectElementContents(document.getElementById('bold_dolorOne'));
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="bold_dolorTwo">dolor</div></b>';
editor = new MediumEditor(document.querySelectorAll('.editor'), { delay: 0 });
editor.stopSelectionUpdates();
selectElementContentsAndFire(document.getElementById('bold_dolorTwo'));
jasmine.clock().tick(51);
expect(editor.toolbar.querySelector('button[data-action="bold"]').classList.contains('medium-editor-button-active')).toBe(false);
editor.startSelectionUpdates();
selectElementContentsAndFire(document.getElementById('bold_dolorTwo'));
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 () {
var editor = new MediumEditor('.editor');
editor.toolbar.classList.add('medium-editor-toolbar-active');
editor.onHideToolbar = function () {};
spyOn(editor, 'onHideToolbar').and.callThrough();
fireEvent(editor.elements[0], 'focus');
fireEvent(editor.elements[0], 'blur');
expect(editor.onHideToolbar).toHaveBeenCalled();
});
it('should hide the toolbar for one medium-editor instance when another medium-editor instance shows its toolbar', function () {
var editorOne,
editorTwo,
elTwo = document.createElement('div');
elTwo.id = 'editor-div-two';
document.body.appendChild(elTwo);
this.el.innerHTML = '<span id="editor-span-1">lorem ipsum</span>';
elTwo.innerHTML = '<span id="editor-span-2">lorem ipsum</span>';
editorOne = new MediumEditor('.editor', { staticToolbar: true });
editorTwo = new MediumEditor(document.getElementById('editor-div-two'), { staticToolbar: true });
selectElementContentsAndFire(document.getElementById('editor-span-1'));
jasmine.clock().tick(1);
expect(editorOne.toolbar.classList.contains('medium-editor-toolbar-active')).toBe(true);
expect(editorTwo.toolbar.classList.contains('medium-editor-toolbar-active')).toBe(false);
selectElementContentsAndFire(document.getElementById('editor-span-2'));
fireEvent(editorTwo.elements[0], 'focus');
jasmine.clock().tick(1);
expect(editorOne.toolbar.classList.contains('medium-editor-toolbar-active')).toBe(false);
expect(editorTwo.toolbar.classList.contains('medium-editor-toolbar-active')).toBe(true);
});
});
describe('Deactive', function () {

@@ -126,4 +212,5 @@ it('should remove select event from elements', function () {

expect(editor.toolbar.style.display).toBe('');
selectElementContents(element);
editor.checkSelection();
selectElementContentsAndFire(element);
jasmine.clock().tick(51);
expect(editor.toolbar.style.display).toBe('');

@@ -144,4 +231,3 @@ // Remove the new element from the DOM

selectElementContents(document.getElementById('cef_el'));
editor.checkSelection();
selectElementContentsAndFire(document.getElementById('cef_el'));

@@ -152,78 +238,2 @@ jasmine.clock().tick(51);

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 () {
var editor = new MediumEditor('.editor');
editor.toolbar.classList.add('medium-editor-toolbar-active');
editor.onHideToolbar = function () {};
spyOn(editor, 'onHideToolbar').and.callThrough();
fireEvent(editor.elements[0], 'focus');
fireEvent(editor.elements[0], 'blur');
expect(editor.onHideToolbar).toHaveBeenCalled();
});
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

@@ -252,3 +262,3 @@ 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 () {

// Because the toolbar appear after 100ms, waits 150ms...
// Because the toolbar appear after 100ms, waits 150ms...
waitsFor(function () {

@@ -255,0 +265,0 @@ value = value + 1; // value += 1 is not accepted by jslint (unused)

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

Sorry, the diff of this file is not supported yet

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