Changeset 774

Show
Ignore:
Timestamp:
2007-09-04 16:34:12 (15 months ago)
Author:
fredck
Message:

Moved branches/features/style to trunk. Introducing the new Style System.

Location:
FCKeditor/trunk
Files:
12 added
4 removed
35 modified

Legend:

Unmodified
Added
Removed
  • FCKeditor/trunk/editor/css/fck_editorarea.css

    r701 r774  
    4141body, td 
    4242{ 
    43         font-family: Arial, Verdana, Sans-Serif; 
     43        font-family: Arial, Verdana, sans-serif; 
    4444        font-size: 12px; 
    4545} 
  • FCKeditor/trunk/editor/fckeditor.html

    r701 r774  
    1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> 
     1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> 
    22<!-- 
    33 * FCKeditor - The text editor for Internet - http://www.fckeditor.net 
     
    8686LoadScript( '_source/classes/fckkeystrokehandler.js' ) ; 
    8787 
     88LoadScript( 'dtd/fck_xhtml10transitional.js' ) ; 
     89LoadScript( '_source/classes/fckstyle.js' ) ; 
     90LoadScript( '_source/internals/fckstyles.js' ) ; 
     91 
    8892LoadScript( '_source/internals/fcklisthandler.js' ) ; 
    8993LoadScript( '_source/classes/fckelementpath.js' ) ; 
     
    101105LoadScript( '_source/internals/fcktablehandler_' + sSuffix + '.js' ) ; 
    102106LoadScript( '_source/classes/fckxml_' + sSuffix + '.js' ) ; 
    103 LoadScript( '_source/classes/fckstyledef.js' ) ; 
    104 LoadScript( '_source/classes/fckstyledef_' + sSuffix + '.js' ) ; 
    105 LoadScript( '_source/classes/fckstylesloader.js' ) ; 
    106107 
    107108LoadScript( '_source/commandclasses/fcknamedcommand.js' ) ; 
     109LoadScript( '_source/commandclasses/fckstylecommand.js' ) ; 
    108110LoadScript( '_source/commandclasses/fck_othercommands.js' ) ; 
    109111LoadScript( '_source/commandclasses/fckshowblocks.js' ) ; 
     
    113115LoadScript( '_source/commandclasses/fckpastewordcommand.js' ) ; 
    114116LoadScript( '_source/commandclasses/fcktablecommand.js' ) ; 
    115 LoadScript( '_source/commandclasses/fckstylecommand.js' ) ; 
    116117LoadScript( '_source/commandclasses/fckfitwindow.js' ) ; 
    117118LoadScript( '_source/commandclasses/fcklistcommands.js' ) ; 
     119LoadScript( '_source/commandclasses/fckcorestylecommand.js' ) ; 
     120LoadScript( '_source/commandclasses/fckremoveformatcommand.js' ) ; 
    118121LoadScript( '_source/internals/fckcommands.js' ) ; 
    119122 
     
    124127LoadScript( '_source/classes/fckspecialcombo.js' ) ; 
    125128LoadScript( '_source/classes/fcktoolbarspecialcombo.js' ) ; 
     129LoadScript( '_source/classes/fcktoolbarstylecombo.js' ) ; 
     130LoadScript( '_source/classes/fcktoolbarfontformatcombo.js' ) ; 
    126131LoadScript( '_source/classes/fcktoolbarfontscombo.js' ) ; 
    127132LoadScript( '_source/classes/fcktoolbarfontsizecombo.js' ) ; 
    128 LoadScript( '_source/classes/fcktoolbarfontformatcombo.js' ) ; 
    129 LoadScript( '_source/classes/fcktoolbarstylecombo.js' ) ; 
    130133LoadScript( '_source/classes/fcktoolbarpanelbutton.js' ) ; 
    131134LoadScript( '_source/internals/fcktoolbaritems.js' ) ; 
     
    169172        FCK.IECleanup.AddItem( FCK, FCK_Cleanup ) ; 
    170173} 
     174 
     175// The first function to be called on selection change must the the styles 
     176// change checker, because the result of its processing may be used by another 
     177// functions listening to the same event. 
     178FCK.Events.AttachEvent( 'OnSelectionChange', function() { FCKStyles.CheckSelectionChanges() ; } ) ; 
    171179 
    172180// The config hidden field is processed immediately, because 
  • FCKeditor/trunk/editor/_source/classes/fckdomrange_gecko.js

    r694 r774  
    7272        } 
    7373} 
     74 
     75// Not compatible with bookmark created with CreateBookmark2. 
     76// The bookmark nodes will be deleted from the document. 
     77FCKDomRange.prototype.SelectBookmark = function( bookmark ) 
     78{ 
     79        var domRange = this.Window.document.createRange() ; 
     80 
     81        var startNode   = this.GetBookmarkNode( bookmark, true ) ; 
     82        var endNode             = this.GetBookmarkNode( bookmark, false ) ; 
     83 
     84        domRange.setStart( startNode.parentNode, FCKDomTools.GetIndexOf( startNode ) ) ; 
     85        FCKDomTools.RemoveNode( startNode ) ; 
     86 
     87        if ( endNode ) 
     88        { 
     89                domRange.setEnd( endNode.parentNode, FCKDomTools.GetIndexOf( endNode ) ) ; 
     90                FCKDomTools.RemoveNode( endNode ) ; 
     91        } 
     92         
     93        var selection = this.Window.getSelection() ; 
     94        selection.removeAllRanges() ; 
     95        selection.addRange( domRange ) ; 
     96} 
  • FCKeditor/trunk/editor/_source/classes/fckdomrange_ie.js

    r733 r774  
    7070{ 
    7171        if ( this._Range ) 
    72         { 
    73                 var bIsCollapsed = this.CheckIsCollapsed() ; 
     72                this.SelectBookmark( this.CreateBookmark( true ) ) ; 
     73} 
    7474 
    75                 // Create marker tags for the start and end boundaries. 
    76                 var eStartMarker        = this._GetRangeMarkerTag( true ) ; 
     75// Not compatible with bookmark created with CreateBookmark2. 
     76// The bookmark nodes will be deleted from the document. 
     77FCKDomRange.prototype.SelectBookmark = function( bookmark ) 
     78{ 
     79        var bIsCollapsed = this.CheckIsCollapsed() ; 
    7780                var bIsStartMakerAlone ; 
    7881 
    79                 if ( !bIsCollapsed ) 
    80                         var eEndMarker  = this._GetRangeMarkerTag( false ) ; 
     82        // Create marker tags for the start and end boundaries. 
     83        var eStartMarker        = this.GetBookmarkNode( bookmark, true ) ; 
     84         
     85        if ( !eStartMarker ) 
     86                return ; 
    8187 
    82                 // Create the main range which will be used for the selection. 
    83                 var oIERange = this.Window.document.body.createTextRange() ; 
     88        var eEndMarker ; 
     89        if ( !bIsCollapsed ) 
     90                eEndMarker = this.GetBookmarkNode( bookmark, false ) ; 
    8491 
    85                 // Position the range at the start boundary. 
    86                 oIERange.moveToElementText( eStartMarker ) ; 
    87                 oIERange.moveStart( 'character', 1 ) ; 
     92        // Create the main range which will be used for the selection. 
     93        var oIERange = this.Window.document.body.createTextRange() ; 
    8894 
    89                 if ( !bIsCollapsed ) 
     95        // Position the range at the start boundary. 
     96        oIERange.moveToElementText( eStartMarker ) ; 
     97        oIERange.moveStart( 'character', 1 ) ; 
     98 
     99        if ( eEndMarker ) 
     100        { 
     101                // Create a tool range for the end. 
     102                var oIERangeEnd = this.Window.document.body.createTextRange() ; 
     103 
     104                // Position the tool range at the end. 
     105                oIERangeEnd.moveToElementText( eEndMarker ) ; 
     106 
     107                // Move the end boundary of the main range to match the tool range. 
     108                oIERange.setEndPoint( 'EndToEnd', oIERangeEnd ) ; 
     109                oIERange.moveEnd( 'character', -1 ) ; 
     110        } 
     111        else 
     112                bIsStartMakerAlone = ( !eStartMarker.previousSibling || eStartMarker.previousSibling.nodeName.toLowerCase() == 'br' ) && !eStartMarker.nextSibing ; 
     113 
     114        if ( !this._Range ) 
     115                this._Range = this.CreateRange() ; 
     116 
     117        // Remove the markers (reset the position, because of the changes in the DOM tree). 
     118        this._Range.setStartBefore( eStartMarker ) ; 
     119        eStartMarker.parentNode.removeChild( eStartMarker ) ; 
     120 
     121        if ( bIsCollapsed ) 
     122        { 
     123                if ( bIsStartMakerAlone ) 
    90124                { 
    91                         // Create a tool range for the end. 
    92                         var oIERangeEnd = this.Window.document.body.createTextRange() ; 
     125                        // The following trick is needed so IE makes collapsed selections 
     126                        // inside empty blocks visible (expands the block). 
    93127 
    94                         // Position the tool range at the end. 
    95                         oIERangeEnd.moveToElementText( eEndMarker ) ; 
     128                        try 
     129                        { 
     130                                oIERange.pasteHTML( '&nbsp;' ) ; 
     131                                 
     132                                // Move the selection start to include the &nbsp;. 
     133                                oIERange.moveStart( 'character', -1 ) ; 
     134                        } 
     135                        catch (e){} 
    96136 
    97                         // Move the end boundary of the main range to match the tool range. 
    98                         oIERange.setEndPoint( 'EndToEnd', oIERangeEnd ) ; 
    99                         oIERange.moveEnd( 'character', -1 ) ; 
     137                        // The following must be done into a separate try block. (#1034) 
     138                        try 
     139                        {        
     140                                oIERange.select() ; 
     141                                this.Window.document.selection.clear() ; 
     142                        } 
     143                        catch (e){} 
    100144                } 
    101145                else 
    102                         bIsStartMakerAlone = ( !eStartMarker.previousSibling || eStartMarker.previousSibling.nodeName.toLowerCase() == 'br' ) && !eStartMarker.nextSibing ; 
    103  
    104                 // Remove the markers (reset the position, because of the changes in the DOM tree). 
    105                 this._Range.setStartBefore( eStartMarker ) ; 
    106                 eStartMarker.parentNode.removeChild( eStartMarker ) ; 
    107  
    108                 if ( bIsCollapsed ) 
    109                 { 
    110                         if ( bIsStartMakerAlone ) 
    111                         { 
    112                                 // The following trick is needed so IE makes collapsed selections 
    113                                 // inside empty blocks visible (expands the block). 
    114  
    115                                 try 
    116                                 { 
    117                                         oIERange.pasteHTML( '&nbsp;' ) ; 
    118                                          
    119                                         // Move the selection start to include the &nbsp;. 
    120                                         oIERange.moveStart( 'character', -1 ) ; 
    121                                 } 
    122                                 catch (e){} 
    123  
    124                                 // The following must be done into a separate try block. (#1034) 
    125                                 try 
    126                                 {        
    127                                         oIERange.select() ; 
    128                                         this.Window.document.selection.clear() ; 
    129                                 } 
    130                                 catch (e){} 
    131                         } 
    132                         else 
    133                                 oIERange.select() ; 
    134                 } 
    135                 else 
    136                 { 
    137                         this._Range.setEndBefore( eEndMarker ) ; 
    138                         eEndMarker.parentNode.removeChild( eEndMarker ) ; 
    139146                        oIERange.select() ; 
    140                 } 
     147        } 
     148        else 
     149        { 
     150                this._Range.setEndBefore( eEndMarker ) ; 
     151                eEndMarker.parentNode.removeChild( eEndMarker ) ; 
     152                oIERange.select() ; 
    141153        } 
    142154} 
     
    175187        return doc.getElementById( sMarkerId ) ; 
    176188} 
    177  
    178 FCKDomRange.prototype._GetRangeMarkerTag = function( toStart ) 
    179 { 
    180         // Get a range for the start boundary. 
    181         var oRange = this._Range ; 
    182  
    183         // insertNode() will add the node at the beginning of the Range, updating 
    184         // the endOffset if necessary. So, we can work with the current range in this case. 
    185         if ( !toStart ) 
    186         { 
    187                 oRange = oRange.cloneRange() ; 
    188                 oRange.collapse( toStart === true ) ; 
    189         } 
    190  
    191         var eSpan = this.Window.document.createElement( 'span' ) ; 
    192         eSpan.innerHTML = '&nbsp;' ; 
    193         oRange.insertNode( eSpan ) ; 
    194  
    195         return eSpan ; 
    196 } 
  • FCKeditor/trunk/editor/_source/classes/fckdomrange.js

    r720 r774  
    3434        _UpdateElementInfo : function() 
    3535        { 
    36                 if ( !this._Range ) 
     36                var innerRange = this._Range ; 
     37 
     38                if ( !innerRange ) 
    3739                        this.Release( true ) ; 
    3840                else 
    3941                { 
    40                         var eStart      = this._Range.startContainer ; 
    41                         var eEnd        = this._Range.endContainer ; 
     42                        // For text nodes, the node itself is the StartNode. 
     43                        var eStart      = innerRange.startContainer ; 
     44                        var eEnd        = innerRange.endContainer ; 
    4245 
    4346                        var oElementPath = new FCKElementPath( eStart ) ; 
    44                         this.StartContainer             = oElementPath.LastElement ; 
     47                        this.StartNode                  = eStart.nodeType == 3 ? eStart : eStart.childNodes[ innerRange.startOffset ] ; 
     48                        this.StartContainer             = eStart ; 
    4549                        this.StartBlock                 = oElementPath.Block ; 
    4650                        this.StartBlockLimit    = oElementPath.BlockLimit ; 
     
    4852                        if ( eStart != eEnd ) 
    4953                                oElementPath = new FCKElementPath( eEnd ) ; 
    50                         this.EndContainer               = oElementPath.LastElement ; 
     54                        this.EndNode                    = eEnd.nodeType == 3 ? eEnd : eEnd.childNodes[ innerRange.endOffset ] ; 
     55                        this.EndContainer               = eEnd ; 
    5156                        this.EndBlock                   = oElementPath.Block ; 
    5257                        this.EndBlockLimit              = oElementPath.BlockLimit ; 
     
    215220        }, 
    216221 
    217         CreateBookmark : function() 
     222        // This is an "intrusive" way to create a bookmark. It includes <span> tags 
     223        // in the range boundaries. The advantage of it is that it is possible to 
     224        // handle DOM mutations when moving back to the bookmark. 
     225        // Attention: the inclusion of nodes in the DOM is a design choice and 
     226        // should not be changes as there are other points in the code that may be 
     227        // using those nodes to perform operations. See GetBookmarkNode. 
     228        // For performance, includeNodes=true if intended to SelectBookmark. 
     229        CreateBookmark : function( includeNodes ) 
    218230        { 
    219231                // Create the bookmark info (random IDs). 
    220232                var oBookmark = 
    221233                { 
    222                         StartId : 'fck_dom_range_start_' + (new Date()).valueOf() + '_' + Math.floor(Math.random()*1000), 
    223                         EndId   : 'fck_dom_range_end_' + (new Date()).valueOf() + '_' + Math.floor(Math.random()*1000) 
     234                        StartId : (new Date()).valueOf() + Math.floor(Math.random()*1000) + 'S', 
     235                        EndId   : (new Date()).valueOf() + Math.floor(Math.random()*1000) + 'E' 
    224236                } ; 
    225237 
     
    233245                        eSpan = oDoc.createElement( 'span' ) ; 
    234246                        eSpan.id = oBookmark.EndId ; 
    235                         eSpan.innerHTML = '&nbsp;' ;    // For IE, it must have something inside, otherwise it may be removed during operations. 
     247                        eSpan.setAttribute( '_fck_bookmark', true ) ; 
     248 
     249                        // For IE, it must have something inside, otherwise it may be 
     250                        // removed during DOM operations. 
     251//                      if ( FCKBrowserInfo.IsIE ) 
     252                                eSpan.innerHTML = '&nbsp;' ; 
    236253 
    237254                        oClone = this.Clone() ; 
    238255                        oClone.Collapse( false ) ; 
    239256                        oClone.InsertNode( eSpan ) ; 
     257 
     258                        if ( includeNodes ) 
     259                                oBookmark.EndNode = eSpan ; 
    240260                } 
    241261 
    242262                eSpan = oDoc.createElement( 'span' ) ; 
    243263                eSpan.id = oBookmark.StartId ; 
    244                 eSpan.innerHTML = '&nbsp;' ;    // For IE, it must have something inside, otherwise it may be removed during operations. 
     264                eSpan.setAttribute( '_fck_bookmark', true ) ; 
     265 
     266                // For IE, it must have something inside, otherwise it may be removed 
     267                // during DOM operations. 
     268//              if ( FCKBrowserInfo.IsIE ) 
     269                        eSpan.innerHTML = '&nbsp;' ; 
    245270 
    246271                oClone = this.Clone() ; 
     
    248273                oClone.InsertNode( eSpan ) ; 
    249274 
     275                if ( includeNodes ) 
     276                        oBookmark.StartNode = eSpan ; 
     277 
    250278                return oBookmark ; 
    251279        }, 
    252280 
     281        // This one should be a part of a hypothetic "bookmark" object. 
     282        GetBookmarkNode : function( bookmark, start ) 
     283        { 
     284                var doc = this.Window.document ; 
     285 
     286                if ( start ) 
     287                        return bookmark.StartNode || doc.getElementById( bookmark.StartId ) ; 
     288                else 
     289                        return bookmark.EndNode || doc.getElementById( bookmark.EndId ) ; 
     290        }, 
     291 
    253292        MoveToBookmark : function( bookmark, preserveBookmark ) 
    254293        { 
    255                 var oDoc = this.Window.document ; 
    256  
    257                 var eStartSpan  =  oDoc.getElementById( bookmark.StartId ) ; 
    258                 var eEndSpan    =  oDoc.getElementById( bookmark.EndId ) ; 
     294                var eStartSpan  = this.GetBookmarkNode( bookmark, true ) ; 
     295                var eEndSpan    = this.GetBookmarkNode( bookmark, false ) ; 
    259296 
    260297                this.SetStart( eStartSpan, 3 ) ; 
     
    263300                        FCKDomTools.RemoveNode( eStartSpan ) ; 
    264301 
    265                 // If collapsed, the start span will not be available. 
     302                // If collapsed, the end span will not be available. 
    266303                if ( eEndSpan ) 
    267304                { 
     
    284321                if ( ! this._Range ) 
    285322                        return { "Start" : 0, "End" : 0 } ; 
    286                          
     323 
    287324                // First, we record down the offset values 
    288                 var bookmark =  
     325                var bookmark = 
    289326                { 
    290327                        "Start" : [ this._Range.startOffset ], 
     
    424461                switch ( unit ) 
    425462                { 
     463                        // Expand the range to include all inline parent elements if we are 
     464                        // are in their boundary limits. 
     465                        // For example (where [ ] are the range limits): 
     466                        //      Before =>               Some <b>[<i>Some sample text]</i></b>. 
     467                        //      After =>                Some [<b><i>Some sample text</i></b>]. 
     468                        case 'inline_elements' : 
     469                                // Expand the start boundary. 
     470                                if ( this._Range.startOffset == 0 ) 
     471                                { 
     472                                        oNode = this._Range.startContainer ; 
     473 
     474                                        if ( oNode.nodeType != 1 ) 
     475                                                oNode = oNode.parentNode ; 
     476 
     477                                        while ( FCKListsLib.InlineNonEmptyElements[ oNode.nodeName.toLowerCase() ] ) 
     478                                        { 
     479                                                this._Range.setStartBefore( oNode ) ; 
     480 
     481                                                if ( oNode != oNode.parentNode.firstChild ) 
     482                                                        break ; 
     483 
     484                                                oNode = oNode.parentNode ; 
     485                                        } 
     486                                } 
     487 
     488                                // Expand the end boundary. 
     489                                oNode = this._Range.endContainer ; 
     490                                var offset = this._Range.endOffset ; 
     491 
     492                                if ( ( oNode.nodeType == 3 && offset >= oNode.nodeValue.length ) || ( oNode.nodeType == 1 && offset >= oNode.childNodes.length ) || ( oNode.nodeType != 1 && oNode.nodeType != 3 ) ) 
     493                                { 
     494                                        if ( oNode.nodeType != 1 ) 
     495                                                oNode = oNode.parentNode ; 
     496 
     497                                        while ( FCKListsLib.InlineNonEmptyElements[ oNode.nodeName.toLowerCase() ] ) 
     498                                        { 
     499                                                this._Range.setEndAfter( oNode ) ; 
     500 
     501                                                if ( oNode != oNode.parentNode.lastChild ) 
     502                                                        break ; 
     503 
     504                                                oNode = oNode.parentNode ; 
     505                                        } 
     506                                } 
     507 
     508                                break ; 
     509 
    426510                        case 'block_contents' : 
    427511                                if ( this.StartBlock ) 
     
    531615                                if ( !eStartBlock ) 
    532616                                { 
    533                                         eStartBlock = this._FixBlock( true ) ; 
    534                                         eEndBlock       = this.EndBlock ;       // _FixBlock may have fixed the EndBlock too. 
     617                                        eStartBlock = this.FixBlock( true ) ; 
     618                                        eEndBlock       = this.EndBlock ;       // FixBlock may have fixed the EndBlock too. 
    535619                                } 
    536620 
    537621                                if ( !eEndBlock ) 
    538                                         eEndBlock = this._FixBlock( false ) ; 
     622                                        eEndBlock = this.FixBlock( false ) ; 
    539623                        } 
    540624 
     
    546630                                this.DeleteContents() ; 
    547631 
    548                         if ( eStartBlock && eEndBlock &&  eStartBlock == eEndBlock ) 
     632                        if ( eStartBlock && eEndBlock && eStartBlock == eEndBlock ) 
    549633                        { 
    550634                                if ( bIsStartOfBlock ) 
     
    596680 
    597681        // Transform a block without a block tag in a valid block (orphan text in the body or td, usually).