如何在选择dropdownItem时向ckeditor添加下拉/按钮以插入内容

我需要能够在ckeditor的工具栏中添加一个下拉列表或按钮,弹出一个列表,当点击一个列表项时,该列表项的文本将被添加到ckeditor的内容中

我还需要能够更改该列表的内容,比如有一个function:

function SetListsContent(arr) { //fill the list with the array arr ... } 

首先要添加插件。 添加插件的代码如下:

 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 }); } }); 

然后在config.js中将插件添加到工具栏中即

 extraPlugins: 'language'; 

我最终这样做了:

 
  • hi
  • how are you
  • good