FCKEditor - how to make a simple plugin?

I have a website that uses FCKEditor. I would like to make an incredibly simple plugin: when the user selects the text and then removes MyPluginIcon, the editor surrounds the text in the span tag with a specific class.

This means that it is like a Bold or Italic button, but for:

<span class="blah">EtcEtc</span>

I am far from a JS expert, so I was looking for a copy plugin. I looked at the FCK wiki, but all the plugins are really complex (file browsers and more). Do you know about a super simple FCK plugin that I can configure for my plugin?

Thanks!

+4
source share
1 answer

Answering my question! Hopefully if someone finds this in the future, this will help.

I used the main file here: http://www.iondev.lu/fckeditor/netnoi.txt

I found and replaced "netnoi" with my own name and uncommented the icon string to create the icon (16x16).

And instructions for installing it: http://docs.fckeditor.net/FCKeditor_2.x/Developers_Guide/Customization/Plug-ins

Be sure to check the plugin catalog is correct - in drupal, the plugins folder is different from the default FCK setting.

EDIT: Apparently netnoi.txt was missing. Here is what I used:

 /*** * Create blank command */ var FCKPixelCaps_command = function() { } /*** * Add Execute prototype */ FCKPixelCaps_command.prototype.Execute = function() { // get whatever is selected in the FCKeditor window var selection = FCK.EditorDocument.getSelection(); // if there is a selection, add tags around it if(selection.length > 0) { FCK.InsertHtml('<span class="caps">' + selection + '</span>'); } else { // for debugging reasons, I added this alert so I see if nothing is selected alert('nothing selected'); } } /*** * Add GetState prototype * - This is one of the lines I can't explain */ FCKPixelCaps_command.prototype.GetState = function() { return; } // register the command so it can be use by a button later FCKCommands.RegisterCommand( 'PixelCaps_command' , new FCKPixelCaps_command() ) ; /*** * Create the toolbar button. */ // create a button with the label "Netnoi" that calls the netnoi_command var oPixelCaps = new FCKToolbarButton( 'PixelCaps_command', 'Pixels & Pulp Caps' ) ; oPixelCaps.IconPath = FCKConfig.PluginsPath + 'PixelCaps/caps.gif' ; // register the item so it can added to a toolbar FCKToolbarItems.RegisterItem( 'PixelCaps', oPixelCaps ) ; 
+5
source

All Articles