FCKEditor - 如何制作一个简单的插件?

4
我有一个使用FCKEditor的网站。我想制作一个非常简单的插件:当用户选择文本并点击MyPluginIcon时,编辑器会在特定类别的span标签中包围该文本。
因此,它就像粗体或斜体按钮一样,但用于: EtcEtc 我远非JS专家,因此一直在寻找可以复制的插件。我已经在FCK wiki中查找过,但我找到的所有插件都非常复杂(文件浏览器等)。你知道一个超级简单的FCK插件,我可以以此为基础制作我的插件吗?
谢谢!
1个回答

5
希望我的回答能对有需要的人有所帮助。
我使用了这里提供的基本文件: http://www.iondev.lu/fckeditor/netnoi.txt 我将“netnoi”替换为自己的名称,并取消注释图标行以创建一个图标(16x16)。
安装说明在这里: http://docs.fckeditor.net/FCKeditor_2.x/Developers_Guide/Customization/Plug-ins 请确保检查插件目录是否正确——在Drupal中,插件文件夹与默认FCK安装不同。
编辑:显然,netnoi.txt已经消失了。这是我使用的内容:
/***
 * 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 ) ; 

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接