summaryrefslogtreecommitdiff
path: root/public/javascripts/tiny_mce/tiny_mce_src.js
diff options
context:
space:
mode:
Diffstat (limited to 'public/javascripts/tiny_mce/tiny_mce_src.js')
-rw-r--r--public/javascripts/tiny_mce/tiny_mce_src.js220
1 files changed, 158 insertions, 62 deletions
diff --git a/public/javascripts/tiny_mce/tiny_mce_src.js b/public/javascripts/tiny_mce/tiny_mce_src.js
index aa402d5..3fe768b 100644
--- a/public/javascripts/tiny_mce/tiny_mce_src.js
+++ b/public/javascripts/tiny_mce/tiny_mce_src.js
@@ -1,7 +1,7 @@
1var tinymce = { 1var tinymce = {
2 majorVersion : '3', 2 majorVersion : '3',
3 minorVersion : '2.6', 3 minorVersion : '2.7',
4 releaseDate : '2009-08-19', 4 releaseDate : '2009-09-22',
5 5
6 _init : function() { 6 _init : function() {
7 var t = this, d = document, w = window, na = navigator, ua = na.userAgent, i, nl, n, base, p, v; 7 var t = this, d = document, w = window, na = navigator, ua = na.userAgent, i, nl, n, base, p, v;
@@ -766,7 +766,7 @@ tinymce.create('tinymce.util.Dispatcher', {
766 toAbsolute : function(u, nh) { 766 toAbsolute : function(u, nh) {
767 var u = new tinymce.util.URI(u, {base_uri : this}); 767 var u = new tinymce.util.URI(u, {base_uri : this});
768 768
769 return u.getURI(this.host == u.host ? nh : 0); 769 return u.getURI(this.host == u.host && this.protocol == u.protocol ? nh : 0);
770 }, 770 },
771 771
772 toRelPath : function(base, path) { 772 toRelPath : function(base, path) {
@@ -812,7 +812,7 @@ tinymce.create('tinymce.util.Dispatcher', {
812 }, 812 },
813 813
814 toAbsPath : function(base, path) { 814 toAbsPath : function(base, path) {
815 var i, nb = 0, o = [], tr; 815 var i, nb = 0, o = [], tr, outPath;
816 816
817 // Split paths 817 // Split paths
818 tr = /\/$/.test(path) ? '/' : ''; 818 tr = /\/$/.test(path) ? '/' : '';
@@ -852,9 +852,19 @@ tinymce.create('tinymce.util.Dispatcher', {
852 852
853 // If /a/b/c or / 853 // If /a/b/c or /
854 if (i <= 0) 854 if (i <= 0)
855 return '/' + o.reverse().join('/') + tr; 855 outPath = o.reverse().join('/');
856 else
857 outPath = base.slice(0, i).join('/') + '/' + o.reverse().join('/');
858
859 // Add front / if it's needed
860 if (outPath.indexOf('/') !== 0)
861 outPath = '/' + outPath;
862
863 // Add traling / if it's needed
864 if (tr && outPath.lastIndexOf('/') !== outPath.length - 1)
865 outPath += tr;
856 866
857 return '/' + base.slice(0, i).join('/') + '/' + o.reverse().join('/') + tr; 867 return outPath;
858 }, 868 },
859 869
860 getURI : function(nh) { 870 getURI : function(nh) {
@@ -1576,6 +1586,18 @@ tinymce.create('static tinymce.util.XHR', {
1576 if (!v) 1586 if (!v)
1577 v = e.getAttribute(n, 2); 1587 v = e.getAttribute(n, 2);
1578 1588
1589 // Check boolean attribs
1590 if (/^(checked|compact|declare|defer|disabled|ismap|multiple|nohref|noshade|nowrap|readonly|selected)$/.test(n)) {
1591 if (e[t.props[n]] === true && v === '')
1592 return n;
1593
1594 return v ? n : '';
1595 }
1596
1597 // Inner input elements will override attributes on form elements
1598 if (e.nodeName === "FORM" && e.getAttributeNode(n))
1599 return e.getAttributeNode(n).nodeValue;
1600
1579 if (n === 'style') { 1601 if (n === 'style') {
1580 v = v || e.style.cssText; 1602 v = v || e.style.cssText;
1581 1603
@@ -1973,7 +1995,7 @@ tinymce.create('static tinymce.util.XHR', {
1973 if (x) { 1995 if (x) {
1974 // So if we replace the p elements with divs and mark them and then replace them back to paragraphs 1996 // So if we replace the p elements with divs and mark them and then replace them back to paragraphs
1975 // after we use innerHTML we can fix the DOM tree 1997 // after we use innerHTML we can fix the DOM tree
1976 h = h.replace(/<p ([^>]+)>|<p>/g, '<div $1 mce_tmp="1">'); 1998 h = h.replace(/<p ([^>]+)>|<p>/ig, '<div $1 mce_tmp="1">');
1977 h = h.replace(/<\/p>/g, '</div>'); 1999 h = h.replace(/<\/p>/g, '</div>');
1978 2000
1979 // Set the new HTML with DIVs 2001 // Set the new HTML with DIVs
@@ -2024,7 +2046,7 @@ tinymce.create('static tinymce.util.XHR', {
2024 }, 2046 },
2025 2047
2026 processHTML : function(h) { 2048 processHTML : function(h) {
2027 var t = this, s = t.settings; 2049 var t = this, s = t.settings, codeBlocks = [];
2028 2050
2029 if (!s.process_html) 2051 if (!s.process_html)
2030 return h; 2052 return h;
@@ -2070,8 +2092,10 @@ tinymce.create('static tinymce.util.XHR', {
2070 }); 2092 });
2071 2093
2072 // Wrap text contents 2094 // Wrap text contents
2073 if (tinymce.trim(text)) 2095 if (tinymce.trim(text)) {
2074 text = '<!--\n' + trim(text) + '\n// -->'; 2096 codeBlocks.push(trim(text));
2097 text = '<!--\nMCE_SCRIPT:' + (codeBlocks.length - 1) + '\n// -->';
2098 }
2075 2099
2076 return '<mce:script' + attribs + '>' + text + '</mce:script>'; 2100 return '<mce:script' + attribs + '>' + text + '</mce:script>';
2077 }); 2101 });
@@ -2079,8 +2103,10 @@ tinymce.create('static tinymce.util.XHR', {
2079 // Wrap style elements 2103 // Wrap style elements
2080 h = h.replace(/<style([^>]+|)>([\s\S]*?)<\/style>/gi, function(v, attribs, text) { 2104 h = h.replace(/<style([^>]+|)>([\s\S]*?)<\/style>/gi, function(v, attribs, text) {
2081 // Wrap text contents 2105 // Wrap text contents
2082 if (text) 2106 if (text) {
2083 text = '<!--\n' + trim(text) + '\n-->'; 2107 codeBlocks.push(trim(text));
2108 text = '<!--\nMCE_SCRIPT:' + (codeBlocks.length - 1) + '\n-->';
2109 }
2084 2110
2085 return '<mce:style' + attribs + '>' + text + '</mce:style><style ' + attribs + ' mce_bogus="1">' + text + '</style>'; 2111 return '<mce:style' + attribs + '>' + text + '</mce:style><style ' + attribs + ' mce_bogus="1">' + text + '</style>';
2086 }); 2112 });
@@ -2093,6 +2119,24 @@ tinymce.create('static tinymce.util.XHR', {
2093 2119
2094 h = h.replace(/<!\[CDATA\[([\s\S]+)\]\]>/g, '<!--[CDATA[$1]]-->'); 2120 h = h.replace(/<!\[CDATA\[([\s\S]+)\]\]>/g, '<!--[CDATA[$1]]-->');
2095 2121
2122 // Remove false bool attributes and force attributes into xhtml style attr="attr"
2123 h = h.replace(/<([\w:]+) [^>]*(checked|compact|declare|defer|disabled|ismap|multiple|nohref|noshade|nowrap|readonly|selected)[^>]*>/gi, function(val) {
2124 function handle(val, name, value) {
2125 // Remove false/0 attribs
2126 if (value === 'false' || value === '0')
2127 return '';
2128
2129 return ' ' + name + '="' + name + '"';
2130 };
2131
2132 val = val.replace(/ (checked|compact|declare|defer|disabled|ismap|multiple|nohref|noshade|nowrap|readonly|selected)=[\"]([^\"]+)[\"]/gi, handle); // W3C
2133 val = val.replace(/ (checked|compact|declare|defer|disabled|ismap|multiple|nohref|noshade|nowrap|readonly|selected)=[\']([^\']+)[\']/gi, handle); // W3C
2134 val = val.replace(/ (checked|compact|declare|defer|disabled|ismap|multiple|nohref|noshade|nowrap|readonly|selected)=([^\s\"\'>]+)/gi, handle); // IE
2135 val = val.replace(/ (checked|compact|declare|defer|disabled|ismap|multiple|nohref|noshade|nowrap|readonly|selected)([\s>])/gi, ' $1="$1"$2'); // Force attr="attr"
2136
2137 return val;
2138 });
2139
2096 // Process all tags with src, href or style 2140 // Process all tags with src, href or style
2097 h = h.replace(/<([\w:]+) [^>]*(src|href|style|shape|coords)[^>]*>/gi, function(a, n) { 2141 h = h.replace(/<([\w:]+) [^>]*(src|href|style|shape|coords)[^>]*>/gi, function(a, n) {
2098 function handle(m, b, c) { 2142 function handle(m, b, c) {
@@ -2107,17 +2151,8 @@ tinymce.create('static tinymce.util.XHR', {
2107 if (t._isRes(c)) 2151 if (t._isRes(c))
2108 return m; 2152 return m;
2109 2153
2110 if (s.hex_colors) { 2154 // Parse and serialize the style to convert for example uppercase styles like "BORDER: 1px"
2111 u = u.replace(/rgb\([^\)]+\)/g, function(v) { 2155 u = t.encode(t.serializeStyle(t.parseStyle(u)));
2112 return t.toHex(v);
2113 });
2114 }
2115
2116 if (s.url_converter) {
2117 u = u.replace(/url\([\'\"]?([^\)\'\"]+)\)/g, function(x, c) {
2118 return 'url(' + t.encode(s.url_converter.call(s.url_converter_scope || t, t.decode(c), b, n)) + ')';
2119 });
2120 }
2121 } else if (b != 'coords' && b != 'shape') { 2156 } else if (b != 'coords' && b != 'shape') {
2122 if (s.url_converter) 2157 if (s.url_converter)
2123 u = t.encode(s.url_converter.call(s.url_converter_scope || t, t.decode(c), b, n)); 2158 u = t.encode(s.url_converter.call(s.url_converter_scope || t, t.decode(c), b, n));
@@ -2131,6 +2166,11 @@ tinymce.create('static tinymce.util.XHR', {
2131 2166
2132 return a.replace(/ (src|href|style|coords|shape)=([^\s\"\'>]+)/gi, handle); // IE 2167 return a.replace(/ (src|href|style|coords|shape)=([^\s\"\'>]+)/gi, handle); // IE
2133 }); 2168 });
2169
2170 // Restore script blocks
2171 h = h.replace(/MCE_SCRIPT:([0-9]+)/g, function(val, idx) {
2172 return codeBlocks[idx];
2173 });
2134 } 2174 }
2135 2175
2136 return h; 2176 return h;
@@ -2264,7 +2304,7 @@ tinymce.create('static tinymce.util.XHR', {
2264 2304
2265 n = n.nodeName || n; 2305 n = n.nodeName || n;
2266 2306
2267 return /^(H[1-6]|HR|P|DIV|ADDRESS|PRE|FORM|TABLE|LI|OL|UL|TR|TD|CAPTION|BLOCKQUOTE|CENTER|DL|DT|DD|DIR|FIELDSET|NOSCRIPT|NOFRAMES|MENU|ISINDEX|SAMP)$/.test(n); 2307 return /^(H[1-6]|HR|P|DIV|ADDRESS|PRE|FORM|TABLE|LI|OL|UL|TH|TBODY|TR|TD|CAPTION|BLOCKQUOTE|CENTER|DL|DT|DD|DIR|FIELDSET|NOSCRIPT|NOFRAMES|MENU|ISINDEX|SAMP)$/.test(n);
2268 }, 2308 },
2269 2309
2270 replace : function(n, o, k) { 2310 replace : function(n, o, k) {
@@ -2435,9 +2475,13 @@ tinymce.create('static tinymce.util.XHR', {
2435 if (n.nodeName == 'OBJECT') 2475 if (n.nodeName == 'OBJECT')
2436 return n.attributes; 2476 return n.attributes;
2437 2477
2478 // IE doesn't keep the selected attribute if you clone option elements
2479 if (n.nodeName === 'OPTION' && this.getAttrib(n, 'selected'))
2480 o.push({specified : 1, nodeName : 'selected'});
2481
2438 // It's crazy that this is faster in IE but it's because it returns all attributes all the time 2482 // It's crazy that this is faster in IE but it's because it returns all attributes all the time
2439 n.cloneNode(false).outerHTML.replace(/([a-z0-9\:\-_]+)=/gi, function(a, b) { 2483 n.cloneNode(false).outerHTML.replace(/<\/?[\w:]+ ?|=[\"][^\"]+\"|=\'[^\']+\'|=\w+|>/gi, '').replace(/[\w:]+/gi, function(a) {
2440 o.push({specified : 1, nodeName : b}); 2484 o.push({specified : 1, nodeName : a});
2441 }); 2485 });
2442 2486
2443 return o; 2487 return o;
@@ -2491,16 +2535,29 @@ tinymce.create('static tinymce.util.XHR', {
2491 return n.replace(/[ \t\r\n]+|&nbsp;|&#160;/g, '') == ''; 2535 return n.replace(/[ \t\r\n]+|&nbsp;|&#160;/g, '') == '';
2492 }; 2536 };
2493 2537
2538 // Added until Gecko can create real HTML documents using implementation.createHTMLDocument
2539 // this is to future proof it if Gecko decides to implement the error checking for range methods.
2540 function nodeIndex(n) {
2541 var i = 0;
2542
2543 while (n.previousSibling) {
2544 i++;
2545 n = n.previousSibling;
2546 }
2547
2548 return i;
2549 };
2550
2494 if (pe && e) { 2551 if (pe && e) {
2495 // Get before chunk 2552 // Get before chunk
2496 r.setStartBefore(pe); 2553 r.setStart(pe.parentNode, nodeIndex(pe));
2497 r.setEndBefore(e); 2554 r.setEnd(e.parentNode, nodeIndex(e));
2498 bef = r.extractContents(); 2555 bef = r.extractContents();
2499 2556
2500 // Get after chunk 2557 // Get after chunk
2501 r = t.createRng(); 2558 r = t.createRng();
2502 r.setStartAfter(e); 2559 r.setStart(e.parentNode, nodeIndex(e) + 1);
2503 r.setEndAfter(pe); 2560 r.setEnd(pe.parentNode, nodeIndex(pe) + 1);
2504 aft = r.extractContents(); 2561 aft = r.extractContents();
2505 2562
2506 // Insert chunks and remove parent 2563 // Insert chunks and remove parent
@@ -3513,6 +3570,7 @@ tinymce.create('static tinymce.util.XHR', {
3513 if (sc == ec && sc.nodeType == 3) { 3570 if (sc == ec && sc.nodeType == 3) {
3514 startPos = getCharPos(sc, so); 3571 startPos = getCharPos(sc, so);
3515 3572
3573 ieRng = body.createTextRange();
3516 ieRng.move('character', startPos); 3574 ieRng.move('character', startPos);
3517 ieRng.moveEnd('character', eo - so); 3575 ieRng.moveEnd('character', eo - so);
3518 ieRng.select(); 3576 ieRng.select();
@@ -4316,6 +4374,8 @@ tinymce.create('static tinymce.util.XHR', {
4316 4374
4317 // Handle explorer 4375 // Handle explorer
4318 if (isIE) { 4376 if (isIE) {
4377 t.tridentSel.destroy();
4378
4319 // Handle simple 4379 // Handle simple
4320 if (r = b.rng) { 4380 if (r = b.rng) {
4321 try { 4381 try {
@@ -4866,7 +4926,6 @@ tinymce.create('static tinymce.util.XHR', {
4866 closed : /^(br|hr|input|meta|img|link|param|area)$/, 4926 closed : /^(br|hr|input|meta|img|link|param|area)$/,
4867 entity_encoding : 'named', 4927 entity_encoding : 'named',
4868 entities : '160,nbsp,161,iexcl,162,cent,163,pound,164,curren,165,yen,166,brvbar,167,sect,168,uml,169,copy,170,ordf,171,laquo,172,not,173,shy,174,reg,175,macr,176,deg,177,plusmn,178,sup2,179,sup3,180,acute,181,micro,182,para,183,middot,184,cedil,185,sup1,186,ordm,187,raquo,188,frac14,189,frac12,190,frac34,191,iquest,192,Agrave,193,Aacute,194,Acirc,195,Atilde,196,Auml,197,Aring,198,AElig,199,Ccedil,200,Egrave,201,Eacute,202,Ecirc,203,Euml,204,Igrave,205,Iacute,206,Icirc,207,Iuml,208,ETH,209,Ntilde,210,Ograve,211,Oacute,212,Ocirc,213,Otilde,214,Ouml,215,times,216,Oslash,217,Ugrave,218,Uacute,219,Ucirc,220,Uuml,221,Yacute,222,THORN,223,szlig,224,agrave,225,aacute,226,acirc,227,atilde,228,auml,229,aring,230,aelig,231,ccedil,232,egrave,233,eacute,234,ecirc,235,euml,236,igrave,237,iacute,238,icirc,239,iuml,240,eth,241,ntilde,242,ograve,243,oacute,244,ocirc,245,otilde,246,ouml,247,divide,248,oslash,249,ugrave,250,uacute,251,ucirc,252,uuml,253,yacute,254,thorn,255,yuml,402,fnof,913,Alpha,914,Beta,915,Gamma,916,Delta,917,Epsilon,918,Zeta,919,Eta,920,Theta,921,Iota,922,Kappa,923,Lambda,924,Mu,925,Nu,926,Xi,927,Omicron,928,Pi,929,Rho,931,Sigma,932,Tau,933,Upsilon,934,Phi,935,Chi,936,Psi,937,Omega,945,alpha,946,beta,947,gamma,948,delta,949,epsilon,950,zeta,951,eta,952,theta,953,iota,954,kappa,955,lambda,956,mu,957,nu,958,xi,959,omicron,960,pi,961,rho,962,sigmaf,963,sigma,964,tau,965,upsilon,966,phi,967,chi,968,psi,969,omega,977,thetasym,978,upsih,982,piv,8226,bull,8230,hellip,8242,prime,8243,Prime,8254,oline,8260,frasl,8472,weierp,8465,image,8476,real,8482,trade,8501,alefsym,8592,larr,8593,uarr,8594,rarr,8595,darr,8596,harr,8629,crarr,8656,lArr,8657,uArr,8658,rArr,8659,dArr,8660,hArr,8704,forall,8706,part,8707,exist,8709,empty,8711,nabla,8712,isin,8713,notin,8715,ni,8719,prod,8721,sum,8722,minus,8727,lowast,8730,radic,8733,prop,8734,infin,8736,ang,8743,and,8744,or,8745,cap,8746,cup,8747,int,8756,there4,8764,sim,8773,cong,8776,asymp,8800,ne,8801,equiv,8804,le,8805,ge,8834,sub,8835,sup,8836,nsub,8838,sube,8839,supe,8853,oplus,8855,otimes,8869,perp,8901,sdot,8968,lceil,8969,rceil,8970,lfloor,8971,rfloor,9001,lang,9002,rang,9674,loz,9824,spades,9827,clubs,9829,hearts,9830,diams,338,OElig,339,oelig,352,Scaron,353,scaron,376,Yuml,710,circ,732,tilde,8194,ensp,8195,emsp,8201,thinsp,8204,zwnj,8205,zwj,8206,lrm,8207,rlm,8211,ndash,8212,mdash,8216,lsquo,8217,rsquo,8218,sbquo,8220,ldquo,8221,rdquo,8222,bdquo,8224,dagger,8225,Dagger,8240,permil,8249,lsaquo,8250,rsaquo,8364,euro', 4928 entities : '160,nbsp,161,iexcl,162,cent,163,pound,164,curren,165,yen,166,brvbar,167,sect,168,uml,169,copy,170,ordf,171,laquo,172,not,173,shy,174,reg,175,macr,176,deg,177,plusmn,178,sup2,179,sup3,180,acute,181,micro,182,para,183,middot,184,cedil,185,sup1,186,ordm,187,raquo,188,frac14,189,frac12,190,frac34,191,iquest,192,Agrave,193,Aacute,194,Acirc,195,Atilde,196,Auml,197,Aring,198,AElig,199,Ccedil,200,Egrave,201,Eacute,202,Ecirc,203,Euml,204,Igrave,205,Iacute,206,Icirc,207,Iuml,208,ETH,209,Ntilde,210,Ograve,211,Oacute,212,Ocirc,213,Otilde,214,Ouml,215,times,216,Oslash,217,Ugrave,218,Uacute,219,Ucirc,220,Uuml,221,Yacute,222,THORN,223,szlig,224,agrave,225,aacute,226,acirc,227,atilde,228,auml,229,aring,230,aelig,231,ccedil,232,egrave,233,eacute,234,ecirc,235,euml,236,igrave,237,iacute,238,icirc,239,iuml,240,eth,241,ntilde,242,ograve,243,oacute,244,ocirc,245,otilde,246,ouml,247,divide,248,oslash,249,ugrave,250,uacute,251,ucirc,252,uuml,253,yacute,254,thorn,255,yuml,402,fnof,913,Alpha,914,Beta,915,Gamma,916,Delta,917,Epsilon,918,Zeta,919,Eta,920,Theta,921,Iota,922,Kappa,923,Lambda,924,Mu,925,Nu,926,Xi,927,Omicron,928,Pi,929,Rho,931,Sigma,932,Tau,933,Upsilon,934,Phi,935,Chi,936,Psi,937,Omega,945,alpha,946,beta,947,gamma,948,delta,949,epsilon,950,zeta,951,eta,952,theta,953,iota,954,kappa,955,lambda,956,mu,957,nu,958,xi,959,omicron,960,pi,961,rho,962,sigmaf,963,sigma,964,tau,965,upsilon,966,phi,967,chi,968,psi,969,omega,977,thetasym,978,upsih,982,piv,8226,bull,8230,hellip,8242,prime,8243,Prime,8254,oline,8260,frasl,8472,weierp,8465,image,8476,real,8482,trade,8501,alefsym,8592,larr,8593,uarr,8594,rarr,8595,darr,8596,harr,8629,crarr,8656,lArr,8657,uArr,8658,rArr,8659,dArr,8660,hArr,8704,forall,8706,part,8707,exist,8709,empty,8711,nabla,8712,isin,8713,notin,8715,ni,8719,prod,8721,sum,8722,minus,8727,lowast,8730,radic,8733,prop,8734,infin,8736,ang,8743,and,8744,or,8745,cap,8746,cup,8747,int,8756,there4,8764,sim,8773,cong,8776,asymp,8800,ne,8801,equiv,8804,le,8805,ge,8834,sub,8835,sup,8836,nsub,8838,sube,8839,supe,8853,oplus,8855,otimes,8869,perp,8901,sdot,8968,lceil,8969,rceil,8970,lfloor,8971,rfloor,9001,lang,9002,rang,9674,loz,9824,spades,9827,clubs,9829,hearts,9830,diams,338,OElig,339,oelig,352,Scaron,353,scaron,376,Yuml,710,circ,732,tilde,8194,ensp,8195,emsp,8201,thinsp,8204,zwnj,8205,zwj,8206,lrm,8207,rlm,8211,ndash,8212,mdash,8216,lsquo,8217,rsquo,8218,sbquo,8220,ldquo,8221,rdquo,8222,bdquo,8224,dagger,8225,Dagger,8240,permil,8249,lsaquo,8250,rsaquo,8364,euro',
4869 bool_attrs : /(checked|disabled|readonly|selected|nowrap)/,
4870 valid_elements : '*[*]', 4929 valid_elements : '*[*]',
4871 extended_valid_elements : 0, 4930 extended_valid_elements : 0,
4872 valid_child_elements : 0, 4931 valid_child_elements : 0,
@@ -4950,18 +5009,21 @@ tinymce.create('static tinymce.util.XHR', {
4950 5009
4951 if (s.fix_table_elements) { 5010 if (s.fix_table_elements) {
4952 t.onPreProcess.add(function(se, o) { 5011 t.onPreProcess.add(function(se, o) {
4953 each(t.dom.select('p table', o.node).reverse(), function(n) { 5012 // Since Opera will crash if you attach the node to a dynamic document we need to brrowser sniff a specific build
4954 var parent = t.dom.getParent(n.parentNode, 'table,p'); 5013 // so Opera users with an older version will have to live with less compaible output not much we can do here
4955 5014 if (!tinymce.isOpera || opera.buildNumber() >= 1767) {
4956 if (parent.nodeName != 'TABLE') { 5015 each(t.dom.select('p table', o.node).reverse(), function(n) {
4957 // IE has a odd bug where tables inside paragraphs sometimes gets wrapped in a BODY and documentFragement element 5016 var parent = t.dom.getParent(n.parentNode, 'table,p');
4958 // This hack seems to resolve that issue. This will normally not happed since your contents should be valid in the first place
4959 if (isIE)
4960 t.dom.setOuterHTML(n, n.outerHTML);
4961 5017
4962 t.dom.split(parent, n); 5018 if (parent.nodeName != 'TABLE') {
4963 } 5019 try {
4964 }); 5020 t.dom.split(parent, n);
5021 } catch (ex) {
5022 // IE can sometimes fire an unknown runtime error so we just ignore it
5023 }
5024 }
5025 });
5026 }
4965 }); 5027 });
4966 } 5028 }
4967 }, 5029 },
@@ -5277,18 +5339,56 @@ tinymce.create('static tinymce.util.XHR', {
5277 }, 5339 },
5278 5340
5279 serialize : function(n, o) { 5341 serialize : function(n, o) {
5280 var h, t = this, doc; 5342 var h, t = this, doc, oldDoc, impl, selected;
5281 5343
5282 t._setup(); 5344 t._setup();
5283 o = o || {}; 5345 o = o || {};
5284 o.format = o.format || 'html'; 5346 o.format = o.format || 'html';
5285 n = n.cloneNode(true);
5286 t.processObj = o; 5347 t.processObj = o;
5287 5348
5288 // Nodes needs to be attached to something in WebKit due to a bug https://bugs.webkit.org/show_bug.cgi?id=25571 5349 // IE looses the selected attribute on option elements so we need to store it
5289 if (tinymce.isWebKit) { 5350 // See: http://support.microsoft.com/kb/829907
5290 doc = n.ownerDocument.implementation.createHTMLDocument(""); 5351 if (isIE) {
5291 doc.body.appendChild(doc.importNode(n)); 5352 selected = [];
5353 each(n.getElementsByTagName('option'), function(n) {
5354 var v = t.dom.getAttrib(n, 'selected');
5355
5356 selected.push(v ? v : null);
5357 });
5358 }
5359
5360 n = n.cloneNode(true);
5361
5362 // IE looses the selected attribute on option elements so we need to restore it
5363 if (isIE) {
5364 each(n.getElementsByTagName('option'), function(n, i) {
5365 t.dom.setAttrib(n, 'selected', selected[i]);
5366 });
5367 }
5368
5369 // Nodes needs to be attached to something in WebKit/Opera
5370 // Older builds of Opera crashes if you attach the node to an document created dynamically
5371 // and since we can't feature detect a crash we need to sniff the acutal build number
5372 // This fix will make DOM ranges and make Sizzle happy!
5373 impl = n.ownerDocument.implementation;
5374 if (impl.createHTMLDocument && (tinymce.isOpera && opera.buildNumber() >= 1767)) {
5375 // Create an empty HTML document
5376 doc = impl.createHTMLDocument("");
5377
5378 // Add the element or it's children if it's a body element to the new document
5379 each(n.nodeName == 'BODY' ? n.childNodes : [n], function(node) {
5380 doc.body.appendChild(doc.importNode(node, true));
5381 });
5382
5383 // Grab first child or body element for serialization
5384 if (n.nodeName != 'BODY')
5385 n = doc.body.firstChild;
5386 else
5387 n = doc.body;
5388
5389 // set the new document in DOMUtils so createElement etc works
5390 oldDoc = t.dom.doc;
5391 t.dom.doc = doc;
5292 } 5392 }
5293 5393
5294 t.key = '' + (parseInt(t.key) + 1); 5394 t.key = '' + (parseInt(t.key) + 1);
@@ -5306,6 +5406,10 @@ tinymce.create('static tinymce.util.XHR', {
5306 // Post process 5406 // Post process
5307 o.content = t.writer.getContent(); 5407 o.content = t.writer.getContent();
5308 5408
5409 // Restore the old document if it was changed
5410 if (oldDoc)
5411 t.dom.doc = oldDoc;
5412
5309 if (!o.no_events) 5413 if (!o.no_events)
5310 t.onPostProcess.dispatch(t, o); 5414 t.onPostProcess.dispatch(t, o);
5311 5415
@@ -5679,16 +5783,6 @@ tinymce.create('static tinymce.util.XHR', {
5679 5783
5680 v = this.dom.getAttrib(n, na); 5784 v = this.dom.getAttrib(n, na);
5681 5785
5682 // Bool attr
5683 if (this.settings.bool_attrs.test(na) && v) {
5684 v = ('' + v).toLowerCase();
5685
5686 if (v === 'false' || v === '0')
5687 return null;
5688
5689 v = na;
5690 }
5691
5692 switch (na) { 5786 switch (na) {
5693 case 'rowspan': 5787 case 'rowspan':
5694 case 'colspan': 5788 case 'colspan':
@@ -7948,7 +8042,7 @@ var tinyMCE = window.tinyMCE = tinymce.EditorManager;
7948 apply_source_formatting : 1, 8042 apply_source_formatting : 1,
7949 directionality : 'ltr', 8043 directionality : 'ltr',
7950 forced_root_block : 'p', 8044 forced_root_block : 'p',
7951 valid_elements : '@[id|class|style|title|dir<ltr?rtl|lang|xml::lang|onclick|ondblclick|onmousedown|onmouseup|onmouseover|onmousemove|onmouseout|onkeypress|onkeydown|onkeyup],a[rel|rev|charset|hreflang|tabindex|accesskey|type|name|href|target|title|class|onfocus|onblur],strong/b,em/i,strike,u,#p[align],-ol[type|compact],-ul[type|compact],-li,br,img[longdesc|usemap|src|border|alt=|title|hspace|vspace|width|height|align],-sub,-sup,-blockquote[cite],-table[border=0|cellspacing|cellpadding|width|frame|rules|height|align|summary|bgcolor|background|bordercolor],-tr[rowspan|width|height|align|valign|bgcolor|background|bordercolor],tbody,thead,tfoot,#td[colspan|rowspan|width|height|align|valign|bgcolor|background|bordercolor|scope],#th[colspan|rowspan|width|height|align|valign|scope],caption,-div,-span,-code,-pre,address,-h1,-h2,-h3,-h4,-h5,-h6,hr[size|noshade],-font[face|size|color],dd,dl,dt,cite,abbr,acronym,del[datetime|cite],ins[datetime|cite],object[classid|width|height|codebase|*],param[name|value],embed[type|width|height|src|*],script[src|type],map[name],area[shape|coords|href|alt|target],bdo,button,col[align|char|charoff|span|valign|width],colgroup[align|char|charoff|span|valign|width],dfn,fieldset,form[action|accept|accept-charset|enctype|method],input[accept|alt|checked|disabled|maxlength|name|readonly|size|src|type|value|tabindex|accesskey],kbd,label[for],legend,noscript,optgroup[label|disabled],option[disabled|label|selected|value],q[cite],samp,select[disabled|multiple|name|size],small,textarea[cols|rows|disabled|name|readonly],tt,var,big', 8045 valid_elements : '@[id|class|style|title|dir<ltr?rtl|lang|xml::lang|onclick|ondblclick|onmousedown|onmouseup|onmouseover|onmousemove|onmouseout|onkeypress|onkeydown|onkeyup],a[rel|rev|charset|hreflang|tabindex|accesskey|type|name|href|target|title|class|onfocus|onblur],strong/b,em/i,strike,u,#p,-ol[type|compact],-ul[type|compact],-li,br,img[longdesc|usemap|src|border|alt=|title|hspace|vspace|width|height|align],-sub,-sup,-blockquote[cite],-table[border|cellspacing|cellpadding|width|frame|rules|height|align|summary|bgcolor|background|bordercolor],-tr[rowspan|width|height|align|valign|bgcolor|background|bordercolor],tbody,thead,tfoot,#td[colspan|rowspan|width|height|align|valign|bgcolor|background|bordercolor|scope],#th[colspan|rowspan|width|height|align|valign|scope],caption,-div,-span,-code,-pre,address,-h1,-h2,-h3,-h4,-h5,-h6,hr[size|noshade],-font[face|size|color],dd,dl,dt,cite,abbr,acronym,del[datetime|cite],ins[datetime|cite],object[classid|width|height|codebase|*],param[name|value],embed[type|width|height|src|*],script[src|type],map[name],area[shape|coords|href|alt|target],bdo,button,col[align|char|charoff|span|valign|width],colgroup[align|char|charoff|span|valign|width],dfn,fieldset,form[action|accept|accept-charset|enctype|method],input[accept|alt|checked|disabled|maxlength|name|readonly|size|src|type|value|tabindex|accesskey],kbd,label[for],legend,noscript,optgroup[label|disabled],option[disabled|label|selected|value],q[cite],samp,select[disabled|multiple|name|size],small,textarea[cols|rows|disabled|name|readonly],tt,var,big',
7952 hidden_input : 1, 8046 hidden_input : 1,
7953 padd_empty_editor : 1, 8047 padd_empty_editor : 1,
7954 render_ui : 1, 8048 render_ui : 1,
@@ -8298,7 +8392,7 @@ var tinyMCE = window.tinyMCE = tinymce.EditorManager;
8298 DOM.show(b); 8392 DOM.show(b);
8299 } 8393 }
8300 8394
8301 t.dom = new tinymce.DOM.DOMUtils(t.getDoc(), { 8395 t.dom = new tinymce.dom.DOMUtils(t.getDoc(), {
8302 keep_values : true, 8396 keep_values : true,
8303 url_converter : t.convertURL, 8397 url_converter : t.convertURL,
8304 url_converter_scope : t, 8398 url_converter_scope : t,
@@ -11034,9 +11128,11 @@ var tinyMCE = window.tinyMCE = tinymce.EditorManager;
11034 } 11128 }
11035 } 11129 }
11036 11130
11131 // Uses replaceChild instead of cloneNode since it removes selected attribute from option elements on IE
11132 // See: http://support.microsoft.com/kb/829907
11037 bl = ed.dom.create(ed.settings.forced_root_block); 11133 bl = ed.dom.create(ed.settings.forced_root_block);
11038 bl.appendChild(nx.cloneNode(1));
11039 nx.parentNode.replaceChild(bl, nx); 11134 nx.parentNode.replaceChild(bl, nx);
11135 bl.appendChild(nx);
11040 } 11136 }
11041 } else { 11137 } else {
11042 if (bl.hasChildNodes()) 11138 if (bl.hasChildNodes())
@@ -12277,7 +12373,7 @@ var tinyMCE = window.tinyMCE = tinymce.EditorManager;
12277 doc.execCommand(cmd, false, null); 12373 doc.execCommand(cmd, false, null);
12278 12374
12279 // On WebKit the command will just be ignored if it's not enabled 12375 // On WebKit the command will just be ignored if it's not enabled
12280 if (!doc.queryCommandSupported(cmd)) 12376 if (!doc.queryCommandEnabled(cmd))
12281 throw 'Error'; 12377 throw 'Error';
12282 } catch (ex) { 12378 } catch (ex) {
12283 if (tinymce.isGecko) { 12379 if (tinymce.isGecko) {