Sunday, 15 July 2012

Problems with mouse events on newly created CKEditor instance -



Problems with mouse events on newly created CKEditor instance -

i'm trying create create new ckeditor ver4 instance in response user clicking on element. due nature of application, can not utilize "autoinline" feature outlined in ckeditor sample. while sample below in fact create editor instance, instance has important problem. inline instances supposed disappear when user clicks away them. in illustration however, user must first click away, click instance, , click away again. how can prevent this?

<!doctype html> <html> <head> <script src="jspath/ckeditor.js"></script> <script> var editor = null; ckeditor.disableautoinline = true; function init() { var e2 = document.getelementbyid("element2"); e2.addeventlistener("click", function () { if(!editor) { editor = ckeditor.inline(e2); editor.on('instanceready', function () { console.log("instanceready") console.log(editor.focusmanager.hasfocus); }); editor.on('focus', function() { console.log("focus"); }) editor.on('blur', function() { console.log("blur"); editor.destroy(); editor = null; }) } }) } </script> </head> <body onload="init()"> <div tabindex="0" id="element2" style="background-color: yellow;" contenteditable = true>element 2</div> </body> </html>

despite fact editor.focusmanager.hasfocus true, editor's element did not in fact have focus. perhaps bug? anyway, adding editor.focus(); instanceready function resolved issue.

ckeditor

No comments:

Post a Comment