From deb30262a766df2886e2bad2a5612a1040b6b05d Mon Sep 17 00:00:00 2001 From: svncommit <devs@roundcube.net> Date: Mon, 10 Dec 2007 11:33:50 -0500 Subject: [PATCH] upgrade TinyMCE version to latest --- program/js/tiny_mce/tiny_mce_src.js | 122 ++++++++++++++++++++++++++-------------- 1 files changed, 79 insertions(+), 43 deletions(-) diff --git a/program/js/tiny_mce/tiny_mce_src.js b/program/js/tiny_mce/tiny_mce_src.js index ba713a8..954ca1a 100644 --- a/program/js/tiny_mce/tiny_mce_src.js +++ b/program/js/tiny_mce/tiny_mce_src.js @@ -5,8 +5,8 @@ var ua; this.majorVersion = "2"; - this.minorVersion = "1.1.1"; - this.releaseDate = "2007-05-14"; + this.minorVersion = "1.3"; + this.releaseDate = "2007-11-27"; this.instances = []; this.switchClassCache = []; @@ -205,6 +205,7 @@ this._def("hide_selects_on_submit", true); this._def("forced_root_block", false); this._def("remove_trailing_nbsp", false); + this._def("save_on_tinymce_forms", false); // Force strict loading mode to false on non Gecko browsers if (this.isMSIE && !this.isOpera) @@ -586,7 +587,7 @@ }, removeMCEControl : function(editor_id) { - var inst = tinyMCE.getInstanceById(editor_id), h, re, ot, tn; + var inst = tinyMCE.getInstanceById(editor_id), h, re, ot, tn, n; if (inst) { inst.switchSettings(); @@ -598,6 +599,18 @@ tinyMCE.selectedElement = null; tinyMCE.selectedInstance = null; + + tinyMCE.selectedElement = null; + tinyMCE.selectedInstance = null; + + // Try finding an instance + for (n in tinyMCE.instances) { + if (!tinyMCE.isInstance(tinyMCE.instances[n])) + continue; + + tinyMCE.selectedInstance = tinyMCE.instances[n]; + break; + } // Remove element re = document.getElementById(editor_id + "_parent"); @@ -1069,8 +1082,8 @@ // s = s.replace(new RegExp('mce_href\\s*=\\s*\"[^ >\"]*\"', 'gi'), ''); if (!s.match(/(mce_src|mce_href)/gi, s)) { - s = s.replace(new RegExp('src\\s*=\\s*\"([^ >\"]*)\"', 'gi'), 'src="$1" mce_src="$1"'); - s = s.replace(new RegExp('href\\s*=\\s*\"([^ >\"]*)\"', 'gi'), 'href="$1" mce_href="$1"'); + s = s.replace(new RegExp('src\\s*=\\s*[\"\']([^ >\"]*)[\"\']', 'gi'), 'src="$1" mce_src="$1"'); + s = s.replace(new RegExp('href\\s*=\\s*[\"\']([^ >\"]*)[\"\']', 'gi'), 'href="$1" mce_href="$1"'); } return s; @@ -1145,18 +1158,14 @@ // Workaround for drag drop/copy paste base href bug case "drop": case "beforepaste": - if (tinyMCE.selectedInstance) +/* if (tinyMCE.selectedInstance) tinyMCE.selectedInstance.setBaseHREF(null); // Fixes odd MSIE bug where drag/droping elements in a iframe with height 100% breaks // This logic forces the width/height to be in pixels while the user is drag/dropping + // NOTE: This has been disabled for now since it messes up copy/paste that is far more important than image drag if (tinyMCE.isRealIE) { var ife = tinyMCE.selectedInstance.iframeElement; - - /*if (ife.style.width.indexOf('%') != -1) { - ife._oldWidth = ife.width.height; - ife.style.width = ife.clientWidth; - }*/ if (ife.style.height.indexOf('%') != -1) { ife._oldHeight = ife.style.height; @@ -1165,6 +1174,7 @@ } window.setTimeout("tinyMCE.selectedInstance.setBaseHREF(tinyMCE.settings.base_href);tinyMCE._resetIframeHeight();", 1); + */ return; case "submit": @@ -1523,19 +1533,22 @@ f = f.form; // Is it a form that has a TinyMCE instance - for (n in tinyMCE.instances) { - inst = tinyMCE.instances[n]; + if (tinyMCE.getParam('save_on_tinymce_forms')) { + for (n in tinyMCE.instances) { + inst = tinyMCE.instances[n]; - if (!tinyMCE.isInstance(inst)) - continue; + if (!tinyMCE.isInstance(inst)) + continue; - if (inst.formElement) { - if (f == inst.formElement.form) { - found = true; - inst.isNotDirty = true; + if (inst.formElement) { + if (f == inst.formElement.form) { + found = true; + inst.isNotDirty = true; + } } } - } + } else + found = true; // Is valid if (found) { @@ -1761,7 +1774,7 @@ }, triggerNodeChange : function(focus, setup_content) { - var elm, inst, editorId, undoIndex = -1, undoLevels = -1, doc, anySelection = false, st; + var elm, inst, editorId, undoIndex = -1, undoLevels = -1, doc, anySelection, st; if (tinyMCE.selectedInstance) { inst = tinyMCE.selectedInstance; @@ -1782,9 +1795,7 @@ elm = inst.getBody(); inst.switchSettings(); - - if (tinyMCE.selectedElement) - anySelection = (tinyMCE.selectedElement.nodeName.toLowerCase() == "img") || (st && st.length > 0); + anySelection = !inst.selection.isCollapsed(); if (tinyMCE.settings.custom_undo_redo) { undoIndex = inst.undoRedo.undoIndex; @@ -1956,7 +1967,7 @@ } // Make it bigger if statusbar is forced - if (tinyMCE.isGecko) { + if (tinyMCE.isGecko && win.document) { if (win.document.defaultView.statusbar.visible) win.resizeBy(0, tinyMCE.isMac ? 10 : 24); } @@ -2420,8 +2431,10 @@ add : function(c, m) { var n; - for (n in m) - c.prototype[n] = m[n]; + for (n in m) { + if (m.hasOwnProperty(n)) + c.prototype[n] = m[n]; + } }, extend : function(p, np) { @@ -2429,11 +2442,15 @@ o.parent = p; - for (n in p) - o[n] = p[n]; + for (n in p) { + if (p.hasOwnProperty(n)) + o[n] = p[n]; + } - for (n in np) - o[n] = np[n]; + for (n in np) { + if (np.hasOwnProperty(n)) + o[n] = np[n]; + } return o; }, @@ -2786,7 +2803,7 @@ nx = ne.nextSibling; // If text node or inline element wrap it in a block element - if (ne.nodeType == 3 || !tinyMCE.blockRegExp.test(ne.nodeName)) { + if ((ne.nodeType == 3 && ne.nodeValue.replace(/\s+/g, '') != '') || (ne.nodeType == 1 && !tinyMCE.blockRegExp.test(ne.nodeName))) { if (!bm) bm = this.selection.getBookmark(); @@ -2863,9 +2880,10 @@ switch (command) { case "JustifyLeft": - if (align == 'left') + if (align == 'left') { + img.setAttribute('align', ''); // Needed for IE img.removeAttribute('align'); - else + } else img.setAttribute('align', 'left'); // Remove the div @@ -2879,6 +2897,7 @@ return; case "JustifyCenter": + img.setAttribute('align', ''); // Needed for IE img.removeAttribute('align'); // Is centered @@ -2901,9 +2920,10 @@ return; case "JustifyRight": - if (align == 'right') + if (align == 'right') { + img.setAttribute('align', ''); // Needed for IE img.removeAttribute('align'); - else + } else img.setAttribute('align', 'right'); // Remove the div @@ -2957,6 +2977,22 @@ switch (command) { case "mceRepaint": this.repaint(); + return true; + + case "JustifyLeft": + case "JustifyCenter": + case "JustifyFull": + case "JustifyRight": + var el = tinyMCE.getParentNode(focusElm, function(n) {return tinyMCE.getAttrib(n, 'align');}); + + if (el) { + el.setAttribute('align', ''); // Needed for IE + el.removeAttribute('align'); + } else + this.getDoc().execCommand(command, user_interface, value); + + tinyMCE.triggerNodeChange(); + return true; case "unlink": @@ -3282,7 +3318,7 @@ value = value.charAt(0) != '#' ? (isNaN('0x' + value) ? value : '#' + value) : value; this.backColor = value; - if (tinyMCE.isGecko) { + if (tinyMCE.isGecko || tinyMCE.isOpera) { this._setUseCSS(true); this.getDoc().execCommand('hilitecolor', false, value); this._setUseCSS(false); @@ -4107,10 +4143,8 @@ if (box[i] == null) return; - for (a=0; a<box.length; a++) { - if (box[a] != box[i]) - return; - } + if (i && box[i] != box[i-1]) + return; } // They are all the same @@ -4387,7 +4421,7 @@ c.settings.on_save = on_save; c.idCount = 0; - c.serializationId = new Date().getTime().toString(32); // Unique ID needed for the content duplication bug + c.serializationId++; // Unique ID needed for the content duplication bug c.serializedNodes = []; c.sourceIndex = -1; @@ -4519,6 +4553,7 @@ this.nlAfterRe = this._arrayToRe(s.newline_after_elements.split(','), 'gi', '<(', ')([^>]*)>'); this.nlBeforeAfterRe = this._arrayToRe(s.newline_before_after_elements.split(','), 'gi', '<(\\/?)(', ')([^>]*)>'); this.serializedNodes = []; + this.serializationId = 0; if (s.invalid_elements !== '') this.iveRe = this._arrayToRe(s.invalid_elements.toUpperCase().split(','), 'g', '^(', ')$'); @@ -6298,7 +6333,7 @@ e = document.createElement("body"); if (r.cloneContents) - e.appendChild(r.cloneContents()); + e.appendChild(document.importNode(r.cloneContents(), true)); else if (typeof(r.item) != 'undefined' || typeof(r.htmlText) != 'undefined') e.innerHTML = r.item ? r.item(0).outerHTML : r.htmlText; else @@ -6971,6 +7006,7 @@ endNode = direct ? sel.focusNode : sel.anchorNode; endOffset = direct ? sel.focusOffset : sel.anchorOffset; + startNode = startNode.nodeName == "HTML" ? doc.body : startNode; // Fix for Opera bug: https://bugs.opera.com/show_bug.cgi?id=273224&comments=yes startNode = startNode.nodeName == "BODY" ? startNode.firstChild : startNode; endNode = endNode.nodeName == "BODY" ? endNode.firstChild : endNode; -- Gitblit v1.9.1