diff --git a/changelog.txt b/changelog.txt index 6f66ce184ee..d0f7e42bc52 100644 --- a/changelog.txt +++ b/changelog.txt @@ -22,6 +22,7 @@ Version 3.3b1 (2009-12-xx) Changed the mce_ attribute prefix to the more standard _mce_ prefix. This is similar to browser vendors prefixes. Optimized performance with named entities on Gecko. Regexp replace was executing very slowly probably due to a Gecko bug. Optimized performance of the IE specific selection/range implementation. + Removed the safari plugin since we now replaced all text formatting logic to custom code. Version 3.2.7 (2009-09-22) Fixed bug where uppercase paragraphs could still produce an invalid DOM tree on IE. Fixed bug where split command didn't work on WebKit since the node serializer needs a real document to work with. diff --git a/examples/full.html b/examples/full.html index c46fe4bb66d..19d8e40f403 100644 --- a/examples/full.html +++ b/examples/full.html @@ -10,7 +10,7 @@ // General options mode : "textareas", theme : "advanced", - plugins : "safari,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,wordcount,advlist,autosave", + plugins : "pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,wordcount,advlist,autosave", // Theme options theme_advanced_buttons1 : "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,styleselect,formatselect,fontselect,fontsizeselect", diff --git a/examples/full_jquery.html b/examples/full_jquery.html index 85f83be1eb0..bf32cc2fc84 100644 --- a/examples/full_jquery.html +++ b/examples/full_jquery.html @@ -19,7 +19,7 @@ // General options theme : "advanced", - plugins : "safari,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,advlist", + plugins : "pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,advlist", // Theme options theme_advanced_buttons1 : "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,styleselect,formatselect,fontselect,fontsizeselect", diff --git a/examples/skins.html b/examples/skins.html index cce9cd66a84..61da950c813 100644 --- a/examples/skins.html +++ b/examples/skins.html @@ -12,7 +12,7 @@ mode : "exact", elements : "elm1", theme : "advanced", - plugins : "safari,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,inlinepopups,autosave", + plugins : "pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,inlinepopups,autosave", // Theme options theme_advanced_buttons1 : "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,styleselect,formatselect,fontselect,fontsizeselect", @@ -47,7 +47,7 @@ elements : "elm2", theme : "advanced", skin : "o2k7", - plugins : "safari,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,inlinepopups,autosave", + plugins : "pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,inlinepopups,autosave", // Theme options theme_advanced_buttons1 : "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,styleselect,formatselect,fontselect,fontsizeselect", @@ -83,7 +83,7 @@ theme : "advanced", skin : "o2k7", skin_variant : "silver", - plugins : "safari,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,inlinepopups,autosave", + plugins : "pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,inlinepopups,autosave", // Theme options theme_advanced_buttons1 : "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,styleselect,formatselect,fontselect,fontsizeselect", @@ -119,7 +119,7 @@ theme : "advanced", skin : "o2k7", skin_variant : "black", - plugins : "safari,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,inlinepopups,autosave", + plugins : "pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,inlinepopups,autosave", // Theme options theme_advanced_buttons1 : "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,styleselect,formatselect,fontselect,fontsizeselect", diff --git a/examples/translate.html b/examples/translate.html index 1427afeb424..eeeea45bd6c 100644 --- a/examples/translate.html +++ b/examples/translate.html @@ -13,7 +13,7 @@ // General options mode : "textareas", theme : "advanced", - plugins : "safari,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template", + plugins : "pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template", // Theme options theme_advanced_buttons1 : "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect,fontselect,fontsizeselect", diff --git a/examples/word.html b/examples/word.html index ea6bc4a3885..f303deca58e 100644 --- a/examples/word.html +++ b/examples/word.html @@ -10,7 +10,7 @@ // General options mode : "textareas", theme : "advanced", - plugins : "safari,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,inlinepopups,autosave", + plugins : "pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,inlinepopups,autosave", // Theme options theme_advanced_buttons1 : "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect,fontselect,fontsizeselect", diff --git a/jscripts/tiny_mce/classes/Editor.js b/jscripts/tiny_mce/classes/Editor.js index 7288d115a17..59cabe2959f 100644 --- a/jscripts/tiny_mce/classes/Editor.js +++ b/jscripts/tiny_mce/classes/Editor.js @@ -556,8 +556,8 @@ each(explode(s.plugins), function(p) { if (p && p.charAt(0) != '-' && !PluginManager.urls[p]) { - // Skip safari plugin for other browsers - if (!isWebKit && p == 'safari') + // Skip safari plugin, since it is removed as of 3.3b1 + if (p == 'safari') return; PluginManager.load(p, 'plugins/' + p + '/editor_plugin' + tinymce.suffix + '.js'); diff --git a/jscripts/tiny_mce/plugins/safari/blank.htm b/jscripts/tiny_mce/plugins/safari/blank.htm deleted file mode 100644 index 266808ce2b2..00000000000 --- a/jscripts/tiny_mce/plugins/safari/blank.htm +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/jscripts/tiny_mce/plugins/safari/editor_plugin_src.js b/jscripts/tiny_mce/plugins/safari/editor_plugin_src.js deleted file mode 100644 index 795ee3d57ca..00000000000 --- a/jscripts/tiny_mce/plugins/safari/editor_plugin_src.js +++ /dev/null @@ -1,441 +0,0 @@ -/** - * editor_plugin_src.js - * - * Copyright 2009, Moxiecode Systems AB - * Released under LGPL License. - * - * License: http://tinymce.moxiecode.com/license - * Contributing: http://tinymce.moxiecode.com/contributing - */ - -(function() { - var Event = tinymce.dom.Event, grep = tinymce.grep, each = tinymce.each, inArray = tinymce.inArray; - - function isEmpty(d, e, f) { - var w, n; - - w = d.createTreeWalker(e, NodeFilter.SHOW_ALL, null, false); - while (n = w.nextNode()) { - // Filter func - if (f) { - if (!f(n)) - return false; - } - - // Non whitespace text node - if (n.nodeType == 3 && n.nodeValue && /[^\s\u00a0]+/.test(n.nodeValue)) - return false; - - // Is non text element byt still content - if (n.nodeType == 1 && /^(HR|IMG|TABLE)$/.test(n.nodeName)) - return false; - } - - return true; - }; - - tinymce.create('tinymce.plugins.Safari', { - init : function(ed) { - var t = this, dom; - - // Ignore on non webkit - if (!tinymce.isWebKit) - return; - - t.editor = ed; - t.webKitFontSizes = ['x-small', 'small', 'medium', 'large', 'x-large', 'xx-large', '-webkit-xxx-large']; - t.namedFontSizes = ['xx-small', 'x-small','small','medium','large','x-large', 'xx-large']; - - // Safari CreateLink command will not work correctly on images that is aligned - ed.addCommand('CreateLink', function(u, v) { - var n = ed.selection.getNode(), dom = ed.dom, a; - - if (n && (/^(left|right)$/i.test(dom.getStyle(n, 'float', 1)) || /^(left|right)$/i.test(dom.getAttrib(n, 'align')))) { - a = dom.create('a', {href : v}, n.cloneNode()); - n.parentNode.replaceChild(a, n); - ed.selection.select(a); - } else - ed.getDoc().execCommand("CreateLink", false, v); - }); - -/* - // WebKit generates spans out of thin air this patch used to remove them but it will also remove styles we want so it's disabled for now - ed.onPaste.add(function(ed, e) { - function removeStyles(e) { - e = e.target; - - if (e.nodeType == 1) { - e.style.cssText = ''; - - each(ed.dom.select('*', e), function(e) { - e.style.cssText = ''; - }); - } - }; - - Event.add(ed.getDoc(), 'DOMNodeInserted', removeStyles); - - window.setTimeout(function() { - Event.remove(ed.getDoc(), 'DOMNodeInserted', removeStyles); - }, 0); - }); -*/ - ed.onKeyUp.add(function(ed, e) { - var h, b, r, n, s; - - // If backspace or delete key - if (e.keyCode == 46 || e.keyCode == 8) { - b = ed.getBody(); - h = b.innerHTML; - s = ed.selection; - - // If there is no text content or images or hr elements then remove everything - if (b.childNodes.length == 1 && !/<(img|hr)/.test(h) && tinymce.trim(h.replace(/<[^>]+>/g, '')).length == 0) { - // Inject paragrah and bogus br - ed.setContent('


', {format : 'raw'}); - - // Move caret before bogus br - n = b.firstChild; - r = s.getRng(); - r.setStart(n, 0); - r.setEnd(n, 0); - s.setRng(r); - } - } - }); - - // Workaround for FormatBlock bug, http://bugs.webkit.org/show_bug.cgi?id=16004 - ed.addCommand('FormatBlock', function(u, v) { - var dom = ed.dom, e = dom.getParent(ed.selection.getNode(), dom.isBlock); - - if (e) - dom.replace(dom.create(v), e, 1); - else - ed.getDoc().execCommand("FormatBlock", false, v); - }); - - // Workaround for InsertHTML bug, http://bugs.webkit.org/show_bug.cgi?id=16382 - ed.addCommand('mceInsertContent', function(u, v) { - ed.getDoc().execCommand("InsertText", false, 'mce_marker'); - ed.getBody().innerHTML = ed.getBody().innerHTML.replace(/mce_marker/g, ed.dom.processHTML(v) + 'XX'); - ed.selection.select(ed.dom.get('_mce_tmp')); - ed.getDoc().execCommand("Delete", false, ' '); - }); - - /* ed.onKeyDown.add(function(ed, e) { - // Ctrl+A select all will fail on WebKit since if you paste the contents you selected it will produce a odd div wrapper - if ((e.ctrlKey || e.metaKey) && e.keyCode == 65) { - ed.selection.select(ed.getBody(), 1); - return Event.cancel(e); - } - });*/ - - ed.onKeyPress.add(function(ed, e) { - var se, li, lic, r1, r2, n, sel, doc, be, af, pa; - - if (e.keyCode == 13) { - sel = ed.selection; - se = sel.getNode(); - - // Workaround for missing shift+enter support, http://bugs.webkit.org/show_bug.cgi?id=16973 - if (e.shiftKey || ed.settings.force_br_newlines && se.nodeName != 'LI') { - t._insertBR(ed); - Event.cancel(e); - } - - // Workaround for DIV elements produced by Safari - if (li = dom.getParent(se, 'LI')) { - lic = dom.getParent(li, 'OL,UL'); - doc = ed.getDoc(); - - pa = dom.create('p'); - dom.add(pa, 'br', {_mce_bogus : "1"}); - - if (isEmpty(doc, li)) { - // If list in list then use browser default behavior - if (n = dom.getParent(lic.parentNode, 'LI,OL,UL')) - return; - - n = dom.getParent(lic, 'p,h1,h2,h3,h4,h5,h6,div') || lic; - - // Create range from the start of block element to the list item - r1 = doc.createRange(); - r1.setStartBefore(n); - r1.setEndBefore(li); - - // Create range after the list to the end of block element - r2 = doc.createRange(); - r2.setStartAfter(li); - r2.setEndAfter(n); - - be = r1.cloneContents(); - af = r2.cloneContents(); - - if (!isEmpty(doc, af)) - dom.insertAfter(af, n); - - dom.insertAfter(pa, n); - - if (!isEmpty(doc, be)) - dom.insertAfter(be, n); - - dom.remove(n); - - n = pa.firstChild; - r1 = doc.createRange(); - r1.setStartBefore(n); - r1.setEndBefore(n); - sel.setRng(r1); - - return Event.cancel(e); - } - } - } - }); - - // Safari doesn't place lists outside block elements - ed.onExecCommand.add(function(ed, cmd) { - var sel, dom, bl, bm; - - if (cmd == 'InsertUnorderedList' || cmd == 'InsertOrderedList') { - sel = ed.selection; - dom = ed.dom; - - if (bl = dom.getParent(sel.getNode(), function(n) {return /^(H[1-6]|P|ADDRESS|PRE)$/.test(n.nodeName);})) { - bm = sel.getBookmark(); - dom.remove(bl, 1); - sel.moveToBookmark(bm); - } - } - }); - - // Workaround for bug, http://bugs.webkit.org/show_bug.cgi?id=12250 - ed.onClick.add(function(ed, e) { - e = e.target; - - if (e.nodeName == 'IMG') { - t.selElm = e; - ed.selection.select(e); - } else - t.selElm = null; - }); - - ed.onInit.add(function() { - t._fixWebKitSpans(); - }); - - ed.onSetContent.add(function() { - dom = ed.dom; - - // Convert strong,b,em,u,strike to spans - each(['strong','b','em','u','strike','sub','sup','a'], function(v) { - each(grep(dom.select(v)).reverse(), function(n) { - var nn = n.nodeName.toLowerCase(), st; - - // Convert anchors into images - if (nn == 'a') { - if (n.name) - dom.replace(dom.create('img', {_mce_name : 'a', name : n.name, 'class' : 'mceItemAnchor'}), n); - - return; - } - - switch (nn) { - case 'b': - case 'strong': - if (nn == 'b') - nn = 'strong'; - - st = 'font-weight: bold;'; - break; - - case 'em': - st = 'font-style: italic;'; - break; - - case 'u': - st = 'text-decoration: underline;'; - break; - - case 'sub': - st = 'vertical-align: sub;'; - break; - - case 'sup': - st = 'vertical-align: super;'; - break; - - case 'strike': - st = 'text-decoration: line-through;'; - break; - } - - dom.replace(dom.create('span', {_mce_name : nn, style : st, 'class' : 'Apple-style-span'}), n, 1); - }); - }); - }); - - ed.onPreProcess.add(function(ed, o) { - dom = ed.dom; - - each(grep(o.node.getElementsByTagName('span')).reverse(), function(n) { - var v, bg; - - if (o.get) { - if (dom.hasClass(n, 'Apple-style-span')) { - bg = n.style.backgroundColor; - - switch (dom.getAttrib(n, '_mce_name')) { - case 'font': - if (!ed.settings.convert_fonts_to_spans) - dom.setAttrib(n, 'style', ''); - break; - - case 'strong': - case 'em': - case 'sub': - case 'sup': - dom.setAttrib(n, 'style', ''); - break; - - case 'strike': - case 'u': - if (!ed.settings.inline_styles) - dom.setAttrib(n, 'style', ''); - else - dom.setAttrib(n, '_mce_name', ''); - - break; - - default: - if (!ed.settings.inline_styles) - dom.setAttrib(n, 'style', ''); - } - - - if (bg) - n.style.backgroundColor = bg; - } - } - - if (dom.hasClass(n, 'mceItemRemoved')) - dom.remove(n, 1); - }); - }); - - ed.onPostProcess.add(function(ed, o) { - // Safari adds BR at end of all block elements - o.content = o.content.replace(/
<\/(h[1-6]|div|p|address|pre)>/g, ''); - - // Safari adds id="undefined" to HR elements - o.content = o.content.replace(/ id=\"undefined\"/g, ''); - }); - }, - - getInfo : function() { - return { - longname : 'Safari compatibility', - author : 'Moxiecode Systems AB', - authorurl : 'http://tinymce.moxiecode.com', - infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/safari', - version : tinymce.majorVersion + "." + tinymce.minorVersion - }; - }, - - // Internal methods - - _fixWebKitSpans : function() { - var t = this, ed = t.editor; - - // Use mutator events on new WebKit - Event.add(ed.getDoc(), 'DOMNodeInserted', function(e) { - e = e.target; - - if (e && e.nodeType == 1) - t._fixAppleSpan(e); - }); - }, - - _fixAppleSpan : function(e) { - var ed = this.editor, dom = ed.dom, fz = this.webKitFontSizes, fzn = this.namedFontSizes, s = ed.settings, st, p; - - if (dom.getAttrib(e, '_mce_fixed')) - return; - - // Handle Apple style spans - if (e.nodeName == 'SPAN' && e.className == 'Apple-style-span') { - st = e.style; - - if (!s.convert_fonts_to_spans) { - if (st.fontSize) { - dom.setAttrib(e, '_mce_name', 'font'); - dom.setAttrib(e, 'size', inArray(fz, st.fontSize) + 1); - } - - if (st.fontFamily) { - dom.setAttrib(e, '_mce_name', 'font'); - dom.setAttrib(e, 'face', st.fontFamily); - } - - if (st.color) { - dom.setAttrib(e, '_mce_name', 'font'); - dom.setAttrib(e, 'color', dom.toHex(st.color)); - } - - if (st.backgroundColor) { - dom.setAttrib(e, '_mce_name', 'font'); - dom.setStyle(e, 'background-color', st.backgroundColor); - } - } else { - if (st.fontSize) - dom.setStyle(e, 'fontSize', fzn[inArray(fz, st.fontSize)]); - } - - if (st.fontWeight == 'bold') - dom.setAttrib(e, '_mce_name', 'strong'); - - if (st.fontStyle == 'italic') - dom.setAttrib(e, '_mce_name', 'em'); - - if (st.textDecoration == 'underline') - dom.setAttrib(e, '_mce_name', 'u'); - - if (st.textDecoration == 'line-through') - dom.setAttrib(e, '_mce_name', 'strike'); - - if (st.verticalAlign == 'super') - dom.setAttrib(e, '_mce_name', 'sup'); - - if (st.verticalAlign == 'sub') - dom.setAttrib(e, '_mce_name', 'sub'); - - dom.setAttrib(e, '_mce_fixed', '1'); - } - }, - - _insertBR : function(ed) { - var dom = ed.dom, s = ed.selection, r = s.getRng(), br; - - // Insert BR element - r.insertNode(br = dom.create('br')); - - // Place caret after BR - r.setStartAfter(br); - r.setEndAfter(br); - s.setRng(r); - - // Could not place caret after BR then insert an nbsp entity and move the caret - if (s.getSel().focusNode == br.previousSibling) { - s.select(dom.insertAfter(dom.doc.createTextNode('\u00a0'), br)); - s.collapse(1); - } - - // Scroll to new position, scrollIntoView can't be used due to bug: http://bugs.webkit.org/show_bug.cgi?id=16117 - ed.getWin().scrollTo(0, dom.getPos(s.getRng().startContainer).y); - } - }); - - // Register plugin - tinymce.PluginManager.add('safari', tinymce.plugins.Safari); -})(); -