Ticket #2203: fckstyles.patch

File fckstyles.patch, 3.4 KB (added by Jesse Redl, 15 years ago)

ataching proper file.....

  • fckstyle.js

     
    1 /*
     1/*
    22 * FCKeditor - The text editor for Internet - http://www.fckeditor.net
    33 * Copyright (C) 2003-2008 Frederico Caldeira Knabben
    44 *
     
    695695
    696696        _CompareAttributeValues : function( attName, valueA, valueB )
    697697        {
     698                var matchedStyle = false;
     699               
    698700                if ( attName == 'style' && valueA && valueB )
    699701                {
    700702                        valueA = valueA.replace( /;$/, '' ).toLowerCase() ;
    701703                        valueB = valueB.replace( /;$/, '' ).toLowerCase() ;
     704                        matchedStyle = valueA.indexOf( valueB ) >= 0 ? true : false ;
    702705                }
    703 
     706               
    704707                // Return true if they match or if valueA is null and valueB is an empty string
    705                 return ( valueA == valueB || ( ( valueA === null || valueA === '' ) && ( valueB === null || valueB === '' ) ) )
     708                return ( matchedStyle || valueA == valueB || ( ( valueA === null || valueA === '' ) && ( valueB === null || valueB === '' ) ) )
    706709        },
    707710
    708711        GetFinalAttributeValue : function( attName )
     
    11621165
    11631166                                        // Let's merge our new style with its neighbors, if possible.
    11641167                                        this._MergeSiblings( styleNode, this._GetAttribsForComparison() ) ;
     1168                                       
     1169                                        // In the case of span tags merge with child nodes to prevent duplication
     1170                                        this._MergeChildren( styleNode ) ;
     1171                                       
    11651172
    11661173                                        // As the style system breaks text nodes constantly, let's normalize
    11671174                                        // things for performance.
     
    12181225                        break ;
    12191226                }
    12201227        },
     1228       
     1229        /**
     1230         * Merge an element with its similar children.
     1231         */
     1232        _MergeChildren : function( element )
     1233        {
     1234                if ( !element || element.nodeType != 1 || !FCKListsLib.InlineNonEmptyElements[ element.nodeName.toLowerCase() ] )
     1235                        return ;
    12211236
     1237                this._MergeFirstChild( element ) ;
     1238                this._MergeLastChild( element ) ;
     1239        },
     1240       
     1241        _MergeFirstChild : function ( element )
     1242        {
     1243                var child = element.firstChild ;
     1244               
     1245                if ( child && child.nodeType == 1 && child.nodeName == element.nodeName && child.nextSibling == null)
     1246                {
     1247                        // Get the style of the element to merge to 
     1248                        var mergeStyle = child.style.cssText;
     1249
     1250                        // IE doesn't return a ";" when asking for a style so we add it here.
     1251                        if ( mergeStyle.charAt(mergeStyle.length - 1) != ";" ) { mergeStyle += ";"; }
     1252
     1253                        // add the selected texts style to the new node
     1254                        element.style.cssText = mergeStyle + element.style.cssText;
     1255
     1256                        // Move contents from the
     1257                        FCKDomTools.MoveChildren( child, element ) ;
     1258                        FCKDomTools.RemoveNode( child ) ;
     1259                }
     1260        },
     1261       
     1262        _MergeLastChild : function ( element )
     1263        {
     1264                var child = element.lastChild ;
     1265               
     1266                if ( child && child.nodeType == 1 && child.nodeName == element.nodeName && child.previousSibling == null)
     1267                {
     1268                        // Get the style of the element to merge to 
     1269                        var mergeStyle = child.style.cssText;
     1270
     1271                        // IE doesn't return a ";" when asking for a style so we add it here.
     1272                        if ( mergeStyle.charAt(mergeStyle.length - 1) != ";" ) { mergeStyle += ";"; }
     1273
     1274                        // add the selected texts style to the new node
     1275                        element.style.cssText = mergeStyle + element.style.cssText;
     1276
     1277                        // Move contents from the child
     1278                        FCKDomTools.MoveChildren( child, element ) ;
     1279                        FCKDomTools.RemoveNode( child ) ;
     1280                }
     1281        },
     1282
    12221283        /**
    12231284         * Merge an element with its similar siblings.
    12241285         * "attribs" is and object computed with _CreateAttribsForComparison.
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy