右键单击tinyMCE 5更改上下文菜单

时间:2019-09-28 18:19:01

标签: javascript tinymce

我一直在所选文本上添加内容工具栏。

但是当您右键单击任何地方时,您将看到一个上下文菜单,其中包含一项“链接”。如何在此列表中添加例如charmap插件? 我想不通。

到目前为止,这是我的代码:

tinymce.init({
    branding : false,
    content_css : '/css/tinymce_content.css',
    language : 'nl',
    menubar : false,
    plugins : ['charmap fullscreen hr link lists paste tabfocus'],
    relative_urls : false,
    remove_script_host : false,
    selector : '#' + alineaId,
    style_formats: [
        {title: 'Heading 2', format: 'h2'},
        {title: 'Heading 3', format: 'h3'},
        {title: 'Heading 4', format: 'h4'},
        {title: 'Heading 5', format: 'h5'},
        {title: 'Heading 6', format: 'h6'},
        {title: 'Normal', block: 'p'}
    ],
    toolbar : 'fullscreen | undo redo',
    fullscreen_new_window : true,
    fullscreen_settings : {
        theme_advanced_path_location : 'top'
    },
    setup: function (editor) {
        editor.ui.registry.addContextToolbar('textselection', {
            predicate: function (node) {
                return !editor.selection.isCollapsed();
            },
            items: 'bold italic | styleselect | link | bullist numlist',
            position: 'selection',
            scope: 'node'
        });
    }
});

这是一个链接,其中还包括一个代码笔。右键单击编辑器,您将看到带有“链接”的上下文菜单,我要在该菜单上添加charmap插件。

https://www.tiny.cloud/docs/ui-components/contextmenu/#

1 个答案:

答案 0 :(得分:1)

使用与toolbar相同的格式:

contextmenu: 'charmap undo | redo'
相关问题