How to call thickbox from tinymce contextmenu plugin?
How to add item in contextmenu of tinymce. I need to open a thickbox from contextmenu selection of tinymce
var url = "upload.php?keepThis=true&TB_iframe=1&width=1000&height=400&model=true";
tb_show("Edit Image", url);
I can call thickbox with above 开发者_StackOverflow社区codes. Where i need to recode in contextmenu plugin. Help me
Ok, in that case you need to load the contextmenu plugin (do this before you load your custom plugin!)
plugins: '...,contextmenu,....,customcontextmenu,...',
Here is the full sample code for an own contextmenu plugin. You need to have this code inside a file called 'editor_plugin.js' (and a file called 'editor_plugin_src.js') in a subdirectory named 'contextmenu' of the plugins directory.
(function() {
tinymce.PluginManager.requireLangPack('customcontextmenu');
tinymce.create('tinymce.plugins.customcontextmenu', {
init : function(ed, url) {
ed.addCommand('custom_option', function() {
// do what you want here!!!
});
// we need the real contextmenu in order to make this work
if (ed && ed.plugins.contextmenu) {
// contextmenu gets called - this is what we do
ed.plugins.contextmenu.onContextMenu.add(function(th, m, e, col) {
// remove all options from standard contextmenu
m.removeAll();
// only if selected node is an image do this
if (typeof e !== "undefined" && e.nodeName.toLowerCase() == 'img'){
th._menu.add({
title: 'Option 1',
icon: 'option1', // you might need to specify an image here
cmd: 'custom_option' // call command custom_option
});
m.addSeparator();
// Second option
//m.add({
// title: 'Option 2',
// icon: 'option2',
// cmd: 'custom_option2'
//});
}
else {
// you might want to hinder the display of the contextmenu in all other cases
// or present other options....
}
});
}
});
},
// Register plugin
tinymce.PluginManager.add('customcontextmenu', tinymce.plugins.customcontextmenu);
})();
Make sure the brackets are set right (i had to copy/paste and delete parts of the code so there might brackets be missing).
精彩评论