| Server IP : 180.180.241.3 / Your IP : 216.73.216.35 Web Server : Microsoft-IIS/7.5 System : Windows NT NETWORK-NHRC 6.1 build 7601 (Windows Server 2008 R2 Standard Edition Service Pack 1) i586 User : IUSR ( 0) PHP Version : 5.3.28 Disable Function : NONE MySQL : ON | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /AppServ/www/umedia3/js/ckeditor/_source/plugins/pastetext/ |
Upload File : |
/*
Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.html or http://ckeditor.com/license
*/
/**
* @file Paste as plain text plugin
*/
(function()
{
// The pastetext command definition.
var pasteTextCmd =
{
exec : function( editor )
{
// We use getClipboardData just to test if the clipboard access has
// been granted by the user.
if ( CKEDITOR.getClipboardData() === false || !window.clipboardData )
{
editor.openDialog( 'pastetext' );
return;
}
editor.insertText( window.clipboardData.getData( 'Text' ) );
}
};
// Register the plugin.
CKEDITOR.plugins.add( 'pastetext',
{
init : function( editor )
{
var commandName = 'pastetext',
command = editor.addCommand( commandName, pasteTextCmd );
editor.ui.addButton( 'PasteText',
{
label : editor.lang.pasteText.button,
command : commandName
});
CKEDITOR.dialog.add( commandName, CKEDITOR.getUrl( this.path + 'dialogs/pastetext.js' ) );
if ( editor.config.forcePasteAsPlainText )
{
editor.on( 'beforePaste', function( event )
{
if ( editor.mode == "wysiwyg" )
{
setTimeout( function() { command.exec(); }, 0 );
event.cancel();
}
},
null, null, 20 );
}
},
requires : [ 'clipboard' ]
});
var clipboardDiv;
CKEDITOR.getClipboardData = function()
{
if ( !CKEDITOR.env.ie )
return false;
var doc = CKEDITOR.document,
body = doc.getBody();
if ( !clipboardDiv )
{
clipboardDiv = doc.createElement( 'div',
{
attributes :
{
id: 'cke_hiddenDiv'
},
styles :
{
position : 'absolute',
visibility : 'hidden',
overflow : 'hidden',
width : '1px',
height : '1px'
}
});
clipboardDiv.setHtml( '' );
clipboardDiv.appendTo( body );
}
// The "enabled" flag is used to check whether the paste operation has
// been completed (the onpaste event has been fired).
var enabled = false;
var setEnabled = function()
{
enabled = true;
};
body.on( 'paste', setEnabled );
// Create a text range and move it inside the div.
var textRange = body.$.createTextRange();
textRange.moveToElementText( clipboardDiv.$ );
// The execCommand in will fire the "onpaste", only if the
// security settings are enabled.
textRange.execCommand( 'Paste' );
// Get the DIV html and reset it.
var html = clipboardDiv.getHtml();
clipboardDiv.setHtml( '' );
body.removeListener( 'paste', setEnabled );
// Return the HTML or false if not enabled.
return enabled && html;
};
})();
CKEDITOR.editor.prototype.insertText = function( text )
{
text = CKEDITOR.tools.htmlEncode( text );
// TODO: Replace the following with fill line break processing (see V2).
text = text.replace( /(?:\r\n)|\n|\r/g, '<br>' );
this.insertHtml( text );
};
/**
* Whether to force all pasting operations to insert on plain text into the
* editor, loosing any formatting information possibly available in the source
* text.
* @type Boolean
* @default false
* @example
* config.forcePasteAsPlainText = true;
*/
CKEDITOR.config.forcePasteAsPlainText = false;