Show
Ignore:
Timestamp:
2007-07-07 13:14:45 (18 months ago)
Author:
martinkou
Message:

Fixed #102 : HTML code generated by the "Paste As Plain Text" feature now obeys the EnterMode setting.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • FCKeditor/trunk/editor/dialog/fck_paste.html

    r224 r414  
    102102        { 
    103103                sHtml = oEditor.FCKTools.HTMLEncode( document.getElementById('txtData').value )  ; 
    104                 sHtml = sHtml.replace( /\n/g, '<BR>' ) ; 
     104                sHtml = FCKTools.ProcessLineBreaks( oEditor, FCKConfig, sHtml ) ; 
     105 
     106                // FCK.InsertHtml() does not work for us, since document fragments cannot contain node fragments. :( 
     107                // Use the marker method instead. It's primitive, but it works. 
     108                var range = new oEditor.FCKDomRange( oEditor.FCK.EditorWindow ) ; 
     109                var oDoc = oEditor.FCK.EditorDocument ; 
     110                range.MoveToSelection() ; 
     111                range.DeleteContents() ; 
     112                var marker = [] ; 
     113                for ( var i = 0 ; i < 5 ; i++ ) 
     114                        marker.push( parseInt(Math.random() * 100000) ) ; 
     115                marker = marker.join( "" ) ; 
     116                range.InsertNode ( oDoc.createTextNode( marker ) ) ; 
     117                range.Release() ; 
     118 
     119                // Now we've got a marker indicating the paste position in the editor document. 
     120                // Find its position in the HTML code. 
     121                var htmlString = oDoc.body.innerHTML ; 
     122                var index = htmlString.indexOf( marker ) ; 
     123 
     124                // Split it the HTML code up, add the code we generated, and put them back together. 
     125                var htmlList = [] ; 
     126                htmlList.push( htmlString.substr( 0, index ) ) ; 
     127                htmlList.push( sHtml ) ; 
     128                htmlList.push( htmlString.substr( index + marker.length ) ) ; 
     129                htmlString = htmlList.join( "" ) ; 
     130 
     131                if ( oEditor.FCKBrowserInfo.IsIE ) 
     132                        oEditor.FCK.SetInnerHtml( htmlString ) ; 
     133                else 
     134                        oDoc.body.innerHTML = htmlString ; 
     135 
     136                return true ; 
    105137        } 
    106138