Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
ichord committed Feb 11, 2015
1 parent 496c2ff commit a03e6be
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 42 deletions.
17 changes: 3 additions & 14 deletions lib/simditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -763,7 +763,7 @@ InputManager = (function(_super) {
};

InputManager.prototype._onKeyDown = function(e) {
var $blockEl, $newBlockEl, metaKey, result, _base, _ref, _ref1;
var result, _base, _ref, _ref1;
if (this.editor.triggerHandler(e) === false) {
return false;
}
Expand Down Expand Up @@ -797,21 +797,10 @@ InputManager = (function(_super) {
if ((_ref = e.which, __indexOf.call(this._modifierKeys, _ref) >= 0) || (_ref1 = e.which, __indexOf.call(this._arrowKeys, _ref1) >= 0)) {
return;
}
metaKey = this.editor.util.metaKey(e);
$blockEl = this.editor.util.closestBlockEl();
if (metaKey && e.which === 86) {
if (this.editor.util.metaKey(e) && e.which === 86) {
return;
}
if (this.editor.util.browser.webkit && e.which === 8 && this.editor.selection.rangeAtStartOf($blockEl)) {
if (!this.focused) {
return;
}
$newBlockEl = this.editor.util.closestBlockEl();
this.editor.selection.save();
this.editor.formatter.cleanNode($newBlockEl, true);
this.editor.selection.restore();
}
if (this.editor.util.support.oninput) {
if (!this.editor.util.support.oninput) {
this.throttledTrigger('valuechanged', ['typing']);
}
return null;
Expand Down
17 changes: 3 additions & 14 deletions site/assets/scripts/simditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -763,7 +763,7 @@ InputManager = (function(_super) {
};

InputManager.prototype._onKeyDown = function(e) {
var $blockEl, $newBlockEl, metaKey, result, _base, _ref, _ref1;
var result, _base, _ref, _ref1;
if (this.editor.triggerHandler(e) === false) {
return false;
}
Expand Down Expand Up @@ -797,21 +797,10 @@ InputManager = (function(_super) {
if ((_ref = e.which, __indexOf.call(this._modifierKeys, _ref) >= 0) || (_ref1 = e.which, __indexOf.call(this._arrowKeys, _ref1) >= 0)) {
return;
}
metaKey = this.editor.util.metaKey(e);
$blockEl = this.editor.util.closestBlockEl();
if (metaKey && e.which === 86) {
if (this.editor.util.metaKey(e) && e.which === 86) {
return;
}
if (this.editor.util.browser.webkit && e.which === 8 && this.editor.selection.rangeAtStartOf($blockEl)) {
if (!this.focused) {
return;
}
$newBlockEl = this.editor.util.closestBlockEl();
this.editor.selection.save();
this.editor.formatter.cleanNode($newBlockEl, true);
this.editor.selection.restore();
}
if (this.editor.util.support.oninput) {
if (!this.editor.util.support.oninput) {
this.throttledTrigger('valuechanged', ['typing']);
}
return null;
Expand Down
16 changes: 2 additions & 14 deletions src/inputManager.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -208,22 +208,10 @@ class InputManager extends SimpleModule

if e.which in @_modifierKeys or e.which in @_arrowKeys
return

metaKey = @editor.util.metaKey e
$blockEl = @editor.util.closestBlockEl()

# paste shortcut
return if metaKey and e.which == 86

if @editor.util.browser.webkit and e.which == 8 and @editor.selection.rangeAtStartOf $blockEl
# fix the span bug in webkit browsers
return unless @focused
$newBlockEl = @editor.util.closestBlockEl()
@editor.selection.save()
@editor.formatter.cleanNode $newBlockEl, true
@editor.selection.restore()
return if @editor.util.metaKey(e) and e.which == 86

if @editor.util.support.oninput
unless @editor.util.support.oninput
@throttledTrigger 'valuechanged', ['typing']

null
Expand Down

0 comments on commit a03e6be

Please sign in to comment.