Skip to content

Commit

Permalink
Fixes #33
Browse files Browse the repository at this point in the history
  • Loading branch information
daviferreira committed Oct 5, 2013
1 parent 96b463e commit 152757c
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 13 deletions.
20 changes: 14 additions & 6 deletions dist/js/medium-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ function MediumEditor(elements, options) {
'use strict';
return this.init(elements, options);
}

(function (window, document) {
'use strict';

Expand Down Expand Up @@ -114,6 +115,10 @@ function MediumEditor(elements, options) {
if (e.which === 13 && !e.shiftKey) {
if (!(self.options.disableReturn || this.getAttribute('data-disable-return'))) {
document.execCommand('formatBlock', false, 'p');
node = getSelectionStart();
if (node.tagName.toLowerCase() === 'a') {
document.execCommand('unlink', null, false);
}
}
}
});
Expand Down Expand Up @@ -389,17 +394,18 @@ function MediumEditor(elements, options) {

showToolbarActions: function () {
var self = this,
timeoutWrapper = function () {
self.keepToolbarAlive = false;
self.toolbar.style.display = 'none';
document.removeEventListener('click', timeoutWrapper);
},
timer;
this.anchorForm.style.display = 'none';
this.toolbarActions.style.display = 'block';
this.keepToolbarAlive = false;
clearTimeout(timer);
timer = setTimeout(function () {
document.addEventListener('click', function () {
self.keepToolbarAlive = false;
self.toolbar.style.display = 'none';
document.removeEventListener('click', this);
});
document.addEventListener('click', timeoutWrapper);
}, 300);
},

Expand Down Expand Up @@ -436,7 +442,7 @@ function MediumEditor(elements, options) {

createLink: function (input) {
restoreSelection(this.savedSelection);
document.execCommand('CreateLink', false, input.value);
document.execCommand('createLink', false, input.value);
this.showToolbarActions();
input.value = '';
},
Expand Down Expand Up @@ -517,5 +523,7 @@ function MediumEditor(elements, options) {
}
return this;
}

};

}(window, document));
Loading

0 comments on commit 152757c

Please sign in to comment.