in cui si crea un'istanza di utilizzo qui di seguito ckedito codice. editor.id utilizzare per tre parti di ckeditor, barra degli strumenti, area di modifica, footer ad esempio se editor.id ha valore 'cke_12' per l'id della barra degli strumenti è 'cke_12_top'. nota questa è per la modalità iframe.
CKEDITOR.replace(divId, {toolbar: [
{ name: 'clipboard', items: [ 'Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord', '-', 'Undo', 'Redo']},
{name: 'editing', items: ['Format', 'Font', 'FontSize', 'TextColor', 'BGColor' , 'Bold', 'Italic', 'Underline', 'Strike', '-', 'RemoveFormat'] }
]});
//use for loop because i have multi ckeditor in page.
for (instance in CKEDITOR.instances) {
var editor = CKEDITOR.instances[instance];
if (editor) {
// Call showToolBarDiv() when editor get the focus
editor.on('focus', function (event) {
showToolBarDiv(event);
});
// Call hideToolBarDiv() when editor loses the focus
editor.on('blur', function (event) {
hideToolBarDiv(event);
});
//Whenever CKEditor get focus. We will show the toolbar span.
function showToolBarDiv(event) {
//'event.editor.id' returns the id of the spans used in ckeditr.
$('#'+event.editor.id+'_top').show();
}
function hideToolBarDiv(event) {
//'event.editor.id' returns the id of the spans used in ckeditr.
$('#'+event.editor.id+'_top').hide()
}
}
}
che funziona, grazie. – Mike
I selettori jQuery non hanno funzionato per me. Ho dovuto usare '$ (evt.editor.element. $). Find ('span.cke_top'). Show();'. Puoi anche ottenere il piè di pagina usando 'find ('span.cke_bottom')'. – Nathan
È inoltre possibile caricare CKEditor con la barra degli strumenti nascosta sottoscrivendo l'evento 'contentDom' e chiamando' hideToolBarDiv' da lì. – Nathan