Hi Folks
Maby this question sounds stupid, but I managed to define my own Plug-In, but I don't really know why it works.
So that in the future I may be more sure about the fckEditor, maybe somebody may explain what I have done.
The target was to create a Toolbar-Button what inserts some HTML:
<table cellspacing="0" cellpadding="0" border="0" background="/pix/content_trennlinie.gif" width="100%"><tr> <td valing="top"><img height="25" border="0" width="100%" src="/pix/0.gif" alt="" /></td> </tr></table>
So I defined I Toolbar Button 'InsertHrTable' in the fckConfig.js:
FCKConfig.ToolbarSets["Default"] = [ ['FitWindow','Source','-','-','Preview'], ['Cut','Copy','Paste','PasteText','PasteWord','-','Print'], ['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'], '/', ['OrderedList','UnorderedList','-','Outdent','Indent'], ['JustifyLeft','JustifyCenter','JustifyRight','JustifyFull'], ['Link','Unlink','Anchor'], ['Image','Flash','Table','Rule','InsertHrTable','Smiley','SpecialChar'], '/', ['Style','FontFormat','-','Bold','Italic','Underline','StrikeThrough','-','Subscript','Superscript'], ['TextColor','BGColor'], ['ShowBlocks'] ];
and added the plugin
FCKConfig.Plugins.Add( 'InsertHrTable', 'de,en' );
after this I created the directory "InsertHrTable" in the Plugins-Folder and created the "fckplugin.js".
All above is not a problem. I even managed some Plugins wich open a popup an return some content, but I never made just a button what does not interact with the user. So the code from here makes me unsure, even if it works, since I would like to understand it :
// Define the command. var FCKInsertHrTable = function() { this.name = 'InsertHrTable'; } FCKInsertHrTable.prototype ={ Execute:function() { FCKUndo.SaveUndoStep(); FCK.InsertHtml('<table cellspacing="0" cellpadding="0" border="0" background="/pix/content_trennlinie.gif" width="100%"><tr><td valing="top"><img height="25" border="0" width="100%" src="/pix/0.gif" alt="" /></td></tr></table>') ; }, GetState:function() { if (FCK.EditMode!=0) return -1; return FCK.GetNamedCommandState('InsertHrTable'); } } // Register the HrTable tag command. FCKCommands.RegisterCommand( 'InsertHrTable', new FCKInsertHrTable() ) ; // Create the 'InsertHrTable' toolbar button. // FCKToolbarButton takes the following arguments: CommandName, Button Caption var oInsertHrTable = new FCKToolbarButton( 'InsertHrTable', FCKLang['DlgInsertHrLineBtn'] ) ; oInsertHrTable.IconPath = FCKPlugins.Items['InsertHrTable'].Path + 'icon.gif' ; FCKToolbarItems.RegisterItem( 'InsertHrTable', oInsertHrTable ) ; //var FCKRuleCommand=function(){ // this.Name='Rule'; //}; //FCKRuleCommand.prototype={ // Execute:function(){ // FCKUndo.SaveUndoStep(); // FCK.InsertElement('hr'); // },GetState:function(){ // if (FCK.EditMode!=0) return -1; // return FCK.GetNamedCommandState('InsertHorizontalRule'); // } //};
As you can see, I did search the original Rule function from "fckeditor_gecko.js" (the code with the remarks) and builded my function with some other examples togeter.
My questions beginn with the var "FCKInsertHrTable".
var FCKInsertHrTable = function() { this.name = 'InsertHrTable'; }
and the Register Command
FCKCommands.RegisterCommand( 'InsertHrTable', new FCKInsertHrTable() ) ;
What excatly does the first parameter from RegisterCommand represent, the Toobar-Placeholder?
And what is allowed for the second Parameter?
In this case I do "understand" in a simple way, that the Instance of FCKInsertHrTable is used.
But I don't see out of the documentation if even some arguments are given to my FCKInserHrTable function.
And don't know, what this statement means and what effects it has:
this.name = 'InsertHrTable';
The next question is about:
FCKInsertHrTable.prototype ={ Execute:function() { FCKUndo.SaveUndoStep(); FCK.InsertHtml('<table cellspacing="0" cellpadding="0" border="0" background="/pix/content_trennlinie.gif" width="100%"><tr><td valing="top"><img height="25" border="0" width="100%" src="/pix/0.gif" alt="" /></td></tr></table>') ; }, GetState:function() { if (FCK.EditMode!=0) return -1; return FCK.GetNamedCommandState('InsertHrTable'); } }
In my opinion, fckeditor allwase uses the Execute command. If I understand it right, this function will be executet on Click on the toolbar icon.
But whatfor is "GetState" and what other default function do exist.
I was looking for some documentation, what the diffrent functions are doing and what arguments they get, but I didn't find anything like it.
The FCKUndo.SaveUndoStep() and FCK.InsertHtml are clear for me.
But since I copied the source out of "fckeditor_gecko.js" I'm not sure if the function will work with the other Browsers.
maybe somebody can enlight me
sorry for the terrible english
For any explenation thanks