Hi @ all,
I have written a FCK-Plugin to select my CSS-styles via keystrokes. I have some problems with IE 6/7 and FF 3.0.3.
IE-problems:
- If I mark a text and use the keystroke CTRL + ALT + 72 for SC_test_7, the FCKeditor lost the mark.
- If I mark a text in a table and use any keystroke, the table collapses and I get a Javascript (Line: 57, Sign: 214, Error: Object needed).
FF-problems:
- It's not possible to switch between the keystrokes which create a <P> and a <H1>. I have to select the line again, to change it.
- If I mark a text and use the keystroke CTRL + ALT + 72 for SC_test_7, the FCKeditor lost the mark.
- In a table it creates many many many many many mistakes.
Can someone help me to correct my script? Is there a easier way to write this plugin?
Thanks,
matze (Sorry for my spelling, my english is not very well )
fckconfig.js:
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' ], ...
My fckplugin.js:
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:
My fckstyles.xml: