Context

Example on how to associate a context menu (right click menu) option

This example shows how to attach a context menu item for the "placeholder" plugin, as found in FCKEditor 2.3. This code will be very similar for your own plugins, just add to the your fckplugin.js file.

FCK.ContextMenu.RegisterListener( {
        AddItems : function( menu, tag, tagName )
        {
                // under what circumstances do we display this option
                if ( tagName == 'SPAN' && tag._fckplaceholder )
                {
                        // when the option is displayed, show a separator  the command
                        menu.AddSeparator() ;
                        // the command needs the registered command name, the title for the context menu, and the icon path
                        menu.AddItem( 'placeholder', FCKLang.PlaceholderDlgTitle, oPlaceholderItem.IconPath ) ;
                }
        }}
);
This page was last modified on 17 January 2008, at 14:23.