/* * FCKeditor - The text editor for Internet - http://www.fckeditor.net * Copyright (C) 2003-2007 Frederico Caldeira Knabben * * == BEGIN LICENSE == * * Licensed under the terms of any of the following licenses at your * choice: * * - GNU General Public License Version 2 or later (the "GPL") * http://www.gnu.org/licenses/gpl.html * * - GNU Lesser General Public License Version 2.1 or later (the "LGPL") * http://www.gnu.org/licenses/lgpl.html * * - Mozilla Public License Version 1.1 or later (the "MPL") * http://www.mozilla.org/MPL/MPL-1.1.html * * == END LICENSE == * * File Name: fck_2_ie.js * This is the second part of the "FCK" object creation. This is the main * object that represents an editor instance. * (IE specific implementations) * * File Authors: * Frederico Caldeira Knabben (fredck@fckeditor.net) */ /* if ( FCKConfig.UseBROnCarriageReturn ) { // Named commands to be handled by this browsers specific implementation. FCK.RedirectNamedCommands = { InsertOrderedList : true, InsertUnorderedList : true } FCK.ExecuteRedirectedNamedCommand = function( commandName, commandParameter ) { if ( commandName == 'InsertOrderedList' || commandName == 'InsertUnorderedList' ) { if ( !(FCK.EditorDocument.queryCommandState( 'InsertOrderedList' ) || FCK.EditorDocument.queryCommandState( 'InsertUnorderedList' )) ) { } } FCK.ExecuteNamedCommand( commandName, commandParameter ) ; } } */ FCK.Paste = function() { if ( FCKConfig.ForcePasteAsPlainText ) { FCK.PasteAsPlainText() ; return ; } var sHTML = FCK.GetClipboardHTML() ; if ( FCKConfig.AutoDetectPasteFromWord ) { var re = /<\w[^>]*(( class="?MsoNormal"?)|(="mso-))/gi ; if ( re.test( sHTML ) ) { if ( confirm( FCKLang["PasteWordConfirm"] ) ) { FCK.PasteFromWord() ; return ; } } } FCK.InsertHtml( sHTML ) ; } FCK.PasteAsPlainText = function() { // Get the data available in the clipboard and encodes it in HTML. var sText = FCKTools.HTMLEncode( clipboardData.getData("Text") ) ; // Replace the carriage returns with
sText = sText.replace( /\n/g, '
' ) ; // Insert the resulting data in the editor. this.InsertHtml( sText ) ; } /* FCK.PasteFromWord = function() { FCK.CleanAndPaste( FCK.GetClipboardHTML() ) ; } */ FCK.InsertElement = function( element ) { FCK.InsertHtml( element.outerHTML ) ; } FCK.GetClipboardHTML = function() { var oDiv = document.getElementById( '___FCKHiddenDiv' ) ; if ( !oDiv ) { var oDiv = document.createElement( 'DIV' ) ; oDiv.id = '___FCKHiddenDiv' ; oDiv.style.visibility = 'hidden' ; oDiv.style.overflow = 'hidden' ; oDiv.style.position = 'absolute' ; oDiv.style.width = 1 ; oDiv.style.height = 1 ; document.body.appendChild( oDiv ) ; } oDiv.innerHTML = '' ; var oTextRange = document.body.createTextRange() ; oTextRange.moveToElementText( oDiv ) ; oTextRange.execCommand( 'Paste' ) ; var sData = oDiv.innerHTML ; oDiv.innerHTML = '' ; return sData ; } FCK.AttachToOnSelectionChange = function( functionPointer ) { this.Events.AttachEvent( 'OnSelectionChange', functionPointer ) ; } /* FCK.AttachToOnSelectionChange = function( functionPointer ) { FCK.EditorDocument.attachEvent( 'onselectionchange', functionPointer ) ; } */ FCK.CreateLink = function( url ) { // Remove any existing link in the selection. FCK.ExecuteNamedCommand( 'Unlink' ) ; if ( url.length > 0 ) { // Generate a temporary name for the link. var sTempUrl = 'javascript:void(0);/*' + ( new Date().getTime() ) + '*/' ; // Use the internal "CreateLink" command to create the link. FCK.ExecuteNamedCommand( 'CreateLink', sTempUrl ) ; // Look for the just create link. var oLinks = this.EditorDocument.links ; for ( i = 0 ; i < oLinks.length ; i++ ) { var oLink = oLinks[i] ; if ( oLink.href == sTempUrl ) { var sInnerHtml = oLink.innerHTML ; // Save the innerHTML (IE changes it if it is like an URL). oLink.href = url ; oLink.innerHTML = sInnerHtml ; // Restore the innerHTML. return oLink ; } } } }