TinyMCE: update to 4.4.0, changelog: https://github.com/tinymce/tinymce/blob/master/changelog.txt. Includes two bugfixes for #36434.

Fixes #37327.
Built from https://develop.svn.wordpress.org/trunk@38034


git-svn-id: http://core.svn.wordpress.org/trunk@37975 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrew Ozz 2016-07-12 00:20:29 +00:00
parent e4eee7ef5c
commit 70fa27a953
13 changed files with 1879 additions and 64 deletions

View File

@ -270,11 +270,17 @@ tinymce.PluginManager.add('lists', function(editor) {
}
}
var shouldMerge = function (listBlock, sibling) {
var targetStyle = editor.dom.getStyle(listBlock, 'list-style-type', true);
var style = editor.dom.getStyle(sibling, 'list-style-type', true);
return targetStyle === style;
};
function mergeWithAdjacentLists(listBlock) {
var sibling, node;
sibling = listBlock.nextSibling;
if (sibling && isListNode(sibling) && sibling.nodeName == listBlock.nodeName) {
if (sibling && isListNode(sibling) && sibling.nodeName == listBlock.nodeName && shouldMerge(listBlock, sibling)) {
while ((node = sibling.firstChild)) {
listBlock.appendChild(node);
}
@ -283,7 +289,7 @@ tinymce.PluginManager.add('lists', function(editor) {
}
sibling = listBlock.previousSibling;
if (sibling && isListNode(sibling) && sibling.nodeName == listBlock.nodeName) {
if (sibling && isListNode(sibling) && sibling.nodeName == listBlock.nodeName && shouldMerge(listBlock, sibling)) {
while ((node = sibling.firstChild)) {
listBlock.insertBefore(node, listBlock.firstChild);
}
@ -394,7 +400,7 @@ tinymce.PluginManager.add('lists', function(editor) {
}
function indent(li) {
var sibling, newList;
var sibling, newList, listStyle;
function mergeLists(from, to) {
var node;
@ -440,6 +446,10 @@ tinymce.PluginManager.add('lists', function(editor) {
sibling = li.previousSibling;
if (sibling && sibling.nodeName == 'LI') {
newList = dom.create(li.parentNode.nodeName);
listStyle = dom.getStyle(li.parentNode, 'listStyleType');
if (listStyle) {
dom.setStyle(newList, 'listStyleType', listStyle);
}
sibling.appendChild(newList);
newList.appendChild(li);
mergeLists(li.lastChild, newList);
@ -505,7 +515,7 @@ tinymce.PluginManager.add('lists', function(editor) {
}
}
function applyList(listName) {
function applyList(listName, detail) {
var rng = selection.getRng(true), bookmark, listItemName = 'LI';
if (dom.getContentEditable(selection.getNode()) === "false") {
@ -600,8 +610,14 @@ tinymce.PluginManager.add('lists', function(editor) {
tinymce.each(getSelectedTextBlocks(), function(block) {
var listBlock, sibling;
var hasCompatibleStyle = function (sib) {
var sibStyle = dom.getStyle(sib, 'list-style-type');
var detailStyle = detail ? detail['list-style-type'] : '';
return sibStyle === detailStyle;
};
sibling = block.previousSibling;
if (sibling && isListNode(sibling) && sibling.nodeName == listName) {
if (sibling && isListNode(sibling) && sibling.nodeName == listName && hasCompatibleStyle(sibling)) {
listBlock = sibling;
block = dom.rename(block, listItemName);
sibling.appendChild(block);
@ -612,12 +628,17 @@ tinymce.PluginManager.add('lists', function(editor) {
block = dom.rename(block, listItemName);
}
updateListStyle(listBlock, detail);
mergeWithAdjacentLists(listBlock);
});
moveToBookmark(bookmark);
}
var updateListStyle = function (el, detail) {
dom.setStyle(el, 'list-style-type', detail ? detail['list-style-type'] : null);
};
function removeList() {
var bookmark = createBookmark(selection.getRng(true)), root = editor.getBody();
@ -645,7 +666,7 @@ tinymce.PluginManager.add('lists', function(editor) {
moveToBookmark(bookmark);
}
function toggleList(listName) {
function toggleList(listName, detail) {
var parentList = dom.getParent(selection.getStart(), 'OL,UL,DL');
if (isEditorBody(parentList)) {
@ -657,11 +678,13 @@ tinymce.PluginManager.add('lists', function(editor) {
removeList(listName);
} else {
var bookmark = createBookmark(selection.getRng(true));
updateListStyle(parentList, detail);
mergeWithAdjacentLists(dom.rename(parentList, listName));
moveToBookmark(bookmark);
}
} else {
applyList(listName);
applyList(listName, detail);
}
}
@ -819,16 +842,16 @@ tinymce.PluginManager.add('lists', function(editor) {
}
});
editor.addCommand('InsertUnorderedList', function() {
toggleList('UL');
editor.addCommand('InsertUnorderedList', function(ui, detail) {
toggleList('UL', detail);
});
editor.addCommand('InsertOrderedList', function() {
toggleList('OL');
editor.addCommand('InsertOrderedList', function(ui, detail) {
toggleList('OL', detail);
});
editor.addCommand('InsertDefinitionList', function() {
toggleList('DL');
editor.addCommand('InsertDefinitionList', function(ui, detail) {
toggleList('DL', detail);
});
editor.addQueryStateHandler('InsertUnorderedList', queryListCommandState('UL'));

File diff suppressed because one or more lines are too long

View File

@ -240,6 +240,95 @@ define("tinymce/pasteplugin/Utils", [
};
});
// Included from: js/tinymce/plugins/paste/classes/SmartPaste.js
/**
* SmartPaste.js
*
* Released under LGPL License.
* Copyright (c) 1999-2016 Ephox Corp. All rights reserved
*
* License: http://www.tinymce.com/license
* Contributing: http://www.tinymce.com/contributing
*/
/**
* Tries to be smart depending on what the user pastes if it looks like an url
* it will make a link out of the current selection. If it's an image url that looks
* like an image it will check if it's an image and insert it as an image.
*
* @class tinymce.pasteplugin.SmartPaste
* @private
*/
define("tinymce/pasteplugin/SmartPaste", [
"tinymce/util/Tools"
], function (Tools) {
var isAbsoluteUrl = function (url) {
return /^https?:\/\/[\w\?\-\/+=.&%]+$/i.test(url);
};
var isImageUrl = function (url) {
return isAbsoluteUrl(url) && /.(gif|jpe?g|jpng)$/.test(url);
};
var createImage = function (editor, url, pasteHtml) {
editor.undoManager.extra(function () {
pasteHtml(url);
}, function () {
editor.insertContent('<img src="' + url + '">');
});
return true;
};
var createLink = function (editor, url, pasteHtml) {
editor.undoManager.extra(function () {
pasteHtml(url);
}, function () {
editor.execCommand('mceInsertLink', false, url);
});
return true;
};
var linkSelection = function (editor, html, pasteHtml) {
return editor.selection.isCollapsed() === false && isAbsoluteUrl(html) ? createLink(editor, html, pasteHtml) : false;
};
var insertImage = function (editor, html, pasteHtml) {
return isImageUrl(html) ? createImage(editor, html, pasteHtml) : false;
};
var insertContent = function (editor, html) {
var pasteHtml = function (html) {
editor.insertContent(html, {
merge: editor.settings.paste_merge_formats !== false,
paste: true
});
return true;
};
var fallback = function (editor, html) {
pasteHtml(html);
};
Tools.each([
linkSelection,
insertImage,
fallback
], function (action) {
return action(editor, html, pasteHtml) !== true;
});
};
return {
isImageUrl: isImageUrl,
isAbsoluteUrl: isAbsoluteUrl,
insertContent: insertContent
};
});
// Included from: js/tinymce/plugins/paste/classes/Clipboard.js
/**
@ -276,8 +365,9 @@ define("tinymce/pasteplugin/Clipboard", [
"tinymce/dom/RangeUtils",
"tinymce/util/VK",
"tinymce/pasteplugin/Utils",
"tinymce/pasteplugin/SmartPaste",
"tinymce/util/Delay"
], function(Env, RangeUtils, VK, Utils, Delay) {
], function(Env, RangeUtils, VK, Utils, SmartPaste, Delay) {
return function(editor) {
var self = this, pasteBinElm, lastRng, keyboardPasteTimeStamp = 0, draggingInternally = false;
var pasteBinDefaultContent = '%MCEPASTEBIN%', keyboardPastePlainTextState;
@ -311,7 +401,7 @@ define("tinymce/pasteplugin/Clipboard", [
}
if (!args.isDefaultPrevented()) {
editor.insertContent(html, {merge: editor.settings.paste_merge_formats !== false, data: {paste: true}});
SmartPaste.insertContent(editor, html);
}
}
}
@ -571,17 +661,6 @@ define("tinymce/pasteplugin/Clipboard", [
return hasContentType(content, 'text/html') || hasContentType(content, 'text/plain');
}
/**
* Checks if the clipboard contains image data if it does it will take that data
* and convert it into a data url image and paste that image at the caret location.
*
* @param {ClipboardEvent} e Paste/drop event object.
* @param {DOMRange} rng Rng object to move selection to.
* @return {Boolean} true/false if the image data was found or not.
*/
function pasteImageData(e, rng) {
var dataTransfer = e.clipboardData || e.dataTransfer;
function getBase64FromUri(uri) {
var idx;
@ -593,21 +672,57 @@ define("tinymce/pasteplugin/Clipboard", [
return null;
}
function processItems(items) {
var i, item, reader, hadImage = false;
function isValidDataUriImage(settings, imgElm) {
return settings.images_dataimg_filter ? settings.images_dataimg_filter(imgElm) : true;
}
function pasteImage(reader, blob) {
function pasteImage(rng, reader, blob) {
if (rng) {
editor.selection.setRng(rng);
rng = null;
}
var dataUri = reader.result;
var base64 = getBase64FromUri(dataUri);
var img = new Image();
img.src = dataUri;
// TODO: Move the bulk of the cache logic to EditorUpload
if (isValidDataUriImage(editor.settings, img)) {
var blobCache = editor.editorUpload.blobCache;
var blobInfo = blobCache.create(uniqueId(), blob, getBase64FromUri(reader.result));
var blobInfo, existingBlobInfo;
existingBlobInfo = blobCache.findFirst(function(cachedBlobInfo) {
return cachedBlobInfo.base64() === base64;
});
if (!existingBlobInfo) {
blobInfo = blobCache.create(uniqueId(), blob, base64);
blobCache.add(blobInfo);
} else {
blobInfo = existingBlobInfo;
}
pasteHtml('<img src="' + blobInfo.blobUri() + '">');
} else {
pasteHtml('<img src="' + dataUri + '">');
}
}
/**
* Checks if the clipboard contains image data if it does it will take that data
* and convert it into a data url image and paste that image at the caret location.
*
* @param {ClipboardEvent} e Paste/drop event object.
* @param {DOMRange} rng Rng object to move selection to.
* @return {Boolean} true/false if the image data was found or not.
*/
function pasteImageData(e, rng) {
var dataTransfer = e.clipboardData || e.dataTransfer;
function processItems(items) {
var i, item, reader, hadImage = false;
if (items) {
for (i = 0; i < items.length; i++) {
@ -617,7 +732,7 @@ define("tinymce/pasteplugin/Clipboard", [
var blob = item.getAsFile ? item.getAsFile() : item;
reader = new FileReader();
reader.onload = pasteImage.bind(null, reader, blob);
reader.onload = pasteImage.bind(null, rng, reader, blob);
reader.readAsDataURL(blob);
e.preventDefault();
@ -874,6 +989,7 @@ define("tinymce/pasteplugin/Clipboard", [
self.pasteHtml = pasteHtml;
self.pasteText = pasteText;
self.pasteImageData = pasteImageData;
editor.on('preInit', function() {
registerEventHandlers();

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -439,7 +439,7 @@ tinymce.ThemeManager.add('modern', function(editor) {
}
function reposition(match) {
var relPos, panelRect, elementRect, contentAreaRect, panel, relRect, testPositions;
var relPos, panelRect, elementRect, contentAreaRect, panel, relRect, testPositions, smallElementWidthThreshold;
if (editor.removed) {
return;
@ -462,6 +462,7 @@ tinymce.ThemeManager.add('modern', function(editor) {
elementRect = getElementRect(match.element);
panelRect = tinymce.DOM.getRect(panel.getEl());
contentAreaRect = tinymce.DOM.getRect(editor.getContentAreaContainer() || editor.getBody());
smallElementWidthThreshold = 25;
// We need to use these instead of the rect values since the style
// size properites might not be the same as the real size for a table
@ -473,7 +474,7 @@ tinymce.ThemeManager.add('modern', function(editor) {
}
// Inflate the elementRect so it doesn't get placed above resize handles
if (editor.selection.controlSelection.isResizable(match.element)) {
if (editor.selection.controlSelection.isResizable(match.element) && elementRect.w < smallElementWidthThreshold) {
elementRect = Rect.inflate(elementRect, 0, 8);
}
@ -485,7 +486,7 @@ tinymce.ThemeManager.add('modern', function(editor) {
movePanelTo(panel, userConstrain(relRect.x, relRect.y, elementRect, contentAreaRect, panelRect));
} else {
// Allow overflow below the editor to avoid placing toolbars ontop of tables
contentAreaRect.h += 40;
contentAreaRect.h += panelRect.h;
elementRect = Rect.intersect(contentAreaRect, elementRect);
if (elementRect) {
@ -505,7 +506,7 @@ tinymce.ThemeManager.add('modern', function(editor) {
}
togglePositionClass(panel, relPos, function(pos1, pos2) {
return (!elementRect || elementRect.w > 40) && pos1 === pos2;
return pos1 === pos2;
});
//drawRect(contentAreaRect, 'blue');

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.6-beta2-38033';
$wp_version = '4.6-beta2-38034';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
@ -18,7 +18,7 @@ $wp_db_version = 37965;
*
* @global string $tinymce_version
*/
$tinymce_version = '4313-20160629';
$tinymce_version = '4400-20160711';
/**
* Holds the required PHP version