Javascript 如何将下拉列表/按钮添加到ckeditor以在选择下拉列表项时插入内容
我需要能够添加一个下拉列表或按钮到ckeditor的工具栏,该工具栏将弹出一个列表,当单击一个列表项时,该列表项的文本将添加到ckeditor的内容中 我还需要能够更改该列表的内容,比如有一个函数:Javascript 如何将下拉列表/按钮添加到ckeditor以在选择下拉列表项时插入内容,javascript,jquery,ckeditor,fckeditor,Javascript,Jquery,Ckeditor,Fckeditor,我需要能够添加一个下拉列表或按钮到ckeditor的工具栏,该工具栏将弹出一个列表,当单击一个列表项时,该列表项的文本将添加到ckeditor的内容中 我还需要能够更改该列表的内容,比如有一个函数: function SetListsContent(arr) { //fill the list with the array arr ... } 我最终会这样做: <div id='stuff'> <ul class="editorlist"> &l
function SetListsContent(arr)
{
//fill the list with the array arr
...
}
我最终会这样做:
<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>
- 嗨
- 你好吗
- 好
函数myfunc(){
$('')
.click(function(){$('#stuff').dialog('open');}).appendTo('.cke_按钮:last');
}
首先添加插件。添加插件的代码如下:
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';