Opened 17 years ago

Closed 17 years ago

#716 closed New Feature (fixed)

Extend Number of Font Sizes

Reported by: Nicholas Couri Owned by:
Priority: Normal Milestone: FCKeditor 2.5 Beta
Component: Core : Styles Version:
Keywords: Cc:

Description

The editor comes with only 7 different font sizes:

xx-small;x-small;small;medium;large;x-large;xx-large

when trying to change the number of fonts, I found out that IE has only 7 different font sizes in its native font size command.

In order to bypass this limitation, I changed the fckconfig.js and fck_othercommands.js and it has worked fine on both IE and firefox.

I don't know if it is the correct solution but it worked fine so far.

FILE: fckconfig.js

// ORIGINAL 
// FCKConfig.FontSizes		= '1/xx-small;2/x-small;3/small;4/medium;5/large;6/x-large;7/xx-large' ;
FCKConfig.FontSizes		= '1/5;2/6;3/7;4/8;5/9;6/10;7/11;8/12;9/14;10/16;11/18;12/20;13/24;14/28;15/30;16/60;17/90' ;

FILE: fck_othercommands.js


FCKFontSizeCommand.prototype.Execute = function( fontSize )
{
//ORIGINAL 
//      if ( typeof( fontSize ) == 'string' ) fontSize = parseInt(fontSize, 10) ;
//
//	if ( fontSize == null || fontSize == '' )
//	{
//		// TODO: Remove font size attribute (Now it works with size 3. Will it work forever?)
//		FCK.ExecuteNamedCommand( 'FontSize', 3 ) ;
//	}
//	else {
//            FCK.ExecuteNamedCommand( 'FontSize', fontSize ) ;
//      }


// CHANGED CODE 
	var oSel = null;
	var bHasSelection = false;

        if ( typeof( fontSize ) == 'string' ) fontSize = parseInt(fontSize, 10) ;

	var e = FCK.EditorDocument.createElement( 'SPAN' ) ;

	if ( fontSize == null || fontSize == '' ) {
		e.style.fontSize = '3px';
	} else {
		e.style.fontSize = fontSize + 'px';
	}
	try{ 
		if(document.all) { 
			oSel = FCK.EditorDocument.selection ; // ie 
			bHasSelection = !(oSel.type == "None"); 
		} else { 				
			oSel = FCK.EditorWindow.getSelection() ; // gecko 
			bHasSelection = (oSel && oSel.rangeCount == 1 && oSel.getRangeAt(0).cloneContents().childNodes.length > 0); 
		} 
	} catch (e) {} 
	if( bHasSelection  )  {
		if (document.selection && document.selection.createRange) { // IE code goes here
			var range = FCK.EditorDocument.selection.createRange();
			e.innerHTML  = FCK.EditorDocument.selection.createRange().text;					
		} else {
			FCK.EditorWindow.getSelection() ;
			e.innerHTML  = FCK.EditorWindow.getSelection();
		}
		FCK.InsertElement( e );				
	}

}


Attachments (1)

proposal.txt (1.8 KB) - added by Nicholas Couri 17 years ago.

Download all attachments as: .zip

Change History (3)

Changed 17 years ago by Nicholas Couri

Attachment: proposal.txt added

comment:1 Changed 17 years ago by Alfonso Martínez de Lizarrondo

Component: GeneralCore : Styles
Summary: Extend Number of Font Sizes ( IE )Extend Number of Font Sizes

I see several problems with that patch:

  1. Only the execute command has been changed, so the combo won't reflect the font size as the user moves around the document.
  1. It always creates a new span, so it will nest several spans if the user tries to adjust the size several times.
  1. It doesn't take care that the user might have selected 2 paragraphs of text, so it will be wrapping any element (be <p>, <table> or whatever) in spans, and that's invalid.

This same behaviour should be possible right now using the styles combo (so no need to change any js file), but a proper implementation will be much easier with the new style system for 2.5

comment:2 Changed 17 years ago by Frederico Caldeira Knabben

Milestone: FCKeditor 2.5
Resolution: fixed
Status: newclosed

Fixed with [774].

The new Style System introduced a very flexible and customizable way to define the font sizes. Now, any kind of font size can be uses, and any king of output tag be be done with it. Check out the fckconfig.js file.

Click here for more info about our SVN system.

Note: See TracTickets for help on using tickets.
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy