From cfbf6c27599c5e423a0fde1965040b76c665fea9 Mon Sep 17 00:00:00 2001
From: Nate Mielnik
Date: Fri, 7 Aug 2015 18:28:03 -0400
Subject: [PATCH] 5.6.0
---
CHANGES.md | 7 +
dist/css/themes/tim.css | 3 +-
dist/css/themes/tim.min.css | 1 +
dist/js/medium-editor.js | 241 +++++++++++++++++++----------------
dist/js/medium-editor.min.js | 8 +-
package.json | 2 +-
src/js/version.js | 2 +-
7 files changed, 148 insertions(+), 116 deletions(-)
create mode 100644 dist/css/themes/tim.min.css
diff --git a/CHANGES.md b/CHANGES.md
index 43c2ad48e..cd19cc810 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -1,3 +1,10 @@
+5.6.0 / 2015-08-07
+==================
+* Add new 'tim' theme for medium-editor toolbar
+* Fix issue Chrome generated comment tags when pasting
+* Fix issue where 'editableInput' is triggered multiple times when creating links
+
+
5.5.4 / 2015-08-04
==================
* Fix issue with anchor and selection inconsitencies in IE
diff --git a/dist/css/themes/tim.css b/dist/css/themes/tim.css
index 72771f06a..c94ddd275 100644
--- a/dist/css/themes/tim.css
+++ b/dist/css/themes/tim.css
@@ -17,7 +17,8 @@
color: #fff;
height: 60px;
min-width: 60px;
- transition: background-color 0.2s ease-in, color 0.2s ease-in; }
+ -webkit-transition: background-color 0.2s ease-in, color 0.2s ease-in;
+ transition: background-color 0.2s ease-in, color 0.2s ease-in; }
.medium-editor-toolbar li button:hover {
background-color: #030200;
color: #fff; }
diff --git a/dist/css/themes/tim.min.css b/dist/css/themes/tim.min.css
new file mode 100644
index 000000000..1b9acc229
--- /dev/null
+++ b/dist/css/themes/tim.min.css
@@ -0,0 +1 @@
+.medium-toolbar-arrow-under:after{border-color:#2f1e07 transparent transparent;top:60px}.medium-toolbar-arrow-over:before{border-color:transparent transparent #2f1e07}.medium-editor-toolbar{background-color:#2f1e07;border:1px solid #5b3a0e;border-radius:4px}.medium-editor-toolbar li button{background-color:transparent;border:none;border-right:1px solid #5b3a0e;box-sizing:border-box;color:#fff;height:60px;min-width:60px;-webkit-transition:background-color .2s ease-in,color .2s ease-in;transition:background-color .2s ease-in,color .2s ease-in}.medium-editor-toolbar li .medium-editor-button-active,.medium-editor-toolbar li button:hover{color:#fff;background-color:#030200}.medium-editor-toolbar li .medium-editor-button-first{border-bottom-left-radius:4px;border-top-left-radius:4px}.medium-editor-toolbar li .medium-editor-button-last{border-bottom-right-radius:4px;border-right:none;border-top-right-radius:4px}.medium-editor-toolbar-form{background:#2f1e07;border-radius:4px;color:#fff}.medium-editor-toolbar-form .medium-editor-toolbar-input{background:#2f1e07;color:#fff;height:60px}.medium-editor-toolbar-form .medium-editor-toolbar-input::-webkit-input-placeholder{color:#fff;color:rgba(255,255,255,.8)}.medium-editor-toolbar-form .medium-editor-toolbar-input:-moz-placeholder{color:#fff;color:rgba(255,255,255,.8)}.medium-editor-toolbar-form .medium-editor-toolbar-input::-moz-placeholder{color:#fff;color:rgba(255,255,255,.8)}.medium-editor-toolbar-form .medium-editor-toolbar-input:-ms-input-placeholder{color:#fff;color:rgba(255,255,255,.8)}.medium-editor-toolbar-form a{color:#fff}.medium-editor-toolbar-anchor-preview{background:#2f1e07;border-radius:4px;color:#fff}.medium-editor-placeholder:after{color:#5b3a0e}
\ No newline at end of file
diff --git a/dist/js/medium-editor.js b/dist/js/medium-editor.js
index c22f3ff29..96315dfab 100644
--- a/dist/js/medium-editor.js
+++ b/dist/js/medium-editor.js
@@ -2184,6 +2184,7 @@ var Events;
this.base = instance;
this.options = this.base.options;
this.events = [];
+ this.disabledEvents = {};
this.customEvents = {};
this.listeners = {};
};
@@ -2226,6 +2227,16 @@ var Events;
}
},
+ enableCustomEvent: function (event) {
+ if (this.disabledEvents[event] !== undefined) {
+ delete this.disabledEvents[event];
+ }
+ },
+
+ disableCustomEvent: function (event) {
+ this.disabledEvents[event] = true;
+ },
+
// custom events
attachCustomEvent: function (event, listener) {
this.setupListener(event);
@@ -2257,7 +2268,7 @@ var Events;
},
triggerCustomEvent: function (name, data, editable) {
- if (this.customEvents[name]) {
+ if (this.customEvents[name] && !this.disabledEvents[name]) {
this.customEvents[name].forEach(function (listener) {
listener(data, editable);
});
@@ -4163,7 +4174,6 @@ var PasteHandler;
*/
function createReplacements() {
return [
-
// replace two bogus tags that begin pastes from google docs
[new RegExp(/<[^>]*docs-internal-guid[^>]*>/gi), ''],
[new RegExp(/<\/b>(
]*>)?$/gi), ''],
@@ -4193,7 +4203,11 @@ var PasteHandler;
[new RegExp(/\n+
- [new RegExp(/<\/?o:[a-z]*>/gi), '']
+ [new RegExp(/<\/?o:[a-z]*>/gi), ''],
+
+ // cleanup comments added by Chrome when pasting html
+ ['', ''],
+ ['', '']
];
}
/*jslint regexp: false*/
@@ -6129,126 +6143,133 @@ function MediumEditor(elements, options) {
},
createLink: function (opts) {
- var customEvent, i;
-
- if (opts.url && opts.url.trim().length > 0) {
- var currentSelection = this.options.contentWindow.getSelection();
- if (currentSelection) {
- var currRange = currentSelection.getRangeAt(0),
- commonAncestorContainer = currRange.commonAncestorContainer,
- exportedSelection,
- startContainerParentElement,
- endContainerParentElement,
- textNodes;
-
- // If the selection is contained within a single text node
- // and the selection starts at the beginning of the text node,
- // MSIE still says the startContainer is the parent of the text node.
- // If the selection is contained within a single text node, we
- // want to just use the default browser 'createLink', so we need
- // to account for this case and adjust the commonAncestorContainer accordingly
- if (currRange.endContainer.nodeType === 3 &&
- currRange.startContainer.nodeType !== 3 &&
- currRange.startOffset === 0 &&
- currRange.startContainer.firstChild === currRange.endContainer) {
- commonAncestorContainer = currRange.endContainer;
- }
+ var currentEditor, customEvent, i;
- startContainerParentElement = Util.getClosestBlockContainer(currRange.startContainer);
- endContainerParentElement = Util.getClosestBlockContainer(currRange.endContainer);
-
- // If the selection is not contained within a single text node
- // but the selection is contained within the same block element
- // we want to make sure we create a single link, and not multiple links
- // which can happen with the built in browser functionality
- if (commonAncestorContainer.nodeType !== 3 && startContainerParentElement === endContainerParentElement) {
-
- var currentEditor = Selection.getSelectionElement(this.options.contentWindow),
- parentElement = (startContainerParentElement || currentEditor),
- fragment = this.options.ownerDocument.createDocumentFragment();
-
- // since we are going to create a link from an extracted text,
- // be sure that if we are updating a link, we won't let an empty link behind (see #754)
- // (Workaroung for Chrome)
- this.execAction('unlink');
-
- exportedSelection = this.exportSelection();
- fragment.appendChild(parentElement.cloneNode(true));
-
- if (currentEditor === parentElement) {
- // We have to avoid the editor itself being wiped out when it's the only block element,
- // as our reference inside this.elements gets detached from the page when insertHTML runs.
- // If we just use [parentElement, 0] and [parentElement, parentElement.childNodes.length]
- // as the range boundaries, this happens whenever parentElement === currentEditor.
- // The tradeoff to this workaround is that a orphaned tag can sometimes be left behind at
- // the end of the editor's content.
- // In Gecko:
- // as an empty if parentElement.lastChild is a tag.
- // In WebKit:
- // an invented
tag at the end in the same situation
- Selection.select(
- this.options.ownerDocument,
- parentElement.firstChild,
- 0,
- parentElement.lastChild,
- parentElement.lastChild.nodeType === 3 ?
- parentElement.lastChild.nodeValue.length : parentElement.lastChild.childNodes.length
- );
- } else {
- Selection.select(
- this.options.ownerDocument,
- parentElement,
- 0,
- parentElement,
- parentElement.childNodes.length
- );
+ try {
+ this.events.disableCustomEvent('editableInput');
+ if (opts.url && opts.url.trim().length > 0) {
+ var currentSelection = this.options.contentWindow.getSelection();
+ if (currentSelection) {
+ var currRange = currentSelection.getRangeAt(0),
+ commonAncestorContainer = currRange.commonAncestorContainer,
+ exportedSelection,
+ startContainerParentElement,
+ endContainerParentElement,
+ textNodes;
+
+ // If the selection is contained within a single text node
+ // and the selection starts at the beginning of the text node,
+ // MSIE still says the startContainer is the parent of the text node.
+ // If the selection is contained within a single text node, we
+ // want to just use the default browser 'createLink', so we need
+ // to account for this case and adjust the commonAncestorContainer accordingly
+ if (currRange.endContainer.nodeType === 3 &&
+ currRange.startContainer.nodeType !== 3 &&
+ currRange.startOffset === 0 &&
+ currRange.startContainer.firstChild === currRange.endContainer) {
+ commonAncestorContainer = currRange.endContainer;
}
- var modifiedExportedSelection = this.exportSelection();
-
- textNodes = Util.findOrCreateMatchingTextNodes(
- this.options.ownerDocument,
- fragment,
- {
- start: exportedSelection.start - modifiedExportedSelection.start,
- end: exportedSelection.end - modifiedExportedSelection.start,
- editableElementIndex: exportedSelection.editableElementIndex
+ startContainerParentElement = Util.getClosestBlockContainer(currRange.startContainer);
+ endContainerParentElement = Util.getClosestBlockContainer(currRange.endContainer);
+
+ // If the selection is not contained within a single text node
+ // but the selection is contained within the same block element
+ // we want to make sure we create a single link, and not multiple links
+ // which can happen with the built in browser functionality
+ if (commonAncestorContainer.nodeType !== 3 && startContainerParentElement === endContainerParentElement) {
+
+ currentEditor = Selection.getSelectionElement(this.options.contentWindow);
+ var parentElement = (startContainerParentElement || currentEditor),
+ fragment = this.options.ownerDocument.createDocumentFragment();
+
+ // since we are going to create a link from an extracted text,
+ // be sure that if we are updating a link, we won't let an empty link behind (see #754)
+ // (Workaroung for Chrome)
+ this.execAction('unlink');
+
+ exportedSelection = this.exportSelection();
+ fragment.appendChild(parentElement.cloneNode(true));
+
+ if (currentEditor === parentElement) {
+ // We have to avoid the editor itself being wiped out when it's the only block element,
+ // as our reference inside this.elements gets detached from the page when insertHTML runs.
+ // If we just use [parentElement, 0] and [parentElement, parentElement.childNodes.length]
+ // as the range boundaries, this happens whenever parentElement === currentEditor.
+ // The tradeoff to this workaround is that a orphaned tag can sometimes be left behind at
+ // the end of the editor's content.
+ // In Gecko:
+ // as an empty if parentElement.lastChild is a tag.
+ // In WebKit:
+ // an invented
tag at the end in the same situation
+ Selection.select(
+ this.options.ownerDocument,
+ parentElement.firstChild,
+ 0,
+ parentElement.lastChild,
+ parentElement.lastChild.nodeType === 3 ?
+ parentElement.lastChild.nodeValue.length : parentElement.lastChild.childNodes.length
+ );
+ } else {
+ Selection.select(
+ this.options.ownerDocument,
+ parentElement,
+ 0,
+ parentElement,
+ parentElement.childNodes.length
+ );
}
- );
- // Creates the link in the document fragment
- Util.createLink(this.options.ownerDocument, textNodes, opts.url.trim());
+ var modifiedExportedSelection = this.exportSelection();
- // Chrome trims the leading whitespaces when inserting HTML, which messes up restoring the selection.
- var leadingWhitespacesCount = (fragment.firstChild.innerHTML.match(/^\s+/) || [''])[0].length;
+ textNodes = Util.findOrCreateMatchingTextNodes(
+ this.options.ownerDocument,
+ fragment,
+ {
+ start: exportedSelection.start - modifiedExportedSelection.start,
+ end: exportedSelection.end - modifiedExportedSelection.start,
+ editableElementIndex: exportedSelection.editableElementIndex
+ }
+ );
- // Now move the created link back into the original document in a way to preserve undo/redo history
- Util.insertHTMLCommand(this.options.ownerDocument, fragment.firstChild.innerHTML.replace(/^\s+/, ''));
- exportedSelection.start -= leadingWhitespacesCount;
- exportedSelection.end -= leadingWhitespacesCount;
+ // Creates the link in the document fragment
+ Util.createLink(this.options.ownerDocument, textNodes, opts.url.trim());
- this.importSelection(exportedSelection);
- } else {
- this.options.ownerDocument.execCommand('createLink', false, opts.url);
- }
+ // Chrome trims the leading whitespaces when inserting HTML, which messes up restoring the selection.
+ var leadingWhitespacesCount = (fragment.firstChild.innerHTML.match(/^\s+/) || [''])[0].length;
- if (this.options.targetBlank || opts.target === '_blank') {
- Util.setTargetBlank(Selection.getSelectionStart(this.options.ownerDocument), opts.url);
- }
+ // Now move the created link back into the original document in a way to preserve undo/redo history
+ Util.insertHTMLCommand(this.options.ownerDocument, fragment.firstChild.innerHTML.replace(/^\s+/, ''));
+ exportedSelection.start -= leadingWhitespacesCount;
+ exportedSelection.end -= leadingWhitespacesCount;
+
+ this.importSelection(exportedSelection);
+ } else {
+ this.options.ownerDocument.execCommand('createLink', false, opts.url);
+ }
+
+ if (this.options.targetBlank || opts.target === '_blank') {
+ Util.setTargetBlank(Selection.getSelectionStart(this.options.ownerDocument), opts.url);
+ }
- if (opts.buttonClass) {
- Util.addClassToAnchors(Selection.getSelectionStart(this.options.ownerDocument), opts.buttonClass);
+ if (opts.buttonClass) {
+ Util.addClassToAnchors(Selection.getSelectionStart(this.options.ownerDocument), opts.buttonClass);
+ }
}
}
- }
-
- if (this.options.targetBlank || opts.target === '_blank' || opts.buttonClass) {
- customEvent = this.options.ownerDocument.createEvent('HTMLEvents');
- customEvent.initEvent('input', true, true, this.options.contentWindow);
- for (i = 0; i < this.elements.length; i += 1) {
- this.elements[i].dispatchEvent(customEvent);
+ // Fire input event for backwards compatibility if anyone was listening directly to the DOM input event
+ if (this.options.targetBlank || opts.target === '_blank' || opts.buttonClass) {
+ customEvent = this.options.ownerDocument.createEvent('HTMLEvents');
+ customEvent.initEvent('input', true, true, this.options.contentWindow);
+ for (i = 0; i < this.elements.length; i += 1) {
+ this.elements[i].dispatchEvent(customEvent);
+ }
}
+ } finally {
+ this.events.enableCustomEvent('editableInput');
}
+ // Fire our custom editableInput event
+ this.events.triggerCustomEvent('editableInput', customEvent, currentEditor);
},
cleanPaste: function (text) {
@@ -6288,7 +6309,7 @@ MediumEditor.parseVersionString = function (release) {
MediumEditor.version = MediumEditor.parseVersionString.call(this, ({
// grunt-bump looks for this:
- 'version': '5.5.4'
+ 'version': '5.6.0'
}).version);
return MediumEditor;
diff --git a/dist/js/medium-editor.min.js b/dist/js/medium-editor.min.js
index 8a7561601..9e9f1414b 100644
--- a/dist/js/medium-editor.min.js
+++ b/dist/js/medium-editor.min.js
@@ -1,3 +1,5 @@
-"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(a,b){var c,d=Array.prototype.slice.call(arguments,2);b=b||{};for(var e=0;e=0,keyCode:{BACKSPACE:8,TAB:9,ENTER:13,ESCAPE:27,SPACE:32,DELETE:46,K:75},isMetaCtrlKey:function(a){return this.isMac&&a.metaKey||!this.isMac&&a.ctrlKey?!0:!1},isKey:function(a,b){var c=this.getKeyCode(a);return!1===Array.isArray(b)?c===b:-1===b.indexOf(c)?!1:!0},getKeyCode:function(a){var b=a.which;return null===b&&(b=null!==a.charCode?a.charCode:a.keyCode),b},blockContainerElementNames:["p","h1","h2","h3","h4","h5","h6","blockquote","pre"],emptyElementNames:["br","col","colgroup","hr","img","input","source","wbr"],extend:function(){var a=[!0].concat(Array.prototype.slice.call(arguments));return c.apply(this,a)},defaults:function(){var a=[!1].concat(Array.prototype.slice.call(arguments));return c.apply(this,a)},createLink:function(a,c,d,e){var f=a.createElement("a");return b.moveTextRangeIntoElement(c[0],c[c.length-1],f),f.setAttribute("href",d),e&&f.setAttribute("target",e),f},findOrCreateMatchingTextNodes:function(a,c,d){for(var e=a.createTreeWalker(c,NodeFilter.SHOW_TEXT,null,!1),f=[],g=0,h=!1,i=null,j=null;null!==(i=e.nextNode())&&(!h&&d.startd.end+1)throw new Error("PerformLinking overshot the target!");h&&f.push(j||i),g+=i.nodeValue.length,null!==j&&(g+=j.nodeValue.length,e.nextNode()),j=null}return f},splitStartNodeIfNeeded:function(a,b,c){return b!==c?a.splitText(b-c):null},splitEndNodeIfNeeded:function(a,b,c,d){var e,f;e=d+(b||a).nodeValue.length+(b?a.nodeValue.length:0)-1,f=(b||a).nodeValue.length-(e+1-c),e>=c&&d!==e&&0!==f&&(b||a).splitText(f)},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)},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,c){if(!a)return!1;do{if(1===a.nodeType){if(c(a))return a;if(b.isMediumEditorElement(a))return!1}a=a.parentNode}while(a);return!1},htmlEntities:function(a){return String(a).replace(/&/g,"&").replace(//g,">").replace(/"/g,""")},insertHTMLCommand:function(a,c){var d,e,f,g,h,i,j;if(a.queryCommandSupported("insertHTML"))try{return a.execCommand("insertHTML",!1,c)}catch(k){}if(d=a.getSelection(),d.rangeCount){if(e=d.getRangeAt(0),j=e.commonAncestorContainer,3===j.nodeType&&0===e.startOffset&&e.endOffset===j.nodeValue.length||3!==j.nodeType&&j.innerHTML===e.toString()){for(;j.parentNode&&1===j.parentNode.childNodes.length&&!b.isMediumEditorElement(j.parentNode);)j=j.parentNode;e.selectNode(j)}for(e.deleteContents(),f=a.createElement("div"),f.innerHTML=c,g=a.createDocumentFragment();f.firstChild;)h=f.firstChild,i=g.appendChild(h);e.insertNode(g),i&&(e=e.cloneRange(),e.setStartAfter(i),e.collapse(!0),d.removeAllRanges(),d.addRange(e))}},execFormatBlock:function(a,c){var d=b.getTopBlockContainer(f.getSelectionStart(a));if("blockquote"===c){if(d){var e=Array.prototype.slice.call(d.childNodes);if(e.some(function(a){return b.isBlockContainer(a)}))return a.execCommand("outdent",!1,null)}if(this.isIE)return a.execCommand("indent",!1,c)}return d&&c===d.nodeName.toLowerCase()&&(c="p"),this.isIE&&(c="<"+c+">"),a.execCommand("formatBlock",!1,c)},setTargetBlank:function(a,b){var c,d=b||!1;if("a"===a.nodeName.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&&a.getAttribute&&!!a.getAttribute("data-medium-editor-element")},getContainerEditorElement:function(a){return b.traverseUp(a,function(a){return b.isMediumEditorElement(a)})},isBlockContainer:function(a){return a&&3!==a.nodeType&&-1!==this.blockContainerElementNames.indexOf(a.nodeName.toLowerCase())},getClosestBlockContainer:function(a){return b.traverseUp(a,function(a){return b.isBlockContainer(a)})},getTopBlockContainer:function(a){var c=a;return this.traverseUp(a,function(a){return b.isBlockContainer(a)&&(c=a),!1}),c},getFirstSelectableLeafNode:function(a){for(;a&&a.firstChild;)a=a.firstChild;if(a=this.traverseUp(a,function(a){return-1===b.emptyElementNames.indexOf(a.nodeName.toLowerCase())}),"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:''},italic:{name:"italic",action:"italic",aria:"italic",tagNames:["i","em"],style:{prop:"font-style",value:"italic"},useQueryState:!0,contentDefault:"I",contentFA:''},underline:{name:"underline",action:"underline",aria:"underline",tagNames:["u"],style:{prop:"text-decoration",value:"underline"},useQueryState:!0,contentDefault:"U",contentFA:''},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:''},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:''},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:''},removeFormat:{name:"removeFormat",aria:"remove formatting",action:"removeFormat",contentDefault:"X",contentFA:''},quote:{name:"quote",action:"append-blockquote",aria:"blockquote",tagNames:["blockquote"],contentDefault:"“",contentFA:''},pre:{name:"pre",action:"append-pre",aria:"preformatted text",tagNames:["pre"],contentDefault:"0101",contentFA:''},h1:{name:"h1",action:"append-h1",aria:"header type one",tagNames:["h1"],contentDefault:"H1",contentFA:'
"],[new RegExp(/\n+/gi),""]]}s=e.extend({forcePlainText:!0,cleanPastedHTML:!1,cleanReplacements:[],cleanAttrs:["class","style","dir"],cleanTags:["meta"],init:function(){e.prototype.init.apply(this,arguments),(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.getEditorOption("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=/
"),void this.pasteHTML("
"+d.join("
")+"
")):this.pasteHTML(b)},pasteHTML:function(a,c){c=b.defaults({},c,{cleanAttrs:this.cleanAttrs,cleanTags:this.cleanTags});var d,e,f,g,h=this.document.createDocumentFragment();for(h.appendChild(this.document.createElement("body")),g=h.querySelector("body"),g.innerHTML=a,this.cleanupSpans(g),d=g.querySelectorAll("*"),f=0;f"+d.innerHTML+"":e.innerHTML=d.innerHTML,d.parentNode.replaceChild(e,d);for(f=a.querySelectorAll("span"),c=0;c0&&(d[0].classList.add(this.firstButtonClass),d[d.length-1].classList.add(this.lastButtonClass)),h},destroy:function(){this.toolbar&&(this.toolbar.parentNode&&this.toolbar.parentNode.removeChild(this.toolbar),delete this.toolbar)},getToolbarElement:function(){return this.toolbar||(this.toolbar=this.createToolbar()),this.toolbar},getToolbarActionsElement:function(){return this.getToolbarElement().querySelector(".medium-editor-toolbar-actions")},initThrottledMethods:function(){this.throttledPositionToolbar=b.throttle(function(){this.base.isActive&&this.positionToolbarIfShown()}.bind(this))},attachEventHandlers:function(){this.subscribe("blur",this.handleBlur.bind(this)),this.subscribe("focus",this.handleFocus.bind(this)),this.subscribe("editableClick",this.handleEditableClick.bind(this)),this.subscribe("editableKeyup",this.handleEditableKeyup.bind(this)),this.on(this.document.documentElement,"mouseup",this.handleDocumentMouseup.bind(this)),this["static"]&&this.sticky&&this.on(this.window,"scroll",this.handleWindowScroll.bind(this),!0),this.on(this.window,"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.trigger("showToolbar",{},this.base.getFocusedElement()))},hideToolbar:function(){this.isDisplayed()&&(this.getToolbarElement().classList.remove("medium-editor-toolbar-active"),this.trigger("hideToolbar",{},this.base.getFocusedElement()))},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.forEachExtension(function(a){a.hasForm&&a.isDisplayed()&&a.hideForm()})},multipleBlockElementsSelected:function(){var a=/<[^\/>][^>]*><\/[^>]+>/gim,c=new RegExp("<("+b.blockContainerElementNames.join("|")+")[^>]*>","g"),d=f.getSelectionHtml(this.document).replace(a,""),e=d.match(c);return!!e&&e.length>1},modifySelection:function(){var a=this.window.getSelection(),c=a.getRangeAt(0);if(this.standardizeSelectionStart&&c.startContainer.nodeValue&&c.startOffset===c.startContainer.nodeValue.length){var d=b.findAdjacentTextNodeWithContent(f.getSelectionElement(this.window),c.startContainer,this.document);if(d){for(var e=0;0===d.nodeValue.substr(e,1).trim().length;)e+=1;c=f.select(this.document,d,e,c.endContainer,c.endOffset)}}},checkState:function(){if(!this.base.preventSelectionUpdates){if(!this.base.getFocusedElement()||f.selectionInContentEditableFalse(this.window))return this.hideToolbar();var a=f.getSelectionElement(this.window);return!a||-1===this.getEditorElements().indexOf(a)||a.getAttribute("data-disable-toolbar")?this.hideToolbar():this.updateOnEmptySelection&&this["static"]?this.showAndUpdateToolbar():""===this.window.getSelection().toString().trim()||this.allowMultiParagraphSelection===!1&&this.multipleBlockElementsSelected()?this.hideToolbar():void this.showAndUpdateToolbar()}},showAndUpdateToolbar:function(){this.modifySelection(),this.setToolbarButtonStates(),this.trigger("positionToolbar",{},this.base.getFocusedElement()),
-this.showToolbarDefaultActions(),this.setToolbarPosition()},setToolbarButtonStates:function(){this.forEachExtension(function(a){"function"==typeof a.isActive&&"function"==typeof a.setInactive&&a.setInactive()}),this.checkActiveButtons()},checkActiveButtons:function(){var a,c=[],d=null,e=f.getSelectionRange(this.document),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&&(this.forEachExtension(function(a){return"function"==typeof a.queryCommandState&&(d=a.queryCommandState(),null!==d)?void(d&&"function"==typeof a.setActive&&a.setActive()):void c.push(a)}),a=f.getSelectedParentElement(e),this.getEditorElements().some(function(c){return b.isDescendant(c,a,!0)})))for(;a&&(c.forEach(g),!b.isMediumEditorElement(a));)a=a.parentNode},positionToolbarIfShown:function(){this.isDisplayed()&&this.setToolbarPosition()},setToolbarPosition:function(){var a,b=this.base.getFocusedElement(),c=this.window.getSelection();return b?(this["static"]?(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.document.documentElement&&this.document.documentElement.scrollTop||this.document.body.scrollTop,d=this.window.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.sticky?c>g+a.offsetHeight-i?(e.style.top=g+a.offsetHeight-i+"px",e.classList.remove("medium-editor-sticky-toolbar")):c>g-i?(e.classList.add("medium-editor-sticky-toolbar"),e.style.top="0px"):(e.classList.remove("medium-editor-sticky-toolbar"),e.style.top=g-i+"px"):e.style.top=g-i+"px",this.align){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.window.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.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 v;!function(){v=e.extend({init:function(){e.prototype.init.apply(this,arguments),this.subscribe("editableDrag",this.handleDrag.bind(this)),this.subscribe("editableDrop",this.handleDrop.bind(this))},handleDrag:function(a){var b="medium-editor-dragover";a.preventDefault(),a.dataTransfer.dropEffect="copy","dragover"===a.type?a.target.classList.add(b):"dragleave"===a.type&&a.target.classList.remove(b)},handleDrop:function(a){var c,d="medium-editor-dragover";a.preventDefault(),a.stopPropagation(),a.dataTransfer.files&&(c=Array.prototype.slice.call(a.dataTransfer.files,0),c.some(function(a){if(a.type.match("image")){var c,d;c=new FileReader,c.readAsDataURL(a),d="medium-img-"+ +new Date,b.insertHTMLCommand(this.document,''),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 w;return function(){w={button:h,form:i,anchor:j,anchorPreview:k,autoLink:l,fileDragging:p,fontSize:r,imageDragging:v,keyboardCommands:q,paste:s,placeholder:t,toolbar:u}}(),function(){function c(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 h(a){var c=f.getSelectionStart(this.options.ownerDocument),d=c&&c.nodeName.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 i(a){var c,d=f.getSelectionStart(this.options.ownerDocument),e=d.nodeName.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.nodeName.toLowerCase())?(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.nodeName.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 j(a){var c,d=f.getSelectionStart(this.options.ownerDocument);d&&(b.isMediumEditorElement(d)&&0===d.children.length&&this.options.ownerDocument.execCommand("formatBlock",!1,"p"),b.isKey(a,b.keyCode.ENTER)&&!b.isListItem(d)&&(c=d.nodeName.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 k(a){a._mediumEditors||(a._mediumEditors=[null]),this.id||(this.id=a._mediumEditors.length),a._mediumEditors[this.id]=this}function l(a){a._mediumEditors&&a._mediumEditors[this.id]&&(a._mediumEditors[this.id]=null)}function m(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.nodeName.toLowerCase()?x.call(this,a,b):a)},this)}function n(a,b){return Object.keys(b).forEach(function(c){void 0===a[c]&&(a[c]=b[c])}),a}function o(a,b,c){var d={window:c.options.contentWindow,document:c.options.ownerDocument,base:c};return a=n(a,d),"function"==typeof a.init&&a.init(),a.name||(a.name=b),a}function p(){return this.elements.every(function(a){return!!a.getAttribute("data-disable-toolbar")})?!1:this.options.toolbar!==!1}function q(){return p.call(this)?this.options.anchorPreview!==!1:!1}function r(){return this.options.placeholder!==!1}function s(){return this.options.autoLink!==!1}function t(){return this.options.imageDragging!==!1}function u(){return this.options.keyboardCommands!==!1}function v(){return!this.options.extensions.imageDragging}function x(a,b){var c=this.options.ownerDocument.createElement("div"),d="medium-editor-"+Date.now()+"-"+b,e=a.attributes;c.className=a.className,c.id=d,c.innerHTML=a.value,a.setAttribute("medium-editor-textarea-id",b);for(var f=0,g=e.length;g>f;f++)c.hasAttribute(e[f].nodeName)||c.setAttribute(e[f].nodeName,e[f].nodeValue);return a.classList.add("medium-editor-hidden"),a.parentNode.insertBefore(c,a),c}function y(){this.elements.forEach(function(a,b){this.options.disableEditing||a.getAttribute("data-disable-editing")||(a.setAttribute("contentEditable",!0),a.setAttribute("spellcheck",this.options.spellcheck)),a.setAttribute("data-medium-editor-element",!0),a.setAttribute("role","textbox"),a.setAttribute("aria-multiline",!0),a.setAttribute("medium-editor-index",b),a.hasAttribute("medium-editor-textarea-id")&&this.on(a,"input",function(a){var b=a.target,c=b.parentNode.querySelector('textarea[medium-editor-textarea-id="'+b.getAttribute("medium-editor-textarea-id")+'"]');c&&(c.value=this.serialize()[b.id].value)}.bind(this))},this)}function z(){var a;if(this.subscribe("editableKeydownTab",h.bind(this)),this.subscribe("editableKeydownDelete",i.bind(this)),this.subscribe("editableKeydownEnter",i.bind(this)),this.options.disableReturn||this.options.disableDoubleReturn)this.subscribe("editableKeydownEnter",c.bind(this));else for(a=0;a=0&&(c=f.exportSelection(a,this.options.ownerDocument)),null!==c&&0!==b&&(c.editableElementIndex=b),c},saveSelection:function(){this.selectionState=this.exportSelection()},importSelection:function(a,b){if(a){var c=this.elements[a.editableElementIndex||0];f.importSelection(a,c,this.options.ownerDocument,b)}},restoreSelection:function(){this.importSelection(this.selectionState)},createLink:function(a){var c,d;if(a.url&&a.url.trim().length>0){var e=this.options.contentWindow.getSelection();if(e){var g,h,i,j,k=e.getRangeAt(0),l=k.commonAncestorContainer;if(3===k.endContainer.nodeType&&3!==k.startContainer.nodeType&&0===k.startOffset&&k.startContainer.firstChild===k.endContainer&&(l=k.endContainer),h=b.getClosestBlockContainer(k.startContainer),i=b.getClosestBlockContainer(k.endContainer),3!==l.nodeType&&h===i){var m=f.getSelectionElement(this.options.contentWindow),n=h||m,o=this.options.ownerDocument.createDocumentFragment();this.execAction("unlink"),g=this.exportSelection(),o.appendChild(n.cloneNode(!0)),m===n?f.select(this.options.ownerDocument,n.firstChild,0,n.lastChild,3===n.lastChild.nodeType?n.lastChild.nodeValue.length:n.lastChild.childNodes.length):f.select(this.options.ownerDocument,n,0,n,n.childNodes.length);var p=this.exportSelection();j=b.findOrCreateMatchingTextNodes(this.options.ownerDocument,o,{start:g.start-p.start,end:g.end-p.start,editableElementIndex:g.editableElementIndex}),b.createLink(this.options.ownerDocument,j,a.url.trim());var q=(o.firstChild.innerHTML.match(/^\s+/)||[""])[0].length;b.insertHTMLCommand(this.options.ownerDocument,o.firstChild.innerHTML.replace(/^\s+/,"")),g.start-=q,g.end-=q,this.importSelection(g)}else 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)}}if(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;d1?b[1]:"";return{major:parseInt(c[0],10),minor:parseInt(c[1],10),revision:parseInt(c[2],10),preRelease:d,toString:function(){return[c[0],c[1],c[2]].join(".")+(d?"-"+d:"")}}},a.version=a.parseVersionString.call(this,{version:"5.5.4"}.version),a}());
\ No newline at end of file
+"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(a,b){var c,d=Array.prototype.slice.call(arguments,2);b=b||{};for(var e=0;e=0,keyCode:{BACKSPACE:8,TAB:9,ENTER:13,ESCAPE:27,SPACE:32,DELETE:46,K:75},isMetaCtrlKey:function(a){return this.isMac&&a.metaKey||!this.isMac&&a.ctrlKey?!0:!1},isKey:function(a,b){var c=this.getKeyCode(a);return!1===Array.isArray(b)?c===b:-1===b.indexOf(c)?!1:!0},getKeyCode:function(a){var b=a.which;return null===b&&(b=null!==a.charCode?a.charCode:a.keyCode),b},blockContainerElementNames:["p","h1","h2","h3","h4","h5","h6","blockquote","pre"],emptyElementNames:["br","col","colgroup","hr","img","input","source","wbr"],extend:function(){var a=[!0].concat(Array.prototype.slice.call(arguments));return c.apply(this,a)},defaults:function(){var a=[!1].concat(Array.prototype.slice.call(arguments));return c.apply(this,a)},createLink:function(a,c,d,e){var f=a.createElement("a");return b.moveTextRangeIntoElement(c[0],c[c.length-1],f),f.setAttribute("href",d),e&&f.setAttribute("target",e),f},findOrCreateMatchingTextNodes:function(a,c,d){for(var e=a.createTreeWalker(c,NodeFilter.SHOW_TEXT,null,!1),f=[],g=0,h=!1,i=null,j=null;null!==(i=e.nextNode())&&(!h&&d.startd.end+1)throw new Error("PerformLinking overshot the target!");h&&f.push(j||i),g+=i.nodeValue.length,null!==j&&(g+=j.nodeValue.length,e.nextNode()),j=null}return f},splitStartNodeIfNeeded:function(a,b,c){return b!==c?a.splitText(b-c):null},splitEndNodeIfNeeded:function(a,b,c,d){var e,f;e=d+(b||a).nodeValue.length+(b?a.nodeValue.length:0)-1,f=(b||a).nodeValue.length-(e+1-c),e>=c&&d!==e&&0!==f&&(b||a).splitText(f)},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)},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,c){if(!a)return!1;do{if(1===a.nodeType){if(c(a))return a;if(b.isMediumEditorElement(a))return!1}a=a.parentNode}while(a);return!1},htmlEntities:function(a){return String(a).replace(/&/g,"&").replace(//g,">").replace(/"/g,""")},insertHTMLCommand:function(a,c){var d,e,f,g,h,i,j;if(a.queryCommandSupported("insertHTML"))try{return a.execCommand("insertHTML",!1,c)}catch(k){}if(d=a.getSelection(),d.rangeCount){if(e=d.getRangeAt(0),j=e.commonAncestorContainer,3===j.nodeType&&0===e.startOffset&&e.endOffset===j.nodeValue.length||3!==j.nodeType&&j.innerHTML===e.toString()){for(;j.parentNode&&1===j.parentNode.childNodes.length&&!b.isMediumEditorElement(j.parentNode);)j=j.parentNode;e.selectNode(j)}for(e.deleteContents(),f=a.createElement("div"),f.innerHTML=c,g=a.createDocumentFragment();f.firstChild;)h=f.firstChild,i=g.appendChild(h);e.insertNode(g),i&&(e=e.cloneRange(),e.setStartAfter(i),e.collapse(!0),d.removeAllRanges(),d.addRange(e))}},execFormatBlock:function(a,c){var d=b.getTopBlockContainer(f.getSelectionStart(a));if("blockquote"===c){if(d){var e=Array.prototype.slice.call(d.childNodes);if(e.some(function(a){return b.isBlockContainer(a)}))return a.execCommand("outdent",!1,null)}if(this.isIE)return a.execCommand("indent",!1,c)}return d&&c===d.nodeName.toLowerCase()&&(c="p"),this.isIE&&(c="<"+c+">"),a.execCommand("formatBlock",!1,c)},setTargetBlank:function(a,b){var c,d=b||!1;if("a"===a.nodeName.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&&a.getAttribute&&!!a.getAttribute("data-medium-editor-element")},getContainerEditorElement:function(a){return b.traverseUp(a,function(a){return b.isMediumEditorElement(a)})},isBlockContainer:function(a){return a&&3!==a.nodeType&&-1!==this.blockContainerElementNames.indexOf(a.nodeName.toLowerCase())},getClosestBlockContainer:function(a){return b.traverseUp(a,function(a){return b.isBlockContainer(a)})},getTopBlockContainer:function(a){var c=a;return this.traverseUp(a,function(a){return b.isBlockContainer(a)&&(c=a),!1}),c},getFirstSelectableLeafNode:function(a){for(;a&&a.firstChild;)a=a.firstChild;if(a=this.traverseUp(a,function(a){return-1===b.emptyElementNames.indexOf(a.nodeName.toLowerCase())}),"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:''},italic:{name:"italic",action:"italic",aria:"italic",tagNames:["i","em"],style:{prop:"font-style",value:"italic"},useQueryState:!0,contentDefault:"I",contentFA:''},underline:{name:"underline",action:"underline",aria:"underline",tagNames:["u"],style:{prop:"text-decoration",value:"underline"},useQueryState:!0,contentDefault:"U",contentFA:''},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:''},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:''},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:''},removeFormat:{name:"removeFormat",aria:"remove formatting",action:"removeFormat",contentDefault:"X",contentFA:''},quote:{name:"quote",action:"append-blockquote",aria:"blockquote",tagNames:["blockquote"],contentDefault:"“",contentFA:''},pre:{name:"pre",action:"append-pre",aria:"preformatted text",tagNames:["pre"],contentDefault:"0101",contentFA:''},h1:{name:"h1",action:"append-h1",aria:"header type one",tagNames:["h1"],contentDefault:"H1",contentFA:'
"],[new RegExp(/\n+/gi),""],["",""],["",""]]}s=e.extend({forcePlainText:!0,cleanPastedHTML:!1,cleanReplacements:[],cleanAttrs:["class","style","dir"],cleanTags:["meta"],init:function(){e.prototype.init.apply(this,arguments),(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.getEditorOption("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=/
"),void this.pasteHTML("
"+d.join("
")+"
")):this.pasteHTML(b)},pasteHTML:function(a,c){c=b.defaults({},c,{cleanAttrs:this.cleanAttrs,cleanTags:this.cleanTags});var d,e,f,g,h=this.document.createDocumentFragment();for(h.appendChild(this.document.createElement("body")),g=h.querySelector("body"),g.innerHTML=a,this.cleanupSpans(g),d=g.querySelectorAll("*"),f=0;f"+d.innerHTML+"":e.innerHTML=d.innerHTML,d.parentNode.replaceChild(e,d);for(f=a.querySelectorAll("span"),c=0;c0&&(d[0].classList.add(this.firstButtonClass),d[d.length-1].classList.add(this.lastButtonClass)),h},destroy:function(){this.toolbar&&(this.toolbar.parentNode&&this.toolbar.parentNode.removeChild(this.toolbar),delete this.toolbar)},getToolbarElement:function(){return this.toolbar||(this.toolbar=this.createToolbar()),this.toolbar},getToolbarActionsElement:function(){return this.getToolbarElement().querySelector(".medium-editor-toolbar-actions")},initThrottledMethods:function(){this.throttledPositionToolbar=b.throttle(function(){this.base.isActive&&this.positionToolbarIfShown()}.bind(this))},attachEventHandlers:function(){this.subscribe("blur",this.handleBlur.bind(this)),this.subscribe("focus",this.handleFocus.bind(this)),this.subscribe("editableClick",this.handleEditableClick.bind(this)),this.subscribe("editableKeyup",this.handleEditableKeyup.bind(this)),this.on(this.document.documentElement,"mouseup",this.handleDocumentMouseup.bind(this)),this["static"]&&this.sticky&&this.on(this.window,"scroll",this.handleWindowScroll.bind(this),!0),this.on(this.window,"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.trigger("showToolbar",{},this.base.getFocusedElement()))},hideToolbar:function(){this.isDisplayed()&&(this.getToolbarElement().classList.remove("medium-editor-toolbar-active"),this.trigger("hideToolbar",{},this.base.getFocusedElement()))},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.forEachExtension(function(a){a.hasForm&&a.isDisplayed()&&a.hideForm()})},multipleBlockElementsSelected:function(){var a=/<[^\/>][^>]*><\/[^>]+>/gim,c=new RegExp("<("+b.blockContainerElementNames.join("|")+")[^>]*>","g"),d=f.getSelectionHtml(this.document).replace(a,""),e=d.match(c);return!!e&&e.length>1},modifySelection:function(){var a=this.window.getSelection(),c=a.getRangeAt(0);if(this.standardizeSelectionStart&&c.startContainer.nodeValue&&c.startOffset===c.startContainer.nodeValue.length){var d=b.findAdjacentTextNodeWithContent(f.getSelectionElement(this.window),c.startContainer,this.document);if(d){for(var e=0;0===d.nodeValue.substr(e,1).trim().length;)e+=1;c=f.select(this.document,d,e,c.endContainer,c.endOffset)}}},checkState:function(){if(!this.base.preventSelectionUpdates){if(!this.base.getFocusedElement()||f.selectionInContentEditableFalse(this.window))return this.hideToolbar();var a=f.getSelectionElement(this.window);return!a||-1===this.getEditorElements().indexOf(a)||a.getAttribute("data-disable-toolbar")?this.hideToolbar():this.updateOnEmptySelection&&this["static"]?this.showAndUpdateToolbar():""===this.window.getSelection().toString().trim()||this.allowMultiParagraphSelection===!1&&this.multipleBlockElementsSelected()?this.hideToolbar():void this.showAndUpdateToolbar();
+
+}},showAndUpdateToolbar:function(){this.modifySelection(),this.setToolbarButtonStates(),this.trigger("positionToolbar",{},this.base.getFocusedElement()),this.showToolbarDefaultActions(),this.setToolbarPosition()},setToolbarButtonStates:function(){this.forEachExtension(function(a){"function"==typeof a.isActive&&"function"==typeof a.setInactive&&a.setInactive()}),this.checkActiveButtons()},checkActiveButtons:function(){var a,c=[],d=null,e=f.getSelectionRange(this.document),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&&(this.forEachExtension(function(a){return"function"==typeof a.queryCommandState&&(d=a.queryCommandState(),null!==d)?void(d&&"function"==typeof a.setActive&&a.setActive()):void c.push(a)}),a=f.getSelectedParentElement(e),this.getEditorElements().some(function(c){return b.isDescendant(c,a,!0)})))for(;a&&(c.forEach(g),!b.isMediumEditorElement(a));)a=a.parentNode},positionToolbarIfShown:function(){this.isDisplayed()&&this.setToolbarPosition()},setToolbarPosition:function(){var a,b=this.base.getFocusedElement(),c=this.window.getSelection();return b?(this["static"]?(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.document.documentElement&&this.document.documentElement.scrollTop||this.document.body.scrollTop,d=this.window.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.sticky?c>g+a.offsetHeight-i?(e.style.top=g+a.offsetHeight-i+"px",e.classList.remove("medium-editor-sticky-toolbar")):c>g-i?(e.classList.add("medium-editor-sticky-toolbar"),e.style.top="0px"):(e.classList.remove("medium-editor-sticky-toolbar"),e.style.top=g-i+"px"):e.style.top=g-i+"px",this.align){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.window.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.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 v;!function(){v=e.extend({init:function(){e.prototype.init.apply(this,arguments),this.subscribe("editableDrag",this.handleDrag.bind(this)),this.subscribe("editableDrop",this.handleDrop.bind(this))},handleDrag:function(a){var b="medium-editor-dragover";a.preventDefault(),a.dataTransfer.dropEffect="copy","dragover"===a.type?a.target.classList.add(b):"dragleave"===a.type&&a.target.classList.remove(b)},handleDrop:function(a){var c,d="medium-editor-dragover";a.preventDefault(),a.stopPropagation(),a.dataTransfer.files&&(c=Array.prototype.slice.call(a.dataTransfer.files,0),c.some(function(a){if(a.type.match("image")){var c,d;c=new FileReader,c.readAsDataURL(a),d="medium-img-"+ +new Date,b.insertHTMLCommand(this.document,''),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 w;return function(){w={button:h,form:i,anchor:j,anchorPreview:k,autoLink:l,fileDragging:p,fontSize:r,imageDragging:v,keyboardCommands:q,paste:s,placeholder:t,toolbar:u}}(),function(){function c(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 h(a){var c=f.getSelectionStart(this.options.ownerDocument),d=c&&c.nodeName.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 i(a){var c,d=f.getSelectionStart(this.options.ownerDocument),e=d.nodeName.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.nodeName.toLowerCase())?(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.nodeName.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 j(a){var c,d=f.getSelectionStart(this.options.ownerDocument);d&&(b.isMediumEditorElement(d)&&0===d.children.length&&this.options.ownerDocument.execCommand("formatBlock",!1,"p"),b.isKey(a,b.keyCode.ENTER)&&!b.isListItem(d)&&(c=d.nodeName.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 k(a){a._mediumEditors||(a._mediumEditors=[null]),this.id||(this.id=a._mediumEditors.length),a._mediumEditors[this.id]=this}function l(a){a._mediumEditors&&a._mediumEditors[this.id]&&(a._mediumEditors[this.id]=null)}function m(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.nodeName.toLowerCase()?x.call(this,a,b):a)},this)}function n(a,b){return Object.keys(b).forEach(function(c){void 0===a[c]&&(a[c]=b[c])}),a}function o(a,b,c){var d={window:c.options.contentWindow,document:c.options.ownerDocument,base:c};return a=n(a,d),"function"==typeof a.init&&a.init(),a.name||(a.name=b),a}function p(){return this.elements.every(function(a){return!!a.getAttribute("data-disable-toolbar")})?!1:this.options.toolbar!==!1}function q(){return p.call(this)?this.options.anchorPreview!==!1:!1}function r(){return this.options.placeholder!==!1}function s(){return this.options.autoLink!==!1}function t(){return this.options.imageDragging!==!1}function u(){return this.options.keyboardCommands!==!1}function v(){return!this.options.extensions.imageDragging}function x(a,b){var c=this.options.ownerDocument.createElement("div"),d="medium-editor-"+Date.now()+"-"+b,e=a.attributes;c.className=a.className,c.id=d,c.innerHTML=a.value,a.setAttribute("medium-editor-textarea-id",b);for(var f=0,g=e.length;g>f;f++)c.hasAttribute(e[f].nodeName)||c.setAttribute(e[f].nodeName,e[f].nodeValue);return a.classList.add("medium-editor-hidden"),a.parentNode.insertBefore(c,a),c}function y(){this.elements.forEach(function(a,b){this.options.disableEditing||a.getAttribute("data-disable-editing")||(a.setAttribute("contentEditable",!0),a.setAttribute("spellcheck",this.options.spellcheck)),a.setAttribute("data-medium-editor-element",!0),a.setAttribute("role","textbox"),a.setAttribute("aria-multiline",!0),a.setAttribute("medium-editor-index",b),a.hasAttribute("medium-editor-textarea-id")&&this.on(a,"input",function(a){var b=a.target,c=b.parentNode.querySelector('textarea[medium-editor-textarea-id="'+b.getAttribute("medium-editor-textarea-id")+'"]');c&&(c.value=this.serialize()[b.id].value)}.bind(this))},this)}function z(){var a;if(this.subscribe("editableKeydownTab",h.bind(this)),this.subscribe("editableKeydownDelete",i.bind(this)),this.subscribe("editableKeydownEnter",i.bind(this)),this.options.disableReturn||this.options.disableDoubleReturn)this.subscribe("editableKeydownEnter",c.bind(this));else for(a=0;a=0&&(c=f.exportSelection(a,this.options.ownerDocument)),null!==c&&0!==b&&(c.editableElementIndex=b),c},saveSelection:function(){this.selectionState=this.exportSelection()},importSelection:function(a,b){if(a){var c=this.elements[a.editableElementIndex||0];f.importSelection(a,c,this.options.ownerDocument,b)}},restoreSelection:function(){this.importSelection(this.selectionState)},createLink:function(a){var c,d,e;try{if(this.events.disableCustomEvent("editableInput"),a.url&&a.url.trim().length>0){var g=this.options.contentWindow.getSelection();if(g){var h,i,j,k,l=g.getRangeAt(0),m=l.commonAncestorContainer;if(3===l.endContainer.nodeType&&3!==l.startContainer.nodeType&&0===l.startOffset&&l.startContainer.firstChild===l.endContainer&&(m=l.endContainer),i=b.getClosestBlockContainer(l.startContainer),j=b.getClosestBlockContainer(l.endContainer),3!==m.nodeType&&i===j){c=f.getSelectionElement(this.options.contentWindow);var n=i||c,o=this.options.ownerDocument.createDocumentFragment();this.execAction("unlink"),h=this.exportSelection(),o.appendChild(n.cloneNode(!0)),c===n?f.select(this.options.ownerDocument,n.firstChild,0,n.lastChild,3===n.lastChild.nodeType?n.lastChild.nodeValue.length:n.lastChild.childNodes.length):f.select(this.options.ownerDocument,n,0,n,n.childNodes.length);var p=this.exportSelection();k=b.findOrCreateMatchingTextNodes(this.options.ownerDocument,o,{start:h.start-p.start,end:h.end-p.start,editableElementIndex:h.editableElementIndex}),b.createLink(this.options.ownerDocument,k,a.url.trim());var q=(o.firstChild.innerHTML.match(/^\s+/)||[""])[0].length;b.insertHTMLCommand(this.options.ownerDocument,o.firstChild.innerHTML.replace(/^\s+/,"")),h.start-=q,h.end-=q,this.importSelection(h)}else 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)}}if(this.options.targetBlank||"_blank"===a.target||a.buttonClass)for(d=this.options.ownerDocument.createEvent("HTMLEvents"),d.initEvent("input",!0,!0,this.options.contentWindow),e=0;e1?b[1]:"";return{major:parseInt(c[0],10),minor:parseInt(c[1],10),revision:parseInt(c[2],10),preRelease:d,toString:function(){return[c[0],c[1],c[2]].join(".")+(d?"-"+d:"")}}},a.version=a.parseVersionString.call(this,{version:"5.6.0"}.version),a}());
\ No newline at end of file
diff --git a/package.json b/package.json
index 5ea993a15..94de8e084 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "medium-editor",
- "version": "5.5.4",
+ "version": "5.6.0",
"author": "Davi Ferreira ",
"contributors": [
{
diff --git a/src/js/version.js b/src/js/version.js
index 5babb3ca8..5a0f422c4 100644
--- a/src/js/version.js
+++ b/src/js/version.js
@@ -17,5 +17,5 @@ MediumEditor.parseVersionString = function (release) {
MediumEditor.version = MediumEditor.parseVersionString.call(this, ({
// grunt-bump looks for this:
- 'version': '5.5.4'
+ 'version': '5.6.0'
}).version);