You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on May 25, 2019. It is now read-only.
I worked on a patch that may help you for the next release:
Let me know if you fix it.
Regards,
Benjamin
// Keep the ngModel in sync with changes from CodeMirror
codemirror.on('change', function(instance) {
var modeDebug = false;
var newValue = instance.getValue();
// patch for enter key
if (newValue.endsWith('\n')) {
if (modeDebug) console.log('patch: last char is eol');
var cursor = codemirror.getCursor();
cursor.line += 1;
cursor.ch = 0;
codemirror.setCursor(cursor); // /!\ need to be improve with smart indent !
}
// patch for space key
else if (newValue.endsWith(' ')) {
if (modeDebug) console.log('patch: last char is a space');
var cursor = codemirror.getCursor();
cursor.ch += 1;
// ngModel.$setViewValue(newValue); // DO NOT SET new value (trim it !)
codemirror.setCursor(cursor);
}
else if (newValue !== ngModel.$viewValue) {
// BUG: cursor returns at position 0 using keys 'space' or 'enter'
// => see previous patches
scope.$evalAsync(function() {
if (modeDebug) console.log('sync ng model');
ngModel.$setViewValue(newValue);
});
}
});
}
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Hi,
Using textarea with ng-model, cursor returns at the position 0 if I press 'space' or 'enter' keys.
It is OK without ng-model !
The text was updated successfully, but these errors were encountered: