Can any one help me create a text editor component that works well on mobile?
I found a basic contenteditable directive. it works fine on a desktop browser, but not so much on a mobile device.
Application.Directives.directive('contenteditable', function () {
return {
restrict: 'A', // only activate on element attribute
require: '?ngModel', // get a hold of NgModelController
transclude: true,
scope:true,
link: function (scope, element, attrs, ngModel, storageService) {
if (!ngModel) return; // do nothing if no ng-model
element.attr('style', 'position:absolute;top:0;left:0;bottom:0;right:0;min-height:400px');
// Specify how UI should be updated
ngModel.$render = function () {
element.html(localStorage.getItem(scope.storageKey));
};
// Listen for change events to enable binding
element.on('blur keyup change', function () {
scope.$apply(readViewText);
localStorage.setItem(scope.storageKey, ngModel.$viewValue)
console.info(localStorage.getItem(scope.storageKey))
});
// No need to initialize, AngularJS will initialize the text based on ng-model attribute
// Write data to the model
function readViewText() {
var html = element.html();
// When we clear the content editable the browser leaves a <br> behind
// If strip-br attribute is provided then we strip this out
if (attrs.stripBr && html == '<br>') {
html = '';
}
ngModel.$setViewValue(html);
}
}
};
});
I need it to also play nice with other ionic components. I.e. having my editor component inside an ion-content with scroll does not play nice on mobile. I read somewhere that there was a fix for this but my experience has the keyboard appearing on touch, but the cursor does not show up and i cannot actually type anthing. Typing works when I disable scroll.
Is there anyway to mimic the notepad app on iphone, but extend it with some editor controls (bullet points, tabbing, etc)
Thanks in advance