Skip to content

Commit

Permalink
4.12.5
Browse files Browse the repository at this point in the history
  • Loading branch information
nmielnik committed Jun 16, 2015
1 parent 21cbef0 commit 1bc86ab
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 12 deletions.
5 changes: 5 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
4.12.5 / 2015-06-16
==================
* Fix issue with restoring selection within nested block elements


4.12.4 / 2015-06-15
==================
* Ensure auto-link will never select an empty element (br, hr, input, etc.)
Expand Down
21 changes: 14 additions & 7 deletions dist/js/medium-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -794,7 +794,7 @@ var Util;

var parentNode = node.parentNode,
tagName = parentNode.tagName.toLowerCase();
while (this.parentElements.indexOf(tagName) === -1 && tagName !== 'div') {
while (!this.isBlockContainer(parentNode) && tagName !== 'div') {
if (tagName === 'li') {
return true;
}
Expand Down Expand Up @@ -1050,8 +1050,7 @@ var Util;
isElementAtBeginningOfBlock: function (node) {
var textVal,
sibling;
while (node.nodeType === 3 ||
(this.parentElements.indexOf(node.tagName.toLowerCase()) === -1 && !node.getAttribute('data-medium-element'))) { // TODO: Change this in v5.0.0
while (!this.isBlockContainer(node) && !this.isMediumEditorElement(node)) {
sibling = node;
while (sibling = sibling.previousSibling) {
textVal = sibling.nodeType === 3 ? sibling.nodeValue : sibling.textContent;
Expand All @@ -1064,9 +1063,17 @@ var Util;
return true;
},

isMediumEditorElement: function (element) {
return element && element.nodeType !== 3 && !!element.getAttribute('data-medium-element');
},

isBlockContainer: function (element) {
return element && element.nodeType !== 3 && this.parentElements.indexOf(element.nodeName.toLowerCase()) !== -1;
},

getBlockContainer: function (element) {
return this.traverseUp(element, function (el) {
return Util.parentElements.indexOf(el.tagName.toLowerCase()) !== -1;
return Util.isBlockContainer(el) && !Util.isBlockContainer(el.parentNode);
});
},

Expand Down Expand Up @@ -1714,7 +1721,7 @@ var Selection;
'use strict';

function filterOnlyParentElements(node) {
if (Util.parentElements.indexOf(node.nodeName.toLowerCase()) !== -1) {
if (Util.isBlockContainer(node)) {
return NodeFilter.FILTER_ACCEPT;
} else {
return NodeFilter.FILTER_SKIP;
Expand Down Expand Up @@ -1987,7 +1994,7 @@ var Selection;
tagName = el.tagName.toLowerCase();
}

while (el && Util.parentElements.indexOf(tagName) === -1) {
while (el && !Util.isBlockContainer(el)) {
el = el.parentNode;
if (el && el.tagName) {
tagName = el.tagName.toLowerCase();
Expand Down Expand Up @@ -6608,7 +6615,7 @@ MediumEditor.version = (function (major, minor, revision) {
};
}).apply(this, ({
// grunt-bump looks for this:
'version': '4.12.4'
'version': '4.12.5'
}).version.split('.'));

return MediumEditor;
Expand Down
6 changes: 3 additions & 3 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.4",
"version": "4.12.5",
"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.4'
'version': '4.12.5'
}).version.split('.'));

0 comments on commit 1bc86ab

Please sign in to comment.