CKeditor - Inline events

Monday, May 12, 2014

Im using ckeditor to edit inline text. the problem Im finding is that I dont see a defenate way of seeing events when ckeditor is "closed" or hidden again. The normal behaviour would be to have an element with contenteditable set to true and this would prevoke the editor once the use clicks on it.


What I want is to initiate the editor by a custom event, like a double click, and once the editor is "closed"/hidden, I want to remove the ckeditor instance from the element so that it becomes "normal" again. But I dont see that anywhere, sure you can use a .blur() event, but I dont think that is a great idea.


So currently what Im doing is to listen for a dblclick event and then:



edit: (e) =>
f = $(e.currentTarget)
f.attr "contenteditable", true
id = f.attr("id")
$("##{id}").draggable({ disabled: true })
$("##{id}").resizable({ disabled: true })
if CKEDITOR.instances[id]
CKEDITOR.instances[id].destroy();
editor = CKEDITOR.inline id
$(e.currentTarget).focus()


element.blur((el) =>
f = $(el.currentTarget)
CKEDITOR.instances[f.attr("id")].destroy();
f.removeClass 'cke_focus'
f.addClass 'cke_editable'


I would love if there is a native callback thats you know the ckeditr is now hidden, perhaps Im missing it??







http://ift.tt/RI83S8