diff --git a/CHANGES.md b/CHANGES.md
index b39f82cad..2ce9648f4 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -1,3 +1,8 @@
+5.5.0 / 2015-07-21
+==================
+* Add setContent method into core API, which triggers editableInput
+
+
5.4.1 / 2015-07-20
==================
* Fix issue where custom anchor-preview extensions weren't overriding built-in anchor preview
diff --git a/dist/js/medium-editor.js b/dist/js/medium-editor.js
index 390ef6ecd..c0a81d87f 100644
--- a/dist/js/medium-editor.js
+++ b/dist/js/medium-editor.js
@@ -2541,6 +2541,9 @@ var Events;
},
updateInput: function (target, eventObj) {
+ if (!this.contentCache) {
+ return;
+ }
// An event triggered which signifies that the user may have changed someting
// Look in our cache of input for the contenteditables to see if something changed
var index = target.getAttribute('medium-editor-index');
@@ -6186,6 +6189,16 @@ function MediumEditor(elements, options) {
pasteHTML: function (html, options) {
this.getExtensionByName('paste').pasteHTML(html, options);
+ },
+
+ setContent: function (html, index) {
+ index = index || 0;
+
+ if (this.elements[index]) {
+ var target = this.elements[index];
+ target.innerHTML = html;
+ this.events.updateInput(target, { target: target, currentTarget: target });
+ }
}
};
}());
@@ -6207,7 +6220,7 @@ MediumEditor.parseVersionString = function (release) {
MediumEditor.version = MediumEditor.parseVersionString.call(this, ({
// grunt-bump looks for this:
- 'version': '5.4.1'
+ 'version': '5.5.0'
}).version);
return MediumEditor;
diff --git a/dist/js/medium-editor.min.js b/dist/js/medium-editor.min.js
index 271bf64e7..d2fd42e7b 100644
--- a/dist/js/medium-editor.min.js
+++ b/dist/js/medium-editor.min.js
@@ -1,5 +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.defaultView.getSelection(),d.getRangeAt&&d.rangeCount){if(e=d.getRangeAt(0),j=e.commonAncestorContainer,3===j.nodeType&&j.nodeValue===e.toString()||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,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.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.offset)}}},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=["data-disable-editing","data-disable-toolbar","data-placeholder","data-disable-return","data-disable-double-return","data-disable-preview","spellcheck"];return c.className=a.className,c.id=d,c.innerHTML=a.value,c.setAttribute("medium-editor-textarea-id",b),e.forEach(function(b){a.hasAttribute(b)&&c.setAttribute(b,a.getAttribute(b))}),a.classList.add("medium-editor-hidden"),a.setAttribute("medium-editor-textarea-id",b),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;if(h=b.getClosestBlockContainer(e.getRangeAt(0).startContainer),i=b.getClosestBlockContainer(e.getRangeAt(0).endContainer),h===i){var k=f.getSelectionElement(this.options.contentWindow),l=h||k,m=this.options.ownerDocument.createDocumentFragment();g=this.exportSelection(),m.appendChild(l.cloneNode(!0)),k===l?f.select(this.options.ownerDocument,l.firstChild,0,l.lastChild,3===l.lastChild.nodeType?l.lastChild.nodeValue.length:l.lastChild.childNodes.length):f.select(this.options.ownerDocument,l,0,l,l.childNodes.length);var n=this.exportSelection();j=b.findOrCreateMatchingTextNodes(this.options.ownerDocument,m,{start:g.start-n.start,end:g.end-n.start,editableElementIndex:g.editableElementIndex}),b.createLink(this.options.ownerDocument,j,a.url.trim());var o=(m.firstChild.innerHTML.match(/^\s+/)||[""])[0].length;b.insertHTMLCommand(this.options.ownerDocument,m.firstChild.innerHTML.replace(/^\s+/,"")),g.start-=o,g.end-=o,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.4.1"}.version),a}());
\ No newline at end of file
+};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=["data-disable-editing","data-disable-toolbar","data-placeholder","data-disable-return","data-disable-double-return","data-disable-preview","spellcheck"];return c.className=a.className,c.id=d,c.innerHTML=a.value,c.setAttribute("medium-editor-textarea-id",b),e.forEach(function(b){a.hasAttribute(b)&&c.setAttribute(b,a.getAttribute(b))}),a.classList.add("medium-editor-hidden"),a.setAttribute("medium-editor-textarea-id",b),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;if(h=b.getClosestBlockContainer(e.getRangeAt(0).startContainer),i=b.getClosestBlockContainer(e.getRangeAt(0).endContainer),h===i){var k=f.getSelectionElement(this.options.contentWindow),l=h||k,m=this.options.ownerDocument.createDocumentFragment();g=this.exportSelection(),m.appendChild(l.cloneNode(!0)),k===l?f.select(this.options.ownerDocument,l.firstChild,0,l.lastChild,3===l.lastChild.nodeType?l.lastChild.nodeValue.length:l.lastChild.childNodes.length):f.select(this.options.ownerDocument,l,0,l,l.childNodes.length);var n=this.exportSelection();j=b.findOrCreateMatchingTextNodes(this.options.ownerDocument,m,{start:g.start-n.start,end:g.end-n.start,editableElementIndex:g.editableElementIndex}),b.createLink(this.options.ownerDocument,j,a.url.trim());var o=(m.firstChild.innerHTML.match(/^\s+/)||[""])[0].length;b.insertHTMLCommand(this.options.ownerDocument,m.firstChild.innerHTML.replace(/^\s+/,"")),g.start-=o,g.end-=o,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.0"}.version),a}());
\ No newline at end of file
diff --git a/package.json b/package.json
index d8e893ac4..3bc89d0c0 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "medium-editor",
- "version": "5.4.1",
+ "version": "5.5.0",
"author": "Davi Ferreira ",
"contributors": [
{
diff --git a/src/js/version.js b/src/js/version.js
index 29ef78111..c7e8c6c39 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.4.1'
+ 'version': '5.5.0'
}).version);