Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove the specified option from right click meun in tinymce?

I want to remove the image property option from the right click menu in tinymce. I'm using tinymce 3.x version please help me.

like image 776
user25226 Avatar asked Oct 03 '22 20:10

user25226


1 Answers

you could do something like:

tinyMCE.init({
    setup: function (ed) {
        ed.onInit.add(editor_oninit);
    }
...
});

function editor_oninit(ed) {
    // Add hook for onContextMenu so that Insert Image can be removed
    ed.plugins.contextmenu.onContextMenu.add(editor_remove_image);
}

And the function

function editor_remove_image(sender, menu) {
    // create a new object
    var otherItems = {};
    for (var itemName in menu.items) {
        var item = menu.items[itemName];
        if (/^mce_/.test(itemName)) {
            if (item.settings) {
                if (item.settings.cmd == "mceImage" || item.settings.cmd == "mceAdvImage") {
                    // skip these items
                    continue;
                }
            }
        }
        // add all other items to this new object, so it is effectively a clone
        // of menu.items but without the offending entries
        otherItems[itemName] = item;
    }
    // replace menu.items with our new object
    menu.items = otherItems;
}
like image 89
Sudhir Bastakoti Avatar answered Oct 11 '22 15:10

Sudhir Bastakoti