Commit ecc59aa6 authored by Cecilia Vela Gurovic's avatar Cecilia Vela Gurovic Committed by Robert Lyon
Browse files

Bug 1779041: Upgrade TinyMCE to v4.8.2

behatnotneeded

Change-Id: I84a279fd731352cd30d90c47831c1438e0fc4cbb
parent f68635ec
TinyMCE
========
Website: http://tinymce.moxiecode.com/
Version: 4.5.5
Website: https://www.tiny.cloud/
Version: 4.8.2
Based on development version
......@@ -10,20 +10,21 @@ Changes:
* Added all of the language packs (original commit: 259a86431ad1140e15288d39702cea885c08f3fe)
* Removed all .min.js and .dev.js files
* Removed all files in 'classes' directory since they're packaged into tinymce.js
* Removed all .less files from skin (original commit: 442ade4e7c7cf991a4001ab8f7cc9d15e2b25890)
* Added code to spellchecker/spellchecker.rpc to use $CFG->spellcheckerengine (original commit: a42e68b43e4a63db19569facae61898af1b86d3f)
* Adding the 'aria-hidden="true"' to presentation icons (original commit: 4ac89c31a719a9f63be6555c4d1a094fd2b09d0e)
* Bug 1605110: Modified the "table" plugin to style the table through CSS instead of HTML attributes (original commit: 63f91a7ea8bd60c102e257c05678cc6d55e21683)
* Add TinyMCE imagebrowser plugin: plugins/imagebrowser/plugin.js
* Modified plugins/link/plugin.js to add 'user_' to the anchorlist value and selected to account for htmlpurification prefixing all user id's with 'user_'
* Removed
plugins/layer removed in v4.5.0
plugins/media/moxieplayer.swf removed in v4.5.0
* Removed files and folders
tinymce.jquery.js removed in v4.3.4
theme/inlite
theme/mobile
skins/lightgray
plugins/help
* Removed 'Powered by Tinymce' text from the modern theme
* Added
plugins/imagebrowser (originally added in commit 36bc9f7d26076d74ebc6cd0672441eed8ed9cd2d)
plugins/mathslate (originally added in commit 325cdfac3dfba40efbbad8cd306dcfb385674709)
plugins/tooltoggle (originally added in commit 2c490a70bfff677c0b95c0565d39162c8c9bc10d)
skins/light (we use it but it's not included in new versions any more)
plugins/imagebrowser (originally added in commit 36bc9f7d26076d74ebc6cd0672441eed8ed9cd2d)
plugins/mathslate (originally added in commit 325cdfac3dfba40efbbad8cd306dcfb385674709)
plugins/tooltoggle (originally added in commit 2c490a70bfff677c0b95c0565d39162c8c9bc10d)
skins/light (we use it but it's not included in new versions any more)
GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999
GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
......@@ -10,7 +10,7 @@
as the successor of the GNU Library Public License, version 2, hence
the version number 2.1.]
Preamble
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
......@@ -112,7 +112,7 @@ modification follow. Pay close attention to the difference between a
former contains code derived from the library, whereas the latter must
be combined with the library in order to run.
GNU LESSER GENERAL PUBLIC LICENSE
GNU LESSER GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library or other
......@@ -432,7 +432,7 @@ decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
......@@ -455,7 +455,7 @@ FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
END OF TERMS AND CONDITIONS
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Libraries
......
/**
* plugin.js
*
* Released under LGPL License.
* Copyright (c) 1999-2015 Ephox Corp. All rights reserved
*
* License: http://www.tinymce.com/license
* Contributing: http://www.tinymce.com/contributing
*/
/*global tinymce:true */
tinymce.PluginManager.add('advlist', function(editor) {
var olMenuItems, ulMenuItems;
var hasPlugin = function (editor, plugin) {
var plugins = editor.settings.plugins ? editor.settings.plugins : '';
return tinymce.util.Tools.inArray(plugins.split(/[ ,]/), plugin) !== -1;
};
function isChildOfBody(elm) {
return editor.$.contains(editor.getBody(), elm);
}
function isListNode(node) {
return node && (/^(OL|UL|DL)$/).test(node.nodeName) && isChildOfBody(node);
}
function buildMenuItems(listName, styleValues) {
var items = [];
if (styleValues) {
tinymce.each(styleValues.split(/[ ,]/), function(styleValue) {
items.push({
text: styleValue.replace(/\-/g, ' ').replace(/\b\w/g, function(chr) {
return chr.toUpperCase();
}),
data: styleValue == 'default' ? '' : styleValue
});
});
}
return items;
}
olMenuItems = buildMenuItems('OL', editor.getParam(
"advlist_number_styles",
"default,lower-alpha,lower-greek,lower-roman,upper-alpha,upper-roman"
));
ulMenuItems = buildMenuItems('UL', editor.getParam("advlist_bullet_styles", "default,circle,disc,square"));
function applyListFormat(listName, styleValue) {
editor.undoManager.transact(function() {
var list, dom = editor.dom, sel = editor.selection;
// Check for existing list element
list = dom.getParent(sel.getNode(), 'ol,ul');
// Switch/add list type if needed
if (!list || list.nodeName != listName || styleValue === false) {
var detail = {
'list-style-type': styleValue ? styleValue : ''
};
editor.execCommand(listName == 'UL' ? 'InsertUnorderedList' : 'InsertOrderedList', false, detail);
}
list = dom.getParent(sel.getNode(), 'ol,ul');
if (list) {
tinymce.util.Tools.each(dom.select('ol,ul', list).concat([list]), function (list) {
if (list.nodeName !== listName && styleValue !== false) {
list = dom.rename(list, listName);
}
dom.setStyle(list, 'listStyleType', styleValue ? styleValue : null);
list.removeAttribute('data-mce-style');
});
}
editor.focus();
});
}
function updateSelection(e) {
var listStyleType = editor.dom.getStyle(editor.dom.getParent(editor.selection.getNode(), 'ol,ul'), 'listStyleType') || '';
e.control.items().each(function(ctrl) {
ctrl.active(ctrl.settings.data === listStyleType);
});
}
var listState = function (listName) {
return function () {
var self = this;
editor.on('NodeChange', function (e) {
var lists = tinymce.util.Tools.grep(e.parents, isListNode);
self.active(lists.length > 0 && lists[0].nodeName === listName);
});
};
};
if (hasPlugin(editor, "lists")) {
editor.addCommand('ApplyUnorderedListStyle', function (ui, value) {
applyListFormat('UL', value['list-style-type']);
});
editor.addCommand('ApplyOrderedListStyle', function (ui, value) {
applyListFormat('OL', value['list-style-type']);
});
editor.addButton('numlist', {
type: (olMenuItems.length > 0) ? 'splitbutton' : 'button',
tooltip: 'Numbered list',
menu: olMenuItems,
onPostRender: listState('OL'),
onshow: updateSelection,
onselect: function(e) {
applyListFormat('OL', e.control.settings.data);
},
onclick: function() {
applyListFormat('OL', false);
}
});
editor.addButton('bullist', {
type: (ulMenuItems.length > 0) ? 'splitbutton' : 'button',
tooltip: 'Bullet list',
onPostRender: listState('UL'),
menu: ulMenuItems,
onshow: updateSelection,
onselect: function(e) {
applyListFormat('UL', e.control.settings.data);
},
onclick: function() {
applyListFormat('UL', false);
}
});
}
});
(function () {
var advlist = (function () {
'use strict';
var global = tinymce.util.Tools.resolve('tinymce.PluginManager');
var global$1 = tinymce.util.Tools.resolve('tinymce.util.Tools');
var applyListFormat = function (editor, listName, styleValue) {
var cmd = listName === 'UL' ? 'InsertUnorderedList' : 'InsertOrderedList';
editor.execCommand(cmd, false, styleValue === false ? null : { 'list-style-type': styleValue });
};
var $_tr6sy8fjkvrikel = { applyListFormat: applyListFormat };
var register = function (editor) {
editor.addCommand('ApplyUnorderedListStyle', function (ui, value) {
$_tr6sy8fjkvrikel.applyListFormat(editor, 'UL', value['list-style-type']);
});
editor.addCommand('ApplyOrderedListStyle', function (ui, value) {
$_tr6sy8fjkvrikel.applyListFormat(editor, 'OL', value['list-style-type']);
});
};
var $_3zcr558ejkvrikek = { register: register };
var getNumberStyles = function (editor) {
var styles = editor.getParam('advlist_number_styles', 'default,lower-alpha,lower-greek,lower-roman,upper-alpha,upper-roman');
return styles ? styles.split(/[ ,]/) : [];
};
var getBulletStyles = function (editor) {
var styles = editor.getParam('advlist_bullet_styles', 'default,circle,disc,square');
return styles ? styles.split(/[ ,]/) : [];
};
var $_3totu98hjkvrikeo = {
getNumberStyles: getNumberStyles,
getBulletStyles: getBulletStyles
};
var isChildOfBody = function (editor, elm) {
return editor.$.contains(editor.getBody(), elm);
};
var isTableCellNode = function (node) {
return node && /^(TH|TD)$/.test(node.nodeName);
};
var isListNode = function (editor) {
return function (node) {
return node && /^(OL|UL|DL)$/.test(node.nodeName) && isChildOfBody(editor, node);
};
};
var getSelectedStyleType = function (editor) {
var listElm = editor.dom.getParent(editor.selection.getNode(), 'ol,ul');
return editor.dom.getStyle(listElm, 'listStyleType') || '';
};
var $_jbgtb8ijkvrikep = {
isTableCellNode: isTableCellNode,
isListNode: isListNode,
getSelectedStyleType: getSelectedStyleType
};
var styleValueToText = function (styleValue) {
return styleValue.replace(/\-/g, ' ').replace(/\b\w/g, function (chr) {
return chr.toUpperCase();
});
};
var toMenuItems = function (styles) {
return global$1.map(styles, function (styleValue) {
var text = styleValueToText(styleValue);
var data = styleValue === 'default' ? '' : styleValue;
return {
text: text,
data: data
};
});
};
var $_3g7f528jjkvriker = { toMenuItems: toMenuItems };
var findIndex = function (list, predicate) {
for (var index = 0; index < list.length; index++) {
var element = list[index];
if (predicate(element)) {
return index;
}
}
return -1;
};
var listState = function (editor, listName) {
return function (e) {
var ctrl = e.control;
editor.on('NodeChange', function (e) {
var tableCellIndex = findIndex(e.parents, $_jbgtb8ijkvrikep.isTableCellNode);
var parents = tableCellIndex !== -1 ? e.parents.slice(0, tableCellIndex) : e.parents;
var lists = global$1.grep(parents, $_jbgtb8ijkvrikep.isListNode(editor));
ctrl.active(lists.length > 0 && lists[0].nodeName === listName);
});
};
};
var updateSelection = function (editor) {
return function (e) {
var listStyleType = $_jbgtb8ijkvrikep.getSelectedStyleType(editor);
e.control.items().each(function (ctrl) {
ctrl.active(ctrl.settings.data === listStyleType);
});
};
};
var addSplitButton = function (editor, id, tooltip, cmd, nodeName, styles) {
editor.addButton(id, {
active: false,
type: 'splitbutton',
tooltip: tooltip,
menu: $_3g7f528jjkvriker.toMenuItems(styles),
onPostRender: listState(editor, nodeName),
onshow: updateSelection(editor),
onselect: function (e) {
$_tr6sy8fjkvrikel.applyListFormat(editor, nodeName, e.control.settings.data);
},
onclick: function () {
editor.execCommand(cmd);
}
});
};
var addButton = function (editor, id, tooltip, cmd, nodeName, styles) {
editor.addButton(id, {
active: false,
type: 'button',
tooltip: tooltip,
onPostRender: listState(editor, nodeName),
onclick: function () {
editor.execCommand(cmd);
}
});
};
var addControl = function (editor, id, tooltip, cmd, nodeName, styles) {
if (styles.length > 0) {
addSplitButton(editor, id, tooltip, cmd, nodeName, styles);
} else {
addButton(editor, id, tooltip, cmd, nodeName, styles);
}
};
var register$1 = function (editor) {
addControl(editor, 'numlist', 'Numbered list', 'InsertOrderedList', 'OL', $_3totu98hjkvrikeo.getNumberStyles(editor));
addControl(editor, 'bullist', 'Bullet list', 'InsertUnorderedList', 'UL', $_3totu98hjkvrikeo.getBulletStyles(editor));
};
var $_19x1qk8gjkvrikem = { register: register$1 };
global.add('advlist', function (editor) {
var hasPlugin = function (editor, plugin) {
var plugins = editor.settings.plugins ? editor.settings.plugins : '';
return global$1.inArray(plugins.split(/[ ,]/), plugin) !== -1;
};
if (hasPlugin(editor, 'lists')) {
$_19x1qk8gjkvrikem.register(editor);
$_3zcr558ejkvrikek.register(editor);
}
});
function Plugin () {
}
return Plugin;
}());
})();
/**
* plugin.js
*
* Released under LGPL License.
* Copyright (c) 1999-2015 Ephox Corp. All rights reserved
*
* License: http://www.tinymce.com/license
* Contributing: http://www.tinymce.com/contributing
*/
(function () {
var anchor = (function () {
'use strict';
/*global tinymce:true */
var global = tinymce.util.Tools.resolve('tinymce.PluginManager');
tinymce.PluginManager.add('anchor', function(editor) {
var isAnchorNode = function (node) {
return !node.attr('href') && (node.attr('id') || node.attr('name')) && !node.firstChild;
};
var isValidId = function (id) {
return /^[A-Za-z][A-Za-z0-9\-:._]*$/.test(id);
};
var getId = function (editor) {
var selectedNode = editor.selection.getNode();
var isAnchor = selectedNode.tagName === 'A' && editor.dom.getAttrib(selectedNode, 'href') === '';
return isAnchor ? selectedNode.id || selectedNode.name : '';
};
var insert = function (editor, id) {
var selectedNode = editor.selection.getNode();
var isAnchor = selectedNode.tagName === 'A' && editor.dom.getAttrib(selectedNode, 'href') === '';
if (isAnchor) {
selectedNode.removeAttribute('name');
selectedNode.id = id;
editor.undoManager.add();
} else {
editor.focus();
editor.selection.collapse(true);
editor.execCommand('mceInsertContent', false, editor.dom.createHTML('a', { id: id }));
}
};
var $_3mpq8e8ojkvrikf7 = {
isValidId: isValidId,
getId: getId,
insert: insert
};
var setContentEditable = function (state) {
return function (nodes) {
for (var i = 0; i < nodes.length; i++) {
if (isAnchorNode(nodes[i])) {
nodes[i].attr('contenteditable', state);
}
}
};
};
var insertAnchor = function (editor, newId) {
if (!$_3mpq8e8ojkvrikf7.isValidId(newId)) {
editor.windowManager.alert('Id should start with a letter, followed only by letters, numbers, dashes, dots, colons or underscores.');
return true;
} else {
$_3mpq8e8ojkvrikf7.insert(editor, newId);
return false;
}
};
var open = function (editor) {
var currentId = $_3mpq8e8ojkvrikf7.getId(editor);
editor.windowManager.open({
title: 'Anchor',
body: {
type: 'textbox',
name: 'id',
size: 40,
label: 'Id',
value: currentId
},
onsubmit: function (e) {
var newId = e.data.id;
if (insertAnchor(editor, newId)) {
e.preventDefault();
}
}
});
};
var $_jtlhu8njkvrikf6 = { open: open };
var isValidId = function (id) {
// Follows HTML4 rules: https://www.w3.org/TR/html401/types.html#type-id
return /^[A-Za-z][A-Za-z0-9\-:._]*$/.test(id);
};
var register = function (editor) {
editor.addCommand('mceAnchor', function () {
$_jtlhu8njkvrikf6.open(editor);
});
};
var $_fq9ajc8mjkvrikf5 = { register: register };
var showDialog = function () {
var selectedNode = editor.selection.getNode();
var isAnchor = selectedNode.tagName == 'A' && editor.dom.getAttrib(selectedNode, 'href') === '';
var value = '';
var isAnchorNode = function (node) {
return !node.attr('href') && (node.attr('id') || node.attr('name')) && !node.firstChild;
};
var setContentEditable = function (state) {
return function (nodes) {
for (var i = 0; i < nodes.length; i++) {
if (isAnchorNode(nodes[i])) {
nodes[i].attr('contenteditable', state);
}
}
};
};
var setup = function (editor) {
editor.on('PreInit', function () {
editor.parser.addNodeFilter('a', setContentEditable('false'));
editor.serializer.addNodeFilter('a', setContentEditable(null));
});
};
var $_bsup2z8pjkvrikf8 = { setup: setup };
if (isAnchor) {
value = selectedNode.id || selectedNode.name || '';
}
var register$1 = function (editor) {
editor.addButton('anchor', {
icon: 'anchor',
tooltip: 'Anchor',
cmd: 'mceAnchor',
stateSelector: 'a:not([href])'
});
editor.addMenuItem('anchor', {
icon: 'anchor',
text: 'Anchor',
context: 'insert',
cmd: 'mceAnchor'
});
};
var $_4ntkbb8qjkvrikf9 = { register: register$1 };
editor.windowManager.open({
title: 'Anchor',
body: {type: 'textbox', name: 'id', size: 40, label: 'Id', value: value},
onsubmit: function(e) {
var id = e.data.id;
global.add('anchor', function (editor) {
$_bsup2z8pjkvrikf8.setup(editor);
$_fq9ajc8mjkvrikf5.register(editor);
$_4ntkbb8qjkvrikf9.register(editor);
});
function Plugin () {
}
if (!isValidId(id)) {
e.preventDefault();
editor.windowManager.alert(
'Id should start with a letter, followed only by letters, numbers, dashes, dots, colons or underscores.'
);
return;
}
return Plugin;
if (isAnchor) {
selectedNode.removeAttribute('name');
selectedNode.id = id;
} else {
editor.selection.collapse(true);
editor.execCommand('mceInsertContent', false, editor.dom.createHTML('a', {
id: id
}));
}
}
});
};
if (tinymce.Env.ceFalse) {