问题
I need to be able to add a dropdown or button to the ckeditor's toolbar that will pop up a list, and when a listitem would be clicked the text of that list item would be added to the ckeditor's content
I also need to be ablee to change the content of that list, like to have a function:
function SetListsContent(arr)
{
//fill the list with the array arr
...
}
回答1:
For this first of all add plugin. code to add plugin is below:
CKEDITOR.plugins.add( 'language', {
requires: 'selection',
init: function( editor ) {
var pluginName = 'language';
CKEDITOR.dialog.add( pluginName, this.path + 'dialogs/language.js' );
editor.addCommand( pluginName, new CKEDITOR.dialogCommand( pluginName ) );
editor.ui.addButton( 'language', {
label: 'language',
command: pluginName
});
}
});
And then add plugin into toolbar in config.js
i.e
extraPlugins: 'language';
回答2:
I end up doing this:
<div id='stuff'>
<ul class="editorlist">
<li>hi</li>
<li>how are you</li>
<li>good</li>
</ul>
</div>
<script type='text/javascript'>
function myfunc() {
$('<a href="#" id="stuffadd">add some text</a>')
.click(function () { $('#stuff').dialog('open'); }).appendTo('.cke_button:last');
}
</script>
来源:https://stackoverflow.com/questions/5747678/how-to-add-a-dropdown-button-to-ckeditor-to-insert-content-when-selecting-a-drop