ckeditor - AngularJS causing textarea focus loss -
my web app deployed angularjs 1.3.7, wakanda 10.187175, etc...
when app angular/wakanda .save()
, textarea
cursor position moved 0,0
this happens in chrome , safari.
updating current version of angularjs not option @ time.
.directive ('ckeditor', function () { return { require: '?ngmodel', link: function($scope, $elm, attr, ngmodel) { var config = { toolbar:[ { name: 'paragraph', items: [ 'numberedlist', 'bulletedlist'] }, { name: 'clipboard', items: [ 'cut', 'copy', 'paste', '-', 'undo', 'redo'] }, { name: 'insert', items: [ 'specialchar'] }, { name: 'editing', items: [ 'scayt', 'options', 'dictionaries', 'check spelling'] } ] };//, 'pastetext', 'pastefromword' config.toolbarlocation = 'top'; config.scayt_autostartup = true; config.autoparagraph = true; config.title = false; config.tabspaces = 4; var ck = ckeditor.inline ($elm[0], config); $scope.lastapply = new date(); $scope.lastsave = new date(); $scope.savestorytimeout = null; $scope.tohtml = false; if (!ngmodel) return; ck.on('change', function( evt ) { console.log(new date().tostring().substring(16,24),'change'); var words = evt.editor.getdata(); if(words) { if($scope.savestorytimeout) { cleartimeout($scope.savestorytimeout); } $scope.savestorytimeout = settimeout(function () {$scope.savestorynow(null,'auto'); }, 1000 * 3); } }); ck.on('activeentermodechange', function() { console.log(new date().tostring().substring(16,24),'activeentermodechange'); } ); ck.on('activefilterchange', function() { console.log(new date().tostring().substring(16,24),'activefilterchange'); } ); ck.on('aftercommandexec', function() { console.log(new date().tostring().substring(16,24),'aftercommandexec'); } ); ck.on('afterinserthtml', function() { console.log(new date().tostring().substring(16,24),'afterinserthtml'); } ); ck.on('afterpaste', function() { console.log(new date().tostring().substring(16,24),'afterpaste'); } ); ck.on('aftersetdata', function() { console.log(new date().tostring().substring(16,24),'aftersetdata'); } ); ck.on('afterundoimage', function(evt) { console.log(new date().tostring().substring(16,24),'afterundoimage'); } ); ck.on('ariaeditorhelplabel', function() { console.log(new date().tostring().substring(16,24),'ariaeditorhelplabel'); } ); ck.on('ariawidget', function() { console.log(new date().tostring().substring(16,24),'ariawidget'); } ); ck.on('autogrow', function() { console.log(new date().tostring().substring(16,24),'autogrow'); } ); ck.on('beforecommandexec', function() { console.log(new date().tostring().substring(16,24),'beforecommandexec'); } ); ck.on('beforegetdata', function(evt) { console.log(new date().tostring().substring(16,24),'beforegetdata'); } ); ck.on('beforemodeunload', function() { console.log(new date().tostring().substring(16,24),'beforemodeunload'); } ); ck.on('beforesetmode', function() { console.log(new date().tostring().substring(16,24),'beforesetmode'); } ); ck.on('beforeundoimage', function(evt) { console.log(new date().tostring().substring(16,24),'beforeundoimage'); } ); ck.on('blur', function() { console.log(new date().tostring().substring(16,24),'blur'); } ); ck.on('change', function(evt) { console.log(new date().tostring().substring(16,24),'change'); } ); ck.on('configloaded', function() { console.log(new date().tostring().substring(16,24),'configloaded'); } ); ck.on('contentdirchanged', function() { console.log(new date().tostring().substring(16,24),'contentdirchanged'); } ); ck.on('contentdom', function() { console.log(new date().tostring().substring(16,24),'contentdom'); } ); ck.on('contentdominvalidated', function() { console.log(new date().tostring().substring(16,24),'contentdominvalidated'); } ); ck.on('contentdomunload', function() { console.log(new date().tostring().substring(16,24),'contentdomunload'); } ); ck.on('customconfigloaded', function() { console.log(new date().tostring().substring(16,24),'customconfigloaded'); } ); ck.on('datafiltered', function() { console.log(new date().tostring().substring(16,24),'datafiltered'); } ); ck.on('dataready', function(evt) { console.log(new date().tostring().substring(16,24),'dataready'); //$scope.restorecursor(evt); } ); ck.on('destroy', function() { console.log(new date().tostring().substring(16,24),'destroy'); } ); ck.on('dialoghide', function() { console.log(new date().tostring().substring(16,24),'dialoghide'); } ); ck.on('dialogshow', function() { console.log(new date().tostring().substring(16,24),'dialogshow'); } ); ck.on('dirchanged', function() { console.log(new date().tostring().substring(16,24),'dirchanged'); } ); ck.on('doubleclick', function() { console.log(new date().tostring().substring(16,24),'doubleclick'); } ); ck.on('dragend', function() { console.log(new date().tostring().substring(16,24),'dragend'); } ); ck.on('dragstart', function() { console.log(new date().tostring().substring(16,24),'dragstart'); } ); ck.on('drop', function() { console.log(new date().tostring().substring(16,24),'drop'); } ); ck.on('elementspathupdate', function() { console.log(new date().tostring().substring(16,24),'elementspathupdate'); } ); ck.on('fileuploadrequest', function() { console.log(new date().tostring().substring(16,24),'fileuploadrequest'); } ); ck.on('fileuploadresponse', function() { console.log(new date().tostring().substring(16,24),'fileuploadresponse'); } ); ck.on('floatingspacelayout', function() { console.log(new date().tostring().substring(16,24),'floatingspacelayout'); } ); ck.on('focus', function() { console.log(new date().tostring().substring(16,24),'focus'); } ); ck.on('getdata', function(evt) { console.log(new date().tostring().substring(16,24),'getdata'); } ); ck.on('getsnapshot', function(evt) { console.log(new date().tostring().substring(16,24),'getsnapshot'); } ); ck.on('insertelement', function() { console.log(new date().tostring().substring(16,24),'insertelement'); } ); ck.on('inserthtml', function() { console.log(new date().tostring().substring(16,24),'inserthtml'); } ); ck.on('inserttext', function() { console.log(new date().tostring().substring(16,24),'inserttext'); } ); ck.on('instanceready', function() { console.log(new date().tostring().substring(16,24),'instanceready'); } ); ck.on('key', function( evt) { console.log(new date().tostring().substring(16,24),'key: ' + evt.data.keycode); $scope.lastkey = evt.data.keycode;} ); ck.on('langloaded', function() { console.log(new date().tostring().substring(16,24),'langloaded'); } ); ck.on('loadsnapshot', function() { console.log(new date().tostring().substring(16,24),'loadsnapshot'); } ); ck.on('loaded', function() { console.log(new date().tostring().substring(16,24),'loaded'); } ); ck.on('locksnapshot', function() { console.log(new date().tostring().substring(16,24),'locksnapshot'); } ); ck.on('maximize', function() { console.log(new date().tostring().substring(16,24),'maximize'); } ); ck.on('menushow', function() { console.log(new date().tostring().substring(16,24),'menushow'); } ); ck.on('mode', function() { console.log(new date().tostring().substring(16,24),'mode'); } ); ck.on('notificationhide', function() { console.log(new date().tostring().substring(16,24),'notificationhide'); } ); ck.on('notificationshow', function() { console.log(new date().tostring().substring(16,24),'notificationshow'); } ); ck.on('notificationupdate', function() { console.log(new date().tostring().substring(16,24),'notificationupdate'); } ); ck.on('paste', function() { console.log(new date().tostring().substring(16,24),'paste'); } ); ck.on('pluginsloaded', function() { console.log(new date().tostring().substring(16,24),'pluginsloaded'); } ); ck.on('readonly', function() { console.log(new date().tostring().substring(16,24),'readonly'); } ); ck.on('removeformatcleanup', function() { console.log(new date().tostring().substring(16,24),'removeformatcleanup'); } ); ck.on('required', function() { console.log(new date().tostring().substring(16,24),'required'); } ); ck.on('resize', function() { console.log(new date().tostring().substring(16,24),'resize'); } ); ck.on('save', function() { console.log(new date().tostring().substring(16,24),'save'); } ); ck.on('savesnapshot', function(evt) { console.log(new date().tostring().substring(16,24),'savesnapshot: '); } ); ck.on('selectionchange', function() { console.log(new date().tostring().substring(16,24),'selectionchange'); } ); ck.on('setdata', function() { console.log(new date().tostring().substring(16,24),'setdata'); } ); ck.on('stylesset', function() { console.log(new date().tostring().substring(16,24),'stylesset'); } ); ck.on('template', function() { console.log(new date().tostring().substring(16,24),'template'); } ); ck.on('todataformat', function(evt) { console.log(new date().tostring().substring(16,24),'todataformat'); } ); //ck.on( 'tohtml', function( evt) { // //$scope.tohtml = true; //}, null, null, 15 ); ck.on('tohtml', function() { console.log(new date().tostring().substring(16,24),'tohtml'); } ); ck.on('unlocksnapshot', function() { console.log(new date().tostring().substring(16,24),'unlocksnapshot'); } ); ck.on('updatesnapshot', function() { console.log(new date().tostring().substring(16,24),'updatesnapshot'); } ); ck.on('widgetdefinition', function() { console.log(new date().tostring().substring(16,24),'widgetdefinition'); } ); ngmodel.$render = function (value) { if($scope.story && $scope.story.content) { ck.setdata($scope.story.content); } }; $scope.$on("$destroy",function() { ckeditor.instances[ck.name].destroy(); }); } }; }) $scope.handlestorysavecancel = function(action) { console.log('[storydetailctrl] $scope.handlestorysavecancel: start'); if($scope.savestorytimeout) { cleartimeout($scope.savestorytimeout); } $scope.lastapply = new date(); if(action && action == 'save') { $scope.story.content = ckeditor.instances.storycontent.getdata(); $scope.story.headline = document.getelementbyid('headline').value; if( $scope.headline === $scope.story.headline && $scope.content === $scope.story.content && $scope.status === $scope.story.status && $scope.journalist === $scope.story.journalist_id && $scope.editor === $scope.story.editor_id) { console.log('[storydetailctrl] $scope.handlestorysavecancel: $scope.storyoriginal === $scope.story'); $state.go('story.list', { storyid : $stateparams.storyid, pubid : $stateparams.pubid }); } else { $scope.story.$save().then(function(e){ console.log('[storydetailctrl] $scope.handlestorysavecancel: $scope.story.$save().then: end'); $state.go('story.list', { storyid : $stateparams.storyid, pubid : $stateparams.pubid }); }, function (e) { console.log('[storydetailctrl] $save failed ', e); var msg = $scope.msgparse(e); $scope.storyfindonechanged({ storyid : $stateparams.storyid, msg : msg }); console.log('[storydetailctrl] $scope.handlestorysavecancel: $save failed : end'); }); } } else if(action && action == 'cancel') { console.log('[storydetailctrl] $scope.handlestorysavecancel: cancel : end'); $state.go('story.list', { storyid : '', pubid : '' }); } else if(action && action == 'commit') { $scope.story.content = ckeditor.instances.storycontent.getdata(); $scope.story.$save().then(function(e){ console.log('[storydetailctrl] $save e ', e); $scope.usermessage = 'saved'; $scope.usermessagetimeout = settimeout(function () {$scope.usermessageclear();}, 1000 * 5); console.log('[storydetailctrl] $scope.handlestorysavecancel: commit : end'); }, function (e) { console.log('[storydetailctrl] $save failed ', e); var msg = $scope.msgparse(e); $scope.storyfindonechanged({ storyid : $stateparams.storyid, msg : msg }); console.log('[storydetailctrl] $scope.handlestorysavecancel: commit failed : end'); }); } console.log('[storydetailctrl] $scope.handlestorysavecancel: end'); };
Comments
Post a Comment