Changeset 589

Show
Ignore:
Timestamp:
2007-07-30 06:38:36 (16 months ago)
Author:
martinkou
Message:

Fixed the issue where calling FCKDomRange.MoveToSelection() throws JavaScript errors under Safari, when the editor frame has not been selected yet.
Fixed the issue where calling FCK.InsertHtml() throws JavaScript errors under Safari, when the editor frame has not been selected yet.
Fixed #338 : Dropping data objects into the editor will now be processed as a paste, and the FCKConfig.ForcePasteAsPlainText setting will be honored.

Location:
FCKeditor/trunk/editor/_source
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • FCKeditor/trunk/editor/_source/classes/fckdomrange_gecko.js

    r444 r589  
    3535                this._UpdateElementInfo() ; 
    3636        } 
     37        else 
     38                this.MoveToElementStart( this.Window.document.body ) ; 
    3739} 
    3840 
  • FCKeditor/trunk/editor/_source/classes/fckeditingarea.js

    r588 r589  
    170170        if ( FCKBrowserInfo.IsIE ) 
    171171        { 
     172                // The fiddling with UNSELECTABLE is a trick for fixing an IE browser bug, don't remove. 
     173                // See #523 for information about the bug. 
    172174                oDoc.body.unselectable = "on" ; 
    173175                oDoc.body.contentEditable = true ; 
  • FCKeditor/trunk/editor/_source/internals/fck_gecko.js

    r587 r589  
    5454                FCK.Events.FireEvent( "OnMouseUp",e ) ; 
    5555        } 
     56 
     57        this._ExecDrop = function( evt ) 
     58        { 
     59                if ( FCKConfig.ForcePasteAsPlainText ) 
     60                { 
     61                        if ( evt.dataTransfer ) 
     62                        { 
     63                                var text = evt.dataTransfer.getData( 'Text' ) ; 
     64                                text = FCKTools.HTMLEncode( text ) ; 
     65                                text = FCKTools.ProcessLineBreaks( window, FCKConfig, text ) ; 
     66                                FCK.InsertHtml( text ) ; 
     67                        } 
     68                        else 
     69                                FCK.PasteAsPlainText() ; 
     70                } 
     71                else 
     72                        FCKDialog.OpenDialog( 'FCKDialog_Paste', FCKLang.Paste, 'dialog/fck_paste.html', 400, 330, 'Security' ) ; 
     73                evt.preventDefault() ; 
     74                evt.stopPropagation() ; 
     75        } 
     76 
    5677        this.ExecOnSelectionChangeTimer = function() 
    5778        { 
     
    83104        this.EditorDocument.addEventListener( 'mouseup', this._ExecMouseUp, true ) ; 
    84105        this.EditorDocument.addEventListener( 'mousemove', this._ExecMouseMove, true ) ; 
     106 
     107        // Hooks for data object drops 
     108        if ( FCKBrowserInfo.IsGecko ) 
     109        { 
     110                this.EditorWindow.captureEvents( Event.DRAGDROP ) ; 
     111                this.EditorWindow.addEventListener( 'dragdrop', this._ExecDrop, true ) ; 
     112        } 
     113        else if ( FCKBrowserInfo.IsSafari ) 
     114        { 
     115                var cancelHandler = function( evt ){ evt.returnValue = false ; } 
     116                this.EditorDocument.addEventListener( 'dragenter', cancelHandler, true ) ; 
     117                this.EditorDocument.addEventListener( 'dragover', cancelHandler, true ) ; 
     118                this.EditorDocument.addEventListener( 'drop', this._ExecDrop, true ) ; 
     119        } 
    85120 
    86121        // Reset the context menu. 
     
    191226        var oRange = oSel.getRangeAt(0) ; 
    192227 
     228        // If a range is not available ( occurs under Safari ) 
     229        // Append to the end of the editor document. 
     230        if ( ! oRange ) 
     231        { 
     232                oRange = this.EditorDocument.createRange() ; 
     233                oRange.selectNodeContents( this.EditorDocument.body ) ; 
     234                oRange.collapse( false ) ; 
     235        } 
     236 
    193237        // Create a fragment with the input HTML. 
    194238        var oFragment = oRange.createContextualFragment( html ) ; 
  • FCKeditor/trunk/editor/_source/internals/fck_ie.js

    r587 r589  
    107107} 
    108108 
     109function Doc_OnDrop() 
     110{ 
     111        var evt = FCK.EditorWindow.event ; 
     112        if ( FCKConfig.ForcePasteAsPlainText ) 
     113                FCK.PasteAsPlainText( evt.dataTransfer.getData( 'Text' ) ) ; 
     114        else 
     115                FCKTools.RunFunction( FCKDialog.OpenDialog, FCKDialog, ['FCKDialog_Paste', FCKLang.Paste, 'dialog/fck_paste.html', 400, 330, 'Security'] ) ; 
     116        evt.returnValue = false ; 
     117        evt.cancelBubble = true ; 
     118} 
     119 
     120function Doc_CancelDefault() 
     121{ 
     122        FCK.EditorWindow.event.returnValue = false ; 
     123} 
     124 
    109125FCK.InitializeBehaviors = function( dontReturn ) 
    110126{ 
     
    115131        // Intercept pasting operations 
    116132        this.EditorDocument.body.attachEvent( 'onpaste', Doc_OnPaste ) ; 
     133 
     134        // Intercept drop operations 
     135        this.EditorDocument.body.attachEvent( 'ondragenter', Doc_CancelDefault ) ; 
     136        this.EditorDocument.body.attachEvent( 'ondragover', Doc_CancelDefault ) ; 
     137        this.EditorDocument.body.attachEvent( 'ondrop', Doc_OnDrop ) ; 
    117138 
    118139        // Reset the context menu. 
     
    251272} 
    252273 
    253 FCK.PasteAsPlainText = function() 
     274FCK.PasteAsPlainText = function( forceText ) 
    254275{ 
    255276        if ( !FCK._CheckIsPastingEnabled() ) 
     
    260281 
    261282        // Get the data available in the clipboard in text format. 
    262         var sText = clipboardData.getData("Text") ; 
     283        var sText = null ; 
     284        if ( ! forceText ) 
     285                sText = clipboardData.getData("Text") ; 
     286        else  
     287                sText = forceText ; 
    263288 
    264289        if ( sText && sText.length > 0 )