summaryrefslogtreecommitdiff
path: root/plugins/pastetext/plugin.js
diff options
context:
space:
mode:
authorLester Caine <lester@lsces.co.uk>2009-11-24 23:57:24 +0000
committerLester Caine <lester@lsces.co.uk>2009-11-24 23:57:24 +0000
commit8630f2bc4d63b3320f5469d9532a1cba1dddb7a3 (patch)
treef3c3122e110458a94aae544164b82fd67f1ae5e0 /plugins/pastetext/plugin.js
parente24cb83aa7f7685a4811e5c8d39541bae7b15cb2 (diff)
downloadckeditor-8630f2bc4d63b3320f5469d9532a1cba1dddb7a3.tar.gz
ckeditor-8630f2bc4d63b3320f5469d9532a1cba1dddb7a3.tar.bz2
ckeditor-8630f2bc4d63b3320f5469d9532a1cba1dddb7a3.zip
ckeditor 3.0.1 'raw' - needs reordering a little, but samples currently functional
Diffstat (limited to 'plugins/pastetext/plugin.js')
-rw-r--r--plugins/pastetext/plugin.js6
1 files changed, 6 insertions, 0 deletions
diff --git a/plugins/pastetext/plugin.js b/plugins/pastetext/plugin.js
new file mode 100644
index 0000000..998c88a
--- /dev/null
+++ b/plugins/pastetext/plugin.js
@@ -0,0 +1,6 @@
+/*
+Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
+For licensing, see LICENSE.html or http://ckeditor.com/license
+*/
+
+(function(){var a={exec:function(c){if(CKEDITOR.getClipboardData()===false||!window.clipboardData){c.openDialog('pastetext');return;}c.insertText(window.clipboardData.getData('Text'));}};CKEDITOR.plugins.add('pastetext',{init:function(c){var d='pastetext',e=c.addCommand(d,a);c.ui.addButton('PasteText',{label:c.lang.pasteText.button,command:d});CKEDITOR.dialog.add(d,CKEDITOR.getUrl(this.path+'dialogs/pastetext.js'));if(c.config.forcePasteAsPlainText)c.on('beforePaste',function(f){if(c.mode=='wysiwyg'){setTimeout(function(){e.exec();},0);f.cancel();}},null,null,20);},requires:['clipboard']});var b;CKEDITOR.getClipboardData=function(){if(!CKEDITOR.env.ie)return false;var c=CKEDITOR.document,d=c.getBody();if(!b){b=c.createElement('div',{attributes:{id:'cke_hiddenDiv'},styles:{position:'absolute',visibility:'hidden',overflow:'hidden',width:'1px',height:'1px'}});b.setHtml('');b.appendTo(d);}var e=false,f=function(){e=true;};d.on('paste',f);var g=d.$.createTextRange();g.moveToElementText(b.$);g.execCommand('Paste');var h=b.getHtml();b.setHtml('');d.removeListener('paste',f);return e&&h;};})();CKEDITOR.editor.prototype.insertText=function(a){a=CKEDITOR.tools.htmlEncode(a);a=a.replace(/(?:\r\n)|\n|\r/g,'<br>');this.insertHtml(a);};CKEDITOR.config.forcePasteAsPlainText=false;