admin管理员组

文章数量:1023794

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 plex (file browsers and whatnot). Do you know of a super simple FCK plugin I can base my plugin off of?

Thanks!

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 plex (file browsers and whatnot). Do you know of a super simple FCK plugin I can base my plugin off of?

Thanks!

Share Improve this question asked Mar 17, 2009 at 14:24 EileenEileen 6,6706 gold badges30 silver badges29 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 5

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 unmented the icon line to make an icon (16x16).

And the instructions on how to install it from here: http://docs.fckeditor/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 mand
 */
var FCKPixelCaps_mand = function()
{

}

/***
 * Add Execute prototype
 */
FCKPixelCaps_mand.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_mand.prototype.GetState = function()
{
        return;
}

// register the mand so it can be use by a button later
FCKCommands.RegisterCommand( 'PixelCaps_mand' , new FCKPixelCaps_mand() ) ;

/***
 * Create the  toolbar button.
 */

// create a button with the label "Netnoi" that calls the netnoi_mand
var oPixelCaps = new FCKToolbarButton( 'PixelCaps_mand', 'Pixels & Pulp Caps' ) ;
oPixelCaps.IconPath = FCKConfig.PluginsPath + 'PixelCaps/caps.gif' ;

// register the item so it can added to a toolbar
FCKToolbarItems.RegisterItem( 'PixelCaps', oPixelCaps ) ; 

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 plex (file browsers and whatnot). Do you know of a super simple FCK plugin I can base my plugin off of?

Thanks!

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 plex (file browsers and whatnot). Do you know of a super simple FCK plugin I can base my plugin off of?

Thanks!

Share Improve this question asked Mar 17, 2009 at 14:24 EileenEileen 6,6706 gold badges30 silver badges29 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 5

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 unmented the icon line to make an icon (16x16).

And the instructions on how to install it from here: http://docs.fckeditor/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 mand
 */
var FCKPixelCaps_mand = function()
{

}

/***
 * Add Execute prototype
 */
FCKPixelCaps_mand.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_mand.prototype.GetState = function()
{
        return;
}

// register the mand so it can be use by a button later
FCKCommands.RegisterCommand( 'PixelCaps_mand' , new FCKPixelCaps_mand() ) ;

/***
 * Create the  toolbar button.
 */

// create a button with the label "Netnoi" that calls the netnoi_mand
var oPixelCaps = new FCKToolbarButton( 'PixelCaps_mand', 'Pixels & Pulp Caps' ) ;
oPixelCaps.IconPath = FCKConfig.PluginsPath + 'PixelCaps/caps.gif' ;

// register the item so it can added to a toolbar
FCKToolbarItems.RegisterItem( 'PixelCaps', oPixelCaps ) ; 

本文标签: javascriptFCKEditorhow to make a simple pluginStack Overflow