- Update to 4.1.2, changelog: https://github.com/tinymce/tinymce/blob/master/changelog.txt
- Update the tests to 4.1.2.
Fixes #28576.

git-svn-id: https://develop.svn.wordpress.org/trunk@29203 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Ozz
2014-07-17 00:58:41 +00:00
parent 50f7313fdd
commit db9a148b34
30 changed files with 6444 additions and 3644 deletions

View File

@@ -170,6 +170,10 @@ define("tinymce/pasteplugin/Utils", [
}
}
html = filter(html, [
/<!\[[^\]]+\]>/g // Conditional comments
]);
walk(domParser.parse(html));
return text;
@@ -182,15 +186,15 @@ define("tinymce/pasteplugin/Utils", [
* @return {String} Html contents that got trimmed.
*/
function trimHtml(html) {
var trimSpaces = function(all, s1, s2) {
function trimSpaces(all, s1, s2) {
// WebKit &nbsp; meant to preserve multiple spaces but instead inserted around all inline tags,
// including the spans with inline stypes created on paste
// including the spans with inline styles created on paste
if (!s1 && !s2) {
return ' ';
}
return '\u00a0';
};
}
html = filter(html, [
/^[\s\S]*<body[^>]*>\s*|\s*<\/body[^>]*>[\s\S]*$/g, // Remove anything but the contents within the BODY element
@@ -535,15 +539,25 @@ define("tinymce/pasteplugin/Clipboard", [
}
function getCaretRangeFromEvent(e) {
var doc = editor.getDoc(), rng;
var doc = editor.getDoc(), rng, point;
if (doc.caretPositionFromPoint) {
var point = doc.caretPositionFromPoint(e.clientX, e.clientY);
point = doc.caretPositionFromPoint(e.clientX, e.clientY);
rng = doc.createRange();
rng.setStart(point.offsetNode, point.offset);
rng.collapse(true);
} else if (doc.caretRangeFromPoint) {
rng = doc.caretRangeFromPoint(e.clientX, e.clientY);
} else if (doc.body.createTextRange) {
rng = doc.body.createTextRange();
try {
rng.moveToPoint(e.clientX, e.clientY);
rng.collapse(true);
} catch (ex) {
// Append to top or bottom depending on drop location
rng.collapse(e.clientY < doc.body.clientHeight);
}
}
return rng;
@@ -835,7 +849,55 @@ define("tinymce/pasteplugin/WordFilter", [
function convertFakeListsToProperLists(node) {
var currentListNode, prevListNode, lastLevel = 1;
function convertParagraphToLi(paragraphNode, listStartTextNode, listName, start) {
function getText(node) {
var txt = '';
if (node.type === 3) {
return node.value;
}
if ((node = node.firstChild)) {
do {
txt += getText(node);
} while ((node = node.next));
}
return txt;
}
function trimListStart(node, regExp) {
if (node.type === 3) {
if (regExp.test(node.value)) {
node.value = node.value.replace(regExp, '');
return false;
}
}
if ((node = node.firstChild)) {
do {
if (!trimListStart(node, regExp)) {
return false;
}
} while ((node = node.next));
}
return true;
}
function removeIgnoredNodes(node) {
if (node._listIgnore) {
node.remove();
return;
}
if ((node = node.firstChild)) {
do {
removeIgnoredNodes(node);
} while ((node = node.next));
}
}
function convertParagraphToLi(paragraphNode, listName, start) {
var level = paragraphNode._listLevel || lastLevel;
// Handle list nesting
@@ -866,12 +928,6 @@ define("tinymce/pasteplugin/WordFilter", [
}
paragraphNode.name = 'li';
listStartTextNode.value = '';
var nextNode = listStartTextNode.next;
if (nextNode && nextNode.type == 3) {
nextNode.value = nextNode.value.replace(/^\u00a0+/, '');
}
// Append list to previous list if it exists
if (level > lastLevel && prevListNode) {
@@ -879,6 +935,12 @@ define("tinymce/pasteplugin/WordFilter", [
}
lastLevel = level;
// Remove start of list item "1. " or "&middot; " etc
removeIgnoredNodes(paragraphNode);
trimListStart(paragraphNode, /^\u00a0+/);
trimListStart(paragraphNode, /^\s*([\u2022\u00b7\u00a7\u00d8\u25CF]|\w+\.)/);
trimListStart(paragraphNode, /^\u00a0+/);
}
var paragraphs = node.getAll('p');
@@ -888,26 +950,17 @@ define("tinymce/pasteplugin/WordFilter", [
if (node.name == 'p' && node.firstChild) {
// Find first text node in paragraph
var nodeText = '';
var nodeText = getText(node);
var listStartTextNode = node.firstChild;
while (listStartTextNode) {
nodeText = listStartTextNode.value;
if (nodeText) {
break;
}
listStartTextNode = listStartTextNode.firstChild;
}
// Detect unordered lists look for bullets
if (/^\s*[\u2022\u00b7\u00a7\u00d8\u25CF]\s*$/.test(nodeText)) {
convertParagraphToLi(node, listStartTextNode, 'ul');
if (/^[\s\u00a0]*[\u2022\u00b7\u00a7\u00d8\u25CF]\s*/.test(nodeText)) {
convertParagraphToLi(node, 'ul');
continue;
}
// Detect ordered lists 1., a. or ixv.
if (/^\s*\w+\.$/.test(nodeText)) {
if (/^[\s\u00a0]*\w+\./.test(nodeText) && !/^[\s\u00a0]*\w+\.\s*[^\s]+/.test(listStartTextNode.value)) {
// Parse OL start number
var matches = /([0-9])\./.exec(nodeText);
var start = 1;
@@ -915,7 +968,13 @@ define("tinymce/pasteplugin/WordFilter", [
start = parseInt(matches[1], 10);
}
convertParagraphToLi(node, listStartTextNode, 'ol', start);
convertParagraphToLi(node, 'ol', start);
continue;
}
// Convert paragraphs marked as lists but doesn't look like anything
if (node._listLevel) {
convertParagraphToLi(node, 'ul', 1);
continue;
}
@@ -925,20 +984,27 @@ define("tinymce/pasteplugin/WordFilter", [
}
function filterStyles(node, styleValue) {
var outputStyles = {}, styles = editor.dom.parseStyle(styleValue);
// Parse out list indent level for lists
if (node.name === 'p') {
var matches = /mso-list:\w+ \w+([0-9]+)/.exec(styleValue);
if (matches) {
node._listLevel = parseInt(matches[1], 10);
}
}
var outputStyles = {}, matches, styles = editor.dom.parseStyle(styleValue);
Tools.each(styles, function(value, name) {
// Convert various MS styles to W3C styles
switch (name) {
case 'mso-list':
// Parse out list indent level for lists
matches = /\w+ \w+([0-9]+)/i.exec(styleValue);
if (matches) {
node._listLevel = parseInt(matches[1], 10);
}
// Remove these nodes <span style="mso-list:Ignore">o</span>
// Since the span gets removed we mark the text node and the span
if (/Ignore/i.test(value) && node.firstChild) {
node._listIgnore = true;
node.firstChild._listIgnore = true;
}
break;
case "horiz-align":
name = "text-align";
break;
@@ -1096,7 +1162,7 @@ define("tinymce/pasteplugin/WordFilter", [
node = nodes[i];
className = node.attr('class');
if (/^(MsoCommentReference|MsoCommentText|msoDel)$/i.test(className)) {
if (/^(MsoCommentReference|MsoCommentText|msoDel|MsoCaption)$/i.test(className)) {
node.remove();
}
@@ -1304,7 +1370,7 @@ define("tinymce/pasteplugin/Quirks", [
return before + ' style="' + outputStyles + '"' + after;
}
return '';
return before + after;
});
} else {
// Remove all external styles
@@ -1443,5 +1509,5 @@ define("tinymce/pasteplugin/Plugin", [
});
});
expose(["tinymce/pasteplugin/Utils","tinymce/pasteplugin/Clipboard","tinymce/pasteplugin/WordFilter","tinymce/pasteplugin/Quirks","tinymce/pasteplugin/Plugin"]);
expose(["tinymce/pasteplugin/Utils","tinymce/pasteplugin/WordFilter"]);
})(this);

File diff suppressed because one or more lines are too long