includes/clientside/tinymce/plugins/paste/editor_plugin_src.js
changeset 778 57ce13805b6f
parent 588 20484deb89cd
child 1193 e3b94bd055dc
equal deleted inserted replaced
777:488665d49417 778:57ce13805b6f
     1 /**
     1 /**
     2  * $Id: editor_plugin_src.js 862 2008-06-02 20:09:06Z spocke $
     2  * $Id: editor_plugin_src.js 919 2008-09-08 20:31:23Z spocke $
     3  *
     3  *
     4  * @author Moxiecode
     4  * @author Moxiecode
     5  * @copyright Copyright © 2004-2008, Moxiecode Systems AB, All rights reserved.
     5  * @copyright Copyright © 2004-2008, Moxiecode Systems AB, All rights reserved.
     6  */
     6  */
     7 
     7 
   105 
   105 
   106 		_insertText : function(content, bLinebreaks) {
   106 		_insertText : function(content, bLinebreaks) {
   107 			content = this.editor.dom.encode(content);
   107 			content = this.editor.dom.encode(content);
   108 
   108 
   109 			if (content && content.length > 0) {
   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 
   110 				if (bLinebreaks) { 
   114 				if (bLinebreaks) { 
   111 					// Special paragraph treatment 
   115 					// Special paragraph treatment 
   112 					if (this.editor.getParam("paste_create_paragraphs", true)) {
   116 					if (this.editor.getParam("paste_create_paragraphs", true)) {
   113 						var rl = this.editor.getParam("paste_replace_list", '\u2122,<sup>TM</sup>,\u2026,...,\u201c|\u201d,",\u2019,\',\u2013|\u2014|\u2015|\u2212,-').split(',');
   117 						var rl = this.editor.getParam("paste_replace_list", '\u2122,<sup>TM</sup>,\u2026,...,\u201c|\u201d,",\u2019,\',\u2013|\u2014|\u2015|\u2212,-').split(',');
   114 						for (var i=0; i<rl.length; i+=2)
   118 						for (var i=0; i<rl.length; i+=2)
   170 				var middot = String.fromCharCode(183);
   174 				var middot = String.fromCharCode(183);
   171 
   175 
   172 				if (ed.getParam('paste_insert_word_content_callback'))
   176 				if (ed.getParam('paste_insert_word_content_callback'))
   173 					content = ed.execCallback('paste_insert_word_content_callback', 'before', content);
   177 					content = ed.execCallback('paste_insert_word_content_callback', 'before', content);
   174 
   178 
   175 				var rl = ed.getParam("paste_replace_list", '\u2122,<sup>TM</sup>,\u2026,...,\u201c|\u201d,",\u2019,\',\u2013|\u2014|\u2015|\u2212,-').split(',');
   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(',');
   176 				for (var i=0; i<rl.length; i+=2)
   180 				for (var i=0; i<rl.length; i+=2)
   177 					content = content.replace(new RegExp(rl[i], 'gi'), rl[i+1]);
   181 					content = content.replace(new RegExp(rl[i], 'gi'), rl[i+1]);
   178 
   182 
   179 				if (this.editor.getParam("paste_convert_headers_to_strong", false)) {
   183 				if (this.editor.getParam("paste_convert_headers_to_strong", false)) {
   180 					content = content.replace(new RegExp('<p class=MsoHeading.*?>(.*?)<\/p>', 'gi'), '<p><b>$1</b></p>');
   184 					content = content.replace(new RegExp('<p class=MsoHeading.*?>(.*?)<\/p>', 'gi'), '<p><b>$1</b></p>');
   183 				content = content.replace(new RegExp('tab-stops: list [0-9]+.0pt">', 'gi'), '">' + "--list--");
   187 				content = content.replace(new RegExp('tab-stops: list [0-9]+.0pt">', 'gi'), '">' + "--list--");
   184 				content = content.replace(new RegExp(bull + "(.*?)<BR>", "gi"), "<p>" + middot + "$1</p>");
   188 				content = content.replace(new RegExp(bull + "(.*?)<BR>", "gi"), "<p>" + middot + "$1</p>");
   185 				content = content.replace(new RegExp('<SPAN style="mso-list: Ignore">', 'gi'), "<span>" + bull); // Covert to bull list
   189 				content = content.replace(new RegExp('<SPAN style="mso-list: Ignore">', 'gi'), "<span>" + bull); // Covert to bull list
   186 				content = content.replace(/<o:p><\/o:p>/gi, "");
   190 				content = content.replace(/<o:p><\/o:p>/gi, "");
   187 				content = content.replace(new RegExp('<br style="page-break-before: always;.*>', 'gi'), '-- page break --'); // Replace pagebreaks
   191 				content = content.replace(new RegExp('<br style="page-break-before: always;.*>', 'gi'), '-- page break --'); // Replace pagebreaks
   188 				content = content.replace(new RegExp('<(!--)([^>]*)(--)>', 'g'), "");  // Word comments
   192 				content = content.replace(/<!--([\s\S]*?)-->|<style>[\s\S]*?<\/style>/g, "");  // Word comments
       
   193 				content = content.replace(/<(meta|link)[^>]+>/g, ""); // Header elements
   189 
   194 
   190 				if (this.editor.getParam("paste_remove_spans", true))
   195 				if (this.editor.getParam("paste_remove_spans", true))
   191 					content = content.replace(/<\/?span[^>]*>/gi, "");
   196 					content = content.replace(/<\/?span[^>]*>/gi, "");
   192 
   197 
   193 				if (this.editor.getParam("paste_remove_styles", true))
   198 				if (this.editor.getParam("paste_remove_styles", true))