Styles via keystrokes plugin

FCKConfig.Plugins.Add( 'style_sc' );
...
[ CTRL + ALT + 65 /*A*/, 'SC_test_1' ],
[ CTRL + ALT + 66 /*B*/, 'SC_test_2' ],
...
[ CTRL + ALT + 72 /*H*/, 'SC_test_7' ],
...
var My_FCKStyleSCCommand = function( A, B )
{
this.SCTagName = A;
this.SCClassName = B;
};
My_FCKStyleSCCommand.prototype.Execute = function( A, B )
{
var allowTag = new Array();
allowTag["H1"] = true;
allowTag["H2"] = true;
allowTag["H3"] = true;
allowTag["H4"] = true;
allowTag["H5"] = true;
allowTag["H6"] = true;
allowTag["P"] = true;
allowTag["SPAN"] = true;
allowTag["DIV"] = true;
allowTag["FONT"] = true;
var element = FCK.ToolbarSet.CurrentInstance.Selection.GetParentElement();
if (allowTag[element.tagName.toUpperCase()])
{
FCKUndo.SaveUndoStep();
if (this.SCTagName != "" && element.tagName.toUpperCase() != this.SCTagName.toUpperCase())
{
var old_value = element.innerText;
if (old_value == undefined)
{
old_value = element.innerHTML;
}
FCKDomTools.RemoveNode(element);
element = FCK.EditorDocument.createElement(this.SCTagName.toLowerCase());
element.innerHTML = old_value;
if (this.SCClassName != "")
{
element.className = this.SCClassName;
}
FCK.InsertElement( element );
element = FCK.ToolbarSet.CurrentInstance.Selection.GetParentElement();
}
if (this.SCClassName != "")
{
element.className = this.SCClassName;
}
FCKUndo.SaveUndoStep();
}
else
{
if (element.tagName.toUpperCase() == "TD" || element.tagName.toUpperCase() == "TH")
{
FCKUndo.SaveUndoStep();
if (this.SCTagName != "" && element.tagName.toUpperCase() != this.SCTagName.toUpperCase())
{
var old_value = element.innerText;
if (old_value == undefined)
{
old_value = element.innerHTML;
}
element.innerHTML = "";
element = FCK.EditorDocument.createElement(this.SCTagName.toLowerCase());
element.innerHTML = old_value;
if (this.SCClassName != "")
{
element.className = this.SCClassName;
}
FCK.InsertElement( element );
element = FCK.ToolbarSet.CurrentInstance.Selection.GetParentElement();
}
if (this.SCClassName != "")
{
element.className = this.SCClassName;
}
FCKUndo.SaveUndoStep();
}
}
};
My_FCKStyleSCCommand.prototype.GetState = function()
{
if (FCK.EditMode == 0)
{
return FCK_TRISTATE_OFF;
}
else
{
return -1;
}
};
FCKCommands.RegisterCommand('SC_test_1', new My_FCKStyleSCCommand('P', 'standard'));
FCKCommands.RegisterCommand('SC_test_2', new My_FCKStyleSCCommand('P', 'example'));
...
FCKCommands.RegisterCommand('SC_test_7', new My_FCKStyleSCCommand('H1', ''));
Re: Styles via keystrokes plugin
I found the "FCKStyleCommand"-function in the fckeditorcode_x.js, which I think change the styles.
Now I copied this function in my plugin and renamed it. But now I need reference of the object "B".
How can I get "B"?
Someone know, if this solution is a possible one?
My fckplugin.js:
var My_FCKStyleSCCommand=function( A ) { var B = ???; // I need to set it }; My_FCKStyleSCCommand.prototype= { Name:'Style', Execute:function( A , B ) { FCKUndo.SaveUndoStep(); if (B.Selected) FCK.Styles.RemoveStyle(B.Style); else FCK.Styles.ApplyStyle(B.Style); FCKUndo.SaveUndoStep(); FCK.Focus(); FCK.Events.FireEvent('OnSelectionChange'); }, GetState:function() { if (FCK.EditMode!=0||!FCK.EditorDocument) return -1; if (FCKSelection.GetType()=='Control') { var A=FCKSelection.GetSelectedElement(); if (!A||!FCKStyles.CheckHasObjectStyle(A.nodeName.toLowerCase())) return -1; }; return 0; } }; FCKCommands.RegisterCommand('SC_test_1', new My_FCKStyleSCCommand('Standard')); FCKCommands.RegisterCommand('SC_test_2', new My_FCKStyleSCCommand('Example')); ... FCKCommands.RegisterCommand('SC_test_7', new My_FCKStyleSCCommand('Topic'));My fckstyles.xml: