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