Skip to content

Commit

Permalink
Fixes #127
Browse files Browse the repository at this point in the history
  • Loading branch information
Davi Ferreira committed Jan 13, 2014
1 parent 1af1211 commit 2742af3
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 3 deletions.
19 changes: 18 additions & 1 deletion dist/js/medium-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ if (typeof module === 'object') {
node = getSelectionStart();
tagName = node.tagName.toLowerCase();
if (!(self.options.disableReturn || this.getAttribute('data-disable-return'))
&& tagName !== 'li') {
&& tagName !== 'li' && !self.isListItemChild(node)) {
document.execCommand('formatBlock', false, 'p');
if (tagName === 'a') {
document.execCommand('unlink', false, null);
Expand All @@ -179,6 +179,23 @@ if (typeof module === 'object') {
return this;
},

isListItemChild: function (node) {
var parentNode = node.parentNode,
tagName = parentNode.tagName.toLowerCase();
while (this.parentElements.indexOf(tagName) === -1 && tagName !== 'div') {
if (tagName === 'li') {
return true;
}
parentNode = parentNode.parentNode;
if (parentNode && parentNode.tagName) {
tagName = parentNode.tagName.toLowerCase();
} else {
return false;
}
}
return false;
},

bindReturn: function (index) {
var self = this;
this.elements[index].addEventListener('keypress', function (e) {
Expand Down
Loading

0 comments on commit 2742af3

Please sign in to comment.