summaryrefslogtreecommitdiff
path: root/public/javascripts/tiny_mce/plugins/paste
diff options
context:
space:
mode:
Diffstat (limited to 'public/javascripts/tiny_mce/plugins/paste')
-rwxr-xr-xpublic/javascripts/tiny_mce/plugins/paste/blank.htm22
-rwxr-xr-xpublic/javascripts/tiny_mce/plugins/paste/css/blank.css14
-rwxr-xr-xpublic/javascripts/tiny_mce/plugins/paste/css/pasteword.css3
-rwxr-xr-xpublic/javascripts/tiny_mce/plugins/paste/editor_plugin.js1
-rwxr-xr-xpublic/javascripts/tiny_mce/plugins/paste/editor_plugin_src.js394
-rwxr-xr-xpublic/javascripts/tiny_mce/plugins/paste/js/pastetext.js42
-rwxr-xr-xpublic/javascripts/tiny_mce/plugins/paste/js/pasteword.js56
-rwxr-xr-xpublic/javascripts/tiny_mce/plugins/paste/langs/en_dlg.js5
-rwxr-xr-xpublic/javascripts/tiny_mce/plugins/paste/pastetext.htm34
-rwxr-xr-xpublic/javascripts/tiny_mce/plugins/paste/pasteword.htm29
10 files changed, 600 insertions, 0 deletions
diff --git a/public/javascripts/tiny_mce/plugins/paste/blank.htm b/public/javascripts/tiny_mce/plugins/paste/blank.htm
new file mode 100755
index 0000000..7ba26bd
--- /dev/null
+++ b/public/javascripts/tiny_mce/plugins/paste/blank.htm
@@ -0,0 +1,22 @@
1<html xmlns="http://www.w3.org/1999/xhtml">
2<head>
3<title>blank_page</title>
4<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
5<link href="css/blank.css" rel="stylesheet" type="text/css" />
6<base target="_self" />
7<script type="text/javascript">
8function init() {
9 if (parent.tinymce.isIE)
10 document.body.contentEditable = true;
11 else
12 document.designMode = 'on';
13
14 parent.initIframe(document);
15 window.focus();
16}
17</script>
18</head>
19<body onload="init();">
20
21</body>
22</html>
diff --git a/public/javascripts/tiny_mce/plugins/paste/css/blank.css b/public/javascripts/tiny_mce/plugins/paste/css/blank.css
new file mode 100755
index 0000000..6b16bac
--- /dev/null
+++ b/public/javascripts/tiny_mce/plugins/paste/css/blank.css
@@ -0,0 +1,14 @@
1html, body {height:98%}
2body {
3background-color: #FFFFFF;
4font-family: Verdana, Arial, Helvetica, sans-serif;
5font-size: 10px;
6scrollbar-3dlight-color: #F0F0EE;
7scrollbar-arrow-color: #676662;
8scrollbar-base-color: #F0F0EE;
9scrollbar-darkshadow-color: #DDDDDD;
10scrollbar-face-color: #E0E0DD;
11scrollbar-highlight-color: #F0F0EE;
12scrollbar-shadow-color: #F0F0EE;
13scrollbar-track-color: #F5F5F5;
14}
diff --git a/public/javascripts/tiny_mce/plugins/paste/css/pasteword.css b/public/javascripts/tiny_mce/plugins/paste/css/pasteword.css
new file mode 100755
index 0000000..b3be627
--- /dev/null
+++ b/public/javascripts/tiny_mce/plugins/paste/css/pasteword.css
@@ -0,0 +1,3 @@
1.sourceIframe {
2 border: 1px solid #808080;
3}
diff --git a/public/javascripts/tiny_mce/plugins/paste/editor_plugin.js b/public/javascripts/tiny_mce/plugins/paste/editor_plugin.js
new file mode 100755
index 0000000..eeeebd5
--- /dev/null
+++ b/public/javascripts/tiny_mce/plugins/paste/editor_plugin.js
@@ -0,0 +1 @@
(function(){var Event=tinymce.dom.Event;tinymce.create('tinymce.plugins.PastePlugin',{init:function(ed,url){var t=this;t.editor=ed;ed.addCommand('mcePasteText',function(ui,v){if(ui){if((ed.getParam('paste_use_dialog',true))||(!tinymce.isIE)){ed.windowManager.open({file:url+'/pastetext.htm',width:450,height:400,inline:1},{plugin_url:url});}else t._insertText(clipboardData.getData("Text"),true);}else t._insertText(v.html,v.linebreaks);});ed.addCommand('mcePasteWord',function(ui,v){if(ui){if((ed.getParam('paste_use_dialog',true))||(!tinymce.isIE)){ed.windowManager.open({file:url+'/pasteword.htm',width:450,height:400,inline:1},{plugin_url:url});}else t._insertText(t._clipboardHTML());}else t._insertWordContent(v);});ed.addCommand('mceSelectAll',function(){ed.execCommand('selectall');});ed.addButton('pastetext',{title:'paste.paste_text_desc',cmd:'mcePasteText',ui:true});ed.addButton('pasteword',{title:'paste.paste_word_desc',cmd:'mcePasteWord',ui:true});ed.addButton('selectall',{title:'paste.selectall_desc',cmd:'mceSelectAll'});if(ed.getParam("paste_auto_cleanup_on_paste",false)){ed.onPaste.add(function(ed,e){return t._handlePasteEvent(e)});}if(!tinymce.isIE&&ed.getParam("paste_auto_cleanup_on_paste",false)){ed.onKeyDown.add(function(ed,e){if(e.ctrlKey&&e.keyCode==86){window.setTimeout(function(){ed.execCommand("mcePasteText",true);},1);Event.cancel(e);}});}},getInfo:function(){return{longname:'Paste text/word',author:'Moxiecode Systems AB',authorurl:'http://tinymce.moxiecode.com',infourl:'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/paste',version:tinymce.majorVersion+"."+tinymce.minorVersion};},_handlePasteEvent:function(e){var html=this._clipboardHTML(),ed=this.editor,sel=ed.selection,r;if(ed&&(r=sel.getRng())&&r.text.length>0)ed.execCommand('delete');if(html&&html.length>0)ed.execCommand('mcePasteWord',false,html);return Event.cancel(e);},_insertText:function(content,bLinebreaks){content=this.editor.dom.encode(content);if(content&&content.length>0){if(!this.editor.selection.isCollapsed())this.editor.execCommand("Delete");if(bLinebreaks){if(this.editor.getParam("paste_create_paragraphs",true)){var rl=this.editor.getParam("paste_replace_list",'\u2122,<sup>TM</sup>,\u2026,...,\u201c|\u201d,",\u2019,\',\u2013|\u2014|\u2015|\u2212,-').split(',');for(var i=0;i<rl.length;i+=2)content=content.replace(new RegExp(rl[i],'gi'),rl[i+1]);content=content.replace(/\r\n\r\n/g,'</p><p>');content=content.replace(/\r\r/g,'</p><p>');content=content.replace(/\n\n/g,'</p><p>');if((pos=content.indexOf('</p><p>'))!=-1){this.editor.execCommand("Delete");var node=this.editor.selection.getNode();var breakElms=[];do{if(node.nodeType==1){if(node.nodeName=="TD"||node.nodeName=="BODY")break;breakElms[breakElms.length]=node;}}while(node=node.parentNode);var before="",after="</p>";before+=content.substring(0,pos);for(var i=0;i<breakElms.length;i++){before+="</"+breakElms[i].nodeName+">";after+="<"+breakElms[(breakElms.length-1)-i].nodeName+">";}before+="<p>";content=before+content.substring(pos+7)+after;}}if(this.editor.getParam("paste_create_linebreaks",true)){content=content.replace(/\r\n/g,'<br />');content=content.replace(/\r/g,'<br />');content=content.replace(/\n/g,'<br />');}}this.editor.execCommand("mceInsertRawHTML",false,content);}},_insertWordContent:function(content){var t=this,ed=t.editor;if(content&&content.length>0){var bull=String.fromCharCode(8226);var middot=String.fromCharCode(183);if(ed.getParam('paste_insert_word_content_callback'))content=ed.execCallback('paste_insert_word_content_callback','before',content);var rl=ed.getParam("paste_replace_list",'\u2122,<sup>TM</sup>,\u2026,...,\x93|\x94|\u201c|\u201d,",\x60|\x91|\x92|\u2018|\u2019,\',\u2013|\u2014|\u2015|\u2212,-').split(',');for(var i=0;i<rl.length;i+=2)content=content.replace(new RegExp(rl[i],'gi'),rl[i+1]);if(this.editor.getParam("paste_convert_headers_to_strong",false)){content=content.replace(new RegExp('<p class=MsoHeading.*?>(.*?)<\/p>','gi'),'<p><b>$1</b></p>');}content=content.replace(new RegExp('tab-stops: list [0-9]+.0pt">','gi'),'">'+"--list--");content=content.replace(new RegExp(bull+"(.*?)<BR>","gi"),"<p>"+middot+"$1</p>");content=content.replace(new RegExp('<SPAN style="mso-list: Ignore">','gi'),"<span>"+bull);content=content.replace(/<o:p><\/o:p>/gi,"");content=content.replace(new RegExp('<br style="page-break-before: always;.*>','gi'),'-- page break --');content=content.replace(/<!--([\s\S]*?)-->|<style>[\s\S]*?<\/style>/g,"");content=content.replace(/<(meta|link)[^>]+>/g,"");if(this.editor.getParam("paste_remove_spans",true))content=content.replace(/<\/?span[^>]*>/gi,"");if(this.editor.getParam("paste_remove_styles",true))content=content.replace(new RegExp('<(\\w[^>]*) style="([^"]*)"([^>]*)','gi'),"<$1$3");content=content.replace(/<\/?font[^>]*>/gi,"");switch(this.editor.getParam("paste_strip_class_attributes","all")){case"all":content=content.replace(/<(\w[^>]*) class=([^ |>]*)([^>]*)/gi,"<$1$3");break;case"mso":content=content.replace(new RegExp('<(\\w[^>]*) class="?mso([^ |>]*)([^>]*)','gi'),"<$1$3");break;}content=content.replace(new RegExp('href="?'+this._reEscape(""+document.location)+'','gi'),'href="'+this.editor.documentBaseURI.getURI());content=content.replace(/<(\w[^>]*) lang=([^ |>]*)([^>]*)/gi,"<$1$3");content=content.replace(/<\\?\?xml[^>]*>/gi,"");content=content.replace(/<\/?\w+:[^>]*>/gi,"");content=content.replace(/-- page break --\s*<p>&nbsp;<\/p>/gi,"");content=content.replace(/-- page break --/gi,"");if(!this.editor.getParam('force_p_newlines')){content=content.replace('','','gi');content=content.replace('</p>','<br /><br />','gi');}if(!tinymce.isIE&&!this.editor.getParam('force_p_newlines')){content=content.replace(/<\/?p[^>]*>/gi,"");}content=content.replace(/<\/?div[^>]*>/gi,"");if(this.editor.getParam("paste_convert_middot_lists",true)){var div=ed.dom.create("div",null,content);var className=this.editor.getParam("paste_unindented_list_class","unIndentedList");while(this._convertMiddots(div,"--list--"));while(this._convertMiddots(div,middot,className));while(this._convertMiddots(div,bull));content=div.innerHTML;}if(this.editor.getParam("paste_convert_headers_to_strong",false)){content=content.replace(/<h[1-6]>&nbsp;<\/h[1-6]>/gi,'<p>&nbsp;&nbsp;</p>');content=content.replace(/<h[1-6]>/gi,'<p><b>');content=content.replace(/<\/h[1-6]>/gi,'</b></p>');content=content.replace(/<b>&nbsp;<\/b>/gi,'<b>&nbsp;&nbsp;</b>');content=content.replace(/^(&nbsp;)*/gi,'');}content=content.replace(/--list--/gi,"");if(ed.getParam('paste_insert_word_content_callback'))content=ed.execCallback('paste_insert_word_content_callback','after',content);this.editor.execCommand("mceInsertContent",false,content);if(this.editor.getParam('paste_force_cleanup_wordpaste',true)){var ed=this.editor;window.setTimeout(function(){ed.execCommand("mceCleanup");},1);}}},_reEscape:function(s){var l="?.\\*[](){}+^$:";var o="";for(var i=0;i<s.length;i++){var c=s.charAt(i);if(l.indexOf(c)!=-1)o+='\\'+c;else o+=c;}return o;},_convertMiddots:function(div,search,class_name){var ed=this.editor,mdot=String.fromCharCode(183),bull=String.fromCharCode(8226);var nodes,prevul,i,p,ul,li,np,cp,li;nodes=div.getElementsByTagName("p");for(i=0;i<nodes.length;i++){p=nodes[i];if(p.innerHTML.indexOf(search)==0){ul=ed.dom.create("ul");if(class_name)ul.className=class_name;li=ed.dom.create("li");li.innerHTML=p.innerHTML.replace(new RegExp(''+mdot+'|'+bull+'|--list--|&nbsp;',"gi"),'');ul.appendChild(li);np=p.nextSibling;while(np){if(np.nodeType==3&&new RegExp('^\\s$','m').test(np.nodeValue)){np=np.nextSibling;continue;}if(search==mdot){if(np.nodeType==1&&new RegExp('^o(\\s+|&nbsp;)').test(np.innerHTML)){if(!prevul){prevul=ul;ul=ed.dom.create("ul");prevul.appendChild(ul);}np.innerHTML=np.innerHTML.replace(/^o/,'');}else{if(prevul){ul=prevul;prevul=null;}if(np.nodeType!=1||np.innerHTML.indexOf(search)!=0)break;}}else{if(np.nodeType!=1||np.innerHTML.indexOf(search)!=0)break;}cp=np.nextSibling;li=ed.dom.create("li");li.innerHTML=np.innerHTML.replace(new RegExp(''+mdot+'|'+bull+'|--list--|&nbsp;',"gi"),'');np.parentNode.removeChild(np);ul.appendChild(li);np=cp;}p.parentNode.replaceChild(ul,p);return true;}}return false;},_clipboardHTML:function(){var div=document.getElementById('_TinyMCE_clipboardHTML');if(!div){var div=document.createElement('DIV');div.id='_TinyMCE_clipboardHTML';with(div.style){visibility='hidden';overflow='hidden';position='absolute';width=1;height=1;}document.body.appendChild(div);}div.innerHTML='';var rng=document.body.createTextRange();rng.moveToElementText(div);rng.execCommand('Paste');var html=div.innerHTML;div.innerHTML='';return html;}});tinymce.PluginManager.add('paste',tinymce.plugins.PastePlugin);})(); \ No newline at end of file
diff --git a/public/javascripts/tiny_mce/plugins/paste/editor_plugin_src.js b/public/javascripts/tiny_mce/plugins/paste/editor_plugin_src.js
new file mode 100755
index 0000000..bb5f5aa
--- /dev/null
+++ b/public/javascripts/tiny_mce/plugins/paste/editor_plugin_src.js
@@ -0,0 +1,394 @@
1/**
2 * $Id: editor_plugin_src.js 919 2008-09-08 20:31:23Z spocke $
3 *
4 * @author Moxiecode
5 * @copyright Copyright © 2004-2008, Moxiecode Systems AB, All rights reserved.
6 */
7
8(function() {
9 var Event = tinymce.dom.Event;
10
11 tinymce.create('tinymce.plugins.PastePlugin', {
12 init : function(ed, url) {
13 var t = this;
14
15 t.editor = ed;
16
17 // Register commands
18 ed.addCommand('mcePasteText', function(ui, v) {
19 if (ui) {
20 if ((ed.getParam('paste_use_dialog', true)) || (!tinymce.isIE)) {
21 ed.windowManager.open({
22 file : url + '/pastetext.htm',
23 width : 450,
24 height : 400,
25 inline : 1
26 }, {
27 plugin_url : url
28 });
29 } else
30 t._insertText(clipboardData.getData("Text"), true);
31 } else
32 t._insertText(v.html, v.linebreaks);
33 });
34
35 ed.addCommand('mcePasteWord', function(ui, v) {
36 if (ui) {
37 if ((ed.getParam('paste_use_dialog', true)) || (!tinymce.isIE)) {
38 ed.windowManager.open({
39 file : url + '/pasteword.htm',
40 width : 450,
41 height : 400,
42 inline : 1
43 }, {
44 plugin_url : url
45 });
46 } else
47 t._insertText(t._clipboardHTML());
48 } else
49 t._insertWordContent(v);
50 });
51
52 ed.addCommand('mceSelectAll', function() {
53 ed.execCommand('selectall');
54 });
55
56 // Register buttons
57 ed.addButton('pastetext', {title : 'paste.paste_text_desc', cmd : 'mcePasteText', ui : true});
58 ed.addButton('pasteword', {title : 'paste.paste_word_desc', cmd : 'mcePasteWord', ui : true});
59 ed.addButton('selectall', {title : 'paste.selectall_desc', cmd : 'mceSelectAll'});
60
61 if (ed.getParam("paste_auto_cleanup_on_paste", false)) {
62 ed.onPaste.add(function(ed, e) {
63 return t._handlePasteEvent(e)
64 });
65 }
66
67 if (!tinymce.isIE && ed.getParam("paste_auto_cleanup_on_paste", false)) {
68 // Force paste dialog if non IE browser
69 ed.onKeyDown.add(function(ed, e) {
70 if (e.ctrlKey && e.keyCode == 86) {
71 window.setTimeout(function() {
72 ed.execCommand("mcePasteText", true);
73 }, 1);
74
75 Event.cancel(e);
76 }
77 });
78 }
79 },
80
81 getInfo : function() {
82 return {
83 longname : 'Paste text/word',
84 author : 'Moxiecode Systems AB',
85 authorurl : 'http://tinymce.moxiecode.com',
86 infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/paste',
87 version : tinymce.majorVersion + "." + tinymce.minorVersion
88 };
89 },
90
91 // Private methods
92
93 _handlePasteEvent : function(e) {
94 var html = this._clipboardHTML(), ed = this.editor, sel = ed.selection, r;
95
96 // Removes italic, strong etc, the if was needed due to bug #1437114
97 if (ed && (r = sel.getRng()) && r.text.length > 0)
98 ed.execCommand('delete');
99
100 if (html && html.length > 0)
101 ed.execCommand('mcePasteWord', false, html);
102
103 return Event.cancel(e);
104 },
105
106 _insertText : function(content, bLinebreaks) {
107 content = this.editor.dom.encode(content);
108
109 if (content && content.length > 0) {
110 // Delete any highlighted text before pasting
111 if (!this.editor.selection.isCollapsed())
112 this.editor.execCommand("Delete");
113
114 if (bLinebreaks) {
115 // Special paragraph treatment
116 if (this.editor.getParam("paste_create_paragraphs", true)) {
117 var rl = this.editor.getParam("paste_replace_list", '\u2122,<sup>TM</sup>,\u2026,...,\u201c|\u201d,",\u2019,\',\u2013|\u2014|\u2015|\u2212,-').split(',');
118 for (var i=0; i<rl.length; i+=2)
119 content = content.replace(new RegExp(rl[i], 'gi'), rl[i+1]);
120
121 content = content.replace(/\r\n\r\n/g, '</p><p>');
122 content = content.replace(/\r\r/g, '</p><p>');
123 content = content.replace(/\n\n/g, '</p><p>');
124
125 // Has paragraphs
126 if ((pos = content.indexOf('</p><p>')) != -1) {
127 this.editor.execCommand("Delete");
128
129 var node = this.editor.selection.getNode();
130
131 // Get list of elements to break
132 var breakElms = [];
133
134 do {
135 if (node.nodeType == 1) {
136 // Don't break tables and break at body
137 if (node.nodeName == "TD" || node.nodeName == "BODY")
138 break;
139
140 breakElms[breakElms.length] = node;
141 }
142 } while(node = node.parentNode);
143
144 var before = "", after = "</p>";
145 before += content.substring(0, pos);
146
147 for (var i=0; i<breakElms.length; i++) {
148 before += "</" + breakElms[i].nodeName + ">";
149 after += "<" + breakElms[(breakElms.length-1)-i].nodeName + ">";
150 }
151
152 before += "<p>";
153 content = before + content.substring(pos+7) + after;
154 }
155 }
156
157 if (this.editor.getParam("paste_create_linebreaks", true)) {
158 content = content.replace(/\r\n/g, '<br />');
159 content = content.replace(/\r/g, '<br />');
160 content = content.replace(/\n/g, '<br />');
161 }
162 }
163
164 this.editor.execCommand("mceInsertRawHTML", false, content);
165 }
166 },
167
168 _insertWordContent : function(content) {
169 var t = this, ed = t.editor;
170
171 if (content && content.length > 0) {
172 // Cleanup Word content
173 var bull = String.fromCharCode(8226);
174 var middot = String.fromCharCode(183);
175
176 if (ed.getParam('paste_insert_word_content_callback'))
177 content = ed.execCallback('paste_insert_word_content_callback', 'before', content);
178
179 var rl = ed.getParam("paste_replace_list", '\u2122,<sup>TM</sup>,\u2026,...,\x93|\x94|\u201c|\u201d,",\x60|\x91|\x92|\u2018|\u2019,\',\u2013|\u2014|\u2015|\u2212,-').split(',');
180 for (var i=0; i<rl.length; i+=2)
181 content = content.replace(new RegExp(rl[i], 'gi'), rl[i+1]);
182
183 if (this.editor.getParam("paste_convert_headers_to_strong", false)) {
184 content = content.replace(new RegExp('<p class=MsoHeading.*?>(.*?)<\/p>', 'gi'), '<p><b>$1</b></p>');
185 }
186
187 content = content.replace(new RegExp('tab-stops: list [0-9]+.0pt">', 'gi'), '">' + "--list--");
188 content = content.replace(new RegExp(bull + "(.*?)<BR>", "gi"), "<p>" + middot + "$1</p>");
189 content = content.replace(new RegExp('<SPAN style="mso-list: Ignore">', 'gi'), "<span>" + bull); // Covert to bull list
190 content = content.replace(/<o:p><\/o:p>/gi, "");
191 content = content.replace(new RegExp('<br style="page-break-before: always;.*>', 'gi'), '-- page break --'); // Replace pagebreaks
192 content = content.replace(/<!--([\s\S]*?)-->|<style>[\s\S]*?<\/style>/g, ""); // Word comments
193 content = content.replace(/<(meta|link)[^>]+>/g, ""); // Header elements
194
195 if (this.editor.getParam("paste_remove_spans", true))
196 content = content.replace(/<\/?span[^>]*>/gi, "");
197
198 if (this.editor.getParam("paste_remove_styles", true))
199 content = content.replace(new RegExp('<(\\w[^>]*) style="([^"]*)"([^>]*)', 'gi'), "<$1$3");
200
201 content = content.replace(/<\/?font[^>]*>/gi, "");
202
203 // Strips class attributes.
204 switch (this.editor.getParam("paste_strip_class_attributes", "all")) {
205 case "all":
206 content = content.replace(/<(\w[^>]*) class=([^ |>]*)([^>]*)/gi, "<$1$3");
207 break;
208
209 case "mso":
210 content = content.replace(new RegExp('<(\\w[^>]*) class="?mso([^ |>]*)([^>]*)', 'gi'), "<$1$3");
211 break;
212 }
213
214 content = content.replace(new RegExp('href="?' + this._reEscape("" + document.location) + '', 'gi'), 'href="' + this.editor.documentBaseURI.getURI());
215 content = content.replace(/<(\w[^>]*) lang=([^ |>]*)([^>]*)/gi, "<$1$3");
216 content = content.replace(/<\\?\?xml[^>]*>/gi, "");
217 content = content.replace(/<\/?\w+:[^>]*>/gi, "");
218 content = content.replace(/-- page break --\s*<p>&nbsp;<\/p>/gi, ""); // Remove pagebreaks
219 content = content.replace(/-- page break --/gi, ""); // Remove pagebreaks
220
221 // content = content.replace(/\/?&nbsp;*/gi, ""); &nbsp;
222 // content = content.replace(/<p>&nbsp;<\/p>/gi, '');
223
224 if (!this.editor.getParam('force_p_newlines')) {
225 content = content.replace('', '' ,'gi');
226 content = content.replace('</p>', '<br /><br />' ,'gi');
227 }
228
229 if (!tinymce.isIE && !this.editor.getParam('force_p_newlines')) {
230 content = content.replace(/<\/?p[^>]*>/gi, "");
231 }
232
233 content = content.replace(/<\/?div[^>]*>/gi, "");
234
235 // Convert all middlot lists to UL lists
236 if (this.editor.getParam("paste_convert_middot_lists", true)) {
237 var div = ed.dom.create("div", null, content);
238
239 // Convert all middot paragraphs to li elements
240 var className = this.editor.getParam("paste_unindented_list_class", "unIndentedList");
241
242 while (this._convertMiddots(div, "--list--")) ; // bull
243 while (this._convertMiddots(div, middot, className)) ; // Middot
244 while (this._convertMiddots(div, bull)) ; // bull
245
246 content = div.innerHTML;
247 }
248
249 // Replace all headers with strong and fix some other issues
250 if (this.editor.getParam("paste_convert_headers_to_strong", false)) {
251 content = content.replace(/<h[1-6]>&nbsp;<\/h[1-6]>/gi, '<p>&nbsp;&nbsp;</p>');
252 content = content.replace(/<h[1-6]>/gi, '<p><b>');
253 content = content.replace(/<\/h[1-6]>/gi, '</b></p>');
254 content = content.replace(/<b>&nbsp;<\/b>/gi, '<b>&nbsp;&nbsp;</b>');
255 content = content.replace(/^(&nbsp;)*/gi, '');
256 }
257
258 content = content.replace(/--list--/gi, ""); // Remove --list--
259
260 if (ed.getParam('paste_insert_word_content_callback'))
261 content = ed.execCallback('paste_insert_word_content_callback', 'after', content);
262
263 // Insert cleaned content
264 this.editor.execCommand("mceInsertContent", false, content);
265
266 if (this.editor.getParam('paste_force_cleanup_wordpaste', true)) {
267 var ed = this.editor;
268
269 window.setTimeout(function() {
270 ed.execCommand("mceCleanup");
271 }, 1); // Do normal cleanup detached from this thread
272 }
273 }
274 },
275
276 _reEscape : function(s) {
277 var l = "?.\\*[](){}+^$:";
278 var o = "";
279
280 for (var i=0; i<s.length; i++) {
281 var c = s.charAt(i);
282
283 if (l.indexOf(c) != -1)
284 o += '\\' + c;
285 else
286 o += c;
287 }
288
289 return o;
290 },
291
292 _convertMiddots : function(div, search, class_name) {
293 var ed = this.editor, mdot = String.fromCharCode(183), bull = String.fromCharCode(8226);
294 var nodes, prevul, i, p, ul, li, np, cp, li;
295
296 nodes = div.getElementsByTagName("p");
297 for (i=0; i<nodes.length; i++) {
298 p = nodes[i];
299
300 // Is middot
301 if (p.innerHTML.indexOf(search) == 0) {
302 ul = ed.dom.create("ul");
303
304 if (class_name)
305 ul.className = class_name;
306
307 // Add the first one
308 li = ed.dom.create("li");
309 li.innerHTML = p.innerHTML.replace(new RegExp('' + mdot + '|' + bull + '|--list--|&nbsp;', "gi"), '');
310 ul.appendChild(li);
311
312 // Add the rest
313 np = p.nextSibling;
314 while (np) {
315 // If the node is whitespace, then
316 // ignore it and continue on.
317 if (np.nodeType == 3 && new RegExp('^\\s$', 'm').test(np.nodeValue)) {
318 np = np.nextSibling;
319 continue;
320 }
321
322 if (search == mdot) {
323 if (np.nodeType == 1 && new RegExp('^o(\\s+|&nbsp;)').test(np.innerHTML)) {
324 // Second level of nesting
325 if (!prevul) {
326 prevul = ul;
327 ul = ed.dom.create("ul");
328 prevul.appendChild(ul);
329 }
330 np.innerHTML = np.innerHTML.replace(/^o/, '');
331 } else {
332 // Pop the stack if we're going back up to the first level
333 if (prevul) {
334 ul = prevul;
335 prevul = null;
336 }
337 // Not element or middot paragraph
338 if (np.nodeType != 1 || np.innerHTML.indexOf(search) != 0)
339 break;
340 }
341 } else {
342 // Not element or middot paragraph
343 if (np.nodeType != 1 || np.innerHTML.indexOf(search) != 0)
344 break;
345 }
346
347 cp = np.nextSibling;
348 li = ed.dom.create("li");
349 li.innerHTML = np.innerHTML.replace(new RegExp('' + mdot + '|' + bull + '|--list--|&nbsp;', "gi"), '');
350 np.parentNode.removeChild(np);
351 ul.appendChild(li);
352 np = cp;
353 }
354
355 p.parentNode.replaceChild(ul, p);
356
357 return true;
358 }
359 }
360
361 return false;
362 },
363
364 _clipboardHTML : function() {
365 var div = document.getElementById('_TinyMCE_clipboardHTML');
366
367 if (!div) {
368 var div = document.createElement('DIV');
369 div.id = '_TinyMCE_clipboardHTML';
370
371 with (div.style) {
372 visibility = 'hidden';
373 overflow = 'hidden';
374 position = 'absolute';
375 width = 1;
376 height = 1;
377 }
378
379 document.body.appendChild(div);
380 }
381
382 div.innerHTML = '';
383 var rng = document.body.createTextRange();
384 rng.moveToElementText(div);
385 rng.execCommand('Paste');
386 var html = div.innerHTML;
387 div.innerHTML = '';
388 return html;
389 }
390 });
391
392 // Register plugin
393 tinymce.PluginManager.add('paste', tinymce.plugins.PastePlugin);
394})(); \ No newline at end of file
diff --git a/public/javascripts/tiny_mce/plugins/paste/js/pastetext.js b/public/javascripts/tiny_mce/plugins/paste/js/pastetext.js
new file mode 100755
index 0000000..326bb16
--- /dev/null
+++ b/public/javascripts/tiny_mce/plugins/paste/js/pastetext.js
@@ -0,0 +1,42 @@
1tinyMCEPopup.requireLangPack();
2
3function saveContent() {
4 if (document.forms[0].htmlSource.value == '') {
5 tinyMCEPopup.close();
6 return false;
7 }
8
9 tinyMCEPopup.execCommand('mcePasteText', false, {
10 html : document.forms[0].htmlSource.value,
11 linebreaks : document.forms[0].linebreaks.checked
12 });
13
14 tinyMCEPopup.close();
15}
16
17function onLoadInit() {
18 tinyMCEPopup.resizeToInnerSize();
19
20 // Remove Gecko spellchecking
21 if (tinymce.isGecko)
22 document.body.spellcheck = tinyMCEPopup.getParam("gecko_spellcheck");
23
24 resizeInputs();
25}
26
27var wHeight=0, wWidth=0, owHeight=0, owWidth=0;
28
29function resizeInputs() {
30 if (!tinymce.isIE) {
31 wHeight = self.innerHeight-80;
32 wWidth = self.innerWidth-17;
33 } else {
34 wHeight = document.body.clientHeight-80;
35 wWidth = document.body.clientWidth-17;
36 }
37
38 document.forms[0].htmlSource.style.height = Math.abs(wHeight) + 'px';
39 document.forms[0].htmlSource.style.width = Math.abs(wWidth) + 'px';
40}
41
42tinyMCEPopup.onInit.add(onLoadInit); \ No newline at end of file
diff --git a/public/javascripts/tiny_mce/plugins/paste/js/pasteword.js b/public/javascripts/tiny_mce/plugins/paste/js/pasteword.js
new file mode 100755
index 0000000..6701b99
--- /dev/null
+++ b/public/javascripts/tiny_mce/plugins/paste/js/pasteword.js
@@ -0,0 +1,56 @@
1tinyMCEPopup.requireLangPack();
2
3function saveContent() {
4 var html = document.getElementById("frmData").contentWindow.document.body.innerHTML;
5
6 if (html == ''){
7 tinyMCEPopup.close();
8 return false;
9 }
10
11 tinyMCEPopup.execCommand('mcePasteWord', false, html);
12 tinyMCEPopup.close();
13}
14
15function onLoadInit() {
16 tinyMCEPopup.resizeToInnerSize();
17
18 // Fix for endless reloading in FF
19 window.setTimeout(createIFrame, 10);
20}
21
22function createIFrame() {
23 document.getElementById('iframecontainer').innerHTML = '<iframe id="frmData" name="frmData" class="sourceIframe" src="blank.htm" height="280" width="400" frameborder="0" style="background-color:#FFFFFF; width:100%;" dir="ltr" wrap="soft"></iframe>';
24}
25
26var wHeight=0, wWidth=0, owHeight=0, owWidth=0;
27
28function initIframe(doc) {
29 var dir = tinyMCEPopup.editor.settings.directionality;
30
31 doc.body.dir = dir;
32
33 // Remove Gecko spellchecking
34 if (tinymce.isGecko)
35 doc.body.spellcheck = tinyMCEPopup.getParam("gecko_spellcheck");
36
37 resizeInputs();
38}
39
40function resizeInputs() {
41 if (!tinymce.isIE) {
42 wHeight = self.innerHeight - 80;
43 wWidth = self.innerWidth - 18;
44 } else {
45 wHeight = document.body.clientHeight - 80;
46 wWidth = document.body.clientWidth - 18;
47 }
48
49 var elm = document.getElementById('frmData');
50 if (elm) {
51 elm.style.height = Math.abs(wHeight) + 'px';
52 elm.style.width = Math.abs(wWidth) + 'px';
53 }
54}
55
56tinyMCEPopup.onInit.add(onLoadInit);
diff --git a/public/javascripts/tiny_mce/plugins/paste/langs/en_dlg.js b/public/javascripts/tiny_mce/plugins/paste/langs/en_dlg.js
new file mode 100755
index 0000000..eeac778
--- /dev/null
+++ b/public/javascripts/tiny_mce/plugins/paste/langs/en_dlg.js
@@ -0,0 +1,5 @@
1tinyMCE.addI18n('en.paste_dlg',{
2text_title:"Use CTRL+V on your keyboard to paste the text into the window.",
3text_linebreaks:"Keep linebreaks",
4word_title:"Use CTRL+V on your keyboard to paste the text into the window."
5}); \ No newline at end of file
diff --git a/public/javascripts/tiny_mce/plugins/paste/pastetext.htm b/public/javascripts/tiny_mce/plugins/paste/pastetext.htm
new file mode 100755
index 0000000..2f2b341
--- /dev/null
+++ b/public/javascripts/tiny_mce/plugins/paste/pastetext.htm
@@ -0,0 +1,34 @@
1<html xmlns="http://www.w3.org/1999/xhtml">
2<head>
3 <title>{#paste.paste_text_desc}</title>
4 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
5 <script type="text/javascript" src="../../tiny_mce_popup.js"></script>
6 <script type="text/javascript" src="js/pastetext.js"></script>
7 <base target="_self" />
8</head>
9<body onresize="resizeInputs();" style="display:none; overflow:hidden;">
10<form name="source" onsubmit="saveContent();return false;" action="#">
11 <div style="float: left" class="title">{#paste.paste_text_desc}</div>
12
13 <div style="float: right">
14 <input type="checkbox" name="linebreaks" id="linebreaks" class="wordWrapCode" checked="checked" /><label for="linebreaks">{#paste_dlg.text_linebreaks}</label>
15 </div>
16
17 <br style="clear: both" />
18
19 <div>{#paste_dlg.text_title}</div>
20
21 <textarea name="htmlSource" id="htmlSource" rows="15" cols="100" style="width: 100%; height: 100%; font-family: 'Courier New',Courier,mono; font-size: 12px;" dir="ltr" wrap="soft" class="mceFocus"></textarea>
22
23 <div class="mceActionPanel">
24 <div style="float: left">
25 <input type="submit" name="insert" value="{#insert}" id="insert" />
26 </div>
27
28 <div style="float: right">
29 <input type="button" name="cancel" value="{#cancel}" onclick="tinyMCEPopup.close();" id="cancel" />
30 </div>
31 </div>
32</form>
33</body>
34</html> \ No newline at end of file
diff --git a/public/javascripts/tiny_mce/plugins/paste/pasteword.htm b/public/javascripts/tiny_mce/plugins/paste/pasteword.htm
new file mode 100755
index 0000000..9e5ab1b
--- /dev/null
+++ b/public/javascripts/tiny_mce/plugins/paste/pasteword.htm
@@ -0,0 +1,29 @@
1<html xmlns="http://www.w3.org/1999/xhtml">
2<head>
3 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
4 <title>{#paste.paste_word_desc}</title>
5 <script type="text/javascript" src="../../tiny_mce_popup.js"></script>
6 <script type="text/javascript" src="js/pasteword.js"></script>
7 <link href="css/pasteword.css" rel="stylesheet" type="text/css" />
8 <base target="_self" />
9</head>
10<body onresize="resizeInputs();" style="display:none; overflow:hidden;">
11 <form name="source" onsubmit="saveContent();" action="#">
12 <div class="title">{#paste.paste_word_desc}</div>
13
14 <div>{#paste_dlg.word_title}</div>
15
16 <div id="iframecontainer"></div>
17
18 <div class="mceActionPanel">
19 <div style="float: left">
20 <input type="button" id="insert" name="insert" value="{#insert}" onclick="saveContent();" />
21 </div>
22
23 <div style="float: right">
24 <input type="button" id="cancel" name="cancel" value="{#cancel}" onclick="tinyMCEPopup.close();" />
25 </div>
26 </div>
27 </form>
28</body>
29</html>