Skip to content

Commit

Permalink
4.12.6
Browse files Browse the repository at this point in the history
  • Loading branch information
j0k3r committed Jun 28, 2015
1 parent bbbf2bd commit 0c98deb
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 18 deletions.
33 changes: 21 additions & 12 deletions dist/js/medium-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -2104,6 +2104,12 @@ var Events;
this.detachAllDOMEvents();
this.detachAllCustomEvents();
this.detachExecCommand();

if (this.base.elements) {
this.base.elements.forEach(function (element) {
element.removeAttribute('data-medium-focused');
});
}
},

// Listening to calls to document.execCommand
Expand Down Expand Up @@ -5221,10 +5227,10 @@ var Toolbar;

// Checks for existance of multiple block elements in the current selection
multipleBlockElementsSelected: function () {
/*jslint regexp: true*/
var selectionHtml = Selection.getSelectionHtml.call(this).replace(/<[\S]+><\/[\S]+>/gim, ''),
hasMultiParagraphs = selectionHtml.match(/<(p|h[1-6]|blockquote)[^>]*>/g);
/*jslint regexp: false*/
var regexEmptyHTMLTags = /<[^\/>][^>]*><\/[^>]+>/gim, // http://stackoverflow.com/questions/3129738/remove-empty-tags-using-regex
regexBlockElements = new RegExp('<(' + Util.parentElements.join('|') + ')[^>]*>', 'g'),
selectionHTML = Selection.getSelectionHtml.call(this).replace(regexEmptyHTMLTags, ''), // Filter out empty blocks from selection
hasMultiParagraphs = selectionHTML.match(regexBlockElements); // Find how many block elements are within the html

return !!hasMultiParagraphs && hasMultiParagraphs.length > 1;
},
Expand Down Expand Up @@ -5705,9 +5711,9 @@ function MediumEditor(elements, options) {

// Loop through elements and convert textarea's into divs
this.elements = [];
elements.forEach(function (element) {
elements.forEach(function (element, index) {
if (element.tagName.toLowerCase() === 'textarea') {
this.elements.push(createContentEditable.call(this, element));
this.elements.push(createContentEditable.call(this, element, index));
} else {
this.elements.push(element);
}
Expand Down Expand Up @@ -5813,9 +5819,9 @@ function MediumEditor(elements, options) {
return this.options.imageDragging !== false;
}

function createContentEditable(textarea) {
function createContentEditable(textarea, id) {
var div = this.options.ownerDocument.createElement('div'),
id = (+new Date()),
uniqueId = 'medium-editor-' + Date.now() + '-' + id,
attributesToClone = [
'data-disable-editing',
'data-disable-toolbar',
Expand All @@ -5827,7 +5833,7 @@ function MediumEditor(elements, options) {
];

div.className = textarea.className;
div.id = id;
div.id = uniqueId;
div.innerHTML = textarea.value;
div.setAttribute('medium-editor-textarea-id', id);
attributesToClone.forEach(function (attr) {
Expand Down Expand Up @@ -6165,6 +6171,8 @@ function MediumEditor(elements, options) {
delete this.toolbar;
}

this.events.destroy();

this.elements.forEach(function (element) {
// Reset elements content, fix for issue where after editor destroyed the red underlines on spelling errors are left
if (this.options.spellcheck) {
Expand All @@ -6174,6 +6182,9 @@ function MediumEditor(elements, options) {
element.removeAttribute('contentEditable');
element.removeAttribute('spellcheck');
element.removeAttribute('data-medium-element');
element.removeAttribute('medium-editor-index');
element.removeAttribute('role');
element.removeAttribute('aria-multiline');

// Remove any elements created for textareas
if (element.hasAttribute('medium-editor-textarea-id')) {
Expand All @@ -6188,8 +6199,6 @@ function MediumEditor(elements, options) {
}
}, this);
this.elements = [];

this.events.destroy();
},

on: function (target, event, listener, useCapture) {
Expand Down Expand Up @@ -6615,7 +6624,7 @@ MediumEditor.version = (function (major, minor, revision) {
};
}).apply(this, ({
// grunt-bump looks for this:
'version': '4.12.5'
'version': '4.12.6'
}).version.split('.'));

return MediumEditor;
Expand Down
8 changes: 4 additions & 4 deletions dist/js/medium-editor.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "medium-editor",
"version": "4.12.5",
"version": "4.12.6",
"author": "Davi Ferreira <hi@daviferreira.com>",
"contributors": [
{
Expand Down
2 changes: 1 addition & 1 deletion src/js/version.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ MediumEditor.version = (function (major, minor, revision) {
};
}).apply(this, ({
// grunt-bump looks for this:
'version': '4.12.5'
'version': '4.12.6'
}).version.split('.'));

0 comments on commit 0c98deb

Please sign in to comment.