All I've got is 3 headings and "normal" (paragraph) defined in the style. If I place a line of text in one style, then decide I want to change it, is there any way I can tell FCKeditor to cancel the previous style when I change the style box? At the moment, just changing the combo box produces something like:
<p><h1><h2>Some menu</h2></h1></p>, which is not good!
<p><h1><h2>Some menu</h2></h1></p>, which is not good!
RE: Select new style to kill old style
I'd like to see an option to make the styles dropdown work more like the font-formats dropdown. ie. the selected style always replaces the containing tag.
RE: Select new style to kill old style
(Note that this is from the uncompressed source and it'll only work on gecko, and I had to retype it into this thread, so I may have made a typo or two - but you get the idea)
FCKStyleCommand.prototype.Execute = function( styleName, styleComboItem )
{
var C=this.GetActiveStyles();
var D = ''+FCK.EditorWindow.getSelection();
if (!D) {
alert("Please select some text to style");
} else {
if (styleComboItem.Selected) {
FCKUndo.SaveUndoStep();
styleComboItem.Style.RemoveFromSelection();
FCKUndo.SaveUndoStep();
FCK.Focus();
FCK.Events.FireEvent("OnSelectionChange");
} else {
FCKUndo.SaveUndoStep();
if (C.length>0){
for (var i=0;i<C.length;i++) {
C[i].RemoveFromSelection();
FCK.EditorWindow.find(D, true, false, false, false, false, false);
};
}
styleComboItem.Style.ApplyToSelection();
FCKUndo.SaveUndoStep();
FCK.Focus();
FCK.Events.FireEvent("OnSelectionChange");
}
}
}
RE: Select new style to kill old style
FCKStyleCommand.prototype.Execute=function(A,B){
FCKUndo.SaveUndoStep();
var C=this.GetActiveStyles();
var D=FCK.EditorDocument.selection.createRange().text;
if(C.length>0)
C[0].RemoveFromSelection();
B.Style.RemoveFromSelection();
var E = FCK.EditorDocument.body.createTextRange();
if(E.findText(D, 1, 0)){
E.scrollIntoView();
E.select();
E.collapse(false);
};
B.Style.ApplyToSelection();
FCKUndo.SaveUndoStep();
FCK.Focus();
FCK.Events.FireEvent("OnSelectionChange");
};
RE: Select new style to kill old style
this code does not alow one style inside of any other
FCKStyleCommand.prototype.Execute=function(A,B){
FCKUndo.SaveUndoStep();
var C = FCK.EditorDocument.selection.createRange().text;
C = C.replace('\r','');
var D = C.split('\n');
var E,F;
for (var i=0;i<D.length;i++){
E = FCK.EditorDocument.body.createTextRange();
if(E.findText(D[i], 1, 0)){
E.select();
F = this.GetActiveStyles();
if(F.length>0)
F[0].RemoveFromSelection();
};
E = FCK.EditorDocument.body.createTextRange();
if(E.findText(D[i], 1, 0)){
E.select();
B.Style.ApplyToSelection();
};
FCKUndo.SaveUndoStep();
FCK.Focus();
FCK.Events.FireEvent("OnSelectionChange");
};
};