2 Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.
3 For licensing, see LICENSE.html or http://ckeditor.com/license
7 * @file Paste as plain text plugin
12 // The pastetext command definition.
15 exec : function( editor )
17 var clipboardText = CKEDITOR.tools.tryThese(
20 var clipboardText = window.clipboardData.getData( 'Text' );
25 // Any other approach that's working...
28 if ( !clipboardText ) // Clipboard access privilege is not granted.
30 editor.openDialog( 'pastetext' );
34 editor.fire( 'paste', { 'text' : clipboardText } );
40 // Register the plugin.
41 CKEDITOR.plugins.add( 'pastetext',
43 init : function( editor )
45 var commandName = 'pastetext',
46 command = editor.addCommand( commandName, pasteTextCmd );
48 editor.ui.addButton( 'PasteText',
50 label : editor.lang.pasteText.button,
54 CKEDITOR.dialog.add( commandName, CKEDITOR.getUrl( this.path + 'dialogs/pastetext.js' ) );
56 if ( editor.config.forcePasteAsPlainText )
58 // Intercept the default pasting process.
59 editor.on( 'beforeCommandExec', function ( evt )
61 if ( evt.data.name == 'paste' )
63 editor.execCommand( 'pastetext' );
69 editor.on( 'pasteState', function( evt )
71 editor.getCommand( 'pastetext' ).setState( evt.data );
75 requires : [ 'clipboard' ]
82 * Whether to force all pasting operations to insert on plain text into the
83 * editor, loosing any formatting information possibly available in the source
85 * @name CKEDITOR.config.forcePasteAsPlainText
89 * config.forcePasteAsPlainText = true;