--- /dev/null
+/*\r
+Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.\r
+For licensing, see LICENSE.html or http://ckeditor.com/license\r
+*/\r
+\r
+/**\r
+ * @file Paste as plain text plugin\r
+ */\r
+\r
+(function()\r
+{\r
+ // The pastetext command definition.\r
+ var pasteTextCmd =\r
+ {\r
+ exec : function( editor )\r
+ {\r
+ var clipboardText = CKEDITOR.tools.tryThese(\r
+ function()\r
+ {\r
+ var clipboardText = window.clipboardData.getData( 'Text' );\r
+ if ( !clipboardText )\r
+ throw 0;\r
+ return clipboardText;\r
+ }\r
+ // Any other approach that's working...\r
+ );\r
+\r
+ if ( !clipboardText ) // Clipboard access privilege is not granted.\r
+ {\r
+ editor.openDialog( 'pastetext' );\r
+ return false;\r
+ }\r
+ else\r
+ editor.fire( 'paste', { 'text' : clipboardText } );\r
+\r
+ return true;\r
+ }\r
+ };\r
+\r
+ // Register the plugin.\r
+ CKEDITOR.plugins.add( 'pastetext',\r
+ {\r
+ init : function( editor )\r
+ {\r
+ var commandName = 'pastetext',\r
+ command = editor.addCommand( commandName, pasteTextCmd );\r
+\r
+ editor.ui.addButton( 'PasteText',\r
+ {\r
+ label : editor.lang.pasteText.button,\r
+ command : commandName\r
+ });\r
+\r
+ CKEDITOR.dialog.add( commandName, CKEDITOR.getUrl( this.path + 'dialogs/pastetext.js' ) );\r
+\r
+ if ( editor.config.forcePasteAsPlainText )\r
+ {\r
+ // Intercept the default pasting process.\r
+ editor.on( 'beforeCommandExec', function ( evt )\r
+ {\r
+ if ( evt.data.name == 'paste' )\r
+ {\r
+ editor.execCommand( 'pastetext' );\r
+ evt.cancel();\r
+ }\r
+ }, null, null, 0 );\r
+ }\r
+\r
+ editor.on( 'pasteState', function( evt )\r
+ {\r
+ editor.getCommand( 'pastetext' ).setState( evt.data );\r
+ });\r
+ },\r
+\r
+ requires : [ 'clipboard' ]\r
+ });\r
+\r
+})();\r
+\r
+\r
+/**\r
+ * Whether to force all pasting operations to insert on plain text into the\r
+ * editor, loosing any formatting information possibly available in the source\r
+ * text.\r
+ * @name CKEDITOR.config.forcePasteAsPlainText\r
+ * @type Boolean\r
+ * @default false\r
+ * @example\r
+ * config.forcePasteAsPlainText = true;\r
+ */\r