Nation Notes module contributed by Z&H Healthcare.
[openemr.git] / library / custom_template / ckeditor / _source / plugins / pastetext / plugin.js
blobcf59db9e8c0c6db854f5ffe5f3283149a37348ea
1 /*
2 Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.
3 For licensing, see LICENSE.html or http://ckeditor.com/license
4 */
6 /**
7  * @file Paste as plain text plugin
8  */
10 (function()
12         // The pastetext command definition.
13         var pasteTextCmd =
14         {
15                 exec : function( editor )
16                 {
17                         var clipboardText = CKEDITOR.tools.tryThese(
18                                 function()
19                                 {
20                                         var clipboardText = window.clipboardData.getData( 'Text' );
21                                         if ( !clipboardText )
22                                                 throw 0;
23                                         return clipboardText;
24                                 }
25                                 // Any other approach that's working...
26                                 );
28                         if ( !clipboardText )   // Clipboard access privilege is not granted.
29                         {
30                                 editor.openDialog( 'pastetext' );
31                                 return false;
32                         }
33                         else
34                                 editor.fire( 'paste', { 'text' : clipboardText } );
36                         return true;
37                 }
38         };
40         // Register the plugin.
41         CKEDITOR.plugins.add( 'pastetext',
42         {
43                 init : function( editor )
44                 {
45                         var commandName = 'pastetext',
46                                 command = editor.addCommand( commandName, pasteTextCmd );
48                         editor.ui.addButton( 'PasteText',
49                                 {
50                                         label : editor.lang.pasteText.button,
51                                         command : commandName
52                                 });
54                         CKEDITOR.dialog.add( commandName, CKEDITOR.getUrl( this.path + 'dialogs/pastetext.js' ) );
56                         if ( editor.config.forcePasteAsPlainText )
57                         {
58                                 // Intercept the default pasting process.
59                                 editor.on( 'beforeCommandExec', function ( evt )
60                                 {
61                                         if ( evt.data.name == 'paste' )
62                                         {
63                                                 editor.execCommand( 'pastetext' );
64                                                 evt.cancel();
65                                         }
66                                 }, null, null, 0 );
67                         }
69                         editor.on( 'pasteState', function( evt )
70                                 {
71                                         editor.getCommand( 'pastetext' ).setState( evt.data );
72                                 });
73                 },
75                 requires : [ 'clipboard' ]
76         });
78 })();
81 /**
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
84  * text.
85  * @name CKEDITOR.config.forcePasteAsPlainText
86  * @type Boolean
87  * @default false
88  * @example
89  * config.forcePasteAsPlainText = true;
90  */