CKEditor custom selection menu
I am trying to add my own select menu to the new CKEditor. The API is a bit confusing, so I'm not sure how to do this. I am using the ui dialog function, but really have no idea how to get it to work.
So far I have:
CKEDITOR.ui.dialog.select(dialogObj, elementDefinition, htmlList);
Anyone have any ideas on how to actually get the custom choice to work?
I am trying to understand this API: http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.ui.dialog.select.html
Try this code,
Something like creating an element dynamically like in javascript, the SELECT control will be created whenever you press the Enter key ...
var editor1 = CKEDITOR.replace('editor');
CKEDITOR.instances["editor"].on("instanceReady" , function(){
var e = this.document;
this.document.on("keyup", function(event){
domEvent = event.data;
key = domEvent.getKey();
switch(key){
case 13:
e = CKEDITOR.instances.editor.document;
b = e.getBody();
s = e.createElement('select');
o = e.createElement('option');
o.appendHtml("hi");
s.append(o);
o = e.createElement('option');
o.appendHtml("hello");
s.append(o);
b.append(s);
s.focus();
break;
default:
}
});
});
Why aren't you checking the _source folder ?
Go to the plugins directory and select the plugin that shows the dropdown, eg. stylescombo . The code can shed some light on it. Create a copy of the folder and start modifying the code from top to bottom and you will have a choice in no time.
Cheers, t ^ e