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

发布于 2024-07-15 03:19:37 字数 324 浏览 5 评论 0原文

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

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

EtcEtc

我距离 JS 专家还很远,所以我一直在寻找一个要复制的插件。 我查看了 FCK wiki,但我发现的所有插件都非常复杂(文件浏览器之类的)。 你知道我可以基于一个超级简单FCK插件来构建我的插件吗?

谢谢!

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

So it's just like the Bold or Italic button, but for:

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

I am far from a JS expert, so I have been looking for a plugin to copy. I have looked in the FCK wiki but all the plugins I have found are really complex (file browsers and whatnot). Do you know of a super simple FCK plugin I can base my plugin off of?

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

娇妻 2024-07-22 03:19:38

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

我使用了这里的基本文件:
http://www.iondev.lu/fckeditor/netnoi.txt

我发现-并用我自己的名字替换“netnoi”,并取消注释图标行以制作图标(16x16)。

以及如何从此处安装它的说明:
http://docs.fckeditor.net/FCKeditor_2.x/Developers_Guide/定制/插件

请务必检查插件目录是否正确——在 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 ) ; 

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

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

I found-and-replaced the "netnoi" with my own name, and uncommented the icon line to make an icon (16x16).

And the instructions on how to install it from here:
http://docs.fckeditor.net/FCKeditor_2.x/Developers_Guide/Customization/Plug-ins

Be sure to check that the plugins directory is correct -- in drupal the plugins folder is different than a default FCK install.

EDIT: Apparently the netnoi.txt has gone 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 ) ; 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文