gdzie utworzyć instancję użytku ckedito poniżej kodu. use editor.id dla trzech części cedenta, paska narzędzi, obszaru edycji, stopka na przykład, jeśli editor.id ma wartość "cke_12" dla div paska narzędzi to "cke_12_top". należy pamiętać, że jest to tryb 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()
}
}
}
który działa, dziękuję. – Mike
Selektory jQuery nie działały dla mnie. Musiałem użyć '$ (evt.editor.element. $). Find ('span.cke_top'). Show();'. Stopkę można również uzyskać za pomocą 'find ('span.cke_bottom')'. – Nathan
Możesz także załadować CKEditor z ukrytym paskiem narzędzi, subskrybując wydarzenie 'contentDom' i wywołując' hideToolBarDiv' stamtąd. – Nathan