Plug-ins"

This website contains links to software which is either no longer maintained or will be supported only until the end of 2019 (CKFinder 2). For the latest documentation about current CKSource projects, including software like CKEditor 4/CKEditor 5, CKFinder 3, Cloud Services, Letters, Accessibility Checker, please visit the new documentation website.

If you look for an information about very old versions of CKEditor, FCKeditor and CKFinder check also the CKEditor forum, which was closed in 2015. If not, please head to StackOverflow for support.

(New page: == Creating & Installing a Plugin in FCKeditor == === Writing a plugin === The directory structure for a plugin must always follow the same pattern. The plugin directory must have the sa...)
 
Line 1: Line 1:
== Creating & Installing a Plugin in FCKeditor ==
+
== Creating & Installing a Plugin in FCKeditor ==
  
 
=== Writing a plugin ===
 
=== Writing a plugin ===
Line 6: Line 6:
  
 
For the 'findreplace' plugin the structure would look like this (assuming the default plugin path is '''editor/plugins/'''):
 
For the 'findreplace' plugin the structure would look like this (assuming the default plugin path is '''editor/plugins/'''):
<pre>
+
<pre>/editor/plugins/findreplace/fckplugin.js
/editor/plugins/findreplace/fckplugin.js
 
 
/editor/plugins/findreplace/lang/en.js
 
/editor/plugins/findreplace/lang/en.js
 
/editor/plugins/findreplace/lang/it.js
 
/editor/plugins/findreplace/lang/it.js
 
</pre>
 
</pre>
 +
 +
The '''fckplugin.js''' file defines your plugin. It should register the command(s) that it implements, and create a toolbar button for each one.
 +
<pre>
 +
/*
 +
FCKCommands.RegisterCommand(commandName, command)
 +
      commandName - Command name, referenced by the Toolbar, etc...
 +
      command - Command object (must provide an Execute() function).
 +
*/
 +
// Register the related commands.
 +
FCKCommands.RegisterCommand(
 +
  'My_Find',
 +
    new FCKDialogCommand(
 +
        FCKLang['DlgMyFindTitle'],
 +
        FCKLang['DlgMyFindTitle'],
 +
        FCKPlugins.Items['findreplace'].Path + 'find.html', 340, 170));
 +
FCKCommands.RegisterCommand('My_Replace',
 +
    new FCKDialogCommand(
 +
        FCKLang['DlgMyReplaceTitle'],
 +
        FCKLang['DlgMyReplaceTitle'],
 +
        FCKPlugins.Items['findreplace'].Path + 'replace.html', 340, 200)) ;
 +
// Create the "Find" toolbar button.
 +
var oFindItem = new FCKToolbarButton('My_Find', FCKLang['DlgMyFindTitle']);
 +
oFindItem.IconPath = FCKPlugins.Items['findreplace'].Path + 'find.gif' ;
 +
// 'My_Find' is the name used in the Toolbar config.
 +
FCKToolbarItems.RegisterItem( 'My_Find', oFindItem ) ;
 +
// Create the "Replace" toolbar button.
 +
var oReplaceItem = new FCKToolbarButton( 'My_Replace', FCKLang['DlgMyReplaceTitle']);
 +
oReplaceItem.IconPath = FCKPlugins.Items['findreplace'].Path + 'replace.gif';
 +
// 'My_Replace' is the name used in the Toolbar config.
 +
FCKToolbarItems.RegisterItem('My_Replace', oReplaceItem);
 +
</pre>
 +
 +
=== Installing a plugin ===
 +
 +
To install a new plugin, copy the unzipped plugin to your editor's plugin directory 'editor/plugins' (e.g. for the placeholder plugin the path to its fckplugin.js file would be 'editor/plugins/placeholder/fckplugin.js'). That's all!
 +
 +
Now to setup the plugin (have it showing up in your editor), follow the next instructions:
 +
 +
==== Establishing the button in the toolbar ====

Revision as of 10:55, 17 January 2008

Creating & Installing a Plugin in FCKeditor

Writing a plugin

The directory structure for a plugin must always follow the same pattern. The plugin directory must have the same name as the plugin and it must contain a fckplugin.js file. It may also optionally include a language directory with various localized language definitions for your Users Interface (UI). Each file defines a single language, and the filenames (without .js) are what should be passed to FCKConfig.Plugins.Add (see below). If your command has no UI then you don't need to supply any language files.

For the 'findreplace' plugin the structure would look like this (assuming the default plugin path is editor/plugins/):

/editor/plugins/findreplace/fckplugin.js
/editor/plugins/findreplace/lang/en.js
/editor/plugins/findreplace/lang/it.js

The fckplugin.js file defines your plugin. It should register the command(s) that it implements, and create a toolbar button for each one.

/*
FCKCommands.RegisterCommand(commandName, command)
       commandName - Command name, referenced by the Toolbar, etc...
       command - Command object (must provide an Execute() function).
*/
// Register the related commands.
FCKCommands.RegisterCommand(
   'My_Find',
    new FCKDialogCommand(
        FCKLang['DlgMyFindTitle'],
        FCKLang['DlgMyFindTitle'],
        FCKPlugins.Items['findreplace'].Path + 'find.html', 340, 170));
FCKCommands.RegisterCommand('My_Replace',
    new FCKDialogCommand(
        FCKLang['DlgMyReplaceTitle'],
        FCKLang['DlgMyReplaceTitle'],
        FCKPlugins.Items['findreplace'].Path + 'replace.html', 340, 200)) ;
// Create the "Find" toolbar button.
var oFindItem = new FCKToolbarButton('My_Find', FCKLang['DlgMyFindTitle']);
oFindItem.IconPath = FCKPlugins.Items['findreplace'].Path + 'find.gif' ;
// 'My_Find' is the name used in the Toolbar config.
FCKToolbarItems.RegisterItem( 'My_Find', oFindItem ) ;
// Create the "Replace" toolbar button.
var oReplaceItem = new FCKToolbarButton( 'My_Replace', FCKLang['DlgMyReplaceTitle']);
oReplaceItem.IconPath = FCKPlugins.Items['findreplace'].Path + 'replace.gif';
// 'My_Replace' is the name used in the Toolbar config.
FCKToolbarItems.RegisterItem('My_Replace', oReplaceItem);

Installing a plugin

To install a new plugin, copy the unzipped plugin to your editor's plugin directory 'editor/plugins' (e.g. for the placeholder plugin the path to its fckplugin.js file would be 'editor/plugins/placeholder/fckplugin.js'). That's all!

Now to setup the plugin (have it showing up in your editor), follow the next instructions:

Establishing the button in the toolbar