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

匆匆过客 提交于 2020-01-05 06:03:26

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!