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

标签 javascript plugins fckeditor

我有一个使用 FCKEditor 的网站。我想制作一个非常简单的插件:当用户选择文本然后点击 MyPluginIcon 时,编辑器会在具有特定类的 span 标记中包围文本。

所以它就像粗体或斜体按钮,但用于:

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

我远不是一个JS高手,所以一直在找一个插件来copy。我查看了 FCK wiki,但我发现的所有插件都非常复杂(文件浏览器等)。你知道一个 super 简单的 FCK 插件吗?

谢谢!

最佳答案

回答我自己的问题!希望将来如果有人发现它会有所帮助。

我使用了这里的基本文件: 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 ) ; 

关于javascript - FCKEditor - 如何制作一个简单的插件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/654472/

相关文章:

javascript - 如何获取 .click 按钮来隐藏警报框

plugins - 在 vim 中使用 Pathogen 暂时禁用一些插件。

css - 如何仅将 CSS 添加到 WordPress 插件的选项页面?

javascript - 在FCKeditor中插入到最后

javascript - 使用 FCKeditor 插件添加自定义 editorarea CSS

c# - jQuery ajax 发布当前日期时间 ASP.NET Web API

javascript - 将鼠标滚轮事件捕获为 native HTML 属性

grails - 如何在grails中使用fckeditor?

javascript - 使用Meteor JS实现Android推送通知有哪些选择

c++ - 添加插件 SDK - 是否多重继承?