Ok, i see, the Justifyleft button also uses the execCommand(). Is there any way insert <span style="clearfloat"> </span> around a selected text or image with an execCommand() under Gecko, or IE?
I modified the fckstyledef_gecko.js in order to apply span tags to images. (Normally only works with text) 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 ) ; }*/ }
I just added a post "How-to: Non-dialog plugin" to the help forum.
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.
RE: Create Plugin
RE: Create Plugin
RE: Create Plugin
http://www.positioniseverything.net/easyclearing.html
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.