开发者

how to add a dropdown/button to ckeditor to insert content when selecting a dropdownItem

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 cont开发者_StackOverflow社区ent

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
...
}


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';


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>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜