CKEditor-可能具有基本样式的上下文菜单吗? [英] CKEditor - Possible to have context menu for basic styles?

查看:63
本文介绍了CKEditor-可能具有基本样式的上下文菜单吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

右键单击上下文菜单中是否可以具有基本样式(如粗体,斜体,下划线等)?

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

推荐答案

当然可以。
首先,您必须添加上下文菜单组和项目。例如,

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

完成!您需要为监听器获取一些更复杂的逻辑。例如,请参见剪贴板插件中的 plugin.js 代码。

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

这篇关于CKEditor-可能具有基本样式的上下文菜单吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆