annotate media/js/tiny_mce/plugins/paste/editor_plugin_src.js @ 200:7d3e5aca095f

Fixing #73: comments no longer getting adding to web page on submit.
author Brian Neal <bgneal@gmail.com>
date Sun, 11 Apr 2010 19:41:13 +0000
parents 149c3567fec1
children 237710206167
rev   line source
bgneal@45 1 /**
bgneal@183 2 * editor_plugin_src.js
bgneal@45 3 *
bgneal@183 4 * Copyright 2009, Moxiecode Systems AB
bgneal@183 5 * Released under LGPL License.
bgneal@183 6 *
bgneal@183 7 * License: http://tinymce.moxiecode.com/license
bgneal@183 8 * Contributing: http://tinymce.moxiecode.com/contributing
bgneal@45 9 */
bgneal@45 10
bgneal@45 11 (function() {
bgneal@183 12 var each = tinymce.each,
bgneal@183 13 entities = null,
bgneal@183 14 defs = {
bgneal@183 15 paste_auto_cleanup_on_paste : true,
bgneal@183 16 paste_block_drop : false,
bgneal@183 17 paste_retain_style_properties : "none",
bgneal@183 18 paste_strip_class_attributes : "mso",
bgneal@183 19 paste_remove_spans : false,
bgneal@183 20 paste_remove_styles : false,
bgneal@183 21 paste_remove_styles_if_webkit : true,
bgneal@183 22 paste_convert_middot_lists : true,
bgneal@183 23 paste_convert_headers_to_strong : false,
bgneal@183 24 paste_dialog_width : "450",
bgneal@183 25 paste_dialog_height : "400",
bgneal@183 26 paste_text_use_dialog : false,
bgneal@183 27 paste_text_sticky : false,
bgneal@183 28 paste_text_notifyalways : false,
bgneal@183 29 paste_text_linebreaktype : "p",
bgneal@183 30 paste_text_replacements : [
bgneal@183 31 [/\u2026/g, "..."],
bgneal@183 32 [/[\x93\x94\u201c\u201d]/g, '"'],
bgneal@183 33 [/[\x60\x91\x92\u2018\u2019]/g, "'"]
bgneal@183 34 ]
bgneal@183 35 };
bgneal@183 36
bgneal@183 37 function getParam(ed, name) {
bgneal@183 38 return ed.getParam(name, defs[name]);
bgneal@183 39 }
bgneal@45 40
bgneal@45 41 tinymce.create('tinymce.plugins.PastePlugin', {
bgneal@45 42 init : function(ed, url) {
bgneal@45 43 var t = this;
bgneal@45 44
bgneal@183 45 t.editor = ed;
bgneal@183 46 t.url = url;
bgneal@45 47
bgneal@183 48 // Setup plugin events
bgneal@183 49 t.onPreProcess = new tinymce.util.Dispatcher(t);
bgneal@183 50 t.onPostProcess = new tinymce.util.Dispatcher(t);
bgneal@183 51
bgneal@183 52 // Register default handlers
bgneal@183 53 t.onPreProcess.add(t._preProcess);
bgneal@183 54 t.onPostProcess.add(t._postProcess);
bgneal@183 55
bgneal@183 56 // Register optional preprocess handler
bgneal@183 57 t.onPreProcess.add(function(pl, o) {
bgneal@183 58 ed.execCallback('paste_preprocess', pl, o);
bgneal@45 59 });
bgneal@45 60
bgneal@183 61 // Register optional postprocess
bgneal@183 62 t.onPostProcess.add(function(pl, o) {
bgneal@183 63 ed.execCallback('paste_postprocess', pl, o);
bgneal@45 64 });
bgneal@45 65
bgneal@183 66 // Initialize plain text flag
bgneal@183 67 ed.pasteAsPlainText = false;
bgneal@183 68
bgneal@183 69 // This function executes the process handlers and inserts the contents
bgneal@183 70 // force_rich overrides plain text mode set by user, important for pasting with execCommand
bgneal@183 71 function process(o, force_rich) {
bgneal@183 72 var dom = ed.dom;
bgneal@183 73
bgneal@183 74 // Execute pre process handlers
bgneal@183 75 t.onPreProcess.dispatch(t, o);
bgneal@183 76
bgneal@183 77 // Create DOM structure
bgneal@183 78 o.node = dom.create('div', 0, o.content);
bgneal@183 79
bgneal@183 80 // Execute post process handlers
bgneal@183 81 t.onPostProcess.dispatch(t, o);
bgneal@183 82
bgneal@183 83 // Serialize content
bgneal@183 84 o.content = ed.serializer.serialize(o.node, {getInner : 1});
bgneal@183 85
bgneal@183 86 // Plain text option active?
bgneal@183 87 if ((!force_rich) && (ed.pasteAsPlainText)) {
bgneal@183 88 t._insertPlainText(ed, dom, o.content);
bgneal@183 89
bgneal@183 90 if (!getParam(ed, "paste_text_sticky")) {
bgneal@183 91 ed.pasteAsPlainText = false;
bgneal@183 92 ed.controlManager.setActive("pastetext", false);
bgneal@183 93 }
bgneal@183 94 } else if (/<(p|h[1-6]|ul|ol)/.test(o.content)) {
bgneal@183 95 // Handle insertion of contents containing block elements separately
bgneal@183 96 t._insertBlockContent(ed, dom, o.content);
bgneal@183 97 } else {
bgneal@183 98 t._insert(o.content);
bgneal@183 99 }
bgneal@183 100 }
bgneal@183 101
bgneal@183 102 // Add command for external usage
bgneal@183 103 ed.addCommand('mceInsertClipboardContent', function(u, o) {
bgneal@183 104 process(o, true);
bgneal@45 105 });
bgneal@45 106
bgneal@183 107 if (!getParam(ed, "paste_text_use_dialog")) {
bgneal@183 108 ed.addCommand('mcePasteText', function(u, v) {
bgneal@183 109 var cookie = tinymce.util.Cookie;
bgneal@45 110
bgneal@183 111 ed.pasteAsPlainText = !ed.pasteAsPlainText;
bgneal@183 112 ed.controlManager.setActive('pastetext', ed.pasteAsPlainText);
bgneal@183 113
bgneal@183 114 if ((ed.pasteAsPlainText) && (!cookie.get("tinymcePasteText"))) {
bgneal@183 115 if (getParam(ed, "paste_text_sticky")) {
bgneal@183 116 ed.windowManager.alert("Paste is now in plain text mode. Click again to toggle back to regular paste mode. After you paste something you will be returned to regular paste mode.");
bgneal@183 117 } else {
bgneal@183 118 ed.windowManager.alert("Paste is now in plain text mode. Click again to toggle back to regular paste mode.");
bgneal@183 119 }
bgneal@183 120
bgneal@183 121 if (!getParam(ed, "paste_text_notifyalways")) {
bgneal@183 122 cookie.set("tinymcePasteText", "1", new Date(new Date().getFullYear() + 1, 12, 31))
bgneal@183 123 }
bgneal@183 124 }
bgneal@45 125 });
bgneal@45 126 }
bgneal@45 127
bgneal@183 128 ed.addButton('pastetext', {title: 'paste.paste_text_desc', cmd: 'mcePasteText'});
bgneal@183 129 ed.addButton('selectall', {title: 'paste.selectall_desc', cmd: 'selectall'});
bgneal@45 130
bgneal@183 131 // This function grabs the contents from the clipboard by adding a
bgneal@183 132 // hidden div and placing the caret inside it and after the browser paste
bgneal@183 133 // is done it grabs that contents and processes that
bgneal@183 134 function grabContent(e) {
bgneal@183 135 var n, or, rng, sel = ed.selection, dom = ed.dom, body = ed.getBody(), posY;
bgneal@183 136
bgneal@183 137 if (dom.get('_mcePaste'))
bgneal@183 138 return;
bgneal@183 139
bgneal@183 140 // Create container to paste into
bgneal@183 141 n = dom.add(body, 'div', {id : '_mcePaste', 'class' : 'mcePaste'}, '\uFEFF');
bgneal@183 142
bgneal@183 143 // If contentEditable mode we need to find out the position of the closest element
bgneal@183 144 if (body != ed.getDoc().body)
bgneal@183 145 posY = dom.getPos(ed.selection.getStart(), body).y;
bgneal@183 146 else
bgneal@183 147 posY = body.scrollTop;
bgneal@183 148
bgneal@183 149 // Styles needs to be applied after the element is added to the document since WebKit will otherwise remove all styles
bgneal@183 150 dom.setStyles(n, {
bgneal@183 151 position : 'absolute',
bgneal@183 152 left : -10000,
bgneal@183 153 top : posY,
bgneal@183 154 width : 1,
bgneal@183 155 height : 1,
bgneal@183 156 overflow : 'hidden'
bgneal@183 157 });
bgneal@183 158
bgneal@183 159 if (tinymce.isIE) {
bgneal@183 160 // Select the container
bgneal@183 161 rng = dom.doc.body.createTextRange();
bgneal@183 162 rng.moveToElementText(n);
bgneal@183 163 rng.execCommand('Paste');
bgneal@183 164
bgneal@183 165 // Remove container
bgneal@183 166 dom.remove(n);
bgneal@183 167
bgneal@183 168 // Check if the contents was changed, if it wasn't then clipboard extraction failed probably due
bgneal@183 169 // to IE security settings so we pass the junk though better than nothing right
bgneal@183 170 if (n.innerHTML === '\uFEFF') {
bgneal@183 171 ed.execCommand('mcePasteWord');
bgneal@183 172 e.preventDefault();
bgneal@183 173 return;
bgneal@45 174 }
bgneal@183 175
bgneal@183 176 // Process contents
bgneal@183 177 process({content : n.innerHTML});
bgneal@183 178
bgneal@183 179 // Block the real paste event
bgneal@183 180 return tinymce.dom.Event.cancel(e);
bgneal@183 181 } else {
bgneal@183 182 function block(e) {
bgneal@183 183 e.preventDefault();
bgneal@183 184 };
bgneal@183 185
bgneal@183 186 // Block mousedown and click to prevent selection change
bgneal@183 187 dom.bind(ed.getDoc(), 'mousedown', block);
bgneal@183 188 dom.bind(ed.getDoc(), 'keydown', block);
bgneal@183 189
bgneal@183 190 or = ed.selection.getRng();
bgneal@183 191
bgneal@183 192 // Move caret into hidden div
bgneal@183 193 n = n.firstChild;
bgneal@183 194 rng = ed.getDoc().createRange();
bgneal@183 195 rng.setStart(n, 0);
bgneal@183 196 rng.setEnd(n, 1);
bgneal@183 197 sel.setRng(rng);
bgneal@183 198
bgneal@183 199 // Wait a while and grab the pasted contents
bgneal@183 200 window.setTimeout(function() {
bgneal@183 201 var h = '', nl = dom.select('div.mcePaste');
bgneal@183 202
bgneal@183 203 // WebKit will split the div into multiple ones so this will loop through then all and join them to get the whole HTML string
bgneal@183 204 each(nl, function(n) {
bgneal@183 205 // WebKit duplicates the divs so we need to remove them
bgneal@183 206 each(dom.select('div.mcePaste', n), function(n) {
bgneal@183 207 dom.remove(n, 1);
bgneal@183 208 });
bgneal@183 209
bgneal@183 210 // Contents in WebKit is sometimes wrapped in a apple style span so we need to grab it from that one
bgneal@183 211 h += (dom.select('> span.Apple-style-span div', n)[0] || dom.select('> span.Apple-style-span', n)[0] || n).innerHTML;
bgneal@183 212 });
bgneal@183 213
bgneal@183 214 // Remove the nodes
bgneal@183 215 each(nl, function(n) {
bgneal@183 216 dom.remove(n);
bgneal@183 217 });
bgneal@183 218
bgneal@183 219 // Restore the old selection
bgneal@183 220 if (or)
bgneal@183 221 sel.setRng(or);
bgneal@183 222
bgneal@183 223 process({content : h});
bgneal@183 224
bgneal@183 225 // Unblock events ones we got the contents
bgneal@183 226 dom.unbind(ed.getDoc(), 'mousedown', block);
bgneal@183 227 dom.unbind(ed.getDoc(), 'keydown', block);
bgneal@183 228 }, 0);
bgneal@183 229 }
bgneal@183 230 }
bgneal@183 231
bgneal@183 232 // Check if we should use the new auto process method
bgneal@183 233 if (getParam(ed, "paste_auto_cleanup_on_paste")) {
bgneal@183 234 // Is it's Opera or older FF use key handler
bgneal@183 235 if (tinymce.isOpera || /Firefox\/2/.test(navigator.userAgent)) {
bgneal@183 236 ed.onKeyDown.add(function(ed, e) {
bgneal@183 237 if (((tinymce.isMac ? e.metaKey : e.ctrlKey) && e.keyCode == 86) || (e.shiftKey && e.keyCode == 45))
bgneal@183 238 grabContent(e);
bgneal@183 239 });
bgneal@183 240 } else {
bgneal@183 241 // Grab contents on paste event on Gecko and WebKit
bgneal@183 242 ed.onPaste.addToTop(function(ed, e) {
bgneal@183 243 return grabContent(e);
bgneal@183 244 });
bgneal@183 245 }
bgneal@183 246 }
bgneal@183 247
bgneal@183 248 // Block all drag/drop events
bgneal@183 249 if (getParam(ed, "paste_block_drop")) {
bgneal@183 250 ed.onInit.add(function() {
bgneal@183 251 ed.dom.bind(ed.getBody(), ['dragend', 'dragover', 'draggesture', 'dragdrop', 'drop', 'drag'], function(e) {
bgneal@183 252 e.preventDefault();
bgneal@183 253 e.stopPropagation();
bgneal@183 254
bgneal@183 255 return false;
bgneal@183 256 });
bgneal@45 257 });
bgneal@45 258 }
bgneal@183 259
bgneal@183 260 // Add legacy support
bgneal@183 261 t._legacySupport();
bgneal@45 262 },
bgneal@45 263
bgneal@45 264 getInfo : function() {
bgneal@45 265 return {
bgneal@45 266 longname : 'Paste text/word',
bgneal@45 267 author : 'Moxiecode Systems AB',
bgneal@45 268 authorurl : 'http://tinymce.moxiecode.com',
bgneal@45 269 infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/paste',
bgneal@45 270 version : tinymce.majorVersion + "." + tinymce.minorVersion
bgneal@45 271 };
bgneal@45 272 },
bgneal@45 273
bgneal@183 274 _preProcess : function(pl, o) {
bgneal@183 275 //console.log('Before preprocess:' + o.content);
bgneal@45 276
bgneal@183 277 var ed = this.editor,
bgneal@183 278 h = o.content,
bgneal@183 279 grep = tinymce.grep,
bgneal@183 280 explode = tinymce.explode,
bgneal@183 281 trim = tinymce.trim,
bgneal@183 282 len, stripClass;
bgneal@45 283
bgneal@183 284 function process(items) {
bgneal@183 285 each(items, function(v) {
bgneal@183 286 // Remove or replace
bgneal@183 287 if (v.constructor == RegExp)
bgneal@183 288 h = h.replace(v, '');
bgneal@183 289 else
bgneal@183 290 h = h.replace(v[0], v[1]);
bgneal@183 291 });
bgneal@183 292 }
bgneal@45 293
bgneal@183 294 // Detect Word content and process it more aggressive
bgneal@183 295 if (/class="?Mso|style="[^"]*\bmso-|w:WordDocument/i.test(h) || o.wordContent) {
bgneal@183 296 o.wordContent = true; // Mark the pasted contents as word specific content
bgneal@183 297 //console.log('Word contents detected.');
bgneal@45 298
bgneal@183 299 // Process away some basic content
bgneal@183 300 process([
bgneal@183 301 /^\s*(&nbsp;)+/gi, // &nbsp; entities at the start of contents
bgneal@183 302 /(&nbsp;|<br[^>]*>)+\s*$/gi // &nbsp; entities at the end of contents
bgneal@183 303 ]);
bgneal@183 304
bgneal@183 305 if (getParam(ed, "paste_convert_headers_to_strong")) {
bgneal@183 306 h = h.replace(/<p [^>]*class="?MsoHeading"?[^>]*>(.*?)<\/p>/gi, "<p><strong>$1</strong></p>");
bgneal@183 307 }
bgneal@183 308
bgneal@183 309 if (getParam(ed, "paste_convert_middot_lists")) {
bgneal@183 310 process([
bgneal@183 311 [/<!--\[if !supportLists\]-->/gi, '$&__MCE_ITEM__'], // Convert supportLists to a list item marker
bgneal@183 312 [/(<span[^>]+(?:mso-list:|:\s*symbol)[^>]+>)/gi, '$1__MCE_ITEM__'] // Convert mso-list and symbol spans to item markers
bgneal@183 313 ]);
bgneal@183 314 }
bgneal@183 315
bgneal@183 316 process([
bgneal@183 317 // Word comments like conditional comments etc
bgneal@183 318 /<!--[\s\S]+?-->/gi,
bgneal@183 319
bgneal@183 320 // Remove comments, scripts (e.g., msoShowComment), XML tag, VML content, MS Office namespaced tags, and a few other tags
bgneal@183 321 /<(!|script[^>]*>.*?<\/script(?=[>\s])|\/?(\?xml(:\w+)?|img|meta|link|style|\w:\w+)(?=[\s\/>]))[^>]*>/gi,
bgneal@183 322
bgneal@183 323 // Convert <s> into <strike> for line-though
bgneal@183 324 [/<(\/?)s>/gi, "<$1strike>"],
bgneal@183 325
bgneal@183 326 // Replace nsbp entites to char since it's easier to handle
bgneal@183 327 [/&nbsp;/gi, "\u00a0"]
bgneal@183 328 ]);
bgneal@183 329
bgneal@183 330 // Remove bad attributes, with or without quotes, ensuring that attribute text is really inside a tag.
bgneal@183 331 // If JavaScript had a RegExp look-behind, we could have integrated this with the last process() array and got rid of the loop. But alas, it does not, so we cannot.
bgneal@183 332 do {
bgneal@183 333 len = h.length;
bgneal@183 334 h = h.replace(/(<[a-z][^>]*\s)(?:id|name|language|type|on\w+|\w+:\w+)=(?:"[^"]*"|\w+)\s?/gi, "$1");
bgneal@183 335 } while (len != h.length);
bgneal@183 336
bgneal@183 337 // Remove all spans if no styles is to be retained
bgneal@183 338 if (getParam(ed, "paste_retain_style_properties").replace(/^none$/i, "").length == 0) {
bgneal@183 339 h = h.replace(/<\/?span[^>]*>/gi, "");
bgneal@183 340 } else {
bgneal@183 341 // We're keeping styles, so at least clean them up.
bgneal@183 342 // CSS Reference: http://msdn.microsoft.com/en-us/library/aa155477.aspx
bgneal@183 343
bgneal@183 344 process([
bgneal@183 345 // Convert <span style="mso-spacerun:yes">___</span> to string of alternating breaking/non-breaking spaces of same length
bgneal@183 346 [/<span\s+style\s*=\s*"\s*mso-spacerun\s*:\s*yes\s*;?\s*"\s*>([\s\u00a0]*)<\/span>/gi,
bgneal@183 347 function(str, spaces) {
bgneal@183 348 return (spaces.length > 0)? spaces.replace(/./, " ").slice(Math.floor(spaces.length/2)).split("").join("\u00a0") : "";
bgneal@183 349 }
bgneal@183 350 ],
bgneal@183 351
bgneal@183 352 // Examine all styles: delete junk, transform some, and keep the rest
bgneal@183 353 [/(<[a-z][^>]*)\sstyle="([^"]*)"/gi,
bgneal@183 354 function(str, tag, style) {
bgneal@183 355 var n = [],
bgneal@183 356 i = 0,
bgneal@183 357 s = explode(trim(style).replace(/&quot;/gi, "'"), ";");
bgneal@183 358
bgneal@183 359 // Examine each style definition within the tag's style attribute
bgneal@183 360 each(s, function(v) {
bgneal@183 361 var name, value,
bgneal@183 362 parts = explode(v, ":");
bgneal@183 363
bgneal@183 364 function ensureUnits(v) {
bgneal@183 365 return v + ((v !== "0") && (/\d$/.test(v)))? "px" : "";
bgneal@183 366 }
bgneal@183 367
bgneal@183 368 if (parts.length == 2) {
bgneal@183 369 name = parts[0].toLowerCase();
bgneal@183 370 value = parts[1].toLowerCase();
bgneal@183 371
bgneal@183 372 // Translate certain MS Office styles into their CSS equivalents
bgneal@183 373 switch (name) {
bgneal@183 374 case "mso-padding-alt":
bgneal@183 375 case "mso-padding-top-alt":
bgneal@183 376 case "mso-padding-right-alt":
bgneal@183 377 case "mso-padding-bottom-alt":
bgneal@183 378 case "mso-padding-left-alt":
bgneal@183 379 case "mso-margin-alt":
bgneal@183 380 case "mso-margin-top-alt":
bgneal@183 381 case "mso-margin-right-alt":
bgneal@183 382 case "mso-margin-bottom-alt":
bgneal@183 383 case "mso-margin-left-alt":
bgneal@183 384 case "mso-table-layout-alt":
bgneal@183 385 case "mso-height":
bgneal@183 386 case "mso-width":
bgneal@183 387 case "mso-vertical-align-alt":
bgneal@183 388 n[i++] = name.replace(/^mso-|-alt$/g, "") + ":" + ensureUnits(value);
bgneal@183 389 return;
bgneal@183 390
bgneal@183 391 case "horiz-align":
bgneal@183 392 n[i++] = "text-align:" + value;
bgneal@183 393 return;
bgneal@183 394
bgneal@183 395 case "vert-align":
bgneal@183 396 n[i++] = "vertical-align:" + value;
bgneal@183 397 return;
bgneal@183 398
bgneal@183 399 case "font-color":
bgneal@183 400 case "mso-foreground":
bgneal@183 401 n[i++] = "color:" + value;
bgneal@183 402 return;
bgneal@183 403
bgneal@183 404 case "mso-background":
bgneal@183 405 case "mso-highlight":
bgneal@183 406 n[i++] = "background:" + value;
bgneal@183 407 return;
bgneal@183 408
bgneal@183 409 case "mso-default-height":
bgneal@183 410 n[i++] = "min-height:" + ensureUnits(value);
bgneal@183 411 return;
bgneal@183 412
bgneal@183 413 case "mso-default-width":
bgneal@183 414 n[i++] = "min-width:" + ensureUnits(value);
bgneal@183 415 return;
bgneal@183 416
bgneal@183 417 case "mso-padding-between-alt":
bgneal@183 418 n[i++] = "border-collapse:separate;border-spacing:" + ensureUnits(value);
bgneal@183 419 return;
bgneal@183 420
bgneal@183 421 case "text-line-through":
bgneal@183 422 if ((value == "single") || (value == "double")) {
bgneal@183 423 n[i++] = "text-decoration:line-through";
bgneal@183 424 }
bgneal@183 425 return;
bgneal@183 426
bgneal@183 427 case "mso-zero-height":
bgneal@183 428 if (value == "yes") {
bgneal@183 429 n[i++] = "display:none";
bgneal@183 430 }
bgneal@183 431 return;
bgneal@183 432 }
bgneal@183 433
bgneal@183 434 // Eliminate all MS Office style definitions that have no CSS equivalent by examining the first characters in the name
bgneal@183 435 if (/^(mso|column|font-emph|lang|layout|line-break|list-image|nav|panose|punct|row|ruby|sep|size|src|tab-|table-border|text-(?!align|decor|indent|trans)|top-bar|version|vnd|word-break)/.test(name)) {
bgneal@183 436 return;
bgneal@183 437 }
bgneal@183 438
bgneal@183 439 // If it reached this point, it must be a valid CSS style
bgneal@183 440 n[i++] = name + ":" + parts[1]; // Lower-case name, but keep value case
bgneal@183 441 }
bgneal@183 442 });
bgneal@183 443
bgneal@183 444 // If style attribute contained any valid styles the re-write it; otherwise delete style attribute.
bgneal@183 445 if (i > 0) {
bgneal@183 446 return tag + ' style="' + n.join(';') + '"';
bgneal@183 447 } else {
bgneal@183 448 return tag;
bgneal@183 449 }
bgneal@183 450 }
bgneal@183 451 ]
bgneal@183 452 ]);
bgneal@183 453 }
bgneal@183 454 }
bgneal@183 455
bgneal@183 456 // Replace headers with <strong>
bgneal@183 457 if (getParam(ed, "paste_convert_headers_to_strong")) {
bgneal@183 458 process([
bgneal@183 459 [/<h[1-6][^>]*>/gi, "<p><strong>"],
bgneal@183 460 [/<\/h[1-6][^>]*>/gi, "</strong></p>"]
bgneal@183 461 ]);
bgneal@183 462 }
bgneal@183 463
bgneal@183 464 // Class attribute options are: leave all as-is ("none"), remove all ("all"), or remove only those starting with mso ("mso").
bgneal@183 465 // Note:- paste_strip_class_attributes: "none", verify_css_classes: true is also a good variation.
bgneal@183 466 stripClass = getParam(ed, "paste_strip_class_attributes");
bgneal@183 467
bgneal@183 468 if (stripClass !== "none") {
bgneal@183 469 function removeClasses(match, g1) {
bgneal@183 470 if (stripClass === "all")
bgneal@183 471 return '';
bgneal@183 472
bgneal@183 473 var cls = grep(explode(g1.replace(/^(["'])(.*)\1$/, "$2"), " "),
bgneal@183 474 function(v) {
bgneal@183 475 return (/^(?!mso)/i.test(v));
bgneal@183 476 }
bgneal@183 477 );
bgneal@183 478
bgneal@183 479 return cls.length ? ' class="' + cls.join(" ") + '"' : '';
bgneal@183 480 };
bgneal@183 481
bgneal@183 482 h = h.replace(/ class="([^"]+)"/gi, removeClasses);
bgneal@183 483 h = h.replace(/ class=(\w+)/gi, removeClasses);
bgneal@183 484 }
bgneal@183 485
bgneal@183 486 // Remove spans option
bgneal@183 487 if (getParam(ed, "paste_remove_spans")) {
bgneal@183 488 h = h.replace(/<\/?span[^>]*>/gi, "");
bgneal@183 489 }
bgneal@183 490
bgneal@183 491 //console.log('After preprocess:' + h);
bgneal@183 492
bgneal@183 493 o.content = h;
bgneal@45 494 },
bgneal@45 495
bgneal@183 496 /**
bgneal@183 497 * Various post process items.
bgneal@183 498 */
bgneal@183 499 _postProcess : function(pl, o) {
bgneal@183 500 var t = this, ed = t.editor, dom = ed.dom, styleProps;
bgneal@45 501
bgneal@183 502 if (o.wordContent) {
bgneal@183 503 // Remove named anchors or TOC links
bgneal@183 504 each(dom.select('a', o.node), function(a) {
bgneal@183 505 if (!a.href || a.href.indexOf('#_Toc') != -1)
bgneal@183 506 dom.remove(a, 1);
bgneal@183 507 });
bgneal@45 508
bgneal@183 509 if (getParam(ed, "paste_convert_middot_lists")) {
bgneal@183 510 t._convertLists(pl, o);
bgneal@45 511 }
bgneal@45 512
bgneal@183 513 // Process styles
bgneal@183 514 styleProps = getParam(ed, "paste_retain_style_properties"); // retained properties
bgneal@45 515
bgneal@183 516 // Process only if a string was specified and not equal to "all" or "*"
bgneal@183 517 if ((tinymce.is(styleProps, "string")) && (styleProps !== "all") && (styleProps !== "*")) {
bgneal@183 518 styleProps = tinymce.explode(styleProps.replace(/^none$/i, ""));
bgneal@45 519
bgneal@183 520 // Retains some style properties
bgneal@183 521 each(dom.select('*', o.node), function(el) {
bgneal@183 522 var newStyle = {}, npc = 0, i, sp, sv;
bgneal@45 523
bgneal@183 524 // Store a subset of the existing styles
bgneal@183 525 if (styleProps) {
bgneal@183 526 for (i = 0; i < styleProps.length; i++) {
bgneal@183 527 sp = styleProps[i];
bgneal@183 528 sv = dom.getStyle(el, sp);
bgneal@45 529
bgneal@183 530 if (sv) {
bgneal@183 531 newStyle[sp] = sv;
bgneal@183 532 npc++;
bgneal@183 533 }
bgneal@183 534 }
bgneal@183 535 }
bgneal@45 536
bgneal@183 537 // Remove all of the existing styles
bgneal@183 538 dom.setAttrib(el, 'style', '');
bgneal@183 539
bgneal@183 540 if (styleProps && npc > 0)
bgneal@183 541 dom.setStyles(el, newStyle); // Add back the stored subset of styles
bgneal@183 542 else // Remove empty span tags that do not have class attributes
bgneal@183 543 if (el.nodeName == 'SPAN' && !el.className)
bgneal@183 544 dom.remove(el, true);
bgneal@183 545 });
bgneal@45 546 }
bgneal@183 547 }
bgneal@45 548
bgneal@183 549 // Remove all style information or only specifically on WebKit to avoid the style bug on that browser
bgneal@183 550 if (getParam(ed, "paste_remove_styles") || (getParam(ed, "paste_remove_styles_if_webkit") && tinymce.isWebKit)) {
bgneal@183 551 each(dom.select('*[style]', o.node), function(el) {
bgneal@183 552 el.removeAttribute('style');
bgneal@183 553 el.removeAttribute('_mce_style');
bgneal@183 554 });
bgneal@183 555 } else {
bgneal@183 556 if (tinymce.isWebKit) {
bgneal@183 557 // 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 ..." />
bgneal@183 558 // Removing the mce_style that contains the real value will force the Serializer engine to compress the styles
bgneal@183 559 each(dom.select('*', o.node), function(el) {
bgneal@183 560 el.removeAttribute('_mce_style');
bgneal@183 561 });
bgneal@45 562 }
bgneal@45 563 }
bgneal@45 564 },
bgneal@45 565
bgneal@183 566 /**
bgneal@183 567 * Converts the most common bullet and number formats in Office into a real semantic UL/LI list.
bgneal@183 568 */
bgneal@183 569 _convertLists : function(pl, o) {
bgneal@183 570 var dom = pl.editor.dom, listElm, li, lastMargin = -1, margin, levels = [], lastType, html;
bgneal@45 571
bgneal@183 572 // Convert middot lists into real semantic lists
bgneal@183 573 each(dom.select('p', o.node), function(p) {
bgneal@183 574 var sib, val = '', type, html, idx, parents;
bgneal@45 575
bgneal@183 576 // Get text node value at beginning of paragraph
bgneal@183 577 for (sib = p.firstChild; sib && sib.nodeType == 3; sib = sib.nextSibling)
bgneal@183 578 val += sib.nodeValue;
bgneal@45 579
bgneal@183 580 val = p.innerHTML.replace(/<\/?\w+[^>]*>/gi, '').replace(/&nbsp;/g, '\u00a0');
bgneal@183 581
bgneal@183 582 // Detect unordered lists look for bullets
bgneal@183 583 if (/^(__MCE_ITEM__)+[\u2022\u00b7\u00a7\u00d8o]\s*\u00a0*/.test(val))
bgneal@183 584 type = 'ul';
bgneal@183 585
bgneal@183 586 // Detect ordered lists 1., a. or ixv.
bgneal@183 587 if (/^__MCE_ITEM__\s*\w+\.\s*\u00a0{2,}/.test(val))
bgneal@183 588 type = 'ol';
bgneal@183 589
bgneal@183 590 // Check if node value matches the list pattern: o&nbsp;&nbsp;
bgneal@183 591 if (type) {
bgneal@183 592 margin = parseFloat(p.style.marginLeft || 0);
bgneal@183 593
bgneal@183 594 if (margin > lastMargin)
bgneal@183 595 levels.push(margin);
bgneal@183 596
bgneal@183 597 if (!listElm || type != lastType) {
bgneal@183 598 listElm = dom.create(type);
bgneal@183 599 dom.insertAfter(listElm, p);
bgneal@183 600 } else {
bgneal@183 601 // Nested list element
bgneal@183 602 if (margin > lastMargin) {
bgneal@183 603 listElm = li.appendChild(dom.create(type));
bgneal@183 604 } else if (margin < lastMargin) {
bgneal@183 605 // Find parent level based on margin value
bgneal@183 606 idx = tinymce.inArray(levels, margin);
bgneal@183 607 parents = dom.getParents(listElm.parentNode, type);
bgneal@183 608 listElm = parents[parents.length - 1 - idx] || listElm;
bgneal@183 609 }
bgneal@183 610 }
bgneal@183 611
bgneal@183 612 // Remove middot or number spans if they exists
bgneal@183 613 each(dom.select('span', p), function(span) {
bgneal@183 614 var html = span.innerHTML.replace(/<\/?\w+[^>]*>/gi, '');
bgneal@183 615
bgneal@183 616 // Remove span with the middot or the number
bgneal@183 617 if (type == 'ul' && /^[\u2022\u00b7\u00a7\u00d8o]/.test(html))
bgneal@183 618 dom.remove(span);
bgneal@183 619 else if (/^[\s\S]*\w+\.(&nbsp;|\u00a0)*\s*/.test(html))
bgneal@183 620 dom.remove(span);
bgneal@183 621 });
bgneal@183 622
bgneal@183 623 html = p.innerHTML;
bgneal@183 624
bgneal@183 625 // Remove middot/list items
bgneal@183 626 if (type == 'ul')
bgneal@183 627 html = p.innerHTML.replace(/__MCE_ITEM__/g, '').replace(/^[\u2022\u00b7\u00a7\u00d8o]\s*(&nbsp;|\u00a0)+\s*/, '');
bgneal@183 628 else
bgneal@183 629 html = p.innerHTML.replace(/__MCE_ITEM__/g, '').replace(/^\s*\w+\.(&nbsp;|\u00a0)+\s*/, '');
bgneal@183 630
bgneal@183 631 // Create li and add paragraph data into the new li
bgneal@183 632 li = listElm.appendChild(dom.create('li', 0, html));
bgneal@183 633 dom.remove(p);
bgneal@183 634
bgneal@183 635 lastMargin = margin;
bgneal@183 636 lastType = type;
bgneal@183 637 } else
bgneal@183 638 listElm = lastMargin = 0; // End list element
bgneal@183 639 });
bgneal@183 640
bgneal@183 641 // Remove any left over makers
bgneal@183 642 html = o.node.innerHTML;
bgneal@183 643 if (html.indexOf('__MCE_ITEM__') != -1)
bgneal@183 644 o.node.innerHTML = html.replace(/__MCE_ITEM__/g, '');
bgneal@45 645 },
bgneal@45 646
bgneal@183 647 /**
bgneal@183 648 * This method will split the current block parent and insert the contents inside the split position.
bgneal@183 649 * This logic can be improved so text nodes at the start/end remain in the start/end block elements
bgneal@183 650 */
bgneal@183 651 _insertBlockContent : function(ed, dom, content) {
bgneal@183 652 var parentBlock, marker, sel = ed.selection, last, elm, vp, y, elmHeight, markerId = 'mce_marker';
bgneal@45 653
bgneal@183 654 function select(n) {
bgneal@183 655 var r;
bgneal@45 656
bgneal@183 657 if (tinymce.isIE) {
bgneal@183 658 r = ed.getDoc().body.createTextRange();
bgneal@183 659 r.moveToElementText(n);
bgneal@183 660 r.collapse(false);
bgneal@183 661 r.select();
bgneal@183 662 } else {
bgneal@183 663 sel.select(n, 1);
bgneal@183 664 sel.collapse(false);
bgneal@45 665 }
bgneal@45 666 }
bgneal@45 667
bgneal@183 668 // Insert a marker for the caret position
bgneal@183 669 this._insert('<span id="' + markerId + '">&nbsp;</span>', 1);
bgneal@183 670 marker = dom.get(markerId);
bgneal@183 671 parentBlock = dom.getParent(marker, 'p,h1,h2,h3,h4,h5,h6,ul,ol,th,td');
bgneal@183 672
bgneal@183 673 // If it's a parent block but not a table cell
bgneal@183 674 if (parentBlock && !/TD|TH/.test(parentBlock.nodeName)) {
bgneal@183 675 // Split parent block
bgneal@183 676 marker = dom.split(parentBlock, marker);
bgneal@183 677
bgneal@183 678 // Insert nodes before the marker
bgneal@183 679 each(dom.create('div', 0, content).childNodes, function(n) {
bgneal@183 680 last = marker.parentNode.insertBefore(n.cloneNode(true), marker);
bgneal@183 681 });
bgneal@183 682
bgneal@183 683 // Move caret after marker
bgneal@183 684 select(last);
bgneal@183 685 } else {
bgneal@183 686 dom.setOuterHTML(marker, content);
bgneal@183 687 sel.select(ed.getBody(), 1);
bgneal@183 688 sel.collapse(0);
bgneal@183 689 }
bgneal@183 690
bgneal@183 691 // Remove marker if it's left
bgneal@183 692 while (elm = dom.get(markerId))
bgneal@183 693 dom.remove(elm);
bgneal@183 694
bgneal@183 695 // Get element, position and height
bgneal@183 696 elm = sel.getStart();
bgneal@183 697 vp = dom.getViewPort(ed.getWin());
bgneal@183 698 y = ed.dom.getPos(elm).y;
bgneal@183 699 elmHeight = elm.clientHeight;
bgneal@183 700
bgneal@183 701 // Is element within viewport if not then scroll it into view
bgneal@183 702 if (y < vp.y || y + elmHeight > vp.y + vp.h)
bgneal@183 703 ed.getDoc().body.scrollTop = y < vp.y ? y : y - vp.h + 25;
bgneal@45 704 },
bgneal@45 705
bgneal@183 706 /**
bgneal@183 707 * Inserts the specified contents at the caret position.
bgneal@183 708 */
bgneal@183 709 _insert : function(h, skip_undo) {
bgneal@183 710 var ed = this.editor;
bgneal@45 711
bgneal@183 712 // First delete the contents seems to work better on WebKit
bgneal@183 713 if (!ed.selection.isCollapsed())
bgneal@183 714 ed.getDoc().execCommand('Delete', false, null);
bgneal@45 715
bgneal@183 716 // It's better to use the insertHTML method on Gecko since it will combine paragraphs correctly before inserting the contents
bgneal@183 717 ed.execCommand(tinymce.isGecko ? 'insertHTML' : 'mceInsertContent', false, h, {skip_undo : skip_undo});
bgneal@183 718 },
bgneal@183 719
bgneal@183 720 /**
bgneal@183 721 * Instead of the old plain text method which tried to re-create a paste operation, the
bgneal@183 722 * new approach adds a plain text mode toggle switch that changes the behavior of paste.
bgneal@183 723 * This function is passed the same input that the regular paste plugin produces.
bgneal@183 724 * It performs additional scrubbing and produces (and inserts) the plain text.
bgneal@183 725 * This approach leverages all of the great existing functionality in the paste
bgneal@183 726 * plugin, and requires minimal changes to add the new functionality.
bgneal@183 727 * Speednet - June 2009
bgneal@183 728 */
bgneal@183 729 _insertPlainText : function(ed, dom, h) {
bgneal@183 730 var i, len, pos, rpos, node, breakElms, before, after,
bgneal@183 731 w = ed.getWin(),
bgneal@183 732 d = ed.getDoc(),
bgneal@183 733 sel = ed.selection,
bgneal@183 734 is = tinymce.is,
bgneal@183 735 inArray = tinymce.inArray,
bgneal@183 736 linebr = getParam(ed, "paste_text_linebreaktype"),
bgneal@183 737 rl = getParam(ed, "paste_text_replacements");
bgneal@183 738
bgneal@183 739 function process(items) {
bgneal@183 740 each(items, function(v) {
bgneal@183 741 if (v.constructor == RegExp)
bgneal@183 742 h = h.replace(v, "");
bgneal@183 743 else
bgneal@183 744 h = h.replace(v[0], v[1]);
bgneal@183 745 });
bgneal@183 746 };
bgneal@183 747
bgneal@183 748 if ((typeof(h) === "string") && (h.length > 0)) {
bgneal@183 749 if (!entities)
bgneal@183 750 entities = ("34,quot,38,amp,39,apos,60,lt,62,gt," + ed.serializer.settings.entities).split(",");
bgneal@183 751
bgneal@183 752 // If HTML content with line-breaking tags, then remove all cr/lf chars because only tags will break a line
bgneal@183 753 if (/<(?:p|br|h[1-6]|ul|ol|dl|table|t[rdh]|div|blockquote|fieldset|pre|address|center)[^>]*>/i.test(h)) {
bgneal@183 754 process([
bgneal@183 755 /[\n\r]+/g
bgneal@183 756 ]);
bgneal@183 757 } else {
bgneal@183 758 // Otherwise just get rid of carriage returns (only need linefeeds)
bgneal@183 759 process([
bgneal@183 760 /\r+/g
bgneal@183 761 ]);
bgneal@45 762 }
bgneal@45 763
bgneal@183 764 process([
bgneal@183 765 [/<\/(?:p|h[1-6]|ul|ol|dl|table|div|blockquote|fieldset|pre|address|center)>/gi, "\n\n"], // Block tags get a blank line after them
bgneal@183 766 [/<br[^>]*>|<\/tr>/gi, "\n"], // Single linebreak for <br /> tags and table rows
bgneal@183 767 [/<\/t[dh]>\s*<t[dh][^>]*>/gi, "\t"], // Table cells get tabs betweem them
bgneal@183 768 /<[a-z!\/?][^>]*>/gi, // Delete all remaining tags
bgneal@183 769 [/&nbsp;/gi, " "], // Convert non-break spaces to regular spaces (remember, *plain text*)
bgneal@183 770 [
bgneal@183 771 // HTML entity
bgneal@183 772 /&(#\d+|[a-z0-9]{1,10});/gi,
bgneal@183 773
bgneal@183 774 // Replace with actual character
bgneal@183 775 function(e, s) {
bgneal@183 776 if (s.charAt(0) === "#") {
bgneal@183 777 return String.fromCharCode(s.slice(1));
bgneal@183 778 }
bgneal@183 779 else {
bgneal@183 780 return ((e = inArray(entities, s)) > 0)? String.fromCharCode(entities[e-1]) : " ";
bgneal@183 781 }
bgneal@183 782 }
bgneal@183 783 ],
bgneal@183 784 [/(?:(?!\n)\s)*(\n+)(?:(?!\n)\s)*/gi, "$1"], // Cool little RegExp deletes whitespace around linebreak chars.
bgneal@183 785 [/\n{3,}/g, "\n\n"], // Max. 2 consecutive linebreaks
bgneal@183 786 /^\s+|\s+$/g // Trim the front & back
bgneal@183 787 ]);
bgneal@183 788
bgneal@183 789 h = dom.encode(h);
bgneal@183 790
bgneal@183 791 // Delete any highlighted text before pasting
bgneal@183 792 if (!sel.isCollapsed()) {
bgneal@183 793 d.execCommand("Delete", false, null);
bgneal@183 794 }
bgneal@183 795
bgneal@183 796 // Perform default or custom replacements
bgneal@183 797 if (is(rl, "array") || (is(rl, "array"))) {
bgneal@183 798 process(rl);
bgneal@183 799 }
bgneal@183 800 else if (is(rl, "string")) {
bgneal@183 801 process(new RegExp(rl, "gi"));
bgneal@183 802 }
bgneal@183 803
bgneal@183 804 // Treat paragraphs as specified in the config
bgneal@183 805 if (linebr == "none") {
bgneal@183 806 process([
bgneal@183 807 [/\n+/g, " "]
bgneal@183 808 ]);
bgneal@183 809 }
bgneal@183 810 else if (linebr == "br") {
bgneal@183 811 process([
bgneal@183 812 [/\n/g, "<br />"]
bgneal@183 813 ]);
bgneal@183 814 }
bgneal@183 815 else {
bgneal@183 816 process([
bgneal@183 817 /^\s+|\s+$/g,
bgneal@183 818 [/\n\n/g, "</p><p>"],
bgneal@183 819 [/\n/g, "<br />"]
bgneal@183 820 ]);
bgneal@183 821 }
bgneal@183 822
bgneal@183 823 // This next piece of code handles the situation where we're pasting more than one paragraph of plain
bgneal@183 824 // text, and we are pasting the content into the middle of a block node in the editor. The block
bgneal@183 825 // node gets split at the selection point into "Para A" and "Para B" (for the purposes of explaining).
bgneal@183 826 // The first paragraph of the pasted text is appended to "Para A", and the last paragraph of the
bgneal@183 827 // pasted text is prepended to "Para B". Any other paragraphs of pasted text are placed between
bgneal@183 828 // "Para A" and "Para B". This code solves a host of problems with the original plain text plugin and
bgneal@183 829 // now handles styles correctly. (Pasting plain text into a styled paragraph is supposed to make the
bgneal@183 830 // plain text take the same style as the existing paragraph.)
bgneal@183 831 if ((pos = h.indexOf("</p><p>")) != -1) {
bgneal@183 832 rpos = h.lastIndexOf("</p><p>");
bgneal@183 833 node = sel.getNode();
bgneal@183 834 breakElms = []; // Get list of elements to break
bgneal@183 835
bgneal@183 836 do {
bgneal@183 837 if (node.nodeType == 1) {
bgneal@183 838 // Don't break tables and break at body
bgneal@183 839 if (node.nodeName == "TD" || node.nodeName == "BODY") {
bgneal@183 840 break;
bgneal@183 841 }
bgneal@183 842
bgneal@183 843 breakElms[breakElms.length] = node;
bgneal@183 844 }
bgneal@183 845 } while (node = node.parentNode);
bgneal@183 846
bgneal@183 847 // Are we in the middle of a block node?
bgneal@183 848 if (breakElms.length > 0) {
bgneal@183 849 before = h.substring(0, pos);
bgneal@183 850 after = "";
bgneal@183 851
bgneal@183 852 for (i=0, len=breakElms.length; i<len; i++) {
bgneal@183 853 before += "</" + breakElms[i].nodeName.toLowerCase() + ">";
bgneal@183 854 after += "<" + breakElms[breakElms.length-i-1].nodeName.toLowerCase() + ">";
bgneal@183 855 }
bgneal@183 856
bgneal@183 857 if (pos == rpos) {
bgneal@183 858 h = before + after + h.substring(pos+7);
bgneal@183 859 }
bgneal@183 860 else {
bgneal@183 861 h = before + h.substring(pos+4, rpos+4) + after + h.substring(rpos+7);
bgneal@183 862 }
bgneal@183 863 }
bgneal@183 864 }
bgneal@183 865
bgneal@183 866 // Insert content at the caret, plus add a marker for repositioning the caret
bgneal@183 867 ed.execCommand("mceInsertRawHTML", false, h + '<span id="_plain_text_marker">&nbsp;</span>');
bgneal@183 868
bgneal@183 869 // Reposition the caret to the marker, which was placed immediately after the inserted content.
bgneal@183 870 // Needs to be done asynchronously (in window.setTimeout) or else it doesn't work in all browsers.
bgneal@183 871 // The second part of the code scrolls the content up if the caret is positioned off-screen.
bgneal@183 872 // This is only necessary for WebKit browsers, but it doesn't hurt to use for all.
bgneal@183 873 window.setTimeout(function() {
bgneal@183 874 var marker = dom.get('_plain_text_marker'),
bgneal@183 875 elm, vp, y, elmHeight;
bgneal@183 876
bgneal@183 877 sel.select(marker, false);
bgneal@183 878 d.execCommand("Delete", false, null);
bgneal@183 879 marker = null;
bgneal@183 880
bgneal@183 881 // Get element, position and height
bgneal@183 882 elm = sel.getStart();
bgneal@183 883 vp = dom.getViewPort(w);
bgneal@183 884 y = dom.getPos(elm).y;
bgneal@183 885 elmHeight = elm.clientHeight;
bgneal@183 886
bgneal@183 887 // Is element within viewport if not then scroll it into view
bgneal@183 888 if ((y < vp.y) || (y + elmHeight > vp.y + vp.h)) {
bgneal@183 889 d.body.scrollTop = y < vp.y ? y : y - vp.h + 25;
bgneal@183 890 }
bgneal@183 891 }, 0);
bgneal@183 892 }
bgneal@183 893 },
bgneal@183 894
bgneal@183 895 /**
bgneal@183 896 * This method will open the old style paste dialogs. Some users might want the old behavior but still use the new cleanup engine.
bgneal@183 897 */
bgneal@183 898 _legacySupport : function() {
bgneal@183 899 var t = this, ed = t.editor;
bgneal@183 900
bgneal@183 901 // Register command(s) for backwards compatibility
bgneal@183 902 ed.addCommand("mcePasteWord", function() {
bgneal@183 903 ed.windowManager.open({
bgneal@183 904 file: t.url + "/pasteword.htm",
bgneal@183 905 width: parseInt(getParam(ed, "paste_dialog_width")),
bgneal@183 906 height: parseInt(getParam(ed, "paste_dialog_height")),
bgneal@183 907 inline: 1
bgneal@183 908 });
bgneal@183 909 });
bgneal@183 910
bgneal@183 911 if (getParam(ed, "paste_text_use_dialog")) {
bgneal@183 912 ed.addCommand("mcePasteText", function() {
bgneal@183 913 ed.windowManager.open({
bgneal@183 914 file : t.url + "/pastetext.htm",
bgneal@183 915 width: parseInt(getParam(ed, "paste_dialog_width")),
bgneal@183 916 height: parseInt(getParam(ed, "paste_dialog_height")),
bgneal@183 917 inline : 1
bgneal@183 918 });
bgneal@183 919 });
bgneal@45 920 }
bgneal@45 921
bgneal@183 922 // Register button for backwards compatibility
bgneal@183 923 ed.addButton("pasteword", {title : "paste.paste_word_desc", cmd : "mcePasteWord"});
bgneal@45 924 }
bgneal@45 925 });
bgneal@45 926
bgneal@45 927 // Register plugin
bgneal@183 928 tinymce.PluginManager.add("paste", tinymce.plugins.PastePlugin);
bgneal@183 929 })();