Comments (1)
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);
});
}
});
}
from ui-codemirror.
Related Issues (20)
- Unknown Provider error when using minified ui-codemirror.js HOT 8
- Refresh problems when switching pages HOT 3
- Form being marked as dirty when text contains line breaks preceeded by a space
- Can't see directive's scope when embedded in a custom directive HOT 1
- ui-codemirror needs CodeMirror to work... (o rly?) HOT 3
- Initial options do not get set due to $digest equality checks
- help me
- Two way databinding HOT 1
- [question] z-index set to 2
- How i can get value from ui-codemirror?
- Controller for ui-codemirror directive
- Indentation with ng-model
- copy (ctr + C) not working when use readOnly HOT 1
- Flick from a textarea to a ui-codemirror frame
- Error: uiCodemirror3 can only be applied to a textarea element HOT 1
- programaticaly adding content to ui-codemirror makes scrollbars buggy
- Cannot edit ui-codemirror in a taskpane of an add-in in Excel for Windows
- Is this dead?
- Live autocomplete support
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.