Hi!
I am using fckEditor2 RC2. I studied the sample plugin code in order to make my own. But the sample plugin only shows a plugin which is a FCKDialogCommand. (FCKCommands.RegisterCommand( 'My_Find' , new FCKDialogCommand( FCKLang['DlgMyFindTitle'] , FCKLang['DlgMyFindTitle'] , FCKConfig.PluginsPath + 'FindReplace/find.html' , 340, 170 ) )
But I want to make a plugin like the Justifyleft-Button, which inserts <span style="clearfloat"> </span> around a selected text or image. The problem is I could not find the command used by the justifyleft-button . (I looked at fckcommands.js, etc.)
Is it a FCKFormatBlockCommand() or what is it? I just want to look at it in order to implement my own command or modify the Justifyleft-Button.
cheers,
Erwin
Sat, 04/09/2005 - 07:19
#1
RE: Create Plugin
RE: Create Plugin
RE: Create Plugin
I also tried this but the editor wont apply styles to images. If you apply a style to an image it sets the style attribute inside the <img> tag. Like this: <img src="..." style="xxx"\>
But i need to have a <span style="clearfloat"> </span> tag around the image in order to fix the float behavior (http://www.positioniseverything.net/easyclearing.html).
And the editor only applies a span if the selected area is text!
Right now i am trying to modify the fckstyledef_gecko.js and fckstyledef_ie.js in order to change this behavior.
If you already know that i am looking at the wrong files plz tell me!
RE: Create Plugin
I simply disabled the object-type recognition (if-statement).
The problem now is that if i only select a image inside the editor-area the style is not recognized. This is a problem because now you can set styles twice, like <span style="clearfloat"> <span style="clearfloat"> <img src="..." .../> </span> </span>. And the editor wont recognize it. It only recognizes a already set style if you select the first char (it isnt actually a char it is only the carret) in front of the image with the image.
FCKStyleDef.prototype.ApplyToSelection = function()
{
/*For Test purposes object-type recognition has been disabled
if ( FCKSelection.GetType() == 'Text' && !this.IsObjectElement )
{*/
var oSelection = FCK.EditorWindow.getSelection() ;
// Create the main element.
var e = FCK.EditorDocument.createElement( this.Element ) ;
for ( var i = 0 ; i < oSelection.rangeCount ; i++ )
{
e.appendChild( oSelection.getRangeAt(i).extractContents() ) ;
}
// Set the attributes.
this._AddAttributes( e ) ;
// Remove the duplicated elements.
this._RemoveDuplicates( e ) ;
var oRange = oSelection.getRangeAt(0) ;
oRange.insertNode( e ) ;
/*For Test purposes object-type recognition has been disabled
}
else
{
var oControl = FCKSelection.GetSelectedElement() ;
if ( oControl.tagName == this.Element )
this._AddAttributes( oControl ) ;
}*/
}
RE: Create Plugin
RE: Create Plugin
RE: Create Plugin
See if that helps. You might be able to tweak it to do what you need. It extracts the text from a selection, then uses insertHTML() to add the text back surrounded by whatever tags you like.