includes/clientside/tinymce/plugins/paste/editor_plugin_src.js
author Dan
Wed, 06 Jan 2010 02:19:58 -0500
changeset 1209 944d2fe1fb1e
parent 1193 e3b94bd055dc
permissions -rw-r--r--
Somehow I broke automatic localization of special page titles.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
     1
/**
1193
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
     2
 * $Id: editor_plugin_src.js 1225 2009-09-07 19:06:19Z spocke $
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
     3
 *
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
     4
 * @author Moxiecode
395
fa4c5ecb7c9a Fixed splitting bug (really the same issue from stable) in get_pageid_from_url(); upgraded TinyMCE to version 3.0-stable
Dan
parents: 335
diff changeset
     5
 * @copyright Copyright © 2004-2008, Moxiecode Systems AB, All rights reserved.
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
     6
 */
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
     7
335
67bd3121a12e Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents: 1
diff changeset
     8
(function() {
1193
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
     9
	var each = tinymce.each;
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    10
335
67bd3121a12e Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents: 1
diff changeset
    11
	tinymce.create('tinymce.plugins.PastePlugin', {
67bd3121a12e Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents: 1
diff changeset
    12
		init : function(ed, url) {
1193
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
    13
			var t = this, cb;
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
    14
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
    15
			t.editor = ed;
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
    16
			t.url = url;
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
    17
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
    18
			// Setup plugin events
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
    19
			t.onPreProcess = new tinymce.util.Dispatcher(t);
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
    20
			t.onPostProcess = new tinymce.util.Dispatcher(t);
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    21
1193
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
    22
			// Register default handlers
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
    23
			t.onPreProcess.add(t._preProcess);
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
    24
			t.onPostProcess.add(t._postProcess);
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
    25
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
    26
			// Register optional preprocess handler
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
    27
			t.onPreProcess.add(function(pl, o) {
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
    28
				ed.execCallback('paste_preprocess', pl, o);
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
    29
			});
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
    30
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
    31
			// Register optional postprocess
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
    32
			t.onPostProcess.add(function(pl, o) {
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
    33
				ed.execCallback('paste_postprocess', pl, o);
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
    34
			});
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    35
1193
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
    36
			// This function executes the process handlers and inserts the contents
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
    37
			function process(o) {
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
    38
				var dom = ed.dom;
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
    39
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
    40
				// Execute pre process handlers
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
    41
				t.onPreProcess.dispatch(t, o);
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
    42
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
    43
				// Create DOM structure
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
    44
				o.node = dom.create('div', 0, o.content);
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
    45
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
    46
				// Execute post process handlers
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
    47
				t.onPostProcess.dispatch(t, o);
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
    48
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
    49
				// Serialize content
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
    50
				o.content = ed.serializer.serialize(o.node, {getInner : 1});
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
    51
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
    52
				//  Insert cleaned content. We need to handle insertion of contents containing block elements separately
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
    53
				if (/<(p|h[1-6]|ul|ol)/.test(o.content))
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
    54
					t._insertBlockContent(ed, dom, o.content);
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
    55
				else
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
    56
					t._insert(o.content);
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
    57
			};
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
    58
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
    59
			// Add command for external usage
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
    60
			ed.addCommand('mceInsertClipboardContent', function(u, o) {
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
    61
				process(o);
335
67bd3121a12e Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents: 1
diff changeset
    62
			});
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    63
1193
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
    64
			// This function grabs the contents from the clipboard by adding a
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
    65
			// hidden div and placing the caret inside it and after the browser paste
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
    66
			// is done it grabs that contents and processes that
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
    67
			function grabContent(e) {
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
    68
				var n, or, rng, sel = ed.selection, dom = ed.dom, body = ed.getBody(), posY;
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
    69
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
    70
				if (dom.get('_mcePaste'))
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
    71
					return;
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
    72
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
    73
				// Create container to paste into
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
    74
				n = dom.add(body, 'div', {id : '_mcePaste'}, '\uFEFF');
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
    75
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
    76
				// If contentEditable mode we need to find out the position of the closest element
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
    77
				if (body != ed.getDoc().body)
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
    78
					posY = dom.getPos(ed.selection.getStart(), body).y;
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
    79
				else
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
    80
					posY = body.scrollTop;
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
    81
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
    82
				// Styles needs to be applied after the element is added to the document since WebKit will otherwise remove all styles
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
    83
				dom.setStyles(n, {
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
    84
					position : 'absolute',
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
    85
					left : -10000,
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
    86
					top : posY,
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
    87
					width : 1,
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
    88
					height : 1,
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
    89
					overflow : 'hidden'
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
    90
				});
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
    91
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
    92
				if (tinymce.isIE) {
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
    93
					// Select the container
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
    94
					rng = dom.doc.body.createTextRange();
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
    95
					rng.moveToElementText(n);
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
    96
					rng.execCommand('Paste');
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
    97
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
    98
					// Remove container
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
    99
					dom.remove(n);
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   100
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   101
					// Check if the contents was changed, if it wasn't then clipboard extraction failed probably due
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   102
					// to IE security settings so we pass the junk though better than nothing right
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   103
					if (n.innerHTML === '\uFEFF') {
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   104
						ed.execCommand('mcePasteWord');
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   105
						e.preventDefault();
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   106
						return;
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   107
					}
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   108
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   109
					// Process contents
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   110
					process({content : n.innerHTML});
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   111
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   112
					// Block the real paste event
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   113
					return tinymce.dom.Event.cancel(e);
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   114
				} else {
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   115
					or = ed.selection.getRng();
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   116
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   117
					// Move caret into hidden div
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   118
					n = n.firstChild;
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   119
					rng = ed.getDoc().createRange();
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   120
					rng.setStart(n, 0);
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   121
					rng.setEnd(n, 1);
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   122
					sel.setRng(rng);
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   123
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   124
					// Wait a while and grab the pasted contents
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   125
					window.setTimeout(function() {
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   126
						var h = '', nl = dom.select('div[id=_mcePaste]');
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   127
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   128
						// WebKit will split the div into multiple ones so this will loop through then all and join them to get the whole HTML string
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   129
						each(nl, function(n) {
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   130
							h += (dom.select('> span.Apple-style-span div', n)[0] || dom.select('> span.Apple-style-span', n)[0] || n).innerHTML;
543
dffcbfbc4e59 Upgraded TinyMCE to version 3.0.8
Dan
parents: 476
diff changeset
   131
						});
1193
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   132
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   133
						// Remove the nodes
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   134
						each(nl, function(n) {
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   135
							dom.remove(n);
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   136
						});
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   137
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   138
						// Restore the old selection
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   139
						if (or)
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   140
							sel.setRng(or);
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   141
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   142
						process({content : h});
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   143
					}, 0);
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   144
				}
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   145
			};
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   146
1193
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   147
			// Check if we should use the new auto process method			
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   148
			if (ed.getParam('paste_auto_cleanup_on_paste', true)) {
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   149
				// Is it's Opera or older FF use key handler
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   150
				if (tinymce.isOpera || /Firefox\/2/.test(navigator.userAgent)) {
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   151
					ed.onKeyDown.add(function(ed, e) {
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   152
						if (((tinymce.isMac ? e.metaKey : e.ctrlKey) && e.keyCode == 86) || (e.shiftKey && e.keyCode == 45))
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   153
							grabContent(e);
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   154
					});
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   155
				} else {
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   156
					// Grab contents on paste event on Gecko and WebKit
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   157
					ed.onPaste.addToTop(function(ed, e) {
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   158
						return grabContent(e);
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   159
					});
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   160
				}
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   161
			}
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   162
1193
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   163
			// Block all drag/drop events
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   164
			if (ed.getParam('paste_block_drop')) {
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   165
				ed.onInit.add(function() {
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   166
					ed.dom.bind(ed.getBody(), ['dragend', 'dragover', 'draggesture', 'dragdrop', 'drop', 'drag'], function(e) {
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   167
						e.preventDefault();
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   168
						e.stopPropagation();
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   169
1193
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   170
						return false;
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   171
					});
335
67bd3121a12e Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents: 1
diff changeset
   172
				});
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   173
			}
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   174
1193
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   175
			// Add legacy support
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   176
			t._legacySupport();
335
67bd3121a12e Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents: 1
diff changeset
   177
		},
67bd3121a12e Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents: 1
diff changeset
   178
67bd3121a12e Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents: 1
diff changeset
   179
		getInfo : function() {
67bd3121a12e Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents: 1
diff changeset
   180
			return {
67bd3121a12e Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents: 1
diff changeset
   181
				longname : 'Paste text/word',
67bd3121a12e Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents: 1
diff changeset
   182
				author : 'Moxiecode Systems AB',
67bd3121a12e Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents: 1
diff changeset
   183
				authorurl : 'http://tinymce.moxiecode.com',
67bd3121a12e Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents: 1
diff changeset
   184
				infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/paste',
67bd3121a12e Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents: 1
diff changeset
   185
				version : tinymce.majorVersion + "." + tinymce.minorVersion
67bd3121a12e Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents: 1
diff changeset
   186
			};
67bd3121a12e Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents: 1
diff changeset
   187
		},
67bd3121a12e Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents: 1
diff changeset
   188
1193
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   189
		_preProcess : function(pl, o) {
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   190
			var ed = this.editor, h = o.content, process, stripClass;
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   191
1193
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   192
			//console.log('Before preprocess:' + o.content);
335
67bd3121a12e Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents: 1
diff changeset
   193
1193
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   194
			function process(items) {
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   195
				each(items, function(v) {
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   196
					// Remove or replace
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   197
					if (v.constructor == RegExp)
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   198
						h = h.replace(v, '');
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   199
					else
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   200
						h = h.replace(v[0], v[1]);
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   201
				});
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   202
			};
335
67bd3121a12e Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents: 1
diff changeset
   203
1193
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   204
			// Detect Word content and process it more aggressive
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   205
			if (/(class=\"?Mso|style=\"[^\"]*\bmso\-|w:WordDocument)/.test(h) || o.wordContent) {
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   206
				o.wordContent = true; // Mark the pasted contents as word specific content
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   207
				//console.log('Word contents detected.');
588
20484deb89cd Upgraded TinyMCE to 3.1.0.1. Ported a couple special pages to the componentized JS system.
Dan
parents: 543
diff changeset
   208
1193
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   209
				// Process away some basic content
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   210
				process([
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   211
					/^\s*(&nbsp;)+/g,											// nbsp entities at the start of contents
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   212
					/(&nbsp;|<br[^>]*>)+\s*$/g									// nbsp entities at the end of contents
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   213
				]);
778
57ce13805b6f Upgraded TinyMCE to version 3.2.1.1
Dan
parents: 588
diff changeset
   214
1193
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   215
				if (ed.getParam('paste_convert_middot_lists', true)) {
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   216
					process([
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   217
						[/<!--\[if !supportLists\]-->/gi, '$&__MCE_ITEM__'],			// Convert supportLists to a list item marker
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   218
						[/(<span[^>]+:\s*symbol[^>]+>)/gi, '$1__MCE_ITEM__'],				// Convert symbol spans to list items
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   219
						[/(<span[^>]+mso-list:[^>]+>)/gi, '$1__MCE_ITEM__']				// Convert mso-list to item marker
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   220
					]);
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   221
				}
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   222
1193
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   223
				process([
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   224
					/<!--[\s\S]+?-->/gi,												// Word comments
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   225
					/<\/?(img|font|meta|link|style|div|v:\w+)[^>]*>/gi,					// Remove some tags including VML content
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   226
					/<\\?\?xml[^>]*>/gi,												// XML namespace declarations
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   227
					/<\/?o:[^>]*>/gi,													// MS namespaced elements <o:tag>
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   228
					/ (id|name|language|type|on\w+|v:\w+)=\"([^\"]*)\"/gi,				// on.., class, style and language attributes with quotes
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   229
					/ (id|name|language|type|on\w+|v:\w+)=(\w+)/gi,						// on.., class, style and language attributes without quotes (IE)
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   230
					[/<(\/?)s>/gi, '<$1strike>'],										// Convert <s> into <strike> for line-though
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   231
					/<script[^>]+>[\s\S]*?<\/script>/gi,								// All scripts elements for msoShowComment for example
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   232
					[/&nbsp;/g, '\u00a0']												// Replace nsbp entites to char since it's easier to handle
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   233
				]);
335
67bd3121a12e Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents: 1
diff changeset
   234
1193
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   235
				// Remove all spans if no styles is to be retained
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   236
				if (!ed.getParam('paste_retain_style_properties')) {
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   237
					process([
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   238
						/<\/?(span)[^>]*>/gi
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   239
					]);
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   240
				}
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   241
			}
335
67bd3121a12e Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents: 1
diff changeset
   242
1193
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   243
			// Allow for class names to be retained if desired; either all, or just the ones from Word
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   244
			// Note that the paste_strip_class_attributes: 'none, verify_css_classes: true is also a good variation.
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   245
			stripClass = ed.getParam('paste_strip_class_attributes');
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   246
			if (stripClass != 'none') {
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   247
				// Cleans everything but mceItem... classes
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   248
				function cleanClasses(str, cls) {
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   249
					var i, out = '';
335
67bd3121a12e Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents: 1
diff changeset
   250
1193
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   251
					// Remove all classes
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   252
					if (stripClass == 'all')
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   253
						return '';
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   254
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   255
					cls = tinymce.explode(cls, ' ');
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   256
1193
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   257
					for (i = cls.length - 1; i >= 0; i--) {
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   258
						// Remove Mso classes
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   259
						if (!/^(Mso)/i.test(cls[i]))
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   260
							out += (!out ? '' : ' ') + cls[i];
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   261
					}
335
67bd3121a12e Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents: 1
diff changeset
   262
1193
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   263
					return ' class="' + out + '"';
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   264
				};
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   265
1193
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   266
				process([
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   267
					[/ class=\"([^\"]*)\"/gi, cleanClasses],	// class attributes with quotes
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   268
					[/ class=(\w+)/gi, cleanClasses]			// class attributes without quotes (IE)
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   269
				]);
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   270
			}
588
20484deb89cd Upgraded TinyMCE to 3.1.0.1. Ported a couple special pages to the componentized JS system.
Dan
parents: 543
diff changeset
   271
1193
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   272
			// Remove spans option
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   273
			if (ed.getParam('paste_remove_spans')) {
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   274
				process([
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   275
					/<\/?(span)[^>]*>/gi
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   276
				]);
335
67bd3121a12e Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents: 1
diff changeset
   277
			}
1193
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   278
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   279
			//console.log('After preprocess:' + h);
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   280
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   281
			o.content = h;
335
67bd3121a12e Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents: 1
diff changeset
   282
		},
67bd3121a12e Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents: 1
diff changeset
   283
1193
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   284
		/**
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   285
		 * Various post process items.
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   286
		 */
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   287
		_postProcess : function(pl, o) {
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   288
			var t = this, ed = t.editor, dom = ed.dom, styleProps;
335
67bd3121a12e Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents: 1
diff changeset
   289
1193
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   290
			if (o.wordContent) {
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   291
				// Remove named anchors or TOC links
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   292
				each(dom.select('a', o.node), function(a) {
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   293
					if (!a.href || a.href.indexOf('#_Toc') != -1)
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   294
						dom.remove(a, 1);
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   295
				});
335
67bd3121a12e Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents: 1
diff changeset
   296
1193
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   297
				if (t.editor.getParam('paste_convert_middot_lists', true))
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   298
					t._convertLists(pl, o);
335
67bd3121a12e Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents: 1
diff changeset
   299
1193
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   300
				// Process styles
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   301
				styleProps = ed.getParam('paste_retain_style_properties'); // retained properties
335
67bd3121a12e Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents: 1
diff changeset
   302
1193
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   303
				// If string property then split it
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   304
				if (tinymce.is(styleProps, 'string'))
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   305
					styleProps = tinymce.explode(styleProps);
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   306
1193
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   307
				// Retains some style properties
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   308
				each(dom.select('*', o.node), function(el) {
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   309
					var newStyle = {}, npc = 0, i, sp, sv;
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   310
1193
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   311
					// Store a subset of the existing styles
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   312
					if (styleProps) {
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   313
						for (i = 0; i < styleProps.length; i++) {
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   314
							sp = styleProps[i];
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   315
							sv = dom.getStyle(el, sp);
335
67bd3121a12e Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents: 1
diff changeset
   316
1193
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   317
							if (sv) {
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   318
								newStyle[sp] = sv;
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   319
								npc++;
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   320
							}
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   321
						}
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   322
					}
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   323
1193
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   324
					// Remove all of the existing styles
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   325
					dom.setAttrib(el, 'style', '');
335
67bd3121a12e Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents: 1
diff changeset
   326
1193
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   327
					if (styleProps && npc > 0)
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   328
						dom.setStyles(el, newStyle); // Add back the stored subset of styles
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   329
					else // Remove empty span tags that do not have class attributes
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   330
						if (el.nodeName == 'SPAN' && !el.className)
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   331
							dom.remove(el, true);
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   332
				});
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   333
			}
335
67bd3121a12e Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents: 1
diff changeset
   334
1193
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   335
			// Remove all style information or only specifically on WebKit to avoid the style bug on that browser
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   336
			if (ed.getParam("paste_remove_styles") || (ed.getParam("paste_remove_styles_if_webkit") && tinymce.isWebKit)) {
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   337
				each(dom.select('*[style]', o.node), function(el) {
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   338
					el.removeAttribute('style');
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   339
					el.removeAttribute('mce_style');
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   340
				});
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   341
			} else {
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   342
				if (tinymce.isWebKit) {
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   343
					// We need to compress the styles on WebKit since if you paste <img border="0" /> it will become <img border="0" style="... lots of junk ..." />
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   344
					// Removing the mce_style that contains the real value will force the Serializer engine to compress the styles
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   345
					each(dom.select('*', o.node), function(el) {
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   346
						el.removeAttribute('mce_style');
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   347
					});
335
67bd3121a12e Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents: 1
diff changeset
   348
				}
67bd3121a12e Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents: 1
diff changeset
   349
			}
67bd3121a12e Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents: 1
diff changeset
   350
		},
67bd3121a12e Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents: 1
diff changeset
   351
1193
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   352
		/**
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   353
		 * Converts the most common bullet and number formats in Office into a real semantic UL/LI list.
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   354
		 */
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   355
		_convertLists : function(pl, o) {
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   356
			var dom = pl.editor.dom, listElm, li, lastMargin = -1, margin, levels = [], lastType, html;
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   357
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   358
			// Convert middot lists into real semantic lists
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   359
			each(dom.select('p', o.node), function(p) {
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   360
				var sib, val = '', type, html, idx, parents;
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   361
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   362
				// Get text node value at beginning of paragraph
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   363
				for (sib = p.firstChild; sib && sib.nodeType == 3; sib = sib.nextSibling)
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   364
					val += sib.nodeValue;
335
67bd3121a12e Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents: 1
diff changeset
   365
1193
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   366
				val = p.innerHTML.replace(/<\/?\w+[^>]*>/gi, '').replace(/&nbsp;/g, '\u00a0');
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   367
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   368
				// Detect unordered lists look for bullets
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   369
				if (/^(__MCE_ITEM__)+[\u2022\u00b7\u00a7\u00d8o]\s*\u00a0*/.test(val))
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   370
					type = 'ul';
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   371
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   372
				// Detect ordered lists 1., a. or ixv.
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   373
				if (/^__MCE_ITEM__\s*\w+\.\s*\u00a0{2,}/.test(val))
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   374
					type = 'ol';
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   375
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   376
				// Check if node value matches the list pattern: o&nbsp;&nbsp;
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   377
				if (type) {
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   378
					margin = parseFloat(p.style.marginLeft || 0);
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   379
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   380
					if (margin > lastMargin)
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   381
						levels.push(margin);
335
67bd3121a12e Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents: 1
diff changeset
   382
1193
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   383
					if (!listElm || type != lastType) {
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   384
						listElm = dom.create(type);
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   385
						dom.insertAfter(listElm, p);
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   386
					} else {
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   387
						// Nested list element
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   388
						if (margin > lastMargin) {
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   389
							listElm = li.appendChild(dom.create(type));
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   390
						} else if (margin < lastMargin) {
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   391
							// Find parent level based on margin value
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   392
							idx = tinymce.inArray(levels, margin);
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   393
							parents = dom.getParents(listElm.parentNode, type);
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   394
							listElm = parents[parents.length - 1 - idx] || listElm;
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   395
						}
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   396
					}
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   397
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   398
					// Remove middot or number spans if they exists
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   399
					each(dom.select('span', p), function(span) {
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   400
						var html = span.innerHTML.replace(/<\/?\w+[^>]*>/gi, '');
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   401
1193
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   402
						// Remove span with the middot or the number
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   403
						if (type == 'ul' && /^[\u2022\u00b7\u00a7\u00d8o]/.test(html))
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   404
							dom.remove(span);
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   405
						else if (/^[\s\S]*\w+\.(&nbsp;|\u00a0)*\s*/.test(html))
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   406
							dom.remove(span);
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   407
					});
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   408
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   409
					html = p.innerHTML;
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   410
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   411
					// Remove middot/list items
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   412
					if (type == 'ul')
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   413
						html = p.innerHTML.replace(/__MCE_ITEM__/g, '').replace(/^[\u2022\u00b7\u00a7\u00d8o]\s*(&nbsp;|\u00a0)+\s*/, '');
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   414
					else
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   415
						html = p.innerHTML.replace(/__MCE_ITEM__/g, '').replace(/^\s*\w+\.(&nbsp;|\u00a0)+\s*/, '');
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   416
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   417
					// Create li and add paragraph data into the new li
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   418
					li = listElm.appendChild(dom.create('li', 0, html));
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   419
					dom.remove(p);
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   420
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   421
					lastMargin = margin;
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   422
					lastType = type;
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   423
				} else
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   424
					listElm = lastMargin = 0; // End list element
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   425
			});
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   426
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   427
			// Remove any left over makers
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   428
			html = o.node.innerHTML;
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   429
			if (html.indexOf('__MCE_ITEM__') != -1)
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   430
				o.node.innerHTML = html.replace(/__MCE_ITEM__/g, '');
335
67bd3121a12e Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents: 1
diff changeset
   431
		},
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   432
1193
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   433
		/**
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   434
		 * This method will split the current block parent and insert the contents inside the split position.
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   435
		 * This logic can be improved so text nodes at the start/end remain in the start/end block elements
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   436
		 */
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   437
		_insertBlockContent : function(ed, dom, content) {
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   438
			var parentBlock, marker, sel = ed.selection, last, elm, vp, y, elmHeight;
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   439
1193
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   440
			function select(n) {
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   441
				var r;
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   442
1193
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   443
				if (tinymce.isIE) {
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   444
					r = ed.getDoc().body.createTextRange();
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   445
					r.moveToElementText(n);
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   446
					r.collapse(false);
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   447
					r.select();
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   448
				} else {
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   449
					sel.select(n, 1);
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   450
					sel.collapse(false);
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   451
				}
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   452
			};
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   453
1193
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   454
			// Insert a marker for the caret position
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   455
			this._insert('<span id="_marker">&nbsp;</span>', 1);
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   456
			marker = dom.get('_marker');
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   457
			parentBlock = dom.getParent(marker, 'p,h1,h2,h3,h4,h5,h6,ul,ol,th,td');
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   458
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   459
			// If it's a parent block but not a table cell
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   460
			if (parentBlock && !/TD|TH/.test(parentBlock.nodeName)) {
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   461
				// Split parent block
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   462
				marker = dom.split(parentBlock, marker);
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   463
1193
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   464
				// Insert nodes before the marker
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   465
				each(dom.create('div', 0, content).childNodes, function(n) {
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   466
					last = marker.parentNode.insertBefore(n.cloneNode(true), marker);
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   467
				});
335
67bd3121a12e Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents: 1
diff changeset
   468
1193
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   469
				// Move caret after marker
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   470
				select(last);
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   471
			} else {
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   472
				dom.setOuterHTML(marker, content);
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   473
				sel.select(ed.getBody(), 1);
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   474
				sel.collapse(0);
335
67bd3121a12e Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents: 1
diff changeset
   475
			}
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   476
1193
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   477
			dom.remove('_marker'); // Remove marker if it's left
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   478
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   479
			// Get element, position and height
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   480
			elm = sel.getStart();
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   481
			vp = dom.getViewPort(ed.getWin());
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   482
			y = ed.dom.getPos(elm).y;
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   483
			elmHeight = elm.clientHeight;
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   484
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   485
			// Is element within viewport if not then scroll it into view
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   486
			if (y < vp.y || y + elmHeight > vp.y + vp.h)
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   487
				ed.getDoc().body.scrollTop = y < vp.y ? y : y - vp.h + 25;
335
67bd3121a12e Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents: 1
diff changeset
   488
		},
67bd3121a12e Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents: 1
diff changeset
   489
1193
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   490
		/**
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   491
		 * Inserts the specified contents at the caret position.
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   492
		 */
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   493
		_insert : function(h, skip_undo) {
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   494
			var ed = this.editor;
335
67bd3121a12e Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents: 1
diff changeset
   495
1193
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   496
			// First delete the contents seems to work better on WebKit
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   497
			if (!ed.selection.isCollapsed())
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   498
				ed.getDoc().execCommand('Delete', false, null);
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   499
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   500
			// It's better to use the insertHTML method on Gecko since it will combine paragraphs correctly before inserting the contents
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   501
			ed.execCommand(tinymce.isGecko ? 'insertHTML' : 'mceInsertContent', false, h, {skip_undo : skip_undo});
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   502
		},
335
67bd3121a12e Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents: 1
diff changeset
   503
1193
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   504
		/**
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   505
		 * This method will open the old style paste dialogs. Some users might want the old behavior but still use the new cleanup engine.
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   506
		 */
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   507
		_legacySupport : function() {
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   508
			var t = this, ed = t.editor;
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   509
1193
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   510
			// Register commands for backwards compatibility
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   511
			each(['mcePasteText', 'mcePasteWord'], function(cmd) {
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   512
				ed.addCommand(cmd, function() {
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   513
					ed.windowManager.open({
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   514
						file : t.url + (cmd == 'mcePasteText' ? '/pastetext.htm' : '/pasteword.htm'),
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   515
						width : parseInt(ed.getParam("paste_dialog_width", "450")),
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   516
						height : parseInt(ed.getParam("paste_dialog_height", "400")),
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   517
						inline : 1
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   518
					});
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   519
				});
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   520
			});
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   521
1193
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   522
			// Register buttons for backwards compatibility
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   523
			ed.addButton('pastetext', {title : 'paste.paste_text_desc', cmd : 'mcePasteText'});
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   524
			ed.addButton('pasteword', {title : 'paste.paste_word_desc', cmd : 'mcePasteWord'});
e3b94bd055dc TinyMCE: Bumped to v3.2.7
Dan
parents: 778
diff changeset
   525
			ed.addButton('selectall', {title : 'paste.selectall_desc', cmd : 'selectall'});
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   526
		}
335
67bd3121a12e Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents: 1
diff changeset
   527
	});
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   528
335
67bd3121a12e Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents: 1
diff changeset
   529
	// Register plugin
67bd3121a12e Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents: 1
diff changeset
   530
	tinymce.PluginManager.add('paste', tinymce.plugins.PastePlugin);
67bd3121a12e Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents: 1
diff changeset
   531
})();