CKEditor - Possible to have context menu for basic styles?

旧街凉风 提交于 2019-12-11 05:29:48

问题


Is it possible to have basic styles(like bold, italic, underline, etc) in right click context menu?


回答1:


Of course, it is. Firstly, you have to add context menu group and items. For example,

editor.addMenuGroup('basicstyles', 1);
    editor.addMenuItems( {
        'bold': {
        label: 'Make it bold!',
        command: 'bold',
        group: 'basicstyles'
        } // add here more buttons like this
    } );

Next, you need to add context menu listeners.Simply, it looks like:

editor.contextMenu.addListener( function( element, selection ) {
    return {
        bold: CKEDITOR.TRISTATE_OFF // , anotherCommand:CKEDITOR.TRISTATE_OFF, etc 
    }
} );

Done! You'll need to get some more complicated logic for listeners. See plugin.js code in clipboard plugin for example.



来源:https://stackoverflow.com/questions/24316207/ckeditor-possible-to-have-context-menu-for-basic-styles

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