Commit 259a8643 authored by Francois Marier's avatar Francois Marier
Browse files

tinymce: New upstream release 3.4.7 (bug #869193)



Change-Id: Idd543e03aec6ee76ba34c5f66b0924a3bc3b3482
Signed-off-by: default avatarFrancois Marier <francois@catalyst.net.nz>
parent 4758c37e
......@@ -2,10 +2,12 @@ TinyMCE
========
Website: http://tinymce.moxiecode.com/
Version: 3.4.4
Version: 3.4.7
PHP Spellchecker plugin: 2.0.6
Changes:
* Additional files in the eu and zh language packs
* Removed unused media plugin to fix Debian bug #591200
* Added all of the language packs
* Removed unused plugins/media/ to fix Debian bug #591200
* Removed the standard spellchecker plugin and replace with the php spellchecker plugin
/**
* TinyMCE - ContentManager class.
*
* Copyright 2009, Moxiecode Systems AB
* Released under LGPL License.
*
* License: http://tinymce.moxiecode.com/license
* Contributing: http://tinymce.moxiecode.com/contributing
*/
(function(tinymce) {
function CommandManager() {
var execCommands = {}, queryStateCommands = {}, queryValueCommands = {};
function add(collection, cmd, func, scope) {
if (typeof(cmd) == 'string')
cmd = [cmd];
tinymce.each(cmd, function(cmd) {
collection[cmd.toLowerCase()] = {func : func, scope : scope};
});
};
tinymce.extend(this, {
add : function(cmd, func, scope) {
add(execCommands, cmd, func, scope);
},
addQueryStateHandler : function(cmd, func, scope) {
add(queryStateCommands, cmd, func, scope);
},
addQueryValueHandler : function(cmd, func, scope) {
add(queryValueCommands, cmd, func, scope);
},
execCommand : function(scope, cmd, ui, value, args) {
if (cmd = execCommands[cmd.toLowerCase()]) {
if (cmd.func.call(scope || cmd.scope, ui, value, args) !== false)
return true;
}
},
queryCommandValue : function() {
if (cmd = queryValueCommands[cmd.toLowerCase()])
return cmd.func.call(scope || cmd.scope, ui, value, args);
},
queryCommandState : function() {
if (cmd = queryStateCommands[cmd.toLowerCase()])
return cmd.func.call(scope || cmd.scope, ui, value, args);
}
});
};
tinymce.GlobalCommands = new CommandManager();
})(tinymce);
\ No newline at end of file
......@@ -235,7 +235,12 @@
id = t.prefix + id;
if (ed.settings.use_native_selects)
function useNativeListForAccessibility(ed) {
return ed.settings.use_accessible_selects && !tinymce.isGecko
}
if (ed.settings.use_native_selects || useNativeListForAccessibility(ed))
c = new tinymce.ui.NativeListBox(id, s);
else {
cls = cc || t._cls.listbox || tinymce.ui.ListBox;
......
/**
* Developer.js
*
* Copyright 2009, Moxiecode Systems AB
* Released under LGPL License.
*
* License: http://tinymce.moxiecode.com/license
* Contributing: http://tinymce.moxiecode.com/contributing
*/
(function() {
var EditorManager = tinymce.EditorManager, each = tinymce.each, DOM = tinymce.DOM;
/**
* This class patches in various development features. This class is only available for the dev version of TinyMCE.
*/
tinymce.create('static tinymce.Developer', {
_piggyBack : function() {
var t = this, em = tinymce.EditorManager, lo = false;
// Makes sure that XML language pack is used instead of JS files
t._runBefore(em, 'init', function(s) {
var par = new tinymce.xml.Parser({async : false}), lng = s.language || "en", i18n = tinymce.EditorManager.i18n, sl = tinymce.ScriptLoader;
if (!s.translate_mode)
return;
if (lo)
return;
lo = true;
// Common language loaded
sl.markDone(tinymce.baseURL + '/langs/' + lng + '.js');
// Theme languages loaded
sl.markDone(tinymce.baseURL + '/themes/simple/langs/' + lng + '.js');
sl.markDone(tinymce.baseURL + '/themes/advanced/langs/' + lng + '.js');
// All plugin packs loaded
each(s.plugins.split(','), function(p) {
sl.markDone(tinymce.baseURL + '/plugins/' + p + '/langs/' + lng + '.js');
});
// Load XML language pack
par.load(tinymce.baseURL + '/langs/' + lng + '.xml', function(doc, ex) {
var c;
if (!doc) {
alert(ex.message);
return;
}
if (doc.documentElement.nodeName == 'parsererror') {
alert('Parse error!!');
return;
}
c = doc.getElementsByTagName('language')[0].getAttribute("code");
each(doc.getElementsByTagName('group'), function(g) {
var gn = g.getAttribute("target"), o = {};
// Build object from XML items
each(g.getElementsByTagName('item'), function(it) {
var itn = it.getAttribute("name");
if (gn == "common")
i18n[c + '.' + itn] = par.getText(it);
else
i18n[c + '.' + gn + "." + itn] = par.getText(it);
});
});
}, {
async : false
});
});
},
_runBefore : function(o, n, f) {
var e = o[n];
o[n] = function() {
var s = f.apply(o, arguments);
if (s !== false)
return e.apply(o, arguments);
};
}
});
tinymce.Developer._piggyBack();
})();
......@@ -802,6 +802,7 @@
visual_table_class : 'mceItemTable',
visual : 1,
font_size_style_values : 'xx-small,x-small,small,medium,large,x-large,xx-large',
font_size_legacy_values : 'xx-small,small,medium,large,x-large,xx-large,300%', // See: http://www.w3.org/TR/CSS2/fonts.html#propdef-font-size
apply_source_formatting : 1,
directionality : 'ltr',
forced_root_block : 'p',
......@@ -1190,12 +1191,9 @@
t.iframeHTML += '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />';
// Firefox 2 doesn't load stylesheets correctly this way
if (!isGecko || !/Firefox\/2/.test(navigator.userAgent)) {
for (i = 0; i < t.contentCSS.length; i++)
t.iframeHTML += '<link type="text/css" rel="stylesheet" href="' + t.contentCSS[i] + '" />';
t.contentCSS = [];
// Load the CSS by injecting them into the HTML this will reduce "flicker"
for (i = 0; i < t.contentCSS.length; i++) {
t.iframeHTML += '<link type="text/css" rel="stylesheet" href="' + t.contentCSS[i] + '" />';
}
bi = s.body_id || 'tinymce';
......@@ -1210,12 +1208,12 @@
bc = bc[t.id] || '';
}
t.iframeHTML += '</head><body id="' + bi + '" class="mceContentBody ' + bc + '"></body></html>';
t.iframeHTML += '</head><body id="' + bi + '" class="mceContentBody ' + bc + '"><br></body></html>';
// Domain relaxing enabled, then set document domain
if (tinymce.relaxedDomain && (isIE || (tinymce.isOpera && parseFloat(opera.version()) < 11))) {
// We need to write the contents here in IE since multiple writes messes up refresh button and back button
u = 'javascript:(function(){document.open();document.domain="' + document.domain + '";var ed = window.parent.tinyMCE.get("' + t.id + '");document.write(ed.iframeHTML);document.close();ed.setupIframe();})()';
u = 'javascript:(function(){document.open();document.domain="' + document.domain + '";var ed = window.parent.tinyMCE.get("' + t.id + '");document.write(ed.iframeHTML);document.close();ed.setupIframe();})()';
}
// Create iframe
......@@ -1228,7 +1226,8 @@
title : s.aria_label,
style : {
width : '100%',
height : h
height : h,
display : 'block' // Important for Gecko to render the iframe correctly
}
});
......@@ -1250,69 +1249,24 @@
*
* @method setupIframe
*/
setupIframe : function(filled) {
setupIframe : function() {
var t = this, s = t.settings, e = DOM.get(t.id), d = t.getDoc(), h, b;
// Setup iframe body
if ((!isIE || !tinymce.relaxedDomain) && !filled) {
// We need to wait for the load event on Gecko
if (isGecko && !s.readonly) {
t.getWin().addEventListener("DOMContentLoaded", function() {
window.setTimeout(function() {
var b = t.getBody(), undef;
// Editable element needs to have some contents or backspace/delete won't work properly for some odd reason on FF 3.6 or older
b.innerHTML = '<br>';
// Check if Gecko supports contentEditable mode FF2 doesn't
if (b.contentEditable !== undef) {
// Setting the contentEditable off/on seems to force caret mode in the editor and enabled auto focus
b.contentEditable = false;
b.contentEditable = true;
// Caret doesn't get rendered when you mousedown on the HTML element on FF 3.x
t.onMouseDown.add(function(ed, e) {
if (e.target.nodeName === "HTML") {
// Setting the contentEditable off/on seems to force caret mode in the editor and enabled auto focus
b.contentEditable = false;
b.contentEditable = true;
d.designMode = 'on'; // Render the caret
// Remove design mode again after a while so it has some time to execute
window.setTimeout(function() {
d.designMode = 'off';
t.getBody().focus();
}, 1);
}
});
} else
d.designMode = 'on';
// Call setup frame once the contentEditable/designMode has been initialized
// since the caret won't be rendered some times otherwise.
t.setupIframe(true);
}, 1);
}, false);
}
if (!isIE || !tinymce.relaxedDomain) {
d.open();
d.write(t.iframeHTML);
d.close();
if (tinymce.relaxedDomain)
d.domain = tinymce.relaxedDomain;
// Wait for iframe onload event on Gecko
if (isGecko && !s.readonly)
return;
}
// It will not steal focus while setting contentEditable
b = t.getBody();
b.disabled = true;
if (!isGecko && !s.readonly)
if (!s.readonly)
b.contentEditable = true;
b.disabled = false;
......@@ -1396,10 +1350,12 @@
// Keep scripts from executing
t.parser.addNodeFilter('script', function(nodes, name) {
var i = nodes.length;
var i = nodes.length, node;
while (i--)
nodes[i].attr('type', 'mce-text/javascript');
while (i--) {
node = nodes[i];
node.attr('type', 'mce-' + (node.attr('type') || 'text/javascript'));
}
});
t.parser.addNodeFilter('#cdata', function(nodes, name) {
......@@ -1513,6 +1469,18 @@
subscript : {inline : 'sub'},
superscript : {inline : 'sup'},
link : {inline : 'a', selector : 'a', remove : 'all', split : true, deep : true,
onmatch : function(node) {
return true;
},
onformat : function(elm, fmt, vars) {
each(vars, function(value, key) {
t.dom.setAttrib(elm, key, value);
});
}
},
removeformat : [
{selector : 'b,strong,em,i,font,u,strike', remove : 'all', split : true, expand : false, block_expand : true, deep : true},
{selector : 'span', attributes : ['style', 'class'], remove : 'empty', split : true, expand : false, deep : true},
......@@ -1880,6 +1848,7 @@
controlElm = ieRng.item(0);
}
t._refreshContentEditable();
selection.normalize();
// Is not content editable
......@@ -2981,16 +2950,7 @@
var t = this, d = t.getDoc(), s = t.settings;
if (isGecko && !s.readonly) {
if (t._isHidden()) {
try {
if (!s.content_editable) {
d.body.contentEditable = false;
d.body.contentEditable = true;
}
} catch (ex) {
// Fails if it's hidden
}
}
t._refreshContentEditable();
try {
// Try new Gecko method
......@@ -3013,21 +2973,6 @@
t.onMouseDown.add(setOpts);
}
t.onClick.add(function(ed, e) {
e = e.target;
// Workaround for bug, http://bugs.webkit.org/show_bug.cgi?id=12250
// WebKit can't even do simple things like selecting an image
// Needs tobe the setBaseAndExtend or it will fail to select floated images
if (tinymce.isWebKit && e.nodeName == 'IMG')
t.selection.getSel().setBaseAndExtent(e, 0, e, 1);
if (e.nodeName == 'A' && dom.hasClass(e, 'mceItemAnchor'))
t.selection.select(e);
t.nodeChanged();
});
// Add node change handlers
t.onMouseUp.add(t.nodeChanged);
//t.onClick.add(t.nodeChanged);
......@@ -3261,21 +3206,6 @@
});
}
// Fire a nodeChanged when the selection is changed on WebKit this fixes selection issues on iOS5
// It only fires the nodeChange event every 50ms since it would other wise update the UI when you type and it hogs the CPU
if (tinymce.isWebKit) {
dom.bind(t.getDoc(), 'selectionchange', function() {
if (t.selectionTimer) {
window.clearTimeout(t.selectionTimer);
t.selectionTimer = 0;
}
t.selectionTimer = window.setTimeout(function() {
t.nodeChanged();
}, 50);
});
}
// Bug fix for FireFox keeping styles from end of selection instead of start.
if (tinymce.isGecko) {
function getAttributeApplyFunction() {
......@@ -3285,7 +3215,7 @@
var target = t.selection.getStart();
if (target !== t.getBody()) {
t.dom.removeAllAttribs(target);
t.dom.setAttrib(target, "style", null);
each(template, function(attr) {
target.setAttributeNode(attr.cloneNode(true));
......@@ -3328,6 +3258,21 @@
}
},
_refreshContentEditable : function() {
var self = this, body, parent;
// Check if the editor was hidden and the re-initalize contentEditable mode by removing and adding the body again
if (self._isHidden()) {
body = self.getBody();
parent = body.parentNode;
parent.removeChild(body);
parent.appendChild(body);
body.focus();
}
},
_isHidden : function() {
var s;
......
......@@ -23,6 +23,7 @@
selection = editor.selection,
commands = {state: {}, exec : {}, value : {}},
settings = editor.settings,
formatter = editor.formatter,
bookmark;
/**
......@@ -118,11 +119,11 @@
};
function isFormatMatch(name) {
return editor.formatter.match(name);
return formatter.match(name);
};
function toggleFormat(name, value) {
editor.formatter.toggle(name, value ? {value : value} : undefined);
formatter.toggle(name, value ? {value : value} : undefined);
};
function storeSelection(type) {
......@@ -182,7 +183,7 @@
// Remove all other alignments first
each('left,center,right,full'.split(','), function(name) {
if (align != name)
editor.formatter.remove('align' + name);
formatter.remove('align' + name);
});
toggleFormat('align' + align);
......@@ -239,7 +240,7 @@
},
RemoveFormat : function(command) {
editor.formatter.remove(command);
formatter.remove(command);
},
mceBlockQuote : function(command) {
......@@ -462,7 +463,7 @@
},
mceToggleFormat : function(command, ui, value) {
editor.formatter.toggle(value);
formatter.toggle(value);
},
InsertHorizontalRule : function() {
......@@ -479,47 +480,27 @@
},
mceInsertLink : function(command, ui, value) {
var link = dom.getParent(selection.getNode(), 'a'), img, style, cls;
var anchor;
if (tinymce.is(value, 'string'))
if (typeof(value) == 'string')
value = {href : value};
anchor = dom.getParent(selection.getNode(), 'a');
// Spaces are never valid in URLs and it's a very common mistake for people to make so we fix it here.
value.href = value.href.replace(' ', '%20');
if (!link) {
// WebKit can't create links on floated images for some odd reason
// So, just remove styles and restore it later
if (tinymce.isWebKit) {
img = dom.getParent(selection.getNode(), 'img');
if (img) {
style = img.style.cssText;
cls = img.className;
img.style.cssText = null;
img.className = null;
}
}
execNativeCommand('CreateLink', FALSE, 'javascript:mctmp(0);');
// Restore styles
if (style)
img.style.cssText = style;
if (cls)
img.className = cls;
// Remove existing links if there could be child links or that the href isn't specified
if (!anchor || !value.href) {
formatter.remove('link');
}
each(dom.select("a[href='javascript:mctmp(0);']"), function(link) {
dom.setAttribs(link, value);
});
} else {
if (value.href)
dom.setAttribs(link, value);
else
editor.dom.remove(link, TRUE);
// Apply new link to selection
if (value.href) {
formatter.apply('link', value, anchor);
}
},
selectAll : function() {
var root = dom.getRoot(), rng = dom.createRng();
......
......@@ -390,6 +390,11 @@
ra.setStart(en, 0);
}
// If the body is totally empty add a BR element this might happen on webkit
if (!d.body.hasChildNodes()) {
d.body.appendChild(dom.create('br'));
}
// Never use body as start or end node
sn = sn.nodeName == "HTML" ? d.body : sn; // Fix for Opera bug: https://bugs.opera.com/show_bug.cgi?id=273224&comments=yes
sn = sn.nodeName == "BODY" ? sn.firstChild : sn;
......
This diff is collapsed.
......@@ -12,7 +12,7 @@ tinymce.onAddEditor.add(function(tinymce, ed) {
var filters, fontSizes, dom, settings = ed.settings;
if (settings.inline_styles) {
fontSizes = tinymce.explode(settings.font_size_style_values);
fontSizes = tinymce.explode(settings.font_size_legacy_values);
function replaceWithSpan(node, styles) {
tinymce.each(styles, function(value, name) {
......
......@@ -655,48 +655,48 @@
return this.run(e, function(e) {
var s = t.settings;
if (v !== null) {
switch (n) {
case "style":
if (!is(v, 'string')) {
each(v, function(v, n) {
t.setStyle(e, n, v);
});
switch (n) {
case "style":
if (!is(v, 'string')) {
each(v, function(v, n) {
t.setStyle(e, n, v);
});
return;
}
return;
}
// No mce_style for elements with these since they might get resized by the user