From 0c98debe8b0e92c5176df3057e8c6b9feec9972f Mon Sep 17 00:00:00 2001
From: Jeremy Benoist
Date: Sun, 28 Jun 2015 10:26:52 +0200
Subject: [PATCH] 4.12.6
---
dist/js/medium-editor.js | 33 +++++++++++++++++++++------------
dist/js/medium-editor.min.js | 8 ++++----
package.json | 2 +-
src/js/version.js | 2 +-
4 files changed, 27 insertions(+), 18 deletions(-)
diff --git a/dist/js/medium-editor.js b/dist/js/medium-editor.js
index 4be7db6e6..94fd49d19 100644
--- a/dist/js/medium-editor.js
+++ b/dist/js/medium-editor.js
@@ -2104,6 +2104,12 @@ var Events;
this.detachAllDOMEvents();
this.detachAllCustomEvents();
this.detachExecCommand();
+
+ if (this.base.elements) {
+ this.base.elements.forEach(function (element) {
+ element.removeAttribute('data-medium-focused');
+ });
+ }
},
// Listening to calls to document.execCommand
@@ -5221,10 +5227,10 @@ var Toolbar;
// Checks for existance of multiple block elements in the current selection
multipleBlockElementsSelected: function () {
- /*jslint regexp: true*/
- var selectionHtml = Selection.getSelectionHtml.call(this).replace(/<[\S]+><\/[\S]+>/gim, ''),
- hasMultiParagraphs = selectionHtml.match(/<(p|h[1-6]|blockquote)[^>]*>/g);
- /*jslint regexp: false*/
+ var regexEmptyHTMLTags = /<[^\/>][^>]*><\/[^>]+>/gim, // http://stackoverflow.com/questions/3129738/remove-empty-tags-using-regex
+ regexBlockElements = new RegExp('<(' + Util.parentElements.join('|') + ')[^>]*>', 'g'),
+ selectionHTML = Selection.getSelectionHtml.call(this).replace(regexEmptyHTMLTags, ''), // Filter out empty blocks from selection
+ hasMultiParagraphs = selectionHTML.match(regexBlockElements); // Find how many block elements are within the html
return !!hasMultiParagraphs && hasMultiParagraphs.length > 1;
},
@@ -5705,9 +5711,9 @@ function MediumEditor(elements, options) {
// Loop through elements and convert textarea's into divs
this.elements = [];
- elements.forEach(function (element) {
+ elements.forEach(function (element, index) {
if (element.tagName.toLowerCase() === 'textarea') {
- this.elements.push(createContentEditable.call(this, element));
+ this.elements.push(createContentEditable.call(this, element, index));
} else {
this.elements.push(element);
}
@@ -5813,9 +5819,9 @@ function MediumEditor(elements, options) {
return this.options.imageDragging !== false;
}
- function createContentEditable(textarea) {
+ function createContentEditable(textarea, id) {
var div = this.options.ownerDocument.createElement('div'),
- id = (+new Date()),
+ uniqueId = 'medium-editor-' + Date.now() + '-' + id,
attributesToClone = [
'data-disable-editing',
'data-disable-toolbar',
@@ -5827,7 +5833,7 @@ function MediumEditor(elements, options) {
];
div.className = textarea.className;
- div.id = id;
+ div.id = uniqueId;
div.innerHTML = textarea.value;
div.setAttribute('medium-editor-textarea-id', id);
attributesToClone.forEach(function (attr) {
@@ -6165,6 +6171,8 @@ function MediumEditor(elements, options) {
delete this.toolbar;
}
+ this.events.destroy();
+
this.elements.forEach(function (element) {
// Reset elements content, fix for issue where after editor destroyed the red underlines on spelling errors are left
if (this.options.spellcheck) {
@@ -6174,6 +6182,9 @@ function MediumEditor(elements, options) {
element.removeAttribute('contentEditable');
element.removeAttribute('spellcheck');
element.removeAttribute('data-medium-element');
+ element.removeAttribute('medium-editor-index');
+ element.removeAttribute('role');
+ element.removeAttribute('aria-multiline');
// Remove any elements created for textareas
if (element.hasAttribute('medium-editor-textarea-id')) {
@@ -6188,8 +6199,6 @@ function MediumEditor(elements, options) {
}
}, this);
this.elements = [];
-
- this.events.destroy();
},
on: function (target, event, listener, useCapture) {
@@ -6615,7 +6624,7 @@ MediumEditor.version = (function (major, minor, revision) {
};
}).apply(this, ({
// grunt-bump looks for this:
- 'version': '4.12.5'
+ 'version': '4.12.6'
}).version.split('.'));
return MediumEditor;
diff --git a/dist/js/medium-editor.min.js b/dist/js/medium-editor.min.js
index d5b098648..5a7d9fbfe 100644
--- a/dist/js/medium-editor.min.js
+++ b/dist/js/medium-editor.min.js
@@ -1,4 +1,4 @@
-"classList"in document.createElement("_")||!function(a){"use strict";if("Element"in a){var b="classList",c="prototype",d=a.Element[c],e=Object,f=String[c].trim||function(){return this.replace(/^\s+|\s+$/g,"")},g=Array[c].indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(b in this&&this[b]===a)return b;return-1},h=function(a,b){this.name=a,this.code=DOMException[a],this.message=b},i=function(a,b){if(""===b)throw new h("SYNTAX_ERR","An invalid or illegal string was specified");if(/\s/.test(b))throw new h("INVALID_CHARACTER_ERR","String contains an invalid character");return g.call(a,b)},j=function(a){for(var b=f.call(a.getAttribute("class")||""),c=b?b.split(/\s+/):[],d=0,e=c.length;e>d;d++)this.push(c[d]);this._updateClassName=function(){a.setAttribute("class",this.toString())}},k=j[c]=[],l=function(){return new j(this)};if(h[c]=Error[c],k.item=function(a){return this[a]||null},k.contains=function(a){return a+="",-1!==i(this,a)},k.add=function(){var a,b=arguments,c=0,d=b.length,e=!1;do a=b[c]+"",-1===i(this,a)&&(this.push(a),e=!0);while(++ci;i++)e+=String.fromCharCode(f[i]);c.push(e)}else if("Blob"===b(a)||"File"===b(a)){if(!g)throw new h("NOT_READABLE_ERR");var k=new g;c.push(k.readAsBinaryString(a))}else a instanceof d?"base64"===a.encoding&&p?c.push(p(a.data)):"URI"===a.encoding?c.push(decodeURIComponent(a.data)):"raw"===a.encoding&&c.push(a.data):("string"!=typeof a&&(a+=""),c.push(unescape(encodeURIComponent(a))))},e.getBlob=function(a){return arguments.length||(a=null),new d(this.data.join(""),a,"raw")},e.toString=function(){return"[object BlobBuilder]"},f.slice=function(a,b,c){var e=arguments.length;return 3>e&&(c=null),new d(this.data.slice(a,e>1?b:this.data.length),c,this.encoding)},f.toString=function(){return"[object Blob]"},f.close=function(){this.size=0,delete this.data},c}(a);a.Blob=function(a,b){var d=b?b.type||"":"",e=new c;if(a)for(var f=0,g=a.length;g>f;f++)e.append(Uint8Array&&a[f]instanceof Uint8Array?a[f].buffer:a[f]);var h=e.getBlob(d);return!h.slice&&h.webkitSlice&&(h.slice=h.webkitSlice),h};var d=Object.getPrototypeOf||function(a){return a.__proto__};a.Blob.prototype=d(new a.Blob)}("undefined"!=typeof self&&self||"undefined"!=typeof window&&window||this.content||this),function(a,b){"use strict";"object"==typeof module?module.exports=b:"function"==typeof define&&define.amd?define(function(){return b}):a.MediumEditor=b}(this,function(){"use strict";function a(a,b){return this.init(a,b)}var b;!function(a){function c(b,c,d){d||(d=a);try{for(var e=0;e=0,keyCode:{BACKSPACE:8,TAB:9,ENTER:13,ESCAPE:27,SPACE:32,DELETE:46},isMetaCtrlKey:function(a){return this.isMac&&a.metaKey||!this.isMac&&a.ctrlKey?!0:!1},isKey:function(a,b){var c=a.which;return null===c&&(c=null!==a.charCode?a.charCode:a.keyCode),!1===Array.isArray(b)?c===b:-1===b.indexOf(c)?!1:!0},parentElements:["p","h1","h2","h3","h4","h5","h6","blockquote","pre"],extend:function(){var a=[!0].concat(Array.prototype.slice.call(arguments));return d.apply(this,a)},defaults:function(){var a=[!1].concat(Array.prototype.slice.call(arguments));return d.apply(this,a)},derives:function(a,b){function c(){}var e=b.prototype;return c.prototype=a.prototype,b.prototype=new c,b.prototype.constructor=a,b.prototype=d(!1,b.prototype,e),b},findAdjacentTextNodeWithContent:function(a,b,c){var d,e=!1,f=c.createNodeIterator(a,NodeFilter.SHOW_TEXT,null,!1);for(d=f.nextNode();d;){if(d===b)e=!0;else if(e&&3===d.nodeType&&d.nodeValue&&d.nodeValue.trim().length>0)break;d=f.nextNode()}return d},isDescendant:function(a,b,c){if(!a||!b)return!1;if(c&&a===b)return!0;for(var d=b.parentNode;null!==d;){if(d===a)return!0;d=d.parentNode}return!1},isElement:function(a){return!(!a||1!==a.nodeType)},now:Date.now,throttle:function(a,b){var c,d,e,f=50,g=null,h=0,i=function(){h=Date.now(),g=null,e=a.apply(c,d),g||(c=d=null)};return b||0===b||(b=f),function(){var f=Date.now(),j=b-(f-h);return c=this,d=arguments,0>=j||j>b?(g&&(clearTimeout(g),g=null),h=f,e=a.apply(c,d),g||(c=d=null)):g||(g=setTimeout(i,j)),e}},traverseUp:function(a,b){if(!a)return!1;do{if(1===a.nodeType){if(b(a))return a;if(a.getAttribute("data-medium-element"))return!1}a=a.parentNode}while(a);return!1},htmlEntities:function(a){return String(a).replace(/&/g,"&").replace(//g,">").replace(/"/g,""")},insertHTMLCommand:function(a,b){var c,d,e,f,g,h,i;if(a.queryCommandSupported("insertHTML"))try{return a.execCommand("insertHTML",!1,b)}catch(j){}if(c=a.defaultView.getSelection(),c.getRangeAt&&c.rangeCount){if(d=c.getRangeAt(0),i=d.commonAncestorContainer,3===i.nodeType&&i.nodeValue===d.toString()||3!==i.nodeType&&i.innerHTML===d.toString()){for(;i.parentNode&&1===i.parentNode.childNodes.length&&!i.parentNode.getAttribute("data-medium-element");)i=i.parentNode;d.selectNode(i)}for(d.deleteContents(),e=a.createElement("div"),e.innerHTML=b,f=a.createDocumentFragment();e.firstChild;)g=e.firstChild,h=f.appendChild(g);d.insertNode(f),h&&(d=d.cloneRange(),d.setStartAfter(h),d.collapse(!0),c.removeAllRanges(),c.addRange(d))}},getSelectionRange:function(a){return this.deprecated("Util.getSelectionRange","Selection.getSelectionRange","v5.0.0"),f.getSelectionRange(a)},getSelectionStart:function(a){return this.deprecated("Util.getSelectionStart","Selection.getSelectionStart","v5.0.0"),f.getSelectionStart(a)},getSelectionData:function(a){return this.deprecated("Util.getSelectionData","Selection.getSelectionData","v5.0.0"),f.getSelectionData(a)},execFormatBlock:function(a,b){var c=f.getSelectionData(f.getSelectionStart(a));if("blockquote"===b&&c.el&&"blockquote"===c.el.parentNode.tagName.toLowerCase())return a.execCommand("outdent",!1,null);if(c.tagName===b&&(b="p"),this.isIE){if("blockquote"===b)return a.execCommand("indent",!1,b);b="<"+b+">"}return a.execCommand("formatBlock",!1,b)},setTargetBlank:function(a,b){var c,d=b||!1;if("a"===a.tagName.toLowerCase())a.target="_blank";else for(a=a.getElementsByTagName("a"),c=0;cd?(e=e.parentNode,c-=1):(f=f.parentNode,d-=1);for(;e!==f;)e=e.parentNode,f=f.parentNode;return e},isElementAtBeginningOfBlock:function(a){for(var b,c;!this.isBlockContainer(a)&&!this.isMediumEditorElement(a);){for(c=a;c=c.previousSibling;)if(b=3===c.nodeType?c.nodeValue:c.textContent,b.length>0)return!1;a=a.parentNode}return!0},isMediumEditorElement:function(a){return a&&3!==a.nodeType&&!!a.getAttribute("data-medium-element")},isBlockContainer:function(a){return a&&3!==a.nodeType&&-1!==this.parentElements.indexOf(a.nodeName.toLowerCase())},getBlockContainer:function(a){return this.traverseUp(a,function(a){return b.isBlockContainer(a)&&!b.isBlockContainer(a.parentNode)})},getFirstSelectableLeafNode:function(a){for(;a&&a.firstChild;)a=a.firstChild;for(var b=["br","col","colgroup","hr","img","input","source","wbr"];-1!==b.indexOf(a.nodeName.toLowerCase());)a=a.parentNode;if("table"===a.nodeName.toLowerCase()){var c=a.querySelector("th, td");c&&(a=c)}return a},getFirstTextNode:function(a){if(3===a.nodeType)return a;for(var b=0;bB",contentFA:'',key:"B"},italic:{name:"italic",action:"italic",aria:"italic",tagNames:["i","em"],style:{prop:"font-style",value:"italic"},useQueryState:!0,contentDefault:"I",contentFA:'',key:"I"},underline:{name:"underline",action:"underline",aria:"underline",tagNames:["u"],style:{prop:"text-decoration",value:"underline"},useQueryState:!0,contentDefault:"U",contentFA:'',key:"U"},strikethrough:{name:"strikethrough",action:"strikethrough",aria:"strike through",tagNames:["strike"],style:{prop:"text-decoration",value:"line-through"},useQueryState:!0,contentDefault:"A",contentFA:''},superscript:{name:"superscript",action:"superscript",aria:"superscript",tagNames:["sup"],contentDefault:"x1",contentFA:''},subscript:{name:"subscript",action:"subscript",aria:"subscript",tagNames:["sub"],contentDefault:"x1",contentFA:''},image:{name:"image",action:"image",aria:"image",tagNames:["img"],contentDefault:"image",contentFA:''},quote:{name:"quote",action:"append-blockquote",aria:"blockquote",tagNames:["blockquote"],contentDefault:"“",contentFA:''},orderedlist:{name:"orderedlist",action:"insertorderedlist",aria:"ordered list",tagNames:["ol"],useQueryState:!0,contentDefault:"1.",contentFA:''},unorderedlist:{name:"unorderedlist",action:"insertunorderedlist",aria:"unordered list",tagNames:["ul"],useQueryState:!0,contentDefault:"•",contentFA:''},pre:{name:"pre",action:"append-pre",aria:"preformatted text",tagNames:["pre"],contentDefault:"0101",contentFA:''},indent:{name:"indent",action:"indent",aria:"indent",tagNames:[],contentDefault:"→",contentFA:''},outdent:{name:"outdent",action:"outdent",aria:"outdent",tagNames:[],contentDefault:"←",contentFA:''},justifyCenter:{name:"justifyCenter",action:"justifyCenter",aria:"center justify",tagNames:[],style:{prop:"text-align",value:"center"},contentDefault:"C",contentFA:''},justifyFull:{name:"justifyFull",action:"justifyFull",aria:"full justify",tagNames:[],style:{prop:"text-align",value:"justify"},contentDefault:"J",contentFA:''},justifyLeft:{name:"justifyLeft",action:"justifyLeft",aria:"left justify",tagNames:[],style:{prop:"text-align",value:"left"},contentDefault:"L",contentFA:''},justifyRight:{name:"justifyRight",action:"justifyRight",aria:"right justify",tagNames:[],style:{prop:"text-align",value:"right"},contentDefault:"R",contentFA:''},header1:{name:"header1",action:function(a){return"append-"+a.firstHeader},aria:function(a){return a.firstHeader},tagNames:function(a){return[a.firstHeader]},contentDefault:"H1"},header2:{name:"header2",action:function(a){return"append-"+a.secondHeader},aria:function(a){return a.secondHeader},tagNames:function(a){return[a.secondHeader]},contentDefault:"H2"},removeFormat:{name:"removeFormat",aria:"remove formatting",action:"removeFormat",contentDefault:"X",contentFA:''}}}();var d;!function(){d={allowMultiParagraphSelection:!0,buttons:["bold","italic","underline","anchor","header1","header2","quote"],buttonLabels:!1,delay:0,diffLeft:0,diffTop:-10,disableReturn:!1,disableDoubleReturn:!1,disableToolbar:!1,disableEditing:!1,autoLink:!1,toolbarAlign:"center",elementsContainer:!1,imageDragging:!0,standardizeSelectionStart:!1,contentWindow:window,ownerDocument:document,firstHeader:"h3",secondHeader:"h4",targetBlank:!1,extensions:{},activeButtonClass:"medium-editor-button-active",firstButtonClass:"medium-editor-button-first",lastButtonClass:"medium-editor-button-last",spellcheck:!0}}();var e;!function(){e=function(a){b.extend(this,a)},e.extend=function(a){var c,d=this;c=a&&a.hasOwnProperty("constructor")?a.constructor:function(){return d.apply(this,arguments)},b.extend(c,d);var e=function(){this.constructor=c};return e.prototype=d.prototype,c.prototype=new e,a&&b.extend(c.prototype,a),c},e.prototype={init:function(){},base:void 0,name:void 0,checkState:void 0,destroy:void 0,queryCommandState:void 0,isActive:void 0,isAlreadyApplied:void 0,setActive:void 0,setInactive:void 0,window:void 0,document:void 0,getEditorElements:function(){return this.base.elements},getEditorId:function(){return this.base.id},getEditorOption:function(a){return this.base.options[a]}},["execAction","on","off","subscribe"].forEach(function(a){e.prototype[a]=function(){return this.base[a].apply(this.base,arguments)}})}();var f;!function(){function a(a){return b.isBlockContainer(a)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}f={findMatchingSelectionParent:function(a,c){var d,e,f=c.getSelection();return 0===f.rangeCount?!1:(d=f.getRangeAt(0),e=d.commonAncestorContainer,b.traverseUp(e,a))},getSelectionElement:function(a){return this.findMatchingSelectionParent(function(a){return a.getAttribute("data-medium-element")},a)},importSelectionMoveCursorPastAnchor:function(a,c){var d=function(a){return"a"===a.nodeName.toLowerCase()};if(a.start===a.end&&3===c.startContainer.nodeType&&c.startOffset===c.startContainer.nodeValue.length&&b.traverseUp(c.startContainer,d)){for(var e=c.startContainer,f=c.startContainer.parentNode;null!==f&&"a"!==f.nodeName.toLowerCase();)f.childNodes[f.childNodes.length-1]!==e?f=null:(e=f,f=f.parentNode);if(null!==f&&"a"===f.nodeName.toLowerCase()){for(var g=null,h=0;null===g&&h0)return 0;var g=e;if(3!==g.nodeType&&(g=e.childNodes[f]),g&&!b.isElementAtBeginningOfBlock(g))return 0;for(var h=c.createTreeWalker(d,NodeFilter.SHOW_ELEMENT,a,!1),i=0;h.nextNode();){var j=""===h.currentNode.textContent;if((j||i>0)&&(i+=1),b.isDescendant(h.currentNode,e,!0))return i;j||(i=0)}return i},selectionInContentEditableFalse:function(a){var b,c=this.findMatchingSelectionParent(function(a){var c=a&&a.getAttribute("contenteditable");return"true"===c&&(b=!0),"#text"!==a.nodeName&&"false"===c},a);return!b&&c},getSelectionHtml:function(){var a,b,c,d="",e=this.options.contentWindow.getSelection();if(e.rangeCount){for(c=this.options.ownerDocument.createElement("div"),a=0,b=e.rangeCount;b>a;a+=1)c.appendChild(e.getRangeAt(a).cloneContents());d=c.innerHTML}return d},getCaretOffsets:function(a,b){var c,d;return b||(b=window.getSelection().getRangeAt(0)),c=b.cloneRange(),d=b.cloneRange(),c.selectNodeContents(a),c.setEnd(b.endContainer,b.endOffset),d.selectNodeContents(a),d.setStart(b.endContainer,b.endOffset),{left:c.toString().length,right:d.toString().length}},rangeSelectsSingleNode:function(a){var b=a.startContainer;return b===a.endContainer&&b.hasChildNodes()&&a.endOffset===a.startOffset+1},getSelectedParentElement:function(a){return a?this.rangeSelectsSingleNode(a)&&3!==a.startContainer.childNodes[a.startOffset].nodeType?a.startContainer.childNodes[a.startOffset]:3===a.startContainer.nodeType?a.startContainer.parentNode:a.startContainer:null},getSelectedElements:function(a){var b,c,d,e=a.getSelection();if(!e.rangeCount||e.isCollapsed||!e.getRangeAt(0).commonAncestorContainer)return[];if(b=e.getRangeAt(0),3===b.commonAncestorContainer.nodeType){for(c=[],d=b.commonAncestorContainer;d.parentNode&&1===d.parentNode.childNodes.length;)c.push(d.parentNode),d=d.parentNode;return c}return[].filter.call(b.commonAncestorContainer.getElementsByTagName("*"),function(a){return"function"==typeof e.containsNode?e.containsNode(a,!0):!0})},selectNode:function(a,b){var c=b.createRange(),d=b.getSelection();c.selectNodeContents(a),d.removeAllRanges(),d.addRange(c)},moveCursor:function(a,b,c){var d,e,f=c||0;d=a.createRange(),e=a.getSelection(),d.setStart(b,f),d.collapse(!0),e.removeAllRanges(),e.addRange(d)},getSelectionRange:function(a){var b=a.getSelection();return 0===b.rangeCount?null:b.getRangeAt(0)},getSelectionStart:function(a){var b=a.getSelection().anchorNode,c=b&&3===b.nodeType?b.parentNode:b;return c},getSelectionData:function(a){var c;for(a&&a.tagName&&(c=a.tagName.toLowerCase());a&&!b.isBlockContainer(a);)a=a.parentNode,a&&a.tagName&&(c=a.tagName.toLowerCase());return{el:a,tagName:c}}}}();var g;!function(){g=function(a){this.base=a,this.options=this.base.options,this.events=[],this.customEvents={},this.listeners={}},g.prototype={InputEventOnContenteditableSupported:!b.isIE,attachDOMEvent:function(a,b,c,d){a.addEventListener(b,c,d),this.events.push([a,b,c,d])},detachDOMEvent:function(a,b,c,d){var e,f=this.indexOfListener(a,b,c,d);-1!==f&&(e=this.events.splice(f,1)[0],e[0].removeEventListener(e[1],e[2],e[3]))},indexOfListener:function(a,b,c,d){var e,f,g;for(e=0,f=this.events.length;f>e;e+=1)if(g=this.events[e],g[0]===a&&g[1]===b&&g[2]===c&&g[3]===d)return e;return-1},detachAllDOMEvents:function(){for(var a=this.events.pop();a;)a[0].removeEventListener(a[1],a[2],a[3]),a=this.events.pop()},attachCustomEvent:function(a,b){this.setupListener(a),this.customEvents[a]||(this.customEvents[a]=[]),this.customEvents[a].push(b)},detachCustomEvent:function(a,b){var c=this.indexOfCustomListener(a,b);-1!==c&&this.customEvents[a].splice(c,1)},indexOfCustomListener:function(a,b){return this.customEvents[a]&&this.customEvents[a].length?this.customEvents[a].indexOf(b):-1},detachAllCustomEvents:function(){this.customEvents={}},triggerCustomEvent:function(a,b,c){this.customEvents[a]&&this.customEvents[a].forEach(function(a){a(b,c)})},destroy:function(){this.detachAllDOMEvents(),this.detachAllCustomEvents(),this.detachExecCommand()},attachToExecCommand:function(){this.execCommandListener||(this.execCommandListener=function(a){this.handleDocumentExecCommand(a)}.bind(this),this.wrapExecCommand(),this.options.ownerDocument.execCommand.listeners.push(this.execCommandListener))},detachExecCommand:function(){var a=this.options.ownerDocument;if(this.execCommandListener&&a.execCommand.listeners){var b=a.execCommand.listeners.indexOf(this.execCommandListener);-1!==b&&a.execCommand.listeners.splice(b,1),a.execCommand.listeners.length||this.unwrapExecCommand()}},wrapExecCommand:function(){var a=this.options.ownerDocument;if(!a.execCommand.listeners){var b=function(b,c,d){var e=a.execCommand.orig.apply(this,arguments);if(!a.execCommand.listeners)return e;var f=Array.prototype.slice.call(arguments);return a.execCommand.listeners.forEach(function(a){a({command:b,value:d,args:f,result:e})}),e};b.orig=a.execCommand,b.listeners=[],a.execCommand=b}},unwrapExecCommand:function(){var a=this.options.ownerDocument;a.execCommand.orig&&(a.execCommand=a.execCommand.orig)},setupListener:function(a){if(!this.listeners[a]){switch(a){case"externalInteraction":this.attachDOMEvent(this.options.ownerDocument.body,"mousedown",this.handleBodyMousedown.bind(this),!0),this.attachDOMEvent(this.options.ownerDocument.body,"click",this.handleBodyClick.bind(this),!0),this.attachDOMEvent(this.options.ownerDocument.body,"focus",this.handleBodyFocus.bind(this),!0);break;case"blur":this.setupListener("externalInteraction");break;case"focus":this.setupListener("externalInteraction");break;case"editableInput":this.contentCache=[],this.base.elements.forEach(function(a){this.contentCache[a.getAttribute("medium-editor-index")]=a.innerHTML,this.InputEventOnContenteditableSupported&&this.attachDOMEvent(a,"input",this.handleInput.bind(this))}.bind(this)),this.InputEventOnContenteditableSupported||(this.setupListener("editableKeypress"),this.keypressUpdateInput=!0,this.attachDOMEvent(document,"selectionchange",this.handleDocumentSelectionChange.bind(this)),this.attachToExecCommand());break;case"editableClick":this.base.elements.forEach(function(a){this.attachDOMEvent(a,"click",this.handleClick.bind(this))}.bind(this));break;case"editableBlur":this.base.elements.forEach(function(a){this.attachDOMEvent(a,"blur",this.handleBlur.bind(this))}.bind(this));break;case"editableKeypress":this.base.elements.forEach(function(a){this.attachDOMEvent(a,"keypress",this.handleKeypress.bind(this))}.bind(this));break;case"editableKeyup":this.base.elements.forEach(function(a){this.attachDOMEvent(a,"keyup",this.handleKeyup.bind(this))}.bind(this));break;case"editableKeydown":this.base.elements.forEach(function(a){this.attachDOMEvent(a,"keydown",this.handleKeydown.bind(this))}.bind(this));break;case"editableKeydownEnter":this.setupListener("editableKeydown");break;case"editableKeydownTab":this.setupListener("editableKeydown");break;case"editableKeydownDelete":this.setupListener("editableKeydown");break;case"editableMouseover":this.base.elements.forEach(function(a){this.attachDOMEvent(a,"mouseover",this.handleMouseover.bind(this))},this);break;case"editableDrag":this.base.elements.forEach(function(a){this.attachDOMEvent(a,"dragover",this.handleDragging.bind(this)),this.attachDOMEvent(a,"dragleave",this.handleDragging.bind(this))},this);break;case"editableDrop":this.base.elements.forEach(function(a){this.attachDOMEvent(a,"drop",this.handleDrop.bind(this))},this);break;case"editablePaste":this.base.elements.forEach(function(a){this.attachDOMEvent(a,"paste",this.handlePaste.bind(this))},this)}this.listeners[a]=!0}},focusElement:function(a){a.focus(),this.updateFocus(a,{target:a,type:"focus"})},updateFocus:function(a,c){var d,e=this.base.toolbar?this.base.toolbar.getToolbarElement():null,f=this.base.getExtensionByName("anchor-preview"),g=f&&f.getPreviewElement?f.getPreviewElement():null,h=this.base.getFocusedElement();h&&"click"===c.type&&this.lastMousedownTarget&&(b.isDescendant(h,this.lastMousedownTarget,!0)||b.isDescendant(e,this.lastMousedownTarget,!0)||b.isDescendant(g,this.lastMousedownTarget,!0))&&(d=h),d||this.base.elements.some(function(c){return!d&&b.isDescendant(c,a,!0)&&(d=c),!!d},this);var i=!b.isDescendant(h,a,!0)&&!b.isDescendant(e,a,!0)&&!b.isDescendant(g,a,!0);d!==h&&(h&&i&&(h.removeAttribute("data-medium-focused"),this.triggerCustomEvent("blur",c,h)),d&&(d.setAttribute("data-medium-focused",!0),this.triggerCustomEvent("focus",c,d))),i&&this.triggerCustomEvent("externalInteraction",c)},updateInput:function(a,b){var c=a.getAttribute("medium-editor-index");a.innerHTML!==this.contentCache[c]&&this.triggerCustomEvent("editableInput",b,a),this.contentCache[c]=a.innerHTML},handleDocumentSelectionChange:function(a){if(a.currentTarget&&a.currentTarget.activeElement){var c,d=a.currentTarget.activeElement;this.base.elements.some(function(a){return b.isDescendant(a,d,!0)?(c=a,!0):!1},this),c&&this.updateInput(c,{target:d,currentTarget:c})}},handleDocumentExecCommand:function(){var a=this.base.getFocusedElement();a&&this.updateInput(a,{target:a,currentTarget:a})},handleBodyClick:function(a){this.updateFocus(a.target,a)},handleBodyFocus:function(a){this.updateFocus(a.target,a)},handleBodyMousedown:function(a){this.lastMousedownTarget=a.target},handleInput:function(a){this.updateInput(a.currentTarget,a)},handleClick:function(a){this.triggerCustomEvent("editableClick",a,a.currentTarget)},handleBlur:function(a){this.triggerCustomEvent("editableBlur",a,a.currentTarget)},handleKeypress:function(a){if(this.triggerCustomEvent("editableKeypress",a,a.currentTarget),this.keypressUpdateInput){var b={target:a.target,currentTarget:a.currentTarget};setTimeout(function(){this.updateInput(b.currentTarget,b)}.bind(this),0)}},handleKeyup:function(a){this.triggerCustomEvent("editableKeyup",a,a.currentTarget)},handleMouseover:function(a){this.triggerCustomEvent("editableMouseover",a,a.currentTarget)},handleDragging:function(a){this.triggerCustomEvent("editableDrag",a,a.currentTarget)},handleDrop:function(a){this.triggerCustomEvent("editableDrop",a,a.currentTarget)},handlePaste:function(a){this.triggerCustomEvent("editablePaste",a,a.currentTarget)},handleKeydown:function(a){return this.triggerCustomEvent("editableKeydown",a,a.currentTarget),b.isKey(a,b.keyCode.ENTER)?this.triggerCustomEvent("editableKeydownEnter",a,a.currentTarget):b.isKey(a,b.keyCode.TAB)?this.triggerCustomEvent("editableKeydownTab",a,a.currentTarget):b.isKey(a,[b.keyCode.DELETE,b.keyCode.BACKSPACE])?this.triggerCustomEvent("editableKeydownDelete",a,a.currentTarget):void 0}}}();var h;!function(){h=function(a,c){b.deprecated("MediumEditor.statics.DefaultButton","MediumEditor.extensions.button","v5.0.0"),this.options=a,this.name=a.name,this.init(c)},h.prototype={init:function(a){this.base=a,this.button=this.createButton(),this.base.on(this.button,"click",this.handleClick.bind(this)),this.options.key&&this.base.subscribe("editableKeydown",this.handleKeydown.bind(this))},getButton:function(){return this.button},getAction:function(){return"function"==typeof this.options.action?this.options.action(this.base.options):this.options.action},getAria:function(){return"function"==typeof this.options.aria?this.options.aria(this.base.options):this.options.aria},getTagNames:function(){return"function"==typeof this.options.tagNames?this.options.tagNames(this.base.options):this.options.tagNames},createButton:function(){var a=this.base.options.ownerDocument.createElement("button"),b=this.options.contentDefault,c=this.getAria();return a.classList.add("medium-editor-action"),a.classList.add("medium-editor-action-"+this.name),a.setAttribute("data-action",this.getAction()),c&&(a.setAttribute("title",c),a.setAttribute("aria-label",c)),this.base.options.buttonLabels&&("fontawesome"===this.base.options.buttonLabels&&this.options.contentFA?b=this.options.contentFA:"object"==typeof this.base.options.buttonLabels&&this.base.options.buttonLabels[this.name]&&(b=this.base.options.buttonLabels[this.options.name])),a.innerHTML=b,a},handleKeydown:function(a){var c,d=String.fromCharCode(a.which||a.keyCode).toLowerCase();this.options.key===d&&b.isMetaCtrlKey(a)&&(a.preventDefault(),a.stopPropagation(),c=this.getAction(),c&&this.base.execAction(c))},handleClick:function(a){a.preventDefault(),a.stopPropagation();var b=this.getAction();b&&this.base.execAction(b)},isActive:function(){return this.button.classList.contains(this.base.options.activeButtonClass)},setInactive:function(){this.button.classList.remove(this.base.options.activeButtonClass),delete this.knownState;
-
-},setActive:function(){this.button.classList.add(this.base.options.activeButtonClass),delete this.knownState},queryCommandState:function(){var a=null;return this.options.useQueryState&&(a=this.base.queryCommandState(this.getAction())),a},isAlreadyApplied:function(a){var b,c,d=!1,e=this.getTagNames();return this.knownState===!1||this.knownState===!0?this.knownState:(e&&e.length>0&&a.tagName&&(d=-1!==e.indexOf(a.tagName.toLowerCase())),!d&&this.options.style&&(b=this.options.style.value.split("|"),c=this.base.options.contentWindow.getComputedStyle(a,null).getPropertyValue(this.options.style.prop),b.forEach(function(a){this.knownState||(d=-1!==c.indexOf(a),(d||"text-decoration"!==this.options.style.prop)&&(this.knownState=d))},this)),d)}}}();var i;!function(){function a(){b.deprecated("MediumEditor.statics.AnchorExtension","MediumEditor.extensions.anchor","v5.0.0"),this.parent=!0,this.options={name:"anchor",action:"createLink",aria:"link",tagNames:["a"],contentDefault:"#",contentFA:'',key:"k"},this.name="anchor",this.hasForm=!0}a.prototype={formSaveLabel:"✓",formCloseLabel:"×",handleClick:function(a){a.preventDefault(),a.stopPropagation();var b=f.getSelectedParentElement(f.getSelectionRange(this.base.options.ownerDocument));return b.tagName&&"a"===b.tagName.toLowerCase()?this.base.execAction("unlink"):(this.isDisplayed()||this.showForm(),!1)},handleKeydown:function(a){var c=String.fromCharCode(a.which||a.keyCode).toLowerCase();this.options.key===c&&b.isMetaCtrlKey(a)&&(a.preventDefault(),a.stopPropagation(),this.handleClick(a))},getForm:function(){return this.form||(this.form=this.createForm()),this.form},getTemplate:function(){var a=[''];return a.push('',"fontawesome"===this.base.options.buttonLabels?'':this.formSaveLabel,""),a.push('',"fontawesome"===this.base.options.buttonLabels?'':this.formCloseLabel,""),this.base.options.anchorTarget&&a.push('',""),this.base.options.anchorButton&&a.push('',""),a.join("")},isDisplayed:function(){return"block"===this.getForm().style.display},hideForm:function(){this.getForm().style.display="none",this.getInput().value=""},showForm:function(a){var b=this.getInput();this.base.saveSelection(),this.base.hideToolbarDefaultActions(),this.getForm().style.display="block",this.base.setToolbarPosition(),b.value=a||"",b.focus()},deactivate:function(){return this.form?(this.form.parentNode&&this.form.parentNode.removeChild(this.form),void delete this.form):!1},getFormOpts:function(){var a=this.getForm().querySelector(".medium-editor-toolbar-anchor-target"),b=this.getForm().querySelector(".medium-editor-toolbar-anchor-button"),c={url:this.getInput().value};return this.base.options.checkLinkFormat&&(c.url=this.checkLinkFormat(c.url)),a&&a.checked?c.target="_blank":c.target="_self",b&&b.checked&&(c.buttonClass=this.base.options.anchorButtonClass),c},doFormSave:function(){var a=this.getFormOpts();this.completeFormSave(a)},completeFormSave:function(a){this.base.restoreSelection(),this.base.createLink(a),this.base.checkSelection()},checkLinkFormat:function(a){var b=/^(https?|ftps?|rtmpt?):\/\/|mailto:/;return(b.test(a)?"":"http://")+a},doFormCancel:function(){this.base.restoreSelection(),this.base.checkSelection()},attachFormEvents:function(a){var b=a.querySelector(".medium-editor-toolbar-close"),c=a.querySelector(".medium-editor-toolbar-save"),d=a.querySelector(".medium-editor-toolbar-input");this.base.on(a,"click",this.handleFormClick.bind(this)),this.base.on(d,"keyup",this.handleTextboxKeyup.bind(this)),this.base.on(b,"click",this.handleCloseClick.bind(this)),this.base.on(c,"click",this.handleSaveClick.bind(this),!0)},createForm:function(){var a=this.base.options.ownerDocument,b=a.createElement("div");return b.className="medium-editor-toolbar-form",b.id="medium-editor-toolbar-form-anchor-"+this.base.id,b.innerHTML=this.getTemplate(),this.attachFormEvents(b),b},getInput:function(){return this.getForm().querySelector("input.medium-editor-toolbar-input")},handleTextboxKeyup:function(a){return a.keyCode===b.keyCode.ENTER?(a.preventDefault(),void this.doFormSave()):void(a.keyCode===b.keyCode.ESCAPE&&(a.preventDefault(),this.doFormCancel()))},handleFormClick:function(a){a.stopPropagation()},handleSaveClick:function(a){a.preventDefault(),this.doFormSave()},handleCloseClick:function(a){a.preventDefault(),this.doFormCancel()}},i=b.derives(h,a)}();var j;!function(){j=function(){b.deprecated("MediumEditor.statics.AnchorPreview","MediumEditor.extensions.anchorPreview","v5.0.0"),this.parent=!0,this.name="anchor-preview"},j.prototype={previewValueSelector:"a",init:function(){this.anchorPreview=this.createPreview(),this.base.options.elementsContainer.appendChild(this.anchorPreview),this.attachToEditables()},getPreviewElement:function(){return this.anchorPreview},createPreview:function(){var a=this.base.options.ownerDocument.createElement("div");return a.id="medium-editor-anchor-preview-"+this.base.id,a.className="medium-editor-anchor-preview",a.innerHTML=this.getTemplate(),this.base.on(a,"click",this.handleClick.bind(this)),a},getTemplate:function(){return''},deactivate:function(){this.anchorPreview&&(this.anchorPreview.parentNode&&this.anchorPreview.parentNode.removeChild(this.anchorPreview),delete this.anchorPreview)},hidePreview:function(){this.anchorPreview.classList.remove("medium-editor-anchor-preview-active"),this.activeAnchor=null},showPreview:function(a){return this.anchorPreview.classList.contains("medium-editor-anchor-preview-active")||a.getAttribute("data-disable-preview")?!0:(this.previewValueSelector&&(this.anchorPreview.querySelector(this.previewValueSelector).textContent=a.attributes.href.value,this.anchorPreview.querySelector(this.previewValueSelector).href=a.attributes.href.value),this.anchorPreview.classList.add("medium-toolbar-arrow-over"),this.anchorPreview.classList.remove("medium-toolbar-arrow-under"),this.anchorPreview.classList.contains("medium-editor-anchor-preview-active")||this.anchorPreview.classList.add("medium-editor-anchor-preview-active"),this.activeAnchor=a,this.positionPreview(),this.attachPreviewHandlers(),this)},positionPreview:function(){var a,b,c=this.anchorPreview.offsetHeight,d=this.activeAnchor.getBoundingClientRect(),e=(d.left+d.right)/2;a=this.anchorPreview.offsetWidth/2,b=this.base.options.diffLeft-a,this.anchorPreview.style.top=Math.round(c+d.bottom-this.base.options.diffTop+this.base.options.contentWindow.pageYOffset-this.anchorPreview.offsetHeight)+"px",a>e?this.anchorPreview.style.left=b+a+"px":this.base.options.contentWindow.innerWidth-ethis.base.options.anchorPreviewHideDelay&&this.detachPreviewHandlers()},detachPreviewHandlers:function(){clearInterval(this.intervalTimer),this.instanceHandlePreviewMouseover&&(this.base.off(this.anchorPreview,"mouseover",this.instanceHandlePreviewMouseover),this.base.off(this.anchorPreview,"mouseout",this.instanceHandlePreviewMouseout),this.activeAnchor&&(this.base.off(this.activeAnchor,"mouseover",this.instanceHandlePreviewMouseover),this.base.off(this.activeAnchor,"mouseout",this.instanceHandlePreviewMouseout))),this.hidePreview(),this.hovering=this.instanceHandlePreviewMouseover=this.instanceHandlePreviewMouseout=null},attachPreviewHandlers:function(){this.lastOver=(new Date).getTime(),this.hovering=!0,this.instanceHandlePreviewMouseover=this.handlePreviewMouseover.bind(this),this.instanceHandlePreviewMouseout=this.handlePreviewMouseout.bind(this),this.intervalTimer=setInterval(this.updatePreview.bind(this),200),this.base.on(this.anchorPreview,"mouseover",this.instanceHandlePreviewMouseover),this.base.on(this.anchorPreview,"mouseout",this.instanceHandlePreviewMouseout),this.base.on(this.activeAnchor,"mouseover",this.instanceHandlePreviewMouseover),this.base.on(this.activeAnchor,"mouseout",this.instanceHandlePreviewMouseout)}}}();var k;!function(){function a(){b.deprecated("MediumEditor.statics.FontSizeExtension","MediumEditor.extensions.fontSize","v5.0.0"),this.parent=!0,this.options={name:"fontsize",action:"fontSize",aria:"increase/decrease font size",contentDefault:"±",contentFA:''},this.name="fontsize",this.hasForm=!0}a.prototype={handleClick:function(a){if(a.preventDefault(),a.stopPropagation(),!this.isDisplayed()){var b=this.base.options.ownerDocument.queryCommandValue("fontSize")+"";this.showForm(b)}return!1},getForm:function(){return this.form||(this.form=this.createForm()),this.form},isDisplayed:function(){return"block"===this.getForm().style.display},hideForm:function(){this.getForm().style.display="none",this.getInput().value=""},showForm:function(a){var b=this.getInput();this.base.saveSelection(),this.base.hideToolbarDefaultActions(),this.getForm().style.display="block",this.base.setToolbarPosition(),b.value=a||"",b.focus()},deactivate:function(){return this.form?(this.form.parentNode&&this.form.parentNode.removeChild(this.form),void delete this.form):!1},doFormSave:function(){this.base.restoreSelection(),this.base.checkSelection()},doFormCancel:function(){this.base.restoreSelection(),this.clearFontSize(),this.base.checkSelection()},createForm:function(){var a=this.base.options.ownerDocument,b=a.createElement("div"),c=a.createElement("input"),d=a.createElement("a"),e=a.createElement("a");return b.className="medium-editor-toolbar-form",b.id="medium-editor-toolbar-form-fontsize-"+this.base.id,this.base.on(b,"click",this.handleFormClick.bind(this)),c.setAttribute("type","range"),c.setAttribute("min","1"),c.setAttribute("max","7"),c.className="medium-editor-toolbar-input",b.appendChild(c),this.base.on(c,"change",this.handleSliderChange.bind(this)),e.setAttribute("href","#"),e.className="medium-editor-toobar-save",e.innerHTML="fontawesome"===this.base.options.buttonLabels?'':"✓",b.appendChild(e),this.base.on(e,"click",this.handleSaveClick.bind(this),!0),d.setAttribute("href","#"),d.className="medium-editor-toobar-close",d.innerHTML="fontawesome"===this.base.options.buttonLabels?'':"×",b.appendChild(d),this.base.on(d,"click",this.handleCloseClick.bind(this)),b},getInput:function(){return this.getForm().querySelector("input.medium-editor-toolbar-input")},clearFontSize:function(){f.getSelectedElements(this.base.options.ownerDocument).forEach(function(a){"FONT"===a.tagName&&a.hasAttribute("size")&&a.removeAttribute("size")})},handleSliderChange:function(){var a=this.getInput().value;"4"===a?this.clearFontSize():this.base.execAction("fontSize",{size:a})},handleFormClick:function(a){a.stopPropagation()},handleSaveClick:function(a){a.preventDefault(),this.doFormSave()},handleCloseClick:function(a){a.preventDefault(),this.doFormCancel()}},k=b.derives(h,a)}();var l;!function(){l=e.extend({init:function(){this.button=this.createButton(),this.on(this.button,"click",this.handleClick.bind(this)),this.key&&this.subscribe("editableKeydown",this.handleKeydown.bind(this))},getButton:function(){return this.button},getAction:function(){return"function"==typeof this.action?this.action(this.base.options):this.action},getAria:function(){return"function"==typeof this.aria?this.aria(this.base.options):this.aria},getTagNames:function(){return"function"==typeof this.tagNames?this.tagNames(this.base.options):this.tagNames},createButton:function(){var a=this.document.createElement("button"),b=this.contentDefault,c=this.getAria(),d=this.getEditorOption("buttonLabels");return a.classList.add("medium-editor-action"),a.classList.add("medium-editor-action-"+this.name),a.setAttribute("data-action",this.getAction()),c&&(a.setAttribute("title",c),a.setAttribute("aria-label",c)),d&&("fontawesome"===d&&this.contentFA?b=this.contentFA:"object"==typeof d&&d[this.name]&&(b=d[this.name])),a.innerHTML=b,a},handleKeydown:function(a){var c;b.isKey(a,this.key.charCodeAt(0))&&b.isMetaCtrlKey(a)&&!a.shiftKey&&(a.preventDefault(),a.stopPropagation(),c=this.getAction(),c&&this.execAction(c))},handleClick:function(a){a.preventDefault(),a.stopPropagation();var b=this.getAction();b&&this.execAction(b)},isActive:function(){return this.button.classList.contains(this.getEditorOption("activeButtonClass"))},setInactive:function(){this.button.classList.remove(this.getEditorOption("activeButtonClass")),delete this.knownState},setActive:function(){this.button.classList.add(this.getEditorOption("activeButtonClass")),delete this.knownState},queryCommandState:function(){var a=null;return this.useQueryState&&(a=this.base.queryCommandState(this.getAction())),a},isAlreadyApplied:function(a){var b,c,d=!1,e=this.getTagNames();return this.knownState===!1||this.knownState===!0?this.knownState:(e&&e.length>0&&a.tagName&&(d=-1!==e.indexOf(a.tagName.toLowerCase())),!d&&this.style&&(b=this.style.value.split("|"),c=this.window.getComputedStyle(a,null).getPropertyValue(this.style.prop),b.forEach(function(a){this.knownState||(d=-1!==c.indexOf(a),(d||"text-decoration"!==this.style.prop)&&(this.knownState=d))},this)),d)}})}();var m;!function(){var a=function(){};m=l.extend({formSaveLabel:"✓",formCloseLabel:"×",hasForm:!0,getForm:a,isDisplayed:a,hideForm:a})}();var n;!function(){n=m.extend({customClassOption:null,customClassOptionText:"Button",linkValidation:!1,placeholderText:"Paste or type a link",targetCheckbox:!1,targetCheckboxText:"Open in new window",name:"anchor",action:"createLink",aria:"link",tagNames:["a"],contentDefault:"#",contentFA:'',key:"K",handleClick:function(a){a.preventDefault(),a.stopPropagation();var c=f.getSelectedParentElement(f.getSelectionRange(this.document)),d=b.getFirstTextNode(c);return b.getClosestTag(d,"a")?this.execAction("unlink"):(this.isDisplayed()||this.showForm(),!1)},handleKeydown:function(a){b.isKey(a,this.key.charCodeAt(0))&&b.isMetaCtrlKey(a)&&this.handleClick(a)},getForm:function(){return this.form||(this.form=this.createForm()),this.form},getTemplate:function(){var a=[''];return a.push('',"fontawesome"===this.getEditorOption("buttonLabels")?'':this.formSaveLabel,""),a.push('',"fontawesome"===this.getEditorOption("buttonLabels")?'':this.formCloseLabel,""),this.targetCheckbox&&a.push('',""),this.customClassOption&&a.push('',""),a.join("")},isDisplayed:function(){return"block"===this.getForm().style.display},hideForm:function(){this.getForm().style.display="none",this.getInput().value=""},showForm:function(a){var b=this.getInput();this.base.saveSelection(),this.base.hideToolbarDefaultActions(),this.getForm().style.display="block",this.base.setToolbarPosition(),b.value=a||"",b.focus()},destroy:function(){return this.form?(this.form.parentNode&&this.form.parentNode.removeChild(this.form),void delete this.form):!1},deactivate:function(){b.deprecatedMethod.call(this,"deactivate","destroy",arguments,"v5.0.0")},getFormOpts:function(){var a=this.getForm().querySelector(".medium-editor-toolbar-anchor-target"),b=this.getForm().querySelector(".medium-editor-toolbar-anchor-button"),c={url:this.getInput().value};return this.linkValidation&&(c.url=this.checkLinkFormat(c.url)),c.target="_self",a&&a.checked&&(c.target="_blank"),b&&b.checked&&(c.buttonClass=this.customClassOption),c},doFormSave:function(){var a=this.getFormOpts();this.completeFormSave(a)},completeFormSave:function(a){this.base.restoreSelection(),this.execAction(this.action,a),this.base.checkSelection()},checkLinkFormat:function(a){var b=/^(https?|ftps?|rtmpt?):\/\/|mailto:/;return(b.test(a)?"":"http://")+a},doFormCancel:function(){this.base.restoreSelection(),this.base.checkSelection()},attachFormEvents:function(a){var b=a.querySelector(".medium-editor-toolbar-close"),c=a.querySelector(".medium-editor-toolbar-save"),d=a.querySelector(".medium-editor-toolbar-input");this.on(a,"click",this.handleFormClick.bind(this)),this.on(d,"keyup",this.handleTextboxKeyup.bind(this)),this.on(b,"click",this.handleCloseClick.bind(this)),this.on(c,"click",this.handleSaveClick.bind(this),!0)},createForm:function(){var a=this.document,b=a.createElement("div");return b.className="medium-editor-toolbar-form",b.id="medium-editor-toolbar-form-anchor-"+this.getEditorId(),b.innerHTML=this.getTemplate(),this.attachFormEvents(b),b},getInput:function(){return this.getForm().querySelector("input.medium-editor-toolbar-input")},handleTextboxKeyup:function(a){return a.keyCode===b.keyCode.ENTER?(a.preventDefault(),void this.doFormSave()):void(a.keyCode===b.keyCode.ESCAPE&&(a.preventDefault(),this.doFormCancel()))},handleFormClick:function(a){a.stopPropagation()},handleSaveClick:function(a){a.preventDefault(),this.doFormSave()},handleCloseClick:function(a){a.preventDefault(),this.doFormCancel()}})}();var o;!function(){o=e.extend({name:"anchor-preview",hideDelay:500,previewValueSelector:"a",diffLeft:0,diffTop:-10,elementsContainer:!1,init:function(){this.anchorPreview=this.createPreview(),this.elementsContainer||(this.elementsContainer=this.document.body),this.elementsContainer.appendChild(this.anchorPreview),this.attachToEditables()},getPreviewElement:function(){return this.anchorPreview},createPreview:function(){var a=this.document.createElement("div");return a.id="medium-editor-anchor-preview-"+this.getEditorId(),a.className="medium-editor-anchor-preview",a.innerHTML=this.getTemplate(),this.on(a,"click",this.handleClick.bind(this)),a},getTemplate:function(){return''},destroy:function(){this.anchorPreview&&(this.anchorPreview.parentNode&&this.anchorPreview.parentNode.removeChild(this.anchorPreview),delete this.anchorPreview)},deactivate:function(){b.deprecatedMethod.call(this,"deactivate","destroy",arguments,"v5.0.0")},hidePreview:function(){this.anchorPreview.classList.remove("medium-editor-anchor-preview-active"),this.activeAnchor=null},showPreview:function(a){return this.anchorPreview.classList.contains("medium-editor-anchor-preview-active")||a.getAttribute("data-disable-preview")?!0:(this.previewValueSelector&&(this.anchorPreview.querySelector(this.previewValueSelector).textContent=a.attributes.href.value,this.anchorPreview.querySelector(this.previewValueSelector).href=a.attributes.href.value),this.anchorPreview.classList.add("medium-toolbar-arrow-over"),this.anchorPreview.classList.remove("medium-toolbar-arrow-under"),this.anchorPreview.classList.contains("medium-editor-anchor-preview-active")||this.anchorPreview.classList.add("medium-editor-anchor-preview-active"),this.activeAnchor=a,this.positionPreview(),this.attachPreviewHandlers(),this)},positionPreview:function(){var a,b,c=this.anchorPreview.offsetHeight,d=this.activeAnchor.getBoundingClientRect(),e=(d.left+d.right)/2;a=this.anchorPreview.offsetWidth/2,b=this.diffLeft-a,this.anchorPreview.style.top=Math.round(c+d.bottom-this.diffTop+this.window.pageYOffset-this.anchorPreview.offsetHeight)+"px",a>e?this.anchorPreview.style.left=b+a+"px":this.window.innerWidth-ethis.hideDelay&&this.detachPreviewHandlers()},detachPreviewHandlers:function(){clearInterval(this.intervalTimer),this.instanceHandlePreviewMouseover&&(this.off(this.anchorPreview,"mouseover",this.instanceHandlePreviewMouseover),this.off(this.anchorPreview,"mouseout",this.instanceHandlePreviewMouseout),this.activeAnchor&&(this.off(this.activeAnchor,"mouseover",this.instanceHandlePreviewMouseover),this.off(this.activeAnchor,"mouseout",this.instanceHandlePreviewMouseout))),this.hidePreview(),this.hovering=this.instanceHandlePreviewMouseover=this.instanceHandlePreviewMouseout=null},attachPreviewHandlers:function(){this.lastOver=(new Date).getTime(),this.hovering=!0,this.instanceHandlePreviewMouseover=this.handlePreviewMouseover.bind(this),this.instanceHandlePreviewMouseout=this.handlePreviewMouseout.bind(this),this.intervalTimer=setInterval(this.updatePreview.bind(this),200),this.on(this.anchorPreview,"mouseover",this.instanceHandlePreviewMouseover),this.on(this.anchorPreview,"mouseout",this.instanceHandlePreviewMouseout),this.on(this.activeAnchor,"mouseover",this.instanceHandlePreviewMouseover),this.on(this.activeAnchor,"mouseout",this.instanceHandlePreviewMouseout)}})}();var p,q,r,s;q=[" "," ","\n","\r"," "," "," "," "," ","\u2028","\u2029"],r="com|net|org|edu|gov|mil|aero|asia|biz|cat|coop|info|int|jobs|mobi|museum|name|post|pro|tel|travel|xxx|ac|ad|ae|af|ag|ai|al|am|an|ao|aq|ar|as|at|au|aw|ax|az|ba|bb|bd|be|bf|bg|bh|bi|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|cr|cs|cu|cv|cx|cy|cz|dd|de|dj|dk|dm|do|dz|ec|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gg|gh|gi|gl|gm|gn|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|im|in|io|iq|ir|is|it|je|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|me|mg|mh|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|mv|mw|mx|my|mz|na|nc|ne|nf|ng|ni|nl|no|np|nr|nu|nz|om|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|ps|pt|pw|py|qa|re|ro|rs|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|ja|sk|sl|sm|sn|so|sr|ss|st|su|sv|sx|sy|sz|tc|td|tf|tg|th|tj|tk|tl|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw",s="(((?:(https?://|ftps?://|nntp://)|www\\d{0,3}[.]|[a-z0-9.\\-]+[.]("+r+")\\/)\\S+(?:[^\\s`!\\[\\]{};:'\".,?«»“”‘’])))|(([a-z0-9\\-]+\\.)?[a-z0-9\\-]+\\.("+r+"))",function(){function a(a){return!b.getClosestTag(a,"a")}var c=new RegExp("^("+r+")$","i");p=e.extend({init:function(){this.disableEventHandling=!1,this.subscribe("editableKeypress",this.onKeypress.bind(this)),this.subscribe("editableBlur",this.onBlur.bind(this)),this.document.execCommand("AutoUrlDetect",!1,!1)},destroy:function(){this.document.queryCommandSupported("AutoUrlDetect")&&this.document.execCommand("AutoUrlDetect",!1,!0)},onBlur:function(a,b){this.performLinking(b)},onKeypress:function(a){this.disableEventHandling||b.isKey(a,[b.keyCode.SPACE,b.keyCode.ENTER])&&(clearTimeout(this.performLinkingTimeout),this.performLinkingTimeout=setTimeout(function(){try{var b=this.base.exportSelection();this.performLinking(a.target)&&this.base.importSelection(b,!0)}catch(c){window.console&&window.console.error("Failed to perform linking",c),this.disableEventHandling=!0}}.bind(this),0))},performLinking:function(a){var b=a.querySelectorAll("p"),c=!1;0===b.length&&(b=[a]);for(var d=0;d=c&&d!==e&&0!==f&&(b||a).splitText(f)},removeObsoleteAutoLinkSpans:function(c){for(var d=c.querySelectorAll('span[data-auto-link="true"]'),e=!1,f=0;f0&&null!==g;)e=c.currentNode,f=e.nodeValue,f.length>b?(g=e.splitText(f.length-b),b=0):(g=c.previousNode(),b-=f.length);return g},performLinkingWithinElement:function(a){for(var b=this.findLinkableText(a),c=!1,d=0;db.end+1)throw new Error("PerformLinking overshot the target!");f&&d.push(h||g),e+=g.nodeValue.length,null!==h&&(e+=h.nodeValue.length,c.nextNode()),h=null}return d},createLink:function(a,c){for(var d=!1,e=0;e'),c.onload=function(){var a=this.document.getElementById(d);a&&(a.removeAttribute("id"),a.removeAttribute("class"),a.src=c.result)}.bind(this)}}.bind(this))),a.target.classList.remove(d)}})}();var u;!function(){u=m.extend({name:"fontsize",action:"fontSize",aria:"increase/decrease font size",contentDefault:"±",contentFA:'',handleClick:function(a){if(a.preventDefault(),a.stopPropagation(),!this.isDisplayed()){var b=this.document.queryCommandValue("fontSize")+"";this.showForm(b)}return!1},getForm:function(){return this.form||(this.form=this.createForm()),this.form},isDisplayed:function(){return"block"===this.getForm().style.display},hideForm:function(){this.getForm().style.display="none",this.getInput().value=""},showForm:function(a){var b=this.getInput();this.base.saveSelection(),this.base.hideToolbarDefaultActions(),this.getForm().style.display="block",this.base.setToolbarPosition(),b.value=a||"",b.focus()},destroy:function(){return this.form?(this.form.parentNode&&this.form.parentNode.removeChild(this.form),void delete this.form):!1},deactivate:function(){b.deprecatedMethod.call(this,"deactivate","destroy",arguments,"v5.0.0")},doFormSave:function(){this.base.restoreSelection(),this.base.checkSelection()},doFormCancel:function(){this.base.restoreSelection(),this.clearFontSize(),this.base.checkSelection()},createForm:function(){var a=this.document,b=a.createElement("div"),c=a.createElement("input"),d=a.createElement("a"),e=a.createElement("a");return b.className="medium-editor-toolbar-form",b.id="medium-editor-toolbar-form-fontsize-"+this.getEditorId(),this.on(b,"click",this.handleFormClick.bind(this)),c.setAttribute("type","range"),c.setAttribute("min","1"),c.setAttribute("max","7"),c.className="medium-editor-toolbar-input",b.appendChild(c),this.on(c,"change",this.handleSliderChange.bind(this)),e.setAttribute("href","#"),e.className="medium-editor-toobar-save",e.innerHTML="fontawesome"===this.getEditorOption("buttonLabels")?'':"✓",b.appendChild(e),this.on(e,"click",this.handleSaveClick.bind(this),!0),d.setAttribute("href","#"),d.className="medium-editor-toobar-close",
-d.innerHTML="fontawesome"===this.getEditorOption("buttonLabels")?'':"×",b.appendChild(d),this.on(d,"click",this.handleCloseClick.bind(this)),b},getInput:function(){return this.getForm().querySelector("input.medium-editor-toolbar-input")},clearFontSize:function(){f.getSelectedElements(this.document).forEach(function(a){"FONT"===a.tagName&&a.hasAttribute("size")&&a.removeAttribute("size")})},handleSliderChange:function(){var a=this.getInput().value;"4"===a?this.clearFontSize():this.execAction("fontSize",{size:a})},handleFormClick:function(a){a.stopPropagation()},handleSaveClick:function(a){a.preventDefault(),this.doFormSave()},handleCloseClick:function(a){a.preventDefault(),this.doFormCancel()}})}();var v;!function(){function a(){return[[new RegExp(/<[^>]*docs-internal-guid[^>]*>/gi),""],[new RegExp(/<\/b>(
]*>)?$/gi),""],[new RegExp(/\s+<\/span>/g)," "],[new RegExp(/
/g),"
"],[new RegExp(/]*(font-style:italic;font-weight:bold|font-weight:bold;font-style:italic)[^>]*>/gi),''],[new RegExp(/]*font-style:italic[^>]*>/gi),''],[new RegExp(/]*font-weight:bold[^>]*>/gi),''],[new RegExp(/<(\/?)(i|b|a)>/gi),"<$1$2>"],[new RegExp(/<a(?:(?!href).)+href=(?:"|”|“|"|“|”)(((?!"|”|“|"|“|”).)*)(?:"|”|“|"|“|”)(?:(?!>).)*>/gi),''],[new RegExp(/<\/p>\n+/gi),"
"],[new RegExp(/\n+/gi),""]]}v=e.extend({forcePlainText:!0,cleanPastedHTML:!1,cleanReplacements:[],cleanAttrs:["class","style","dir"],cleanTags:["meta"],targetBlank:!1,disableReturn:!1,init:function(){(this.forcePlainText||this.cleanPastedHTML)&&this.subscribe("editablePaste",this.handlePaste.bind(this))},handlePaste:function(a,c){var d,e,f,g,h="",i="text/html",j="text/plain";if(this.window.clipboardData&&void 0===a.clipboardData&&(a.clipboardData=this.window.clipboardData,i="Text",j="Text"),a.clipboardData&&a.clipboardData.getData&&!a.defaultPrevented){if(a.preventDefault(),f=a.clipboardData.getData(i),g=a.clipboardData.getData(j),this.cleanPastedHTML&&f)return this.cleanPaste(f);if(this.disableReturn||c.getAttribute("data-disable-return"))h=b.htmlEntities(g);else if(d=g.split(/[\r\n]+/g),d.length>1)for(e=0;e"+b.htmlEntities(d[e])+"
");else h=b.htmlEntities(d[0]);b.insertHTMLCommand(this.document,h)}},cleanPaste:function(b){var c,d,e,g=f.getSelectionElement(this.window),h=/
"),this.pasteHTML("
"+d.join("
")+"
");try{this.document.execCommand("insertText",!1,"\n")}catch(j){}for(d=g.querySelectorAll("a,p,div,br"),c=0;c"+d.innerHTML+"":e.innerHTML=d.innerHTML,d.parentNode.replaceChild(e,d);for(f=a.querySelectorAll("span"),c=0;c0&&(d[0].classList.add(this.options.firstButtonClass),d[d.length-1].classList.add(this.options.lastButtonClass)),f},destroy:function(){this.toolbar&&(this.toolbar.parentNode&&this.toolbar.parentNode.removeChild(this.toolbar),delete this.toolbar)},deactivate:function(){b.deprecatedMethod.call(this,"deactivate","destroy",arguments,"v5.0.0")},getToolbarElement:function(){return this.toolbar||(this.toolbar=this.createToolbar()),this.toolbar},getToolbarActionsElement:function(){return this.getToolbarElement().querySelector(".medium-editor-toolbar-actions")},initThrottledMethods:function(){this.throttledPositionToolbar=b.throttle(function(){this.base.isActive&&this.positionToolbarIfShown()}.bind(this))},attachEventHandlers:function(){this.base.subscribe("blur",this.handleBlur.bind(this)),this.base.subscribe("focus",this.handleFocus.bind(this)),this.base.subscribe("editableClick",this.handleEditableClick.bind(this)),this.base.subscribe("editableKeyup",this.handleEditableKeyup.bind(this)),this.base.on(this.options.ownerDocument.documentElement,"mouseup",this.handleDocumentMouseup.bind(this)),this.options.staticToolbar&&this.options.stickyToolbar&&this.base.on(this.options.contentWindow,"scroll",this.handleWindowScroll.bind(this),!0),this.base.on(this.options.contentWindow,"resize",this.handleWindowResize.bind(this))},handleWindowScroll:function(){this.positionToolbarIfShown()},handleWindowResize:function(){this.throttledPositionToolbar()},handleDocumentMouseup:function(a){return a&&a.target&&b.isDescendant(this.getToolbarElement(),a.target)?!1:void this.checkState()},handleEditableClick:function(){setTimeout(function(){this.checkState()}.bind(this),0)},handleEditableKeyup:function(){this.checkState()},handleBlur:function(){clearTimeout(this.hideTimeout),clearTimeout(this.delayShowTimeout),this.hideTimeout=setTimeout(function(){this.hideToolbar()}.bind(this),1)},handleFocus:function(){this.checkState()},isDisplayed:function(){return this.getToolbarElement().classList.contains("medium-editor-toolbar-active")},showToolbar:function(){clearTimeout(this.hideTimeout),this.isDisplayed()||(this.getToolbarElement().classList.add("medium-editor-toolbar-active"),this.base.trigger("showToolbar",{},this.base.getFocusedElement()),"function"==typeof this.options.onShowToolbar&&(b.deprecated("onShowToolbar","the showToolbar custom event","v5.0.0"),this.options.onShowToolbar()))},hideToolbar:function(){this.isDisplayed()&&(this.getToolbarElement().classList.remove("medium-editor-toolbar-active"),this.base.trigger("hideToolbar",{},this.base.getFocusedElement()),this.base.commands.forEach(function(a){"function"==typeof a.onHide&&(b.deprecated("onHide","the hideToolbar custom event","v5.0.0"),a.onHide())}),"function"==typeof this.options.onHideToolbar&&(b.deprecated("onHideToolbar","the hideToolbar custom event","v5.0.0"),this.options.onHideToolbar()))},isToolbarDefaultActionsDisplayed:function(){return"block"===this.getToolbarActionsElement().style.display},hideToolbarDefaultActions:function(){this.isToolbarDefaultActionsDisplayed()&&(this.getToolbarActionsElement().style.display="none")},showToolbarDefaultActions:function(){this.hideExtensionForms(),this.isToolbarDefaultActionsDisplayed()||(this.getToolbarActionsElement().style.display="block"),this.delayShowTimeout=this.base.delay(function(){this.showToolbar()}.bind(this))},hideExtensionForms:function(){this.base.commands.forEach(function(a){a.hasForm&&a.isDisplayed()&&a.hideForm()})},multipleBlockElementsSelected:function(){var a=f.getSelectionHtml.call(this).replace(/<[\S]+><\/[\S]+>/gim,""),b=a.match(/<(p|h[1-6]|blockquote)[^>]*>/g);return!!b&&b.length>1},modifySelection:function(){var a=this.options.contentWindow.getSelection(),c=a.getRangeAt(0);if(this.options.standardizeSelectionStart&&c.startContainer.nodeValue&&c.startOffset===c.startContainer.nodeValue.length){var d=b.findAdjacentTextNodeWithContent(f.getSelectionElement(this.options.contentWindow),c.startContainer,this.options.ownerDocument);if(d){for(var e=0;0===d.nodeValue.substr(e,1).trim().length;)e+=1;var g=this.options.ownerDocument.createRange();g.setStart(d,e),g.setEnd(c.endContainer,c.endOffset),a.removeAllRanges(),a.addRange(g),c=g}}},checkState:function(){if(!this.base.preventSelectionUpdates){if(!this.base.getFocusedElement()||f.selectionInContentEditableFalse(this.options.contentWindow))return this.hideToolbar();var a=f.getSelectionElement(this.options.contentWindow);return!a||-1===this.base.elements.indexOf(a)||a.getAttribute("data-disable-toolbar")?this.hideToolbar():this.options.updateOnEmptySelection&&this.options.staticToolbar?this.showAndUpdateToolbar():""===this.options.contentWindow.getSelection().toString().trim()||this.options.allowMultiParagraphSelection===!1&&this.multipleBlockElementsSelected()?this.hideToolbar():void this.showAndUpdateToolbar()}},getFocusedElement:function(){return this.base.getFocusedElement()},showAndUpdateToolbar:function(){this.modifySelection(),this.setToolbarButtonStates(),this.base.trigger("positionToolbar",{},this.base.getFocusedElement()),this.showToolbarDefaultActions(),this.setToolbarPosition()},setToolbarButtonStates:function(){this.base.commands.forEach(function(a){"function"==typeof a.isActive&&"function"==typeof a.setInactive&&a.setInactive()}.bind(this)),this.checkActiveButtons()},checkActiveButtons:function(){var a,c=[],d=null,e=f.getSelectionRange(this.options.ownerDocument),g=function(b){"function"==typeof b.checkState?b.checkState(a):"function"==typeof b.isActive&&"function"==typeof b.isAlreadyApplied&&"function"==typeof b.setActive&&!b.isActive()&&b.isAlreadyApplied(a)&&b.setActive()};if(e)for(a=f.getSelectedParentElement(e),this.base.commands.forEach(function(a){return"function"==typeof a.queryCommandState&&(d=a.queryCommandState(),null!==d)?void(d&&"function"==typeof a.setActive&&a.setActive()):void c.push(a)});void 0!==a.tagName&&-1===b.parentElements.indexOf(a.tagName.toLowerCase)&&(c.forEach(g),-1===this.base.elements.indexOf(a));)a=a.parentNode},positionToolbarIfShown:function(){this.isDisplayed()&&this.setToolbarPosition()},setToolbarPosition:function(){var a,b=this.base.getFocusedElement(),c=this.options.contentWindow.getSelection();return b?(this.options.staticToolbar?(this.showToolbar(),this.positionStaticToolbar(b)):c.isCollapsed||(this.showToolbar(),this.positionToolbar(c)),a=this.base.getExtensionByName("anchor-preview"),void(a&&"function"==typeof a.hidePreview&&a.hidePreview())):this},positionStaticToolbar:function(a){this.getToolbarElement().style.left="0";var b,c=this.options.ownerDocument.documentElement&&this.options.ownerDocument.documentElement.scrollTop||this.options.ownerDocument.body.scrollTop,d=this.options.contentWindow.innerWidth,e=this.getToolbarElement(),f=a.getBoundingClientRect(),g=f.top+c,h=f.left+f.width/2,i=e.offsetHeight,j=e.offsetWidth,k=j/2;switch(this.options.stickyToolbar?c>g+a.offsetHeight-i?(e.style.top=g+a.offsetHeight-i+"px",e.classList.remove("sticky-toolbar")):c>g-i?(e.classList.add("sticky-toolbar"),e.style.top="0px"):(e.classList.remove("sticky-toolbar"),e.style.top=g-i+"px"):e.style.top=g-i+"px",this.options.toolbarAlign){case"left":b=f.left;break;case"right":b=f.right-j;break;case"center":b=h-k}0>b?b=0:b+j>d&&(b=d-Math.ceil(j)-1),e.style.left=b+"px"},positionToolbar:function(a){this.getToolbarElement().style.left="0";var b=this.options.contentWindow.innerWidth,c=a.getRangeAt(0),d=c.getBoundingClientRect(),e=(d.left+d.right)/2,f=this.getToolbarElement(),g=f.offsetHeight,h=f.offsetWidth,i=h/2,j=50,k=this.options.diffLeft-i;d.tope?f.style.left=k+i+"px":i>b-e?f.style.left=b+k-i+"px":f.style.left=k+e+"px"}}}();var y;return function(){y={button:l,form:m,anchor:n,anchorPreview:o,autoLink:p,fontSize:u,imageDragging:t,paste:v,placeholder:w}}(),function(){function l(a,b){if(this.options.disableReturn||b.getAttribute("data-disable-return"))a.preventDefault();else if(this.options.disableDoubleReturn||b.getAttribute("data-disable-double-return")){var c=f.getSelectionStart(this.options.ownerDocument);(c&&""===c.textContent.trim()||c.previousElementSibling&&""===c.previousElementSibling.textContent.trim())&&a.preventDefault()}}function m(a){var c=f.getSelectionStart(this.options.ownerDocument),d=c&&c.tagName.toLowerCase();"pre"===d&&(a.preventDefault(),b.insertHTMLCommand(this.options.ownerDocument," ")),b.isListItem(c)&&(a.preventDefault(),a.shiftKey?this.options.ownerDocument.execCommand("outdent",!1,null):this.options.ownerDocument.execCommand("indent",!1,null))}function n(a){var c,d=f.getSelectionStart(this.options.ownerDocument),e=d.tagName.toLowerCase(),g=/^(\s+|
)?$/i,h=/h\d/i;b.isKey(a,[b.keyCode.BACKSPACE,b.keyCode.ENTER])&&d.previousElementSibling&&h.test(e)&&0===f.getCaretOffsets(d).left?b.isKey(a,b.keyCode.BACKSPACE)&&g.test(d.previousElementSibling.innerHTML)?(d.previousElementSibling.parentNode.removeChild(d.previousElementSibling),a.preventDefault()):b.isKey(a,b.keyCode.ENTER)&&(c=this.options.ownerDocument.createElement("p"),c.innerHTML="
",d.previousElementSibling.parentNode.insertBefore(c,d),a.preventDefault()):b.isKey(a,b.keyCode.DELETE)&&d.nextElementSibling&&d.previousElementSibling&&!h.test(e)&&g.test(d.innerHTML)&&h.test(d.nextElementSibling.tagName)?(f.moveCursor(this.options.ownerDocument,d.nextElementSibling),d.previousElementSibling.parentNode.removeChild(d),a.preventDefault()):b.isKey(a,b.keyCode.BACKSPACE)&&"li"===e&&g.test(d.innerHTML)&&!d.previousElementSibling&&!d.parentElement.previousElementSibling&&d.nextElementSibling&&"li"===d.nextElementSibling.tagName.toLowerCase()&&(c=this.options.ownerDocument.createElement("p"),c.innerHTML="
",d.parentElement.parentElement.insertBefore(c,d.parentElement),f.moveCursor(this.options.ownerDocument,c),d.parentElement.removeChild(d),a.preventDefault())}function o(a){var c,d=f.getSelectionStart(this.options.ownerDocument);d&&(d.getAttribute("data-medium-element")&&0===d.children.length&&this.options.ownerDocument.execCommand("formatBlock",!1,"p"),b.isKey(a,b.keyCode.ENTER)&&!b.isListItem(d)&&(c=d.tagName.toLowerCase(),"a"===c?this.options.ownerDocument.execCommand("unlink",!1,null):a.shiftKey||a.ctrlKey||/h\d/.test(c)||this.options.ownerDocument.execCommand("formatBlock",!1,"p")))}function p(a){a||(a=[]),"string"==typeof a&&(a=this.options.ownerDocument.querySelectorAll(a)),b.isElement(a)&&(a=[a]);var c=Array.prototype.slice.apply(a);this.elements=[],c.forEach(function(a){this.elements.push("textarea"===a.tagName.toLowerCase()?w.call(this,a):a)},this)}function q(a,b){return Object.keys(b).forEach(function(c){void 0===a[c]&&(a[c]=b[c])}),a}function r(a,c,d){"undefined"!=typeof a.parent&&b.warn("Extension .parent property has been deprecated. The .base property for extensions will always be set to MediumEditor in version 5.0.0");var e={window:d.options.contentWindow,document:d.options.ownerDocument};return a.parent!==!1&&(e.base=d),a=q(a,e),"function"==typeof a.init&&a.init(d),a.name||(a.name=c),a}function s(){var a,b=!1;if(this.options.disableAnchorPreview)return!1;if(this.options.anchorPreview===!1)return!1;if(this.options.extensions["anchor-preview"])return!1;if(this.options.disableToolbar)return!1;for(a=0;a0&&(a=g.getRangeAt(0),c=a.cloneRange(),this.elements.some(function(c,d){return c===a.startContainer||b.isDescendant(c,a.startContainer)?(h=d,!0):!1}),h>-1&&(c.selectNodeContents(this.elements[h]),c.setEnd(a.startContainer,a.startOffset),d=c.toString().length,e={start:d,end:d+a.toString().length,editableElementIndex:h},0!==d))){var i=f.getIndexRelativeToAdjacentEmptyBlocks(this.options.ownerDocument,this.elements[h],a.startContainer,a.startOffset);0!==i&&(e.emptyBlocksIndex=i)}return null!==e&&0===e.editableElementIndex&&delete e.editableElementIndex,e},saveSelection:function(){this.selectionState=this.exportSelection()},importSelection:function(a,c){if(a){var d,e,g,h,i=void 0===a.editableElementIndex?0:a.editableElementIndex,j={editableElementIndex:i,start:a.start,end:a.end},k=this.elements[j.editableElementIndex],l=0,m=this.options.ownerDocument.createRange(),n=[k],o=!1,p=!1;for(m.setStart(k,0),m.collapse(!0),d=n.pop();!p&&d;){if(3===d.nodeType)h=l+d.length,!o&&j.start>=l&&j.start<=h&&(m.setStart(d,j.start-l),o=!0),o&&j.end>=l&&j.end<=h&&(m.setEnd(d,j.end-l),p=!0),l=h;else for(e=d.childNodes.length-1;e>=0;)n.push(d.childNodes[e]),e-=1;p||(d=n.pop())}if(a.emptyBlocksIndex&&j.end===h){for(var q=b.getBlockContainer(m.startContainer),r=0;r0)););m.setStart(b.getFirstSelectableLeafNode(q),0),m.collapse(!0)}c&&(m=f.importSelectionMoveCursorPastAnchor(j,m)),g=this.options.contentWindow.getSelection(),g.removeAllRanges(),g.addRange(m)}},restoreSelection:function(){this.importSelection(this.selectionState)},createLink:function(a){var c,d;if(a.url&&a.url.trim().length>0&&(this.options.ownerDocument.execCommand("createLink",!1,a.url),(this.options.targetBlank||"_blank"===a.target)&&b.setTargetBlank(f.getSelectionStart(this.options.ownerDocument),a.url),a.buttonClass&&b.addClassToAnchors(f.getSelectionStart(this.options.ownerDocument),a.buttonClass)),this.options.targetBlank||"_blank"===a.target||a.buttonClass)for(c=this.options.ownerDocument.createEvent("HTMLEvents"),c.initEvent("input",!0,!0,this.options.contentWindow),d=0;db;b++)if(b in this&&this[b]===a)return b;return-1},h=function(a,b){this.name=a,this.code=DOMException[a],this.message=b},i=function(a,b){if(""===b)throw new h("SYNTAX_ERR","An invalid or illegal string was specified");if(/\s/.test(b))throw new h("INVALID_CHARACTER_ERR","String contains an invalid character");return g.call(a,b)},j=function(a){for(var b=f.call(a.getAttribute("class")||""),c=b?b.split(/\s+/):[],d=0,e=c.length;e>d;d++)this.push(c[d]);this._updateClassName=function(){a.setAttribute("class",this.toString())}},k=j[c]=[],l=function(){return new j(this)};if(h[c]=Error[c],k.item=function(a){return this[a]||null},k.contains=function(a){return a+="",-1!==i(this,a)},k.add=function(){var a,b=arguments,c=0,d=b.length,e=!1;do a=b[c]+"",-1===i(this,a)&&(this.push(a),e=!0);while(++ci;i++)e+=String.fromCharCode(f[i]);c.push(e)}else if("Blob"===b(a)||"File"===b(a)){if(!g)throw new h("NOT_READABLE_ERR");var k=new g;c.push(k.readAsBinaryString(a))}else a instanceof d?"base64"===a.encoding&&p?c.push(p(a.data)):"URI"===a.encoding?c.push(decodeURIComponent(a.data)):"raw"===a.encoding&&c.push(a.data):("string"!=typeof a&&(a+=""),c.push(unescape(encodeURIComponent(a))))},e.getBlob=function(a){return arguments.length||(a=null),new d(this.data.join(""),a,"raw")},e.toString=function(){return"[object BlobBuilder]"},f.slice=function(a,b,c){var e=arguments.length;return 3>e&&(c=null),new d(this.data.slice(a,e>1?b:this.data.length),c,this.encoding)},f.toString=function(){return"[object Blob]"},f.close=function(){this.size=0,delete this.data},c}(a);a.Blob=function(a,b){var d=b?b.type||"":"",e=new c;if(a)for(var f=0,g=a.length;g>f;f++)e.append(Uint8Array&&a[f]instanceof Uint8Array?a[f].buffer:a[f]);var h=e.getBlob(d);return!h.slice&&h.webkitSlice&&(h.slice=h.webkitSlice),h};var d=Object.getPrototypeOf||function(a){return a.__proto__};a.Blob.prototype=d(new a.Blob)}("undefined"!=typeof self&&self||"undefined"!=typeof window&&window||this.content||this),function(a,b){"use strict";"object"==typeof module?module.exports=b:"function"==typeof define&&define.amd?define(function(){return b}):a.MediumEditor=b}(this,function(){"use strict";function a(a,b){return this.init(a,b)}var b;!function(a){function c(b,c,d){d||(d=a);try{for(var e=0;e=0,keyCode:{BACKSPACE:8,TAB:9,ENTER:13,ESCAPE:27,SPACE:32,DELETE:46},isMetaCtrlKey:function(a){return this.isMac&&a.metaKey||!this.isMac&&a.ctrlKey?!0:!1},isKey:function(a,b){var c=a.which;return null===c&&(c=null!==a.charCode?a.charCode:a.keyCode),!1===Array.isArray(b)?c===b:-1===b.indexOf(c)?!1:!0},parentElements:["p","h1","h2","h3","h4","h5","h6","blockquote","pre"],extend:function(){var a=[!0].concat(Array.prototype.slice.call(arguments));return d.apply(this,a)},defaults:function(){var a=[!1].concat(Array.prototype.slice.call(arguments));return d.apply(this,a)},derives:function(a,b){function c(){}var e=b.prototype;return c.prototype=a.prototype,b.prototype=new c,b.prototype.constructor=a,b.prototype=d(!1,b.prototype,e),b},findAdjacentTextNodeWithContent:function(a,b,c){var d,e=!1,f=c.createNodeIterator(a,NodeFilter.SHOW_TEXT,null,!1);for(d=f.nextNode();d;){if(d===b)e=!0;else if(e&&3===d.nodeType&&d.nodeValue&&d.nodeValue.trim().length>0)break;d=f.nextNode()}return d},isDescendant:function(a,b,c){if(!a||!b)return!1;if(c&&a===b)return!0;for(var d=b.parentNode;null!==d;){if(d===a)return!0;d=d.parentNode}return!1},isElement:function(a){return!(!a||1!==a.nodeType)},now:Date.now,throttle:function(a,b){var c,d,e,f=50,g=null,h=0,i=function(){h=Date.now(),g=null,e=a.apply(c,d),g||(c=d=null)};return b||0===b||(b=f),function(){var f=Date.now(),j=b-(f-h);return c=this,d=arguments,0>=j||j>b?(g&&(clearTimeout(g),g=null),h=f,e=a.apply(c,d),g||(c=d=null)):g||(g=setTimeout(i,j)),e}},traverseUp:function(a,b){if(!a)return!1;do{if(1===a.nodeType){if(b(a))return a;if(a.getAttribute("data-medium-element"))return!1}a=a.parentNode}while(a);return!1},htmlEntities:function(a){return String(a).replace(/&/g,"&").replace(//g,">").replace(/"/g,""")},insertHTMLCommand:function(a,b){var c,d,e,f,g,h,i;if(a.queryCommandSupported("insertHTML"))try{return a.execCommand("insertHTML",!1,b)}catch(j){}if(c=a.defaultView.getSelection(),c.getRangeAt&&c.rangeCount){if(d=c.getRangeAt(0),i=d.commonAncestorContainer,3===i.nodeType&&i.nodeValue===d.toString()||3!==i.nodeType&&i.innerHTML===d.toString()){for(;i.parentNode&&1===i.parentNode.childNodes.length&&!i.parentNode.getAttribute("data-medium-element");)i=i.parentNode;d.selectNode(i)}for(d.deleteContents(),e=a.createElement("div"),e.innerHTML=b,f=a.createDocumentFragment();e.firstChild;)g=e.firstChild,h=f.appendChild(g);d.insertNode(f),h&&(d=d.cloneRange(),d.setStartAfter(h),d.collapse(!0),c.removeAllRanges(),c.addRange(d))}},getSelectionRange:function(a){return this.deprecated("Util.getSelectionRange","Selection.getSelectionRange","v5.0.0"),f.getSelectionRange(a)},getSelectionStart:function(a){return this.deprecated("Util.getSelectionStart","Selection.getSelectionStart","v5.0.0"),f.getSelectionStart(a)},getSelectionData:function(a){return this.deprecated("Util.getSelectionData","Selection.getSelectionData","v5.0.0"),f.getSelectionData(a)},execFormatBlock:function(a,b){var c=f.getSelectionData(f.getSelectionStart(a));if("blockquote"===b&&c.el&&"blockquote"===c.el.parentNode.tagName.toLowerCase())return a.execCommand("outdent",!1,null);if(c.tagName===b&&(b="p"),this.isIE){if("blockquote"===b)return a.execCommand("indent",!1,b);b="<"+b+">"}return a.execCommand("formatBlock",!1,b)},setTargetBlank:function(a,b){var c,d=b||!1;if("a"===a.tagName.toLowerCase())a.target="_blank";else for(a=a.getElementsByTagName("a"),c=0;cd?(e=e.parentNode,c-=1):(f=f.parentNode,d-=1);for(;e!==f;)e=e.parentNode,f=f.parentNode;return e},isElementAtBeginningOfBlock:function(a){for(var b,c;!this.isBlockContainer(a)&&!this.isMediumEditorElement(a);){for(c=a;c=c.previousSibling;)if(b=3===c.nodeType?c.nodeValue:c.textContent,b.length>0)return!1;a=a.parentNode}return!0},isMediumEditorElement:function(a){return a&&3!==a.nodeType&&!!a.getAttribute("data-medium-element")},isBlockContainer:function(a){return a&&3!==a.nodeType&&-1!==this.parentElements.indexOf(a.nodeName.toLowerCase())},getBlockContainer:function(a){return this.traverseUp(a,function(a){return b.isBlockContainer(a)&&!b.isBlockContainer(a.parentNode)})},getFirstSelectableLeafNode:function(a){for(;a&&a.firstChild;)a=a.firstChild;for(var b=["br","col","colgroup","hr","img","input","source","wbr"];-1!==b.indexOf(a.nodeName.toLowerCase());)a=a.parentNode;if("table"===a.nodeName.toLowerCase()){var c=a.querySelector("th, td");c&&(a=c)}return a},getFirstTextNode:function(a){if(3===a.nodeType)return a;for(var b=0;bB",contentFA:'',key:"B"},italic:{name:"italic",action:"italic",aria:"italic",tagNames:["i","em"],style:{prop:"font-style",value:"italic"},useQueryState:!0,contentDefault:"I",contentFA:'',key:"I"},underline:{name:"underline",action:"underline",aria:"underline",tagNames:["u"],style:{prop:"text-decoration",value:"underline"},useQueryState:!0,contentDefault:"U",contentFA:'',key:"U"},strikethrough:{name:"strikethrough",action:"strikethrough",aria:"strike through",tagNames:["strike"],style:{prop:"text-decoration",value:"line-through"},useQueryState:!0,contentDefault:"A",contentFA:''},superscript:{name:"superscript",action:"superscript",aria:"superscript",tagNames:["sup"],contentDefault:"x1",contentFA:''},subscript:{name:"subscript",action:"subscript",aria:"subscript",tagNames:["sub"],contentDefault:"x1",contentFA:''},image:{name:"image",action:"image",aria:"image",tagNames:["img"],contentDefault:"image",contentFA:''},quote:{name:"quote",action:"append-blockquote",aria:"blockquote",tagNames:["blockquote"],contentDefault:"“",contentFA:''},orderedlist:{name:"orderedlist",action:"insertorderedlist",aria:"ordered list",tagNames:["ol"],useQueryState:!0,contentDefault:"1.",contentFA:''},unorderedlist:{name:"unorderedlist",action:"insertunorderedlist",aria:"unordered list",tagNames:["ul"],useQueryState:!0,contentDefault:"•",contentFA:''},pre:{name:"pre",action:"append-pre",aria:"preformatted text",tagNames:["pre"],contentDefault:"0101",contentFA:''},indent:{name:"indent",action:"indent",aria:"indent",tagNames:[],contentDefault:"→",contentFA:''},outdent:{name:"outdent",action:"outdent",aria:"outdent",tagNames:[],contentDefault:"←",contentFA:''},justifyCenter:{name:"justifyCenter",action:"justifyCenter",aria:"center justify",tagNames:[],style:{prop:"text-align",value:"center"},contentDefault:"C",contentFA:''},justifyFull:{name:"justifyFull",action:"justifyFull",aria:"full justify",tagNames:[],style:{prop:"text-align",value:"justify"},contentDefault:"J",contentFA:''},justifyLeft:{name:"justifyLeft",action:"justifyLeft",aria:"left justify",tagNames:[],style:{prop:"text-align",value:"left"},contentDefault:"L",contentFA:''},justifyRight:{name:"justifyRight",action:"justifyRight",aria:"right justify",tagNames:[],style:{prop:"text-align",value:"right"},contentDefault:"R",contentFA:''},header1:{name:"header1",action:function(a){return"append-"+a.firstHeader},aria:function(a){return a.firstHeader},tagNames:function(a){return[a.firstHeader]},contentDefault:"H1"},header2:{name:"header2",action:function(a){return"append-"+a.secondHeader},aria:function(a){return a.secondHeader},tagNames:function(a){return[a.secondHeader]},contentDefault:"H2"},removeFormat:{name:"removeFormat",aria:"remove formatting",action:"removeFormat",contentDefault:"X",contentFA:''}}}();var d;!function(){d={allowMultiParagraphSelection:!0,buttons:["bold","italic","underline","anchor","header1","header2","quote"],buttonLabels:!1,delay:0,diffLeft:0,diffTop:-10,disableReturn:!1,disableDoubleReturn:!1,disableToolbar:!1,disableEditing:!1,autoLink:!1,toolbarAlign:"center",elementsContainer:!1,imageDragging:!0,standardizeSelectionStart:!1,contentWindow:window,ownerDocument:document,firstHeader:"h3",secondHeader:"h4",targetBlank:!1,extensions:{},activeButtonClass:"medium-editor-button-active",firstButtonClass:"medium-editor-button-first",lastButtonClass:"medium-editor-button-last",spellcheck:!0}}();var e;!function(){e=function(a){b.extend(this,a)},e.extend=function(a){var c,d=this;c=a&&a.hasOwnProperty("constructor")?a.constructor:function(){return d.apply(this,arguments)},b.extend(c,d);var e=function(){this.constructor=c};return e.prototype=d.prototype,c.prototype=new e,a&&b.extend(c.prototype,a),c},e.prototype={init:function(){},base:void 0,name:void 0,checkState:void 0,destroy:void 0,queryCommandState:void 0,isActive:void 0,isAlreadyApplied:void 0,setActive:void 0,setInactive:void 0,window:void 0,document:void 0,getEditorElements:function(){return this.base.elements},getEditorId:function(){return this.base.id},getEditorOption:function(a){return this.base.options[a]}},["execAction","on","off","subscribe"].forEach(function(a){e.prototype[a]=function(){return this.base[a].apply(this.base,arguments)}})}();var f;!function(){function a(a){return b.isBlockContainer(a)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}f={findMatchingSelectionParent:function(a,c){var d,e,f=c.getSelection();return 0===f.rangeCount?!1:(d=f.getRangeAt(0),e=d.commonAncestorContainer,b.traverseUp(e,a))},getSelectionElement:function(a){return this.findMatchingSelectionParent(function(a){return a.getAttribute("data-medium-element")},a)},importSelectionMoveCursorPastAnchor:function(a,c){var d=function(a){return"a"===a.nodeName.toLowerCase()};if(a.start===a.end&&3===c.startContainer.nodeType&&c.startOffset===c.startContainer.nodeValue.length&&b.traverseUp(c.startContainer,d)){for(var e=c.startContainer,f=c.startContainer.parentNode;null!==f&&"a"!==f.nodeName.toLowerCase();)f.childNodes[f.childNodes.length-1]!==e?f=null:(e=f,f=f.parentNode);if(null!==f&&"a"===f.nodeName.toLowerCase()){for(var g=null,h=0;null===g&&h0)return 0;var g=e;if(3!==g.nodeType&&(g=e.childNodes[f]),g&&!b.isElementAtBeginningOfBlock(g))return 0;for(var h=c.createTreeWalker(d,NodeFilter.SHOW_ELEMENT,a,!1),i=0;h.nextNode();){var j=""===h.currentNode.textContent;if((j||i>0)&&(i+=1),b.isDescendant(h.currentNode,e,!0))return i;j||(i=0)}return i},selectionInContentEditableFalse:function(a){var b,c=this.findMatchingSelectionParent(function(a){var c=a&&a.getAttribute("contenteditable");return"true"===c&&(b=!0),"#text"!==a.nodeName&&"false"===c},a);return!b&&c},getSelectionHtml:function(){var a,b,c,d="",e=this.options.contentWindow.getSelection();if(e.rangeCount){for(c=this.options.ownerDocument.createElement("div"),a=0,b=e.rangeCount;b>a;a+=1)c.appendChild(e.getRangeAt(a).cloneContents());d=c.innerHTML}return d},getCaretOffsets:function(a,b){var c,d;return b||(b=window.getSelection().getRangeAt(0)),c=b.cloneRange(),d=b.cloneRange(),c.selectNodeContents(a),c.setEnd(b.endContainer,b.endOffset),d.selectNodeContents(a),d.setStart(b.endContainer,b.endOffset),{left:c.toString().length,right:d.toString().length}},rangeSelectsSingleNode:function(a){var b=a.startContainer;return b===a.endContainer&&b.hasChildNodes()&&a.endOffset===a.startOffset+1},getSelectedParentElement:function(a){return a?this.rangeSelectsSingleNode(a)&&3!==a.startContainer.childNodes[a.startOffset].nodeType?a.startContainer.childNodes[a.startOffset]:3===a.startContainer.nodeType?a.startContainer.parentNode:a.startContainer:null},getSelectedElements:function(a){var b,c,d,e=a.getSelection();if(!e.rangeCount||e.isCollapsed||!e.getRangeAt(0).commonAncestorContainer)return[];if(b=e.getRangeAt(0),3===b.commonAncestorContainer.nodeType){for(c=[],d=b.commonAncestorContainer;d.parentNode&&1===d.parentNode.childNodes.length;)c.push(d.parentNode),d=d.parentNode;return c}return[].filter.call(b.commonAncestorContainer.getElementsByTagName("*"),function(a){return"function"==typeof e.containsNode?e.containsNode(a,!0):!0})},selectNode:function(a,b){var c=b.createRange(),d=b.getSelection();c.selectNodeContents(a),d.removeAllRanges(),d.addRange(c)},moveCursor:function(a,b,c){var d,e,f=c||0;d=a.createRange(),e=a.getSelection(),d.setStart(b,f),d.collapse(!0),e.removeAllRanges(),e.addRange(d)},getSelectionRange:function(a){var b=a.getSelection();return 0===b.rangeCount?null:b.getRangeAt(0)},getSelectionStart:function(a){var b=a.getSelection().anchorNode,c=b&&3===b.nodeType?b.parentNode:b;return c},getSelectionData:function(a){var c;for(a&&a.tagName&&(c=a.tagName.toLowerCase());a&&!b.isBlockContainer(a);)a=a.parentNode,a&&a.tagName&&(c=a.tagName.toLowerCase());return{el:a,tagName:c}}}}();var g;!function(){g=function(a){this.base=a,this.options=this.base.options,this.events=[],this.customEvents={},this.listeners={}},g.prototype={InputEventOnContenteditableSupported:!b.isIE,attachDOMEvent:function(a,b,c,d){a.addEventListener(b,c,d),this.events.push([a,b,c,d])},detachDOMEvent:function(a,b,c,d){var e,f=this.indexOfListener(a,b,c,d);-1!==f&&(e=this.events.splice(f,1)[0],e[0].removeEventListener(e[1],e[2],e[3]))},indexOfListener:function(a,b,c,d){var e,f,g;for(e=0,f=this.events.length;f>e;e+=1)if(g=this.events[e],g[0]===a&&g[1]===b&&g[2]===c&&g[3]===d)return e;return-1},detachAllDOMEvents:function(){for(var a=this.events.pop();a;)a[0].removeEventListener(a[1],a[2],a[3]),a=this.events.pop()},attachCustomEvent:function(a,b){this.setupListener(a),this.customEvents[a]||(this.customEvents[a]=[]),this.customEvents[a].push(b)},detachCustomEvent:function(a,b){var c=this.indexOfCustomListener(a,b);-1!==c&&this.customEvents[a].splice(c,1)},indexOfCustomListener:function(a,b){return this.customEvents[a]&&this.customEvents[a].length?this.customEvents[a].indexOf(b):-1},detachAllCustomEvents:function(){this.customEvents={}},triggerCustomEvent:function(a,b,c){this.customEvents[a]&&this.customEvents[a].forEach(function(a){a(b,c)})},destroy:function(){this.detachAllDOMEvents(),this.detachAllCustomEvents(),this.detachExecCommand(),this.base.elements&&this.base.elements.forEach(function(a){a.removeAttribute("data-medium-focused")})},attachToExecCommand:function(){this.execCommandListener||(this.execCommandListener=function(a){this.handleDocumentExecCommand(a)}.bind(this),this.wrapExecCommand(),this.options.ownerDocument.execCommand.listeners.push(this.execCommandListener))},detachExecCommand:function(){var a=this.options.ownerDocument;if(this.execCommandListener&&a.execCommand.listeners){var b=a.execCommand.listeners.indexOf(this.execCommandListener);-1!==b&&a.execCommand.listeners.splice(b,1),a.execCommand.listeners.length||this.unwrapExecCommand()}},wrapExecCommand:function(){var a=this.options.ownerDocument;if(!a.execCommand.listeners){var b=function(b,c,d){var e=a.execCommand.orig.apply(this,arguments);if(!a.execCommand.listeners)return e;var f=Array.prototype.slice.call(arguments);return a.execCommand.listeners.forEach(function(a){a({command:b,value:d,args:f,result:e})}),e};b.orig=a.execCommand,b.listeners=[],a.execCommand=b}},unwrapExecCommand:function(){var a=this.options.ownerDocument;a.execCommand.orig&&(a.execCommand=a.execCommand.orig)},setupListener:function(a){if(!this.listeners[a]){switch(a){case"externalInteraction":this.attachDOMEvent(this.options.ownerDocument.body,"mousedown",this.handleBodyMousedown.bind(this),!0),this.attachDOMEvent(this.options.ownerDocument.body,"click",this.handleBodyClick.bind(this),!0),this.attachDOMEvent(this.options.ownerDocument.body,"focus",this.handleBodyFocus.bind(this),!0);break;case"blur":this.setupListener("externalInteraction");break;case"focus":this.setupListener("externalInteraction");break;case"editableInput":this.contentCache=[],this.base.elements.forEach(function(a){this.contentCache[a.getAttribute("medium-editor-index")]=a.innerHTML,this.InputEventOnContenteditableSupported&&this.attachDOMEvent(a,"input",this.handleInput.bind(this))}.bind(this)),this.InputEventOnContenteditableSupported||(this.setupListener("editableKeypress"),this.keypressUpdateInput=!0,this.attachDOMEvent(document,"selectionchange",this.handleDocumentSelectionChange.bind(this)),this.attachToExecCommand());break;case"editableClick":this.base.elements.forEach(function(a){this.attachDOMEvent(a,"click",this.handleClick.bind(this))}.bind(this));break;case"editableBlur":this.base.elements.forEach(function(a){this.attachDOMEvent(a,"blur",this.handleBlur.bind(this))}.bind(this));break;case"editableKeypress":this.base.elements.forEach(function(a){this.attachDOMEvent(a,"keypress",this.handleKeypress.bind(this))}.bind(this));break;case"editableKeyup":this.base.elements.forEach(function(a){this.attachDOMEvent(a,"keyup",this.handleKeyup.bind(this))}.bind(this));break;case"editableKeydown":this.base.elements.forEach(function(a){this.attachDOMEvent(a,"keydown",this.handleKeydown.bind(this))}.bind(this));break;case"editableKeydownEnter":this.setupListener("editableKeydown");break;case"editableKeydownTab":this.setupListener("editableKeydown");break;case"editableKeydownDelete":this.setupListener("editableKeydown");break;case"editableMouseover":this.base.elements.forEach(function(a){this.attachDOMEvent(a,"mouseover",this.handleMouseover.bind(this))},this);break;case"editableDrag":this.base.elements.forEach(function(a){this.attachDOMEvent(a,"dragover",this.handleDragging.bind(this)),this.attachDOMEvent(a,"dragleave",this.handleDragging.bind(this))},this);break;case"editableDrop":this.base.elements.forEach(function(a){this.attachDOMEvent(a,"drop",this.handleDrop.bind(this))},this);break;case"editablePaste":this.base.elements.forEach(function(a){this.attachDOMEvent(a,"paste",this.handlePaste.bind(this))},this)}this.listeners[a]=!0}},focusElement:function(a){a.focus(),this.updateFocus(a,{target:a,type:"focus"})},updateFocus:function(a,c){var d,e=this.base.toolbar?this.base.toolbar.getToolbarElement():null,f=this.base.getExtensionByName("anchor-preview"),g=f&&f.getPreviewElement?f.getPreviewElement():null,h=this.base.getFocusedElement();h&&"click"===c.type&&this.lastMousedownTarget&&(b.isDescendant(h,this.lastMousedownTarget,!0)||b.isDescendant(e,this.lastMousedownTarget,!0)||b.isDescendant(g,this.lastMousedownTarget,!0))&&(d=h),d||this.base.elements.some(function(c){return!d&&b.isDescendant(c,a,!0)&&(d=c),!!d},this);var i=!b.isDescendant(h,a,!0)&&!b.isDescendant(e,a,!0)&&!b.isDescendant(g,a,!0);d!==h&&(h&&i&&(h.removeAttribute("data-medium-focused"),this.triggerCustomEvent("blur",c,h)),d&&(d.setAttribute("data-medium-focused",!0),this.triggerCustomEvent("focus",c,d))),i&&this.triggerCustomEvent("externalInteraction",c)},updateInput:function(a,b){var c=a.getAttribute("medium-editor-index");a.innerHTML!==this.contentCache[c]&&this.triggerCustomEvent("editableInput",b,a),this.contentCache[c]=a.innerHTML},handleDocumentSelectionChange:function(a){if(a.currentTarget&&a.currentTarget.activeElement){var c,d=a.currentTarget.activeElement;this.base.elements.some(function(a){return b.isDescendant(a,d,!0)?(c=a,!0):!1},this),c&&this.updateInput(c,{target:d,currentTarget:c})}},handleDocumentExecCommand:function(){var a=this.base.getFocusedElement();a&&this.updateInput(a,{target:a,currentTarget:a})},handleBodyClick:function(a){this.updateFocus(a.target,a)},handleBodyFocus:function(a){this.updateFocus(a.target,a)},handleBodyMousedown:function(a){this.lastMousedownTarget=a.target},handleInput:function(a){this.updateInput(a.currentTarget,a)},handleClick:function(a){this.triggerCustomEvent("editableClick",a,a.currentTarget)},handleBlur:function(a){this.triggerCustomEvent("editableBlur",a,a.currentTarget)},handleKeypress:function(a){if(this.triggerCustomEvent("editableKeypress",a,a.currentTarget),this.keypressUpdateInput){var b={target:a.target,currentTarget:a.currentTarget};setTimeout(function(){this.updateInput(b.currentTarget,b)}.bind(this),0)}},handleKeyup:function(a){this.triggerCustomEvent("editableKeyup",a,a.currentTarget)},handleMouseover:function(a){this.triggerCustomEvent("editableMouseover",a,a.currentTarget)},handleDragging:function(a){this.triggerCustomEvent("editableDrag",a,a.currentTarget)},handleDrop:function(a){this.triggerCustomEvent("editableDrop",a,a.currentTarget)},handlePaste:function(a){this.triggerCustomEvent("editablePaste",a,a.currentTarget)},handleKeydown:function(a){return this.triggerCustomEvent("editableKeydown",a,a.currentTarget),b.isKey(a,b.keyCode.ENTER)?this.triggerCustomEvent("editableKeydownEnter",a,a.currentTarget):b.isKey(a,b.keyCode.TAB)?this.triggerCustomEvent("editableKeydownTab",a,a.currentTarget):b.isKey(a,[b.keyCode.DELETE,b.keyCode.BACKSPACE])?this.triggerCustomEvent("editableKeydownDelete",a,a.currentTarget):void 0}}}();var h;!function(){h=function(a,c){b.deprecated("MediumEditor.statics.DefaultButton","MediumEditor.extensions.button","v5.0.0"),this.options=a,this.name=a.name,this.init(c)},h.prototype={init:function(a){this.base=a,this.button=this.createButton(),this.base.on(this.button,"click",this.handleClick.bind(this)),this.options.key&&this.base.subscribe("editableKeydown",this.handleKeydown.bind(this))},getButton:function(){return this.button},getAction:function(){return"function"==typeof this.options.action?this.options.action(this.base.options):this.options.action},getAria:function(){return"function"==typeof this.options.aria?this.options.aria(this.base.options):this.options.aria},getTagNames:function(){return"function"==typeof this.options.tagNames?this.options.tagNames(this.base.options):this.options.tagNames},createButton:function(){var a=this.base.options.ownerDocument.createElement("button"),b=this.options.contentDefault,c=this.getAria();return a.classList.add("medium-editor-action"),a.classList.add("medium-editor-action-"+this.name),a.setAttribute("data-action",this.getAction()),c&&(a.setAttribute("title",c),a.setAttribute("aria-label",c)),this.base.options.buttonLabels&&("fontawesome"===this.base.options.buttonLabels&&this.options.contentFA?b=this.options.contentFA:"object"==typeof this.base.options.buttonLabels&&this.base.options.buttonLabels[this.name]&&(b=this.base.options.buttonLabels[this.options.name])),a.innerHTML=b,a},handleKeydown:function(a){var c,d=String.fromCharCode(a.which||a.keyCode).toLowerCase();this.options.key===d&&b.isMetaCtrlKey(a)&&(a.preventDefault(),a.stopPropagation(),c=this.getAction(),c&&this.base.execAction(c))},handleClick:function(a){a.preventDefault(),a.stopPropagation();var b=this.getAction();b&&this.base.execAction(b)},isActive:function(){return this.button.classList.contains(this.base.options.activeButtonClass)},
+setInactive:function(){this.button.classList.remove(this.base.options.activeButtonClass),delete this.knownState},setActive:function(){this.button.classList.add(this.base.options.activeButtonClass),delete this.knownState},queryCommandState:function(){var a=null;return this.options.useQueryState&&(a=this.base.queryCommandState(this.getAction())),a},isAlreadyApplied:function(a){var b,c,d=!1,e=this.getTagNames();return this.knownState===!1||this.knownState===!0?this.knownState:(e&&e.length>0&&a.tagName&&(d=-1!==e.indexOf(a.tagName.toLowerCase())),!d&&this.options.style&&(b=this.options.style.value.split("|"),c=this.base.options.contentWindow.getComputedStyle(a,null).getPropertyValue(this.options.style.prop),b.forEach(function(a){this.knownState||(d=-1!==c.indexOf(a),(d||"text-decoration"!==this.options.style.prop)&&(this.knownState=d))},this)),d)}}}();var i;!function(){function a(){b.deprecated("MediumEditor.statics.AnchorExtension","MediumEditor.extensions.anchor","v5.0.0"),this.parent=!0,this.options={name:"anchor",action:"createLink",aria:"link",tagNames:["a"],contentDefault:"#",contentFA:'',key:"k"},this.name="anchor",this.hasForm=!0}a.prototype={formSaveLabel:"✓",formCloseLabel:"×",handleClick:function(a){a.preventDefault(),a.stopPropagation();var b=f.getSelectedParentElement(f.getSelectionRange(this.base.options.ownerDocument));return b.tagName&&"a"===b.tagName.toLowerCase()?this.base.execAction("unlink"):(this.isDisplayed()||this.showForm(),!1)},handleKeydown:function(a){var c=String.fromCharCode(a.which||a.keyCode).toLowerCase();this.options.key===c&&b.isMetaCtrlKey(a)&&(a.preventDefault(),a.stopPropagation(),this.handleClick(a))},getForm:function(){return this.form||(this.form=this.createForm()),this.form},getTemplate:function(){var a=[''];return a.push('',"fontawesome"===this.base.options.buttonLabels?'':this.formSaveLabel,""),a.push('',"fontawesome"===this.base.options.buttonLabels?'':this.formCloseLabel,""),this.base.options.anchorTarget&&a.push('',""),this.base.options.anchorButton&&a.push('',""),a.join("")},isDisplayed:function(){return"block"===this.getForm().style.display},hideForm:function(){this.getForm().style.display="none",this.getInput().value=""},showForm:function(a){var b=this.getInput();this.base.saveSelection(),this.base.hideToolbarDefaultActions(),this.getForm().style.display="block",this.base.setToolbarPosition(),b.value=a||"",b.focus()},deactivate:function(){return this.form?(this.form.parentNode&&this.form.parentNode.removeChild(this.form),void delete this.form):!1},getFormOpts:function(){var a=this.getForm().querySelector(".medium-editor-toolbar-anchor-target"),b=this.getForm().querySelector(".medium-editor-toolbar-anchor-button"),c={url:this.getInput().value};return this.base.options.checkLinkFormat&&(c.url=this.checkLinkFormat(c.url)),a&&a.checked?c.target="_blank":c.target="_self",b&&b.checked&&(c.buttonClass=this.base.options.anchorButtonClass),c},doFormSave:function(){var a=this.getFormOpts();this.completeFormSave(a)},completeFormSave:function(a){this.base.restoreSelection(),this.base.createLink(a),this.base.checkSelection()},checkLinkFormat:function(a){var b=/^(https?|ftps?|rtmpt?):\/\/|mailto:/;return(b.test(a)?"":"http://")+a},doFormCancel:function(){this.base.restoreSelection(),this.base.checkSelection()},attachFormEvents:function(a){var b=a.querySelector(".medium-editor-toolbar-close"),c=a.querySelector(".medium-editor-toolbar-save"),d=a.querySelector(".medium-editor-toolbar-input");this.base.on(a,"click",this.handleFormClick.bind(this)),this.base.on(d,"keyup",this.handleTextboxKeyup.bind(this)),this.base.on(b,"click",this.handleCloseClick.bind(this)),this.base.on(c,"click",this.handleSaveClick.bind(this),!0)},createForm:function(){var a=this.base.options.ownerDocument,b=a.createElement("div");return b.className="medium-editor-toolbar-form",b.id="medium-editor-toolbar-form-anchor-"+this.base.id,b.innerHTML=this.getTemplate(),this.attachFormEvents(b),b},getInput:function(){return this.getForm().querySelector("input.medium-editor-toolbar-input")},handleTextboxKeyup:function(a){return a.keyCode===b.keyCode.ENTER?(a.preventDefault(),void this.doFormSave()):void(a.keyCode===b.keyCode.ESCAPE&&(a.preventDefault(),this.doFormCancel()))},handleFormClick:function(a){a.stopPropagation()},handleSaveClick:function(a){a.preventDefault(),this.doFormSave()},handleCloseClick:function(a){a.preventDefault(),this.doFormCancel()}},i=b.derives(h,a)}();var j;!function(){j=function(){b.deprecated("MediumEditor.statics.AnchorPreview","MediumEditor.extensions.anchorPreview","v5.0.0"),this.parent=!0,this.name="anchor-preview"},j.prototype={previewValueSelector:"a",init:function(){this.anchorPreview=this.createPreview(),this.base.options.elementsContainer.appendChild(this.anchorPreview),this.attachToEditables()},getPreviewElement:function(){return this.anchorPreview},createPreview:function(){var a=this.base.options.ownerDocument.createElement("div");return a.id="medium-editor-anchor-preview-"+this.base.id,a.className="medium-editor-anchor-preview",a.innerHTML=this.getTemplate(),this.base.on(a,"click",this.handleClick.bind(this)),a},getTemplate:function(){return''},deactivate:function(){this.anchorPreview&&(this.anchorPreview.parentNode&&this.anchorPreview.parentNode.removeChild(this.anchorPreview),delete this.anchorPreview)},hidePreview:function(){this.anchorPreview.classList.remove("medium-editor-anchor-preview-active"),this.activeAnchor=null},showPreview:function(a){return this.anchorPreview.classList.contains("medium-editor-anchor-preview-active")||a.getAttribute("data-disable-preview")?!0:(this.previewValueSelector&&(this.anchorPreview.querySelector(this.previewValueSelector).textContent=a.attributes.href.value,this.anchorPreview.querySelector(this.previewValueSelector).href=a.attributes.href.value),this.anchorPreview.classList.add("medium-toolbar-arrow-over"),this.anchorPreview.classList.remove("medium-toolbar-arrow-under"),this.anchorPreview.classList.contains("medium-editor-anchor-preview-active")||this.anchorPreview.classList.add("medium-editor-anchor-preview-active"),this.activeAnchor=a,this.positionPreview(),this.attachPreviewHandlers(),this)},positionPreview:function(){var a,b,c=this.anchorPreview.offsetHeight,d=this.activeAnchor.getBoundingClientRect(),e=(d.left+d.right)/2;a=this.anchorPreview.offsetWidth/2,b=this.base.options.diffLeft-a,this.anchorPreview.style.top=Math.round(c+d.bottom-this.base.options.diffTop+this.base.options.contentWindow.pageYOffset-this.anchorPreview.offsetHeight)+"px",a>e?this.anchorPreview.style.left=b+a+"px":this.base.options.contentWindow.innerWidth-ethis.base.options.anchorPreviewHideDelay&&this.detachPreviewHandlers()},detachPreviewHandlers:function(){clearInterval(this.intervalTimer),this.instanceHandlePreviewMouseover&&(this.base.off(this.anchorPreview,"mouseover",this.instanceHandlePreviewMouseover),this.base.off(this.anchorPreview,"mouseout",this.instanceHandlePreviewMouseout),this.activeAnchor&&(this.base.off(this.activeAnchor,"mouseover",this.instanceHandlePreviewMouseover),this.base.off(this.activeAnchor,"mouseout",this.instanceHandlePreviewMouseout))),this.hidePreview(),this.hovering=this.instanceHandlePreviewMouseover=this.instanceHandlePreviewMouseout=null},attachPreviewHandlers:function(){this.lastOver=(new Date).getTime(),this.hovering=!0,this.instanceHandlePreviewMouseover=this.handlePreviewMouseover.bind(this),this.instanceHandlePreviewMouseout=this.handlePreviewMouseout.bind(this),this.intervalTimer=setInterval(this.updatePreview.bind(this),200),this.base.on(this.anchorPreview,"mouseover",this.instanceHandlePreviewMouseover),this.base.on(this.anchorPreview,"mouseout",this.instanceHandlePreviewMouseout),this.base.on(this.activeAnchor,"mouseover",this.instanceHandlePreviewMouseover),this.base.on(this.activeAnchor,"mouseout",this.instanceHandlePreviewMouseout)}}}();var k;!function(){function a(){b.deprecated("MediumEditor.statics.FontSizeExtension","MediumEditor.extensions.fontSize","v5.0.0"),this.parent=!0,this.options={name:"fontsize",action:"fontSize",aria:"increase/decrease font size",contentDefault:"±",contentFA:''},this.name="fontsize",this.hasForm=!0}a.prototype={handleClick:function(a){if(a.preventDefault(),a.stopPropagation(),!this.isDisplayed()){var b=this.base.options.ownerDocument.queryCommandValue("fontSize")+"";this.showForm(b)}return!1},getForm:function(){return this.form||(this.form=this.createForm()),this.form},isDisplayed:function(){return"block"===this.getForm().style.display},hideForm:function(){this.getForm().style.display="none",this.getInput().value=""},showForm:function(a){var b=this.getInput();this.base.saveSelection(),this.base.hideToolbarDefaultActions(),this.getForm().style.display="block",this.base.setToolbarPosition(),b.value=a||"",b.focus()},deactivate:function(){return this.form?(this.form.parentNode&&this.form.parentNode.removeChild(this.form),void delete this.form):!1},doFormSave:function(){this.base.restoreSelection(),this.base.checkSelection()},doFormCancel:function(){this.base.restoreSelection(),this.clearFontSize(),this.base.checkSelection()},createForm:function(){var a=this.base.options.ownerDocument,b=a.createElement("div"),c=a.createElement("input"),d=a.createElement("a"),e=a.createElement("a");return b.className="medium-editor-toolbar-form",b.id="medium-editor-toolbar-form-fontsize-"+this.base.id,this.base.on(b,"click",this.handleFormClick.bind(this)),c.setAttribute("type","range"),c.setAttribute("min","1"),c.setAttribute("max","7"),c.className="medium-editor-toolbar-input",b.appendChild(c),this.base.on(c,"change",this.handleSliderChange.bind(this)),e.setAttribute("href","#"),e.className="medium-editor-toobar-save",e.innerHTML="fontawesome"===this.base.options.buttonLabels?'':"✓",b.appendChild(e),this.base.on(e,"click",this.handleSaveClick.bind(this),!0),d.setAttribute("href","#"),d.className="medium-editor-toobar-close",d.innerHTML="fontawesome"===this.base.options.buttonLabels?'':"×",b.appendChild(d),this.base.on(d,"click",this.handleCloseClick.bind(this)),b},getInput:function(){return this.getForm().querySelector("input.medium-editor-toolbar-input")},clearFontSize:function(){f.getSelectedElements(this.base.options.ownerDocument).forEach(function(a){"FONT"===a.tagName&&a.hasAttribute("size")&&a.removeAttribute("size")})},handleSliderChange:function(){var a=this.getInput().value;"4"===a?this.clearFontSize():this.base.execAction("fontSize",{size:a})},handleFormClick:function(a){a.stopPropagation()},handleSaveClick:function(a){a.preventDefault(),this.doFormSave()},handleCloseClick:function(a){a.preventDefault(),this.doFormCancel()}},k=b.derives(h,a)}();var l;!function(){l=e.extend({init:function(){this.button=this.createButton(),this.on(this.button,"click",this.handleClick.bind(this)),this.key&&this.subscribe("editableKeydown",this.handleKeydown.bind(this))},getButton:function(){return this.button},getAction:function(){return"function"==typeof this.action?this.action(this.base.options):this.action},getAria:function(){return"function"==typeof this.aria?this.aria(this.base.options):this.aria},getTagNames:function(){return"function"==typeof this.tagNames?this.tagNames(this.base.options):this.tagNames},createButton:function(){var a=this.document.createElement("button"),b=this.contentDefault,c=this.getAria(),d=this.getEditorOption("buttonLabels");return a.classList.add("medium-editor-action"),a.classList.add("medium-editor-action-"+this.name),a.setAttribute("data-action",this.getAction()),c&&(a.setAttribute("title",c),a.setAttribute("aria-label",c)),d&&("fontawesome"===d&&this.contentFA?b=this.contentFA:"object"==typeof d&&d[this.name]&&(b=d[this.name])),a.innerHTML=b,a},handleKeydown:function(a){var c;b.isKey(a,this.key.charCodeAt(0))&&b.isMetaCtrlKey(a)&&!a.shiftKey&&(a.preventDefault(),a.stopPropagation(),c=this.getAction(),c&&this.execAction(c))},handleClick:function(a){a.preventDefault(),a.stopPropagation();var b=this.getAction();b&&this.execAction(b)},isActive:function(){return this.button.classList.contains(this.getEditorOption("activeButtonClass"))},setInactive:function(){this.button.classList.remove(this.getEditorOption("activeButtonClass")),delete this.knownState},setActive:function(){this.button.classList.add(this.getEditorOption("activeButtonClass")),delete this.knownState},queryCommandState:function(){var a=null;return this.useQueryState&&(a=this.base.queryCommandState(this.getAction())),a},isAlreadyApplied:function(a){var b,c,d=!1,e=this.getTagNames();return this.knownState===!1||this.knownState===!0?this.knownState:(e&&e.length>0&&a.tagName&&(d=-1!==e.indexOf(a.tagName.toLowerCase())),!d&&this.style&&(b=this.style.value.split("|"),c=this.window.getComputedStyle(a,null).getPropertyValue(this.style.prop),b.forEach(function(a){this.knownState||(d=-1!==c.indexOf(a),(d||"text-decoration"!==this.style.prop)&&(this.knownState=d))},this)),d)}})}();var m;!function(){var a=function(){};m=l.extend({formSaveLabel:"✓",formCloseLabel:"×",hasForm:!0,getForm:a,isDisplayed:a,hideForm:a})}();var n;!function(){n=m.extend({customClassOption:null,customClassOptionText:"Button",linkValidation:!1,placeholderText:"Paste or type a link",targetCheckbox:!1,targetCheckboxText:"Open in new window",name:"anchor",action:"createLink",aria:"link",tagNames:["a"],contentDefault:"#",contentFA:'',key:"K",handleClick:function(a){a.preventDefault(),a.stopPropagation();var c=f.getSelectedParentElement(f.getSelectionRange(this.document)),d=b.getFirstTextNode(c);return b.getClosestTag(d,"a")?this.execAction("unlink"):(this.isDisplayed()||this.showForm(),!1)},handleKeydown:function(a){b.isKey(a,this.key.charCodeAt(0))&&b.isMetaCtrlKey(a)&&this.handleClick(a)},getForm:function(){return this.form||(this.form=this.createForm()),this.form},getTemplate:function(){var a=[''];return a.push('',"fontawesome"===this.getEditorOption("buttonLabels")?'':this.formSaveLabel,""),a.push('',"fontawesome"===this.getEditorOption("buttonLabels")?'':this.formCloseLabel,""),this.targetCheckbox&&a.push('',""),this.customClassOption&&a.push('',""),a.join("")},isDisplayed:function(){return"block"===this.getForm().style.display},hideForm:function(){this.getForm().style.display="none",this.getInput().value=""},showForm:function(a){var b=this.getInput();this.base.saveSelection(),this.base.hideToolbarDefaultActions(),this.getForm().style.display="block",this.base.setToolbarPosition(),b.value=a||"",b.focus()},destroy:function(){return this.form?(this.form.parentNode&&this.form.parentNode.removeChild(this.form),void delete this.form):!1},deactivate:function(){b.deprecatedMethod.call(this,"deactivate","destroy",arguments,"v5.0.0")},getFormOpts:function(){var a=this.getForm().querySelector(".medium-editor-toolbar-anchor-target"),b=this.getForm().querySelector(".medium-editor-toolbar-anchor-button"),c={url:this.getInput().value};return this.linkValidation&&(c.url=this.checkLinkFormat(c.url)),c.target="_self",a&&a.checked&&(c.target="_blank"),b&&b.checked&&(c.buttonClass=this.customClassOption),c},doFormSave:function(){var a=this.getFormOpts();this.completeFormSave(a)},completeFormSave:function(a){this.base.restoreSelection(),this.execAction(this.action,a),this.base.checkSelection()},checkLinkFormat:function(a){var b=/^(https?|ftps?|rtmpt?):\/\/|mailto:/;return(b.test(a)?"":"http://")+a},doFormCancel:function(){this.base.restoreSelection(),this.base.checkSelection()},attachFormEvents:function(a){var b=a.querySelector(".medium-editor-toolbar-close"),c=a.querySelector(".medium-editor-toolbar-save"),d=a.querySelector(".medium-editor-toolbar-input");this.on(a,"click",this.handleFormClick.bind(this)),this.on(d,"keyup",this.handleTextboxKeyup.bind(this)),this.on(b,"click",this.handleCloseClick.bind(this)),this.on(c,"click",this.handleSaveClick.bind(this),!0)},createForm:function(){var a=this.document,b=a.createElement("div");return b.className="medium-editor-toolbar-form",b.id="medium-editor-toolbar-form-anchor-"+this.getEditorId(),b.innerHTML=this.getTemplate(),this.attachFormEvents(b),b},getInput:function(){return this.getForm().querySelector("input.medium-editor-toolbar-input")},handleTextboxKeyup:function(a){return a.keyCode===b.keyCode.ENTER?(a.preventDefault(),void this.doFormSave()):void(a.keyCode===b.keyCode.ESCAPE&&(a.preventDefault(),this.doFormCancel()))},handleFormClick:function(a){a.stopPropagation()},handleSaveClick:function(a){a.preventDefault(),this.doFormSave()},handleCloseClick:function(a){a.preventDefault(),this.doFormCancel()}})}();var o;!function(){o=e.extend({name:"anchor-preview",hideDelay:500,previewValueSelector:"a",diffLeft:0,diffTop:-10,elementsContainer:!1,init:function(){this.anchorPreview=this.createPreview(),this.elementsContainer||(this.elementsContainer=this.document.body),this.elementsContainer.appendChild(this.anchorPreview),this.attachToEditables()},getPreviewElement:function(){return this.anchorPreview},createPreview:function(){var a=this.document.createElement("div");return a.id="medium-editor-anchor-preview-"+this.getEditorId(),a.className="medium-editor-anchor-preview",a.innerHTML=this.getTemplate(),this.on(a,"click",this.handleClick.bind(this)),a},getTemplate:function(){return''},destroy:function(){this.anchorPreview&&(this.anchorPreview.parentNode&&this.anchorPreview.parentNode.removeChild(this.anchorPreview),delete this.anchorPreview)},deactivate:function(){b.deprecatedMethod.call(this,"deactivate","destroy",arguments,"v5.0.0")},hidePreview:function(){this.anchorPreview.classList.remove("medium-editor-anchor-preview-active"),this.activeAnchor=null},showPreview:function(a){return this.anchorPreview.classList.contains("medium-editor-anchor-preview-active")||a.getAttribute("data-disable-preview")?!0:(this.previewValueSelector&&(this.anchorPreview.querySelector(this.previewValueSelector).textContent=a.attributes.href.value,this.anchorPreview.querySelector(this.previewValueSelector).href=a.attributes.href.value),this.anchorPreview.classList.add("medium-toolbar-arrow-over"),this.anchorPreview.classList.remove("medium-toolbar-arrow-under"),this.anchorPreview.classList.contains("medium-editor-anchor-preview-active")||this.anchorPreview.classList.add("medium-editor-anchor-preview-active"),this.activeAnchor=a,this.positionPreview(),this.attachPreviewHandlers(),this)},positionPreview:function(){var a,b,c=this.anchorPreview.offsetHeight,d=this.activeAnchor.getBoundingClientRect(),e=(d.left+d.right)/2;a=this.anchorPreview.offsetWidth/2,b=this.diffLeft-a,this.anchorPreview.style.top=Math.round(c+d.bottom-this.diffTop+this.window.pageYOffset-this.anchorPreview.offsetHeight)+"px",a>e?this.anchorPreview.style.left=b+a+"px":this.window.innerWidth-ethis.hideDelay&&this.detachPreviewHandlers()},detachPreviewHandlers:function(){clearInterval(this.intervalTimer),this.instanceHandlePreviewMouseover&&(this.off(this.anchorPreview,"mouseover",this.instanceHandlePreviewMouseover),this.off(this.anchorPreview,"mouseout",this.instanceHandlePreviewMouseout),this.activeAnchor&&(this.off(this.activeAnchor,"mouseover",this.instanceHandlePreviewMouseover),this.off(this.activeAnchor,"mouseout",this.instanceHandlePreviewMouseout))),this.hidePreview(),this.hovering=this.instanceHandlePreviewMouseover=this.instanceHandlePreviewMouseout=null},attachPreviewHandlers:function(){this.lastOver=(new Date).getTime(),this.hovering=!0,this.instanceHandlePreviewMouseover=this.handlePreviewMouseover.bind(this),this.instanceHandlePreviewMouseout=this.handlePreviewMouseout.bind(this),this.intervalTimer=setInterval(this.updatePreview.bind(this),200),this.on(this.anchorPreview,"mouseover",this.instanceHandlePreviewMouseover),this.on(this.anchorPreview,"mouseout",this.instanceHandlePreviewMouseout),this.on(this.activeAnchor,"mouseover",this.instanceHandlePreviewMouseover),this.on(this.activeAnchor,"mouseout",this.instanceHandlePreviewMouseout)}})}();var p,q,r,s;q=[" "," ","\n","\r"," "," "," "," "," ","\u2028","\u2029"],r="com|net|org|edu|gov|mil|aero|asia|biz|cat|coop|info|int|jobs|mobi|museum|name|post|pro|tel|travel|xxx|ac|ad|ae|af|ag|ai|al|am|an|ao|aq|ar|as|at|au|aw|ax|az|ba|bb|bd|be|bf|bg|bh|bi|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|cr|cs|cu|cv|cx|cy|cz|dd|de|dj|dk|dm|do|dz|ec|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gg|gh|gi|gl|gm|gn|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|im|in|io|iq|ir|is|it|je|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|me|mg|mh|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|mv|mw|mx|my|mz|na|nc|ne|nf|ng|ni|nl|no|np|nr|nu|nz|om|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|ps|pt|pw|py|qa|re|ro|rs|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|ja|sk|sl|sm|sn|so|sr|ss|st|su|sv|sx|sy|sz|tc|td|tf|tg|th|tj|tk|tl|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw",s="(((?:(https?://|ftps?://|nntp://)|www\\d{0,3}[.]|[a-z0-9.\\-]+[.]("+r+")\\/)\\S+(?:[^\\s`!\\[\\]{};:'\".,?«»“”‘’])))|(([a-z0-9\\-]+\\.)?[a-z0-9\\-]+\\.("+r+"))",function(){function a(a){return!b.getClosestTag(a,"a")}var c=new RegExp("^("+r+")$","i");p=e.extend({init:function(){this.disableEventHandling=!1,this.subscribe("editableKeypress",this.onKeypress.bind(this)),this.subscribe("editableBlur",this.onBlur.bind(this)),this.document.execCommand("AutoUrlDetect",!1,!1)},destroy:function(){this.document.queryCommandSupported("AutoUrlDetect")&&this.document.execCommand("AutoUrlDetect",!1,!0)},onBlur:function(a,b){this.performLinking(b)},onKeypress:function(a){this.disableEventHandling||b.isKey(a,[b.keyCode.SPACE,b.keyCode.ENTER])&&(clearTimeout(this.performLinkingTimeout),this.performLinkingTimeout=setTimeout(function(){try{var b=this.base.exportSelection();this.performLinking(a.target)&&this.base.importSelection(b,!0)}catch(c){window.console&&window.console.error("Failed to perform linking",c),this.disableEventHandling=!0}}.bind(this),0))},performLinking:function(a){var b=a.querySelectorAll("p"),c=!1;0===b.length&&(b=[a]);for(var d=0;d=c&&d!==e&&0!==f&&(b||a).splitText(f)},removeObsoleteAutoLinkSpans:function(c){for(var d=c.querySelectorAll('span[data-auto-link="true"]'),e=!1,f=0;f0&&null!==g;)e=c.currentNode,f=e.nodeValue,f.length>b?(g=e.splitText(f.length-b),b=0):(g=c.previousNode(),b-=f.length);return g},performLinkingWithinElement:function(a){for(var b=this.findLinkableText(a),c=!1,d=0;db.end+1)throw new Error("PerformLinking overshot the target!");f&&d.push(h||g),e+=g.nodeValue.length,null!==h&&(e+=h.nodeValue.length,c.nextNode()),h=null}return d},createLink:function(a,c){for(var d=!1,e=0;e'),c.onload=function(){var a=this.document.getElementById(d);a&&(a.removeAttribute("id"),a.removeAttribute("class"),a.src=c.result)}.bind(this)}}.bind(this))),a.target.classList.remove(d)}})}();var u;!function(){u=m.extend({name:"fontsize",action:"fontSize",aria:"increase/decrease font size",contentDefault:"±",contentFA:'',handleClick:function(a){if(a.preventDefault(),a.stopPropagation(),!this.isDisplayed()){var b=this.document.queryCommandValue("fontSize")+"";this.showForm(b)}return!1},getForm:function(){return this.form||(this.form=this.createForm()),this.form},isDisplayed:function(){return"block"===this.getForm().style.display},hideForm:function(){this.getForm().style.display="none",this.getInput().value=""},showForm:function(a){var b=this.getInput();this.base.saveSelection(),this.base.hideToolbarDefaultActions(),this.getForm().style.display="block",this.base.setToolbarPosition(),b.value=a||"",b.focus()},destroy:function(){return this.form?(this.form.parentNode&&this.form.parentNode.removeChild(this.form),void delete this.form):!1},deactivate:function(){b.deprecatedMethod.call(this,"deactivate","destroy",arguments,"v5.0.0")},doFormSave:function(){this.base.restoreSelection(),this.base.checkSelection()},doFormCancel:function(){this.base.restoreSelection(),this.clearFontSize(),this.base.checkSelection()},createForm:function(){var a=this.document,b=a.createElement("div"),c=a.createElement("input"),d=a.createElement("a"),e=a.createElement("a");return b.className="medium-editor-toolbar-form",b.id="medium-editor-toolbar-form-fontsize-"+this.getEditorId(),this.on(b,"click",this.handleFormClick.bind(this)),c.setAttribute("type","range"),c.setAttribute("min","1"),c.setAttribute("max","7"),c.className="medium-editor-toolbar-input",b.appendChild(c),this.on(c,"change",this.handleSliderChange.bind(this)),e.setAttribute("href","#"),e.className="medium-editor-toobar-save",e.innerHTML="fontawesome"===this.getEditorOption("buttonLabels")?'':"✓",b.appendChild(e),this.on(e,"click",this.handleSaveClick.bind(this),!0),
+d.setAttribute("href","#"),d.className="medium-editor-toobar-close",d.innerHTML="fontawesome"===this.getEditorOption("buttonLabels")?'':"×",b.appendChild(d),this.on(d,"click",this.handleCloseClick.bind(this)),b},getInput:function(){return this.getForm().querySelector("input.medium-editor-toolbar-input")},clearFontSize:function(){f.getSelectedElements(this.document).forEach(function(a){"FONT"===a.tagName&&a.hasAttribute("size")&&a.removeAttribute("size")})},handleSliderChange:function(){var a=this.getInput().value;"4"===a?this.clearFontSize():this.execAction("fontSize",{size:a})},handleFormClick:function(a){a.stopPropagation()},handleSaveClick:function(a){a.preventDefault(),this.doFormSave()},handleCloseClick:function(a){a.preventDefault(),this.doFormCancel()}})}();var v;!function(){function a(){return[[new RegExp(/<[^>]*docs-internal-guid[^>]*>/gi),""],[new RegExp(/<\/b>(
]*>)?$/gi),""],[new RegExp(/\s+<\/span>/g)," "],[new RegExp(/
/g),"
"],[new RegExp(/]*(font-style:italic;font-weight:bold|font-weight:bold;font-style:italic)[^>]*>/gi),''],[new RegExp(/]*font-style:italic[^>]*>/gi),''],[new RegExp(/]*font-weight:bold[^>]*>/gi),''],[new RegExp(/<(\/?)(i|b|a)>/gi),"<$1$2>"],[new RegExp(/<a(?:(?!href).)+href=(?:"|”|“|"|“|”)(((?!"|”|“|"|“|”).)*)(?:"|”|“|"|“|”)(?:(?!>).)*>/gi),''],[new RegExp(/<\/p>\n+/gi),""],[new RegExp(/\n+/gi),""]]}v=e.extend({forcePlainText:!0,cleanPastedHTML:!1,cleanReplacements:[],cleanAttrs:["class","style","dir"],cleanTags:["meta"],targetBlank:!1,disableReturn:!1,init:function(){(this.forcePlainText||this.cleanPastedHTML)&&this.subscribe("editablePaste",this.handlePaste.bind(this))},handlePaste:function(a,c){var d,e,f,g,h="",i="text/html",j="text/plain";if(this.window.clipboardData&&void 0===a.clipboardData&&(a.clipboardData=this.window.clipboardData,i="Text",j="Text"),a.clipboardData&&a.clipboardData.getData&&!a.defaultPrevented){if(a.preventDefault(),f=a.clipboardData.getData(i),g=a.clipboardData.getData(j),this.cleanPastedHTML&&f)return this.cleanPaste(f);if(this.disableReturn||c.getAttribute("data-disable-return"))h=b.htmlEntities(g);else if(d=g.split(/[\r\n]+/g),d.length>1)for(e=0;e"+b.htmlEntities(d[e])+"
");else h=b.htmlEntities(d[0]);b.insertHTMLCommand(this.document,h)}},cleanPaste:function(b){var c,d,e,g=f.getSelectionElement(this.window),h=/
"),this.pasteHTML("
"+d.join("
")+"
");try{this.document.execCommand("insertText",!1,"\n")}catch(j){}for(d=g.querySelectorAll("a,p,div,br"),c=0;c"+d.innerHTML+"":e.innerHTML=d.innerHTML,d.parentNode.replaceChild(e,d);for(f=a.querySelectorAll("span"),c=0;c0&&(d[0].classList.add(this.options.firstButtonClass),d[d.length-1].classList.add(this.options.lastButtonClass)),f},destroy:function(){this.toolbar&&(this.toolbar.parentNode&&this.toolbar.parentNode.removeChild(this.toolbar),delete this.toolbar)},deactivate:function(){b.deprecatedMethod.call(this,"deactivate","destroy",arguments,"v5.0.0")},getToolbarElement:function(){return this.toolbar||(this.toolbar=this.createToolbar()),this.toolbar},getToolbarActionsElement:function(){return this.getToolbarElement().querySelector(".medium-editor-toolbar-actions")},initThrottledMethods:function(){this.throttledPositionToolbar=b.throttle(function(){this.base.isActive&&this.positionToolbarIfShown()}.bind(this))},attachEventHandlers:function(){this.base.subscribe("blur",this.handleBlur.bind(this)),this.base.subscribe("focus",this.handleFocus.bind(this)),this.base.subscribe("editableClick",this.handleEditableClick.bind(this)),this.base.subscribe("editableKeyup",this.handleEditableKeyup.bind(this)),this.base.on(this.options.ownerDocument.documentElement,"mouseup",this.handleDocumentMouseup.bind(this)),this.options.staticToolbar&&this.options.stickyToolbar&&this.base.on(this.options.contentWindow,"scroll",this.handleWindowScroll.bind(this),!0),this.base.on(this.options.contentWindow,"resize",this.handleWindowResize.bind(this))},handleWindowScroll:function(){this.positionToolbarIfShown()},handleWindowResize:function(){this.throttledPositionToolbar()},handleDocumentMouseup:function(a){return a&&a.target&&b.isDescendant(this.getToolbarElement(),a.target)?!1:void this.checkState()},handleEditableClick:function(){setTimeout(function(){this.checkState()}.bind(this),0)},handleEditableKeyup:function(){this.checkState()},handleBlur:function(){clearTimeout(this.hideTimeout),clearTimeout(this.delayShowTimeout),this.hideTimeout=setTimeout(function(){this.hideToolbar()}.bind(this),1)},handleFocus:function(){this.checkState()},isDisplayed:function(){return this.getToolbarElement().classList.contains("medium-editor-toolbar-active")},showToolbar:function(){clearTimeout(this.hideTimeout),this.isDisplayed()||(this.getToolbarElement().classList.add("medium-editor-toolbar-active"),this.base.trigger("showToolbar",{},this.base.getFocusedElement()),"function"==typeof this.options.onShowToolbar&&(b.deprecated("onShowToolbar","the showToolbar custom event","v5.0.0"),this.options.onShowToolbar()))},hideToolbar:function(){this.isDisplayed()&&(this.getToolbarElement().classList.remove("medium-editor-toolbar-active"),this.base.trigger("hideToolbar",{},this.base.getFocusedElement()),this.base.commands.forEach(function(a){"function"==typeof a.onHide&&(b.deprecated("onHide","the hideToolbar custom event","v5.0.0"),a.onHide())}),"function"==typeof this.options.onHideToolbar&&(b.deprecated("onHideToolbar","the hideToolbar custom event","v5.0.0"),this.options.onHideToolbar()))},isToolbarDefaultActionsDisplayed:function(){return"block"===this.getToolbarActionsElement().style.display},hideToolbarDefaultActions:function(){this.isToolbarDefaultActionsDisplayed()&&(this.getToolbarActionsElement().style.display="none")},showToolbarDefaultActions:function(){this.hideExtensionForms(),this.isToolbarDefaultActionsDisplayed()||(this.getToolbarActionsElement().style.display="block"),this.delayShowTimeout=this.base.delay(function(){this.showToolbar()}.bind(this))},hideExtensionForms:function(){this.base.commands.forEach(function(a){a.hasForm&&a.isDisplayed()&&a.hideForm()})},multipleBlockElementsSelected:function(){var a=/<[^\/>][^>]*><\/[^>]+>/gim,c=new RegExp("<("+b.parentElements.join("|")+")[^>]*>","g"),d=f.getSelectionHtml.call(this).replace(a,""),e=d.match(c);return!!e&&e.length>1},modifySelection:function(){var a=this.options.contentWindow.getSelection(),c=a.getRangeAt(0);if(this.options.standardizeSelectionStart&&c.startContainer.nodeValue&&c.startOffset===c.startContainer.nodeValue.length){var d=b.findAdjacentTextNodeWithContent(f.getSelectionElement(this.options.contentWindow),c.startContainer,this.options.ownerDocument);if(d){for(var e=0;0===d.nodeValue.substr(e,1).trim().length;)e+=1;var g=this.options.ownerDocument.createRange();g.setStart(d,e),g.setEnd(c.endContainer,c.endOffset),a.removeAllRanges(),a.addRange(g),c=g}}},checkState:function(){if(!this.base.preventSelectionUpdates){if(!this.base.getFocusedElement()||f.selectionInContentEditableFalse(this.options.contentWindow))return this.hideToolbar();var a=f.getSelectionElement(this.options.contentWindow);return!a||-1===this.base.elements.indexOf(a)||a.getAttribute("data-disable-toolbar")?this.hideToolbar():this.options.updateOnEmptySelection&&this.options.staticToolbar?this.showAndUpdateToolbar():""===this.options.contentWindow.getSelection().toString().trim()||this.options.allowMultiParagraphSelection===!1&&this.multipleBlockElementsSelected()?this.hideToolbar():void this.showAndUpdateToolbar()}},getFocusedElement:function(){return this.base.getFocusedElement()},showAndUpdateToolbar:function(){this.modifySelection(),this.setToolbarButtonStates(),this.base.trigger("positionToolbar",{},this.base.getFocusedElement()),this.showToolbarDefaultActions(),this.setToolbarPosition()},setToolbarButtonStates:function(){this.base.commands.forEach(function(a){"function"==typeof a.isActive&&"function"==typeof a.setInactive&&a.setInactive()}.bind(this)),this.checkActiveButtons()},checkActiveButtons:function(){var a,c=[],d=null,e=f.getSelectionRange(this.options.ownerDocument),g=function(b){"function"==typeof b.checkState?b.checkState(a):"function"==typeof b.isActive&&"function"==typeof b.isAlreadyApplied&&"function"==typeof b.setActive&&!b.isActive()&&b.isAlreadyApplied(a)&&b.setActive()};if(e)for(a=f.getSelectedParentElement(e),this.base.commands.forEach(function(a){return"function"==typeof a.queryCommandState&&(d=a.queryCommandState(),null!==d)?void(d&&"function"==typeof a.setActive&&a.setActive()):void c.push(a)});void 0!==a.tagName&&-1===b.parentElements.indexOf(a.tagName.toLowerCase)&&(c.forEach(g),-1===this.base.elements.indexOf(a));)a=a.parentNode},positionToolbarIfShown:function(){this.isDisplayed()&&this.setToolbarPosition()},setToolbarPosition:function(){var a,b=this.base.getFocusedElement(),c=this.options.contentWindow.getSelection();return b?(this.options.staticToolbar?(this.showToolbar(),this.positionStaticToolbar(b)):c.isCollapsed||(this.showToolbar(),this.positionToolbar(c)),a=this.base.getExtensionByName("anchor-preview"),void(a&&"function"==typeof a.hidePreview&&a.hidePreview())):this},positionStaticToolbar:function(a){this.getToolbarElement().style.left="0";var b,c=this.options.ownerDocument.documentElement&&this.options.ownerDocument.documentElement.scrollTop||this.options.ownerDocument.body.scrollTop,d=this.options.contentWindow.innerWidth,e=this.getToolbarElement(),f=a.getBoundingClientRect(),g=f.top+c,h=f.left+f.width/2,i=e.offsetHeight,j=e.offsetWidth,k=j/2;switch(this.options.stickyToolbar?c>g+a.offsetHeight-i?(e.style.top=g+a.offsetHeight-i+"px",e.classList.remove("sticky-toolbar")):c>g-i?(e.classList.add("sticky-toolbar"),e.style.top="0px"):(e.classList.remove("sticky-toolbar"),e.style.top=g-i+"px"):e.style.top=g-i+"px",this.options.toolbarAlign){case"left":b=f.left;break;case"right":b=f.right-j;break;case"center":b=h-k}0>b?b=0:b+j>d&&(b=d-Math.ceil(j)-1),e.style.left=b+"px"},positionToolbar:function(a){this.getToolbarElement().style.left="0";var b=this.options.contentWindow.innerWidth,c=a.getRangeAt(0),d=c.getBoundingClientRect(),e=(d.left+d.right)/2,f=this.getToolbarElement(),g=f.offsetHeight,h=f.offsetWidth,i=h/2,j=50,k=this.options.diffLeft-i;d.tope?f.style.left=k+i+"px":i>b-e?f.style.left=b+k-i+"px":f.style.left=k+e+"px"}}}();var y;return function(){y={button:l,form:m,anchor:n,anchorPreview:o,autoLink:p,fontSize:u,imageDragging:t,paste:v,placeholder:w}}(),function(){function l(a,b){if(this.options.disableReturn||b.getAttribute("data-disable-return"))a.preventDefault();else if(this.options.disableDoubleReturn||b.getAttribute("data-disable-double-return")){var c=f.getSelectionStart(this.options.ownerDocument);(c&&""===c.textContent.trim()||c.previousElementSibling&&""===c.previousElementSibling.textContent.trim())&&a.preventDefault()}}function m(a){var c=f.getSelectionStart(this.options.ownerDocument),d=c&&c.tagName.toLowerCase();"pre"===d&&(a.preventDefault(),b.insertHTMLCommand(this.options.ownerDocument," ")),b.isListItem(c)&&(a.preventDefault(),a.shiftKey?this.options.ownerDocument.execCommand("outdent",!1,null):this.options.ownerDocument.execCommand("indent",!1,null))}function n(a){var c,d=f.getSelectionStart(this.options.ownerDocument),e=d.tagName.toLowerCase(),g=/^(\s+|
)?$/i,h=/h\d/i;b.isKey(a,[b.keyCode.BACKSPACE,b.keyCode.ENTER])&&d.previousElementSibling&&h.test(e)&&0===f.getCaretOffsets(d).left?b.isKey(a,b.keyCode.BACKSPACE)&&g.test(d.previousElementSibling.innerHTML)?(d.previousElementSibling.parentNode.removeChild(d.previousElementSibling),a.preventDefault()):b.isKey(a,b.keyCode.ENTER)&&(c=this.options.ownerDocument.createElement("p"),c.innerHTML="
",d.previousElementSibling.parentNode.insertBefore(c,d),a.preventDefault()):b.isKey(a,b.keyCode.DELETE)&&d.nextElementSibling&&d.previousElementSibling&&!h.test(e)&&g.test(d.innerHTML)&&h.test(d.nextElementSibling.tagName)?(f.moveCursor(this.options.ownerDocument,d.nextElementSibling),d.previousElementSibling.parentNode.removeChild(d),a.preventDefault()):b.isKey(a,b.keyCode.BACKSPACE)&&"li"===e&&g.test(d.innerHTML)&&!d.previousElementSibling&&!d.parentElement.previousElementSibling&&d.nextElementSibling&&"li"===d.nextElementSibling.tagName.toLowerCase()&&(c=this.options.ownerDocument.createElement("p"),c.innerHTML="
",d.parentElement.parentElement.insertBefore(c,d.parentElement),f.moveCursor(this.options.ownerDocument,c),d.parentElement.removeChild(d),a.preventDefault())}function o(a){var c,d=f.getSelectionStart(this.options.ownerDocument);d&&(d.getAttribute("data-medium-element")&&0===d.children.length&&this.options.ownerDocument.execCommand("formatBlock",!1,"p"),b.isKey(a,b.keyCode.ENTER)&&!b.isListItem(d)&&(c=d.tagName.toLowerCase(),"a"===c?this.options.ownerDocument.execCommand("unlink",!1,null):a.shiftKey||a.ctrlKey||/h\d/.test(c)||this.options.ownerDocument.execCommand("formatBlock",!1,"p")))}function p(a){a||(a=[]),"string"==typeof a&&(a=this.options.ownerDocument.querySelectorAll(a)),b.isElement(a)&&(a=[a]);var c=Array.prototype.slice.apply(a);this.elements=[],c.forEach(function(a,b){this.elements.push("textarea"===a.tagName.toLowerCase()?w.call(this,a,b):a)},this)}function q(a,b){return Object.keys(b).forEach(function(c){void 0===a[c]&&(a[c]=b[c])}),a}function r(a,c,d){"undefined"!=typeof a.parent&&b.warn("Extension .parent property has been deprecated. The .base property for extensions will always be set to MediumEditor in version 5.0.0");var e={window:d.options.contentWindow,document:d.options.ownerDocument};return a.parent!==!1&&(e.base=d),a=q(a,e),"function"==typeof a.init&&a.init(d),a.name||(a.name=c),a}function s(){var a,b=!1;if(this.options.disableAnchorPreview)return!1;if(this.options.anchorPreview===!1)return!1;if(this.options.extensions["anchor-preview"])return!1;if(this.options.disableToolbar)return!1;for(a=0;a0&&(a=g.getRangeAt(0),c=a.cloneRange(),this.elements.some(function(c,d){return c===a.startContainer||b.isDescendant(c,a.startContainer)?(h=d,!0):!1}),h>-1&&(c.selectNodeContents(this.elements[h]),c.setEnd(a.startContainer,a.startOffset),d=c.toString().length,e={start:d,end:d+a.toString().length,editableElementIndex:h},0!==d))){var i=f.getIndexRelativeToAdjacentEmptyBlocks(this.options.ownerDocument,this.elements[h],a.startContainer,a.startOffset);0!==i&&(e.emptyBlocksIndex=i)}return null!==e&&0===e.editableElementIndex&&delete e.editableElementIndex,e},saveSelection:function(){this.selectionState=this.exportSelection()},importSelection:function(a,c){if(a){var d,e,g,h,i=void 0===a.editableElementIndex?0:a.editableElementIndex,j={editableElementIndex:i,start:a.start,end:a.end},k=this.elements[j.editableElementIndex],l=0,m=this.options.ownerDocument.createRange(),n=[k],o=!1,p=!1;for(m.setStart(k,0),m.collapse(!0),d=n.pop();!p&&d;){if(3===d.nodeType)h=l+d.length,!o&&j.start>=l&&j.start<=h&&(m.setStart(d,j.start-l),o=!0),o&&j.end>=l&&j.end<=h&&(m.setEnd(d,j.end-l),p=!0),l=h;else for(e=d.childNodes.length-1;e>=0;)n.push(d.childNodes[e]),e-=1;p||(d=n.pop())}if(a.emptyBlocksIndex&&j.end===h){for(var q=b.getBlockContainer(m.startContainer),r=0;r0)););m.setStart(b.getFirstSelectableLeafNode(q),0),m.collapse(!0)}c&&(m=f.importSelectionMoveCursorPastAnchor(j,m)),g=this.options.contentWindow.getSelection(),g.removeAllRanges(),g.addRange(m)}},restoreSelection:function(){this.importSelection(this.selectionState)},createLink:function(a){var c,d;if(a.url&&a.url.trim().length>0&&(this.options.ownerDocument.execCommand("createLink",!1,a.url),(this.options.targetBlank||"_blank"===a.target)&&b.setTargetBlank(f.getSelectionStart(this.options.ownerDocument),a.url),a.buttonClass&&b.addClassToAnchors(f.getSelectionStart(this.options.ownerDocument),a.buttonClass)),this.options.targetBlank||"_blank"===a.target||a.buttonClass)for(c=this.options.ownerDocument.createEvent("HTMLEvents"),c.initEvent("input",!0,!0,this.options.contentWindow),d=0;d",
"contributors": [
{
diff --git a/src/js/version.js b/src/js/version.js
index 4b77917e9..6dbd86c8b 100644
--- a/src/js/version.js
+++ b/src/js/version.js
@@ -11,5 +11,5 @@ MediumEditor.version = (function (major, minor, revision) {
};
}).apply(this, ({
// grunt-bump looks for this:
- 'version': '4.12.5'
+ 'version': '4.12.6'
}).version.split('.'));