Changeset 637

Show
Ignore:
Timestamp:
2007-08-08 11:11:57 (16 months ago)
Author:
martinkou
Message:

Fixed #328 : Added logic for inserting a bogus <$EnterMode> tag towards the end in WYSIWYG mode, such that the user can escape from a formatted block at the end of the document.

Location:
FCKeditor/trunk/editor/_source/internals
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • FCKeditor/trunk/editor/_source/internals/fckdomtools.js

    r600 r637  
    292292 
    293293                return -1 ; 
     294        }, 
     295 
     296        PaddingNodeTag : ( new Date() ).getTime() + "_documentPadding", 
     297 
     298        EnforcePaddingNode : function( doc, tagName ) 
     299        { 
     300                this.CheckAndRemovePaddingNode( doc, tagName, true ) ; 
     301                if ( ! doc.body.lastChild  
     302                                || doc.body.lastChild.nodeType != 1  
     303                                || doc.body.lastChild.tagName.toLowerCase() == tagName.toLowerCase() ) 
     304                        return ; 
     305                var node = doc.createElement( tagName ) ; 
     306                if ( FCKBrowserInfo.IsGecko && FCKListsLib.NonEmptyBlockElements[ tagName ] ) 
     307                        FCKTools.AppendBogusBr( node ) ; 
     308                node.id = this.PaddingNodeTag ; 
     309                doc.body.appendChild( node ) ; 
     310        }, 
     311 
     312        CheckAndRemovePaddingNode : function( doc, tagName, dontRemove ) 
     313        { 
     314                var paddingNode = doc.getElementById( this.PaddingNodeTag ) ; 
     315                if ( ! paddingNode ) 
     316                        return ; 
     317 
     318                // If the padding node is changed, remove its status as a padding node. 
     319                if ( paddingNode.parentNode != doc.body 
     320                        || paddingNode.tagName.toLowerCase() != tagName 
     321                        || ( paddingNode.childNodes.length > 1 )  
     322                        || ( paddingNode.firstChild && paddingNode.firstChild.nodeValue != '\xa0'  
     323                                && String(paddingNode.firstChild.tagName).toLowerCase() != 'br' ) ) 
     324                { 
     325                        paddingNode.removeAttribute( 'id' ) ; 
     326                        return ; 
     327                } 
     328 
     329                // Now we're sure the padding node exists, and it is unchanged, remove it. 
     330                if ( !dontRemove ) 
     331                paddingNode.parentNode.removeChild( paddingNode ) ; 
    294332        } 
    295333} ; 
  • FCKeditor/trunk/editor/_source/internals/fck.js

    r621 r637  
    772772} 
    773773 
     774function _FCK_PaddingNodeListener() 
     775{ 
     776        FCKDomTools.EnforcePaddingNode( FCK.EditorDocument, FCKConfig.EnterMode ) ; 
     777} 
     778 
    774779function _FCK_EditingArea_OnLoad() 
    775780{ 
     
    779784 
    780785        FCK.InitializeBehaviors() ; 
     786        FCK.AttachToOnSelectionChange( _FCK_PaddingNodeListener ) ; 
    781787         
    782788        // Listen for mousedown and mouseup events for tracking drag and drops. 
  • FCKeditor/trunk/editor/_source/internals/fckxhtml.js

    r600 r637  
    2828FCKXHtml.GetXHTML = function( node, includeNode, format ) 
    2929{ 
     30        FCKDomTools.CheckAndRemovePaddingNode( node.ownerDocument, FCKConfig.EnterMode ) ; 
    3031        FCKXHtmlEntities.Initialize() ; 
    3132 
     
    9798                FCK.ResetIsDirty() ; 
    9899 
     100        FCKDomTools.EnforcePaddingNode( node.ownerDocument, FCKConfig.EnterMode ) ; 
    99101        return sXHTML ; 
    100102}