\/body><\/html>\') ;' + 'document.close() ;' + 'document.body.contentEditable = true ;' + 'window.focus() ;' + '})() )' ; var eFrameSpace = document.getElementById( 'xFrameSpace' ) ; eFrameSpace.innerHTML = '<\/iframe>' ; var oFrame = eFrameSpace.firstChild ; if ( !oEditor.FCK_IS_CUSTOM_DOMAIN || !FCKBrowserInfo.IsIE ) { // Avoid errors if the pasted content has any script that fails: #389 var oDoc = oFrame.contentWindow.document ; oDoc.open() ; oDoc.write(' <\/body><\/html>') ; oDoc.close() ; if ( FCKBrowserInfo.IsIE ) oDoc.body.contentEditable = true ; else oDoc.designMode = 'on' ; oFrame.contentWindow.focus(); } } else { document.getElementById('txtData').style.display = '' ; } if ( sPastingType != 'Word' ) document.getElementById('oWordCommands').style.display = 'none' ; dialog.SetOkButton( true ) ; dialog.SetAutoSize( true ) ; } function Ok() { // Before doing anything, save undo snapshot. oEditor.FCKUndo.SaveUndoStep() ; var sHtml ; var sPastingType = dialog.Args().CustomValue ; if ( sPastingType == 'Word' || sPastingType == 'Security' ) { var oFrame = document.getElementById('frmData') ; var oBody ; if ( oFrame.contentDocument ) oBody = oFrame.contentDocument.body ; else oBody = oFrame.contentWindow.document.body ; if ( sPastingType == 'Word' ) { // If a plugin creates a FCK.CustomCleanWord function it will be called instead of the default one if ( typeof( FCK.CustomCleanWord ) == 'function' ) sHtml = FCK.CustomCleanWord( oBody, document.getElementById('chkRemoveFont').checked, document.getElementById('chkRemoveStyles').checked ) ; else sHtml = CleanWord( oBody, document.getElementById('chkRemoveFont').checked, document.getElementById('chkRemoveStyles').checked ) ; } else sHtml = oBody.innerHTML ; // Fix relative anchor URLs (IE automatically adds the current page URL). var re = new RegExp( window.location + "#", "g" ) ; sHtml = sHtml.replace( re, '#') ; } else { sHtml = oEditor.FCKTools.HTMLEncode( document.getElementById('txtData').value ) ; sHtml = FCKTools.ProcessLineBreaks( oEditor, FCKConfig, sHtml ) ; // FCK.InsertHtml() does not work for us, since document fragments cannot contain node fragments. :( // Use the marker method instead. It's primitive, but it works. var range = new oEditor.FCKDomRange( oEditor.FCK.EditorWindow ) ; var oDoc = oEditor.FCK.EditorDocument ; dialog.Selection.EnsureSelection() ; range.MoveToSelection() ; range.DeleteContents() ; var marker = [] ; for ( var i = 0 ; i < 5 ; i++ ) marker.push( parseInt(Math.random() * 100000, 10 ) ) ; marker = marker.join( "" ) ; range.InsertNode ( oDoc.createTextNode( marker ) ) ; var bookmark = range.CreateBookmark() ; // Now we've got a marker indicating the paste position in the editor document. // Find its position in the HTML code. var htmlString = oDoc.body.innerHTML ; var index = htmlString.indexOf( marker ) ; // Split it the HTML code up, add the code we generated, and put them back together. var htmlList = [] ; htmlList.push( htmlString.substr( 0, index ) ) ; htmlList.push( sHtml ) ; htmlList.push( htmlString.substr( index + marker.length ) ) ; htmlString = htmlList.join( "" ) ; if ( oEditor.FCKBrowserInfo.IsIE ) oEditor.FCK.SetInnerHtml( htmlString ) ; else oDoc.body.innerHTML = htmlString ; range.MoveToBookmark( bookmark ) ; range.Collapse( false ) ; range.Select() ; range.Release() ; return true ; } oEditor.FCK.InsertHtml( sHtml ) ; return true ; } // This function will be called from the PasteFromWord dialog (fck_paste.html) // Input: oNode a DOM node that contains the raw paste from the clipboard // bIgnoreFont, bRemoveStyles booleans according to the values set in the dialog // Output: the cleaned string function CleanWord( oNode, bIgnoreFont, bRemoveStyles ) { var html = oNode.innerHTML ; html = html.replace(/\s*<\/o:p>/g, '') ; html = html.replace(/[\s\S]*?<\/o:p>/g, ' ') ; // Remove mso-xxx styles. html = html.replace( /\s*mso-[^:]+:[^;"]+;?/gi, '' ) ; // Remove margin styles. html = html.replace( /\s*MARGIN: 0cm 0cm 0pt\s*;/gi, '' ) ; html = html.replace( /\s*MARGIN: 0cm 0cm 0pt\s*"/gi, "\"" ) ; html = html.replace( /\s*TEXT-INDENT: 0cm\s*;/gi, '' ) ; html = html.replace( /\s*TEXT-INDENT: 0cm\s*"/gi, "\"" ) ; html = html.replace( /\s*TEXT-ALIGN: [^\s;]+;?"/gi, "\"" ) ; html = html.replace( /\s*PAGE-BREAK-BEFORE: [^\s;]+;?"/gi, "\"" ) ; html = html.replace( /\s*FONT-VARIANT: [^\s;]+;?"/gi, "\"" ) ; html = html.replace( /\s*tab-stops:[^;"]*;?/gi, '' ) ; html = html.replace( /\s*tab-stops:[^"]*/gi, '' ) ; // Remove FONT face attributes. if ( bIgnoreFont ) { html = html.replace( /\s*face="[^"]*"/gi, '' ) ; html = html.replace( /\s*face=[^ >]*/gi, '' ) ; html = html.replace( /\s*FONT-FAMILY:[^;"]*;?/gi, '' ) ; } // Remove Class attributes html = html.replace(/<(\w[^>]*) class=([^ |>]*)([^>]*)/gi, "<$1$3") ; // Remove styles. if ( bRemoveStyles ) html = html.replace( /<(\w[^>]*) style="([^\"]*)"([^>]*)/gi, "<$1$3" ) ; // Remove style, meta and link tags html = html.replace( /