Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Trigger the blur event only if there is no selection #11

Merged
merged 1 commit into from

2 participants

@benbro

Improves #10

@timjb timjb merged commit 85e0d20 into Operational-Transformation:master

1 check failed

Details default The Travis build failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 8 additions and 2 deletions.
  1. +8 −2 lib/codemirror-adapter.js
View
10 lib/codemirror-adapter.js
@@ -12,7 +12,7 @@ ot.CodeMirrorAdapter = (function () {
var self = this;
cm.on('change', function (_, change) { self.onChange(change); });
cm.on('cursorActivity', function () { self.trigger('cursorActivity'); });
- cm.on('blur', function () { self.trigger('blur'); });
+ cm.on('blur', function () { self.onBlur(); });
}
// The oldValue is needed to find
@@ -143,6 +143,12 @@ ot.CodeMirrorAdapter = (function () {
this.oldValue = this.cm.getValue();
};
+ CodeMirrorAdapter.prototype.onBlur = function () {
+ if(!cm.getSelection()) {
+ this.trigger('blur');
+ }
+ }
+
CodeMirrorAdapter.prototype.getValue = function () {
return this.oldValue;
};
@@ -255,4 +261,4 @@ ot.CodeMirrorAdapter = (function () {
return CodeMirrorAdapter;
-}());
+}());
Something went wrong with that request. Please try again.