I figured it out how to customize the Context Menus! In fact you don't need to change any internal code, just need to overwrite two internal functions at your custom fckplugin.js! Here is the code I put at the bottom of the fckplugin.js file:
/** * Add an additional Context Menu for the "Variable" plugin * Overwrite the internal function that returns the Context Menu items */ FCKContextMenu.__GetGroup = FCKContextMenu._GetGroup; FCKContextMenu._GetGroup = function( groupName ) { var oGroup ;
switch ( groupName ) { case 'Variable' : oGroup = new FCKContextMenuGroup() ; oGroup.Add( new FCKContextMenuItem( this, 'Variable', FCKLang.VariableProp, true ) );
/** * Overwrite the internal function that tells the visibility of items * in a Context Menu */ oGroup.__RefreshState = oGroup.RefreshState; oGroup.RefreshState = function() { // Get the actual selected tag (if any). var oTag = FCKSelection.GetSelectedElement() ; var sTagName ;
if ( oTag ) sTagName = oTag.tagName ; // Set items visibility. this.SetVisible( sTagName == 'INPUT' && ( oTag.type == 'text' ) ) ; /** * Calls the original function */ this.__RefreshState(); } break ; default: /** * Calls the original function */ oGroup = this.__GetGroup(groupName); } return oGroup; }
RE: Image Properties in context menu
RE: Image Properties in context menu
/**
* Add an additional Context Menu for the "Variable" plugin
* Overwrite the internal function that returns the Context Menu items
*/
FCKContextMenu.__GetGroup = FCKContextMenu._GetGroup;
FCKContextMenu._GetGroup = function( groupName )
{
var oGroup ;
switch ( groupName )
{
case 'Variable' :
oGroup = new FCKContextMenuGroup() ;
oGroup.Add( new FCKContextMenuItem( this, 'Variable', FCKLang.VariableProp, true ) );
/**
* Overwrite the internal function that tells the visibility of items
* in a Context Menu
*/
oGroup.__RefreshState = oGroup.RefreshState;
oGroup.RefreshState = function()
{
// Get the actual selected tag (if any).
var oTag = FCKSelection.GetSelectedElement() ;
var sTagName ;
if ( oTag )
sTagName = oTag.tagName ;
// Set items visibility.
this.SetVisible( sTagName == 'INPUT' && ( oTag.type == 'text' ) ) ;
/**
* Calls the original function
*/
this.__RefreshState();
}
break ;
default:
/**
* Calls the original function
*/
oGroup = this.__GetGroup(groupName);
}
return oGroup;
}