mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-04-05 05:04:31 +00:00
TinyMCE: update to 4.4.0, changelog: https://github.com/tinymce/tinymce/blob/master/changelog.txt. Includes two bugfixes for #36434.
Fixes #37327. git-svn-id: https://develop.svn.wordpress.org/trunk@38034 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -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
@@ -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,6 +661,55 @@ define("tinymce/pasteplugin/Clipboard", [
|
||||
return hasContentType(content, 'text/html') || hasContentType(content, 'text/plain');
|
||||
}
|
||||
|
||||
function getBase64FromUri(uri) {
|
||||
var idx;
|
||||
|
||||
idx = uri.indexOf(',');
|
||||
if (idx !== -1) {
|
||||
return uri.substr(idx + 1);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
function isValidDataUriImage(settings, imgElm) {
|
||||
return settings.images_dataimg_filter ? settings.images_dataimg_filter(imgElm) : true;
|
||||
}
|
||||
|
||||
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, 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.
|
||||
@@ -582,33 +721,9 @@ define("tinymce/pasteplugin/Clipboard", [
|
||||
function pasteImageData(e, rng) {
|
||||
var dataTransfer = e.clipboardData || e.dataTransfer;
|
||||
|
||||
function getBase64FromUri(uri) {
|
||||
var idx;
|
||||
|
||||
idx = uri.indexOf(',');
|
||||
if (idx !== -1) {
|
||||
return uri.substr(idx + 1);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
function processItems(items) {
|
||||
var i, item, reader, hadImage = false;
|
||||
|
||||
function pasteImage(reader, blob) {
|
||||
if (rng) {
|
||||
editor.selection.setRng(rng);
|
||||
rng = null;
|
||||
}
|
||||
|
||||
var blobCache = editor.editorUpload.blobCache;
|
||||
var blobInfo = blobCache.create(uniqueId(), blob, getBase64FromUri(reader.result));
|
||||
blobCache.add(blobInfo);
|
||||
|
||||
pasteHtml('<img src="' + blobInfo.blobUri() + '">');
|
||||
}
|
||||
|
||||
if (items) {
|
||||
for (i = 0; i < items.length; i++) {
|
||||
item = items[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
1674
src/wp-includes/js/tinymce/themes/inlite/theme.js
Normal file
1674
src/wp-includes/js/tinymce/themes/inlite/theme.js
Normal file
File diff suppressed because it is too large
Load Diff
1
src/wp-includes/js/tinymce/themes/inlite/theme.min.js
vendored
Normal file
1
src/wp-includes/js/tinymce/themes/inlite/theme.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@@ -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
@@ -1,4 +1,4 @@
|
||||
// 4.3.13 (2016-06-08)
|
||||
// 4.4.0 (2016-06-30)
|
||||
|
||||
/**
|
||||
* Compiled inline version. (Library mode)
|
||||
@@ -10580,6 +10580,11 @@ define("tinymce/dom/RangeUtils", [
|
||||
container = container.childNodes[offset];
|
||||
offset = 0;
|
||||
|
||||
// Don't normalize non collapsed selections like <p>[a</p><table></table>]
|
||||
if (!collapsed && container === body.lastChild && container.nodeName === 'TABLE') {
|
||||
return;
|
||||
}
|
||||
|
||||
if (hasContentEditableFalseParent(container) || isCaretContainer(container)) {
|
||||
return;
|
||||
}
|
||||
@@ -17356,8 +17361,9 @@ define("tinymce/dom/Selection", [
|
||||
"tinymce/dom/BookmarkManager",
|
||||
"tinymce/dom/NodeType",
|
||||
"tinymce/Env",
|
||||
"tinymce/util/Tools"
|
||||
], function(TreeWalker, TridentSelection, ControlSelection, RangeUtils, BookmarkManager, NodeType, Env, Tools) {
|
||||
"tinymce/util/Tools",
|
||||
"tinymce/caret/CaretPosition"
|
||||
], function(TreeWalker, TridentSelection, ControlSelection, RangeUtils, BookmarkManager, NodeType, Env, Tools, CaretPosition) {
|
||||
var each = Tools.each, trim = Tools.trim;
|
||||
var isIE = Env.ie;
|
||||
|
||||
@@ -18333,6 +18339,11 @@ define("tinymce/dom/Selection", [
|
||||
}
|
||||
},
|
||||
|
||||
getBoundingClientRect: function() {
|
||||
var rng = this.getRng();
|
||||
return rng.collapsed ? CaretPosition.fromRangeStart(rng).getClientRects()[0] : rng.getBoundingClientRect();
|
||||
},
|
||||
|
||||
destroy: function() {
|
||||
this.win = null;
|
||||
this.controlSelection.destroy();
|
||||
@@ -21420,6 +21431,7 @@ define("tinymce/UndoManager", [
|
||||
data = [];
|
||||
index = 0;
|
||||
self.typing = false;
|
||||
self.data = data;
|
||||
editor.fire('ClearUndos');
|
||||
},
|
||||
|
||||
@@ -21445,13 +21457,14 @@ define("tinymce/UndoManager", [
|
||||
},
|
||||
|
||||
/**
|
||||
* Executes the specified function in an undo translation. The selection
|
||||
* Executes the specified mutator function as an undo transaction. The selection
|
||||
* before the modification will be stored to the undo stack and if the DOM changes
|
||||
* it will add a new undo level. Any methods within the translation that adds undo levels will
|
||||
* be ignored. So a translation can include calls to execCommand or editor.insertContent.
|
||||
*
|
||||
* @method transact
|
||||
* @param {function} callback Function to execute dom manipulation logic in.
|
||||
* @param {function} callback Function that gets executed and has dom manipulation logic in it.
|
||||
* @return {Object} Undo level that got added or null it a level wasn't needed.
|
||||
*/
|
||||
transact: function(callback) {
|
||||
self.beforeChange();
|
||||
@@ -21463,7 +21476,31 @@ define("tinymce/UndoManager", [
|
||||
locks--;
|
||||
}
|
||||
|
||||
self.add();
|
||||
return self.add();
|
||||
},
|
||||
|
||||
/**
|
||||
* Adds an extra "hidden" undo level by first applying the first mutation and store that to the undo stack
|
||||
* then roll back that change and do the second mutation on top of the stack. This will produce an extra
|
||||
* undo level that the user doesn't see until they undo.
|
||||
*
|
||||
* @method extra
|
||||
* @param {function} callback1 Function that does mutation but gets stored as a "hidden" extra undo level.
|
||||
* @param {function} callback2 Function that does mutation but gets displayed to the user.
|
||||
*/
|
||||
extra: function (callback1, callback2) {
|
||||
var lastLevel, bookmark;
|
||||
|
||||
if (self.transact(callback1)) {
|
||||
bookmark = data[index].bookmark;
|
||||
lastLevel = data[index - 1];
|
||||
editor.setContent(lastLevel.content, {format: 'raw'});
|
||||
editor.selection.moveToBookmark(lastLevel.beforeBookmark);
|
||||
|
||||
if (self.transact(callback2)) {
|
||||
data[index - 1].beforeBookmark = bookmark;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -23050,9 +23087,9 @@ define("tinymce/InsertContent", [
|
||||
], function(Env, Tools, Serializer, CaretWalker, CaretPosition, ElementUtils, NodeType, InsertList) {
|
||||
var isTableCell = NodeType.matchNodeNames('td th');
|
||||
|
||||
var insertAtCaret = function(editor, value) {
|
||||
var insertHtmlAtCaret = function(editor, value, details) {
|
||||
var parser, serializer, parentNode, rootNode, fragment, args;
|
||||
var marker, rng, node, node2, bookmarkHtml, merge, data;
|
||||
var marker, rng, node, node2, bookmarkHtml, merge;
|
||||
var textInlineElements = editor.schema.getTextInlineElements();
|
||||
var selection = editor.selection, dom = editor.dom;
|
||||
|
||||
@@ -23109,25 +23146,13 @@ define("tinymce/InsertContent", [
|
||||
}
|
||||
}
|
||||
|
||||
function markInlineFormatElements(fragment) {
|
||||
if (merge) {
|
||||
for (node = fragment.firstChild; node; node = node.walk(true)) {
|
||||
if (textInlineElements[node.name]) {
|
||||
node.attr('data-mce-new', "true");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function reduceInlineTextElements() {
|
||||
if (merge) {
|
||||
var root = editor.getBody(), elementUtils = new ElementUtils(dom);
|
||||
|
||||
Tools.each(dom.select('*[data-mce-new]'), function(node) {
|
||||
node.removeAttribute('data-mce-new');
|
||||
|
||||
Tools.each(dom.select('*[data-mce-fragment]'), function(node) {
|
||||
for (var testNode = node.parentNode; testNode && testNode != root; testNode = testNode.parentNode) {
|
||||
if (elementUtils.compare(testNode, node)) {
|
||||
if (textInlineElements[node.nodeName.toLowerCase()] && elementUtils.compare(testNode, node)) {
|
||||
dom.remove(node, true);
|
||||
}
|
||||
}
|
||||
@@ -23241,12 +23266,6 @@ define("tinymce/InsertContent", [
|
||||
selection.setRng(rng);
|
||||
}
|
||||
|
||||
if (typeof value != 'string') {
|
||||
merge = value.merge;
|
||||
data = value.data;
|
||||
value = value.content;
|
||||
}
|
||||
|
||||
// Check for whitespace before/after value
|
||||
if (/^ | $/.test(value)) {
|
||||
value = trimOrPaddLeftRight(value);
|
||||
@@ -23254,6 +23273,8 @@ define("tinymce/InsertContent", [
|
||||
|
||||
// Setup parser and serializer
|
||||
parser = editor.parser;
|
||||
merge = details.merge;
|
||||
|
||||
serializer = new Serializer({
|
||||
validate: editor.settings.validate
|
||||
}, editor.schema);
|
||||
@@ -23297,7 +23318,7 @@ define("tinymce/InsertContent", [
|
||||
parentNode = selection.getNode();
|
||||
|
||||
// Parse the fragment within the context of the parent node
|
||||
var parserArgs = {context: parentNode.nodeName.toLowerCase(), data: data};
|
||||
var parserArgs = {context: parentNode.nodeName.toLowerCase(), data: details.data};
|
||||
fragment = parser.parse(value, parserArgs);
|
||||
|
||||
// Custom handling of lists
|
||||
@@ -23309,7 +23330,6 @@ define("tinymce/InsertContent", [
|
||||
}
|
||||
|
||||
markFragmentElements(fragment);
|
||||
markInlineFormatElements(fragment);
|
||||
|
||||
// Move the caret to a more suitable location
|
||||
node = fragment.lastChild;
|
||||
@@ -23388,6 +23408,34 @@ define("tinymce/InsertContent", [
|
||||
editor.addVisual();
|
||||
};
|
||||
|
||||
var processValue = function (value) {
|
||||
var details;
|
||||
|
||||
if (typeof value !== 'string') {
|
||||
details = Tools.extend({
|
||||
paste: value.paste,
|
||||
data: {
|
||||
paste: value.paste
|
||||
}
|
||||
}, value);
|
||||
|
||||
return {
|
||||
content: value.content,
|
||||
details: details
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
content: value,
|
||||
details: {}
|
||||
};
|
||||
};
|
||||
|
||||
var insertAtCaret = function (editor, value) {
|
||||
var result = processValue(value);
|
||||
insertHtmlAtCaret(editor, result.content, result.details);
|
||||
};
|
||||
|
||||
return {
|
||||
insertAtCaret: insertAtCaret
|
||||
};
|
||||
@@ -31802,8 +31850,10 @@ define("tinymce/util/Quirks", [
|
||||
"tinymce/Env",
|
||||
"tinymce/util/Tools",
|
||||
"tinymce/util/Delay",
|
||||
"tinymce/caret/CaretContainer"
|
||||
], function(VK, RangeUtils, TreeWalker, NodePath, Node, Entities, Env, Tools, Delay, CaretContainer) {
|
||||
"tinymce/caret/CaretContainer",
|
||||
"tinymce/caret/CaretPosition",
|
||||
"tinymce/caret/CaretWalker"
|
||||
], function(VK, RangeUtils, TreeWalker, NodePath, Node, Entities, Env, Tools, Delay, CaretContainer, CaretPosition, CaretWalker) {
|
||||
return function(editor) {
|
||||
var each = Tools.each, $ = editor.$;
|
||||
var BACKSPACE = VK.BACKSPACE, DELETE = VK.DELETE, dom = editor.dom, selection = editor.selection,
|
||||
@@ -33435,6 +33485,46 @@ define("tinymce/util/Quirks", [
|
||||
return (!sel || !sel.rangeCount || sel.rangeCount === 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Properly empties the editor if all contents is selected and deleted this to
|
||||
* prevent empty paragraphs from being produced at beginning/end of contents.
|
||||
*/
|
||||
function emptyEditorOnDeleteEverything() {
|
||||
function isEverythingSelected(editor) {
|
||||
var caretWalker = new CaretWalker(editor.getBody());
|
||||
var rng = editor.selection.getRng();
|
||||
var startCaretPos = CaretPosition.fromRangeStart(rng);
|
||||
var endCaretPos = CaretPosition.fromRangeEnd(rng);
|
||||
|
||||
return !editor.selection.isCollapsed() && !caretWalker.prev(startCaretPos) && !caretWalker.next(endCaretPos);
|
||||
}
|
||||
|
||||
// Type over case delete and insert this won't cover typeover with a IME but at least it covers the common case
|
||||
editor.on('keypress', function (e) {
|
||||
if (!isDefaultPrevented(e) && !selection.isCollapsed() && e.charCode > 31 && !VK.metaKeyPressed(e)) {
|
||||
if (isEverythingSelected(editor)) {
|
||||
e.preventDefault();
|
||||
editor.setContent(String.fromCharCode(e.charCode));
|
||||
editor.selection.select(editor.getBody(), true);
|
||||
editor.selection.collapse(false);
|
||||
editor.nodeChanged();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
editor.on('keydown', function (e) {
|
||||
var keyCode = e.keyCode;
|
||||
|
||||
if (!isDefaultPrevented(e) && (keyCode == DELETE || keyCode == BACKSPACE)) {
|
||||
if (isEverythingSelected(editor)) {
|
||||
e.preventDefault();
|
||||
editor.setContent('');
|
||||
editor.nodeChanged();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// All browsers
|
||||
removeBlockQuoteOnBackSpace();
|
||||
emptyEditorWhenDeleting();
|
||||
@@ -33447,6 +33537,7 @@ define("tinymce/util/Quirks", [
|
||||
|
||||
// WebKit
|
||||
if (isWebKit) {
|
||||
emptyEditorOnDeleteEverything();
|
||||
cleanupStylesWhenDeleting();
|
||||
inputMethodFocus();
|
||||
selectControlElements();
|
||||
@@ -33454,6 +33545,7 @@ define("tinymce/util/Quirks", [
|
||||
blockFormSubmitInsideEditor();
|
||||
disableBackspaceIntoATable();
|
||||
removeAppleInterchangeBrs();
|
||||
|
||||
//touchClickEvent();
|
||||
|
||||
// iOS
|
||||
@@ -33491,6 +33583,7 @@ define("tinymce/util/Quirks", [
|
||||
|
||||
// Gecko
|
||||
if (isGecko) {
|
||||
emptyEditorOnDeleteEverything();
|
||||
removeHrOnBackspace();
|
||||
focusBody();
|
||||
removeStylesWhenDeletingAcrossBlockElements();
|
||||
@@ -35584,6 +35677,7 @@ define("tinymce/DragDropOverrides", [
|
||||
}
|
||||
|
||||
if (state.dragging) {
|
||||
editor._selectionOverrides.hideFakeCaret();
|
||||
editor.selection.placeCaretAt(e.clientX, e.clientY);
|
||||
|
||||
clientX = state.clientX + deltaX - state.relX;
|
||||
@@ -35612,8 +35706,8 @@ define("tinymce/DragDropOverrides", [
|
||||
}
|
||||
}
|
||||
|
||||
function drop() {
|
||||
var evt;
|
||||
function drop(evt) {
|
||||
var dropEvt;
|
||||
|
||||
if (state.dragging) {
|
||||
// Hack for IE since it doesn't sync W3C Range with IE Specific range
|
||||
@@ -35622,12 +35716,18 @@ define("tinymce/DragDropOverrides", [
|
||||
if (isValidDropTarget(editor.selection.getNode())) {
|
||||
var targetClone = state.element;
|
||||
|
||||
evt = editor.fire('drop', {targetClone: targetClone});
|
||||
if (evt.isDefaultPrevented()) {
|
||||
// Pass along clientX, clientY if we have them
|
||||
dropEvt = editor.fire('drop', {
|
||||
targetClone: targetClone,
|
||||
clientX: evt.clientX,
|
||||
clientY: evt.clientY
|
||||
});
|
||||
|
||||
if (dropEvt.isDefaultPrevented()) {
|
||||
return;
|
||||
}
|
||||
|
||||
targetClone = evt.targetClone;
|
||||
targetClone = dropEvt.targetClone;
|
||||
|
||||
editor.undoManager.transact(function() {
|
||||
editor.insertContent(dom.getOuterHTML(targetClone));
|
||||
@@ -35693,7 +35793,8 @@ define("tinymce/DragDropOverrides", [
|
||||
|
||||
// Blocks drop inside cE=false on IE
|
||||
editor.on('drop', function(e) {
|
||||
var realTarget = editor.getDoc().elementFromPoint(e.clientX, e.clientY);
|
||||
// FF doesn't pass out clientX/clientY for drop since this is for IE we just use null instead
|
||||
var realTarget = typeof e.clientX !== 'undefined' ? editor.getDoc().elementFromPoint(e.clientX, e.clientY) : null;
|
||||
|
||||
if (isContentEditableFalse(realTarget) || isContentEditableFalse(editor.dom.getContentEditableParent(realTarget))) {
|
||||
e.preventDefault();
|
||||
@@ -36169,8 +36270,8 @@ define("tinymce/SelectionOverrides", [
|
||||
return toCaretPosition.toRange();
|
||||
}
|
||||
|
||||
function backspaceDelete(direction, beforeFn, range) {
|
||||
var node, caretPosition, peekCaretPosition;
|
||||
function backspaceDelete(direction, beforeFn, afterFn, range) {
|
||||
var node, caretPosition, peekCaretPosition, newCaretPosition;
|
||||
|
||||
if (!range.collapsed) {
|
||||
node = getSelectedNode(range);
|
||||
@@ -36181,6 +36282,11 @@ define("tinymce/SelectionOverrides", [
|
||||
|
||||
caretPosition = getNormalizedRangeEndPoint(direction, range);
|
||||
|
||||
if (afterFn(caretPosition) && CaretContainer.isCaretContainerBlock(range.startContainer)) {
|
||||
newCaretPosition = direction == -1 ? caretWalker.prev(caretPosition) : caretWalker.next(caretPosition);
|
||||
return newCaretPosition ? renderRangeCaret(newCaretPosition.toRange()) : range;
|
||||
}
|
||||
|
||||
if (beforeFn(caretPosition)) {
|
||||
return renderRangeCaret(deleteContentEditableNode(caretPosition.getNode(direction == -1)));
|
||||
}
|
||||
@@ -36198,8 +36304,8 @@ define("tinymce/SelectionOverrides", [
|
||||
function registerEvents() {
|
||||
var right = curry(moveH, 1, getNextVisualCaretPosition, isBeforeContentEditableFalse);
|
||||
var left = curry(moveH, -1, getPrevVisualCaretPosition, isAfterContentEditableFalse);
|
||||
var deleteForward = curry(backspaceDelete, 1, isBeforeContentEditableFalse);
|
||||
var backspace = curry(backspaceDelete, -1, isAfterContentEditableFalse);
|
||||
var deleteForward = curry(backspaceDelete, 1, isBeforeContentEditableFalse, isAfterContentEditableFalse);
|
||||
var backspace = curry(backspaceDelete, -1, isAfterContentEditableFalse, isBeforeContentEditableFalse);
|
||||
var up = curry(moveV, -1, LineWalker.upUntil);
|
||||
var down = curry(moveV, 1, LineWalker.downUntil);
|
||||
|
||||
@@ -36562,7 +36668,6 @@ define("tinymce/SelectionOverrides", [
|
||||
top: dom.getPos(node, editor.getBody()).y
|
||||
});
|
||||
|
||||
editor.getBody().focus();
|
||||
$realSelectionContainer[0].focus();
|
||||
sel = editor.selection.getSel();
|
||||
sel.removeAllRanges();
|
||||
@@ -36588,6 +36693,10 @@ define("tinymce/SelectionOverrides", [
|
||||
selectedContentEditableNode = null;
|
||||
}
|
||||
|
||||
function hideFakeCaret() {
|
||||
fakeCaret.hide();
|
||||
}
|
||||
|
||||
if (Env.ceFalse) {
|
||||
registerEvents();
|
||||
addCss();
|
||||
@@ -36595,6 +36704,7 @@ define("tinymce/SelectionOverrides", [
|
||||
|
||||
return {
|
||||
showBlockCaretContainer: showBlockCaretContainer,
|
||||
hideFakeCaret: hideFakeCaret,
|
||||
destroy: destroy
|
||||
};
|
||||
}
|
||||
@@ -36602,6 +36712,45 @@ define("tinymce/SelectionOverrides", [
|
||||
return SelectionOverrides;
|
||||
});
|
||||
|
||||
// Included from: js/tinymce/classes/util/Uuid.js
|
||||
|
||||
/**
|
||||
* Uuid.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
|
||||
*/
|
||||
|
||||
/**
|
||||
* Generates unique ids.
|
||||
*
|
||||
* @class tinymce.util.Uuid
|
||||
* @private
|
||||
*/
|
||||
define("tinymce/util/Uuid", [
|
||||
], function() {
|
||||
var count = 0;
|
||||
|
||||
var seed = function () {
|
||||
var rnd = function () {
|
||||
return Math.round(Math.random() * 0xFFFFFFFF).toString(36);
|
||||
};
|
||||
|
||||
return 's' + Date.now().toString(36) + rnd() + rnd() + rnd();
|
||||
};
|
||||
|
||||
var uuid = function (prefix) {
|
||||
return prefix + (count++) + seed();
|
||||
};
|
||||
|
||||
return {
|
||||
uuid: uuid
|
||||
};
|
||||
});
|
||||
|
||||
// Included from: js/tinymce/classes/Editor.js
|
||||
|
||||
/**
|
||||
@@ -36675,13 +36824,14 @@ define("tinymce/Editor", [
|
||||
"tinymce/Mode",
|
||||
"tinymce/Shortcuts",
|
||||
"tinymce/EditorUpload",
|
||||
"tinymce/SelectionOverrides"
|
||||
"tinymce/SelectionOverrides",
|
||||
"tinymce/util/Uuid"
|
||||
], function(
|
||||
DOMUtils, DomQuery, AddOnManager, NodeChange, Node, DomSerializer, Serializer,
|
||||
Selection, Formatter, UndoManager, EnterKey, ForceBlocks, EditorCommands,
|
||||
URI, ScriptLoader, EventUtils, WindowManager, NotificationManager,
|
||||
Schema, DomParser, Quirks, Env, Tools, Delay, EditorObservable, Mode, Shortcuts, EditorUpload,
|
||||
SelectionOverrides
|
||||
SelectionOverrides, Uuid
|
||||
) {
|
||||
// Shorten these names
|
||||
var DOM = DOMUtils.DOM, ThemeManager = AddOnManager.ThemeManager, PluginManager = AddOnManager.PluginManager;
|
||||
@@ -36857,6 +37007,7 @@ define("tinymce/Editor", [
|
||||
self.suffix = editorManager.suffix;
|
||||
self.editorManager = editorManager;
|
||||
self.inline = settings.inline;
|
||||
self.settings.content_editable = self.inline;
|
||||
|
||||
if (settings.cache_suffix) {
|
||||
Env.cacheSuffix = settings.cache_suffix.replace(/^[\?\&]+/, '');
|
||||
@@ -37974,6 +38125,7 @@ define("tinymce/Editor", [
|
||||
}
|
||||
|
||||
self.contextToolbars.push({
|
||||
id: Uuid.uuid('mcet'),
|
||||
predicate: predicate,
|
||||
items: items
|
||||
});
|
||||
@@ -39149,9 +39301,9 @@ define("tinymce/FocusManager", [
|
||||
// Gecko doesn't have the "selectionchange" event we need to do this. Fixes: #6843
|
||||
if (editor.inline && !documentMouseUpHandler) {
|
||||
documentMouseUpHandler = function(e) {
|
||||
var activeEditor = editorManager.activeEditor;
|
||||
var activeEditor = editorManager.activeEditor, dom = activeEditor.dom;
|
||||
|
||||
if (activeEditor.inline && !activeEditor.dom.isChildOf(e.target, activeEditor.getBody())) {
|
||||
if (activeEditor.inline && dom && !dom.isChildOf(e.target, activeEditor.getBody())) {
|
||||
var rng = activeEditor.selection.getRng();
|
||||
|
||||
if (!rng.collapsed) {
|
||||
@@ -39318,7 +39470,7 @@ define("tinymce/EditorManager", [
|
||||
* @property minorVersion
|
||||
* @type String
|
||||
*/
|
||||
minorVersion: '3.13',
|
||||
minorVersion: '4.0',
|
||||
|
||||
/**
|
||||
* Release date of TinyMCE build.
|
||||
@@ -39326,7 +39478,7 @@ define("tinymce/EditorManager", [
|
||||
* @property releaseDate
|
||||
* @type String
|
||||
*/
|
||||
releaseDate: '2016-06-08',
|
||||
releaseDate: '2016-06-30',
|
||||
|
||||
/**
|
||||
* Collection of editor instances.
|
||||
@@ -39491,7 +39643,24 @@ define("tinymce/EditorManager", [
|
||||
* });
|
||||
*/
|
||||
init: function(settings) {
|
||||
var self = this, result;
|
||||
var self = this, result, invalidInlineTargets;
|
||||
|
||||
invalidInlineTargets = Tools.makeMap(
|
||||
'area base basefont br col frame hr img input isindex link meta param embed source wbr track ' +
|
||||
'colgroup option tbody tfoot thead tr script noscript style textarea video audio iframe object menu',
|
||||
' '
|
||||
);
|
||||
|
||||
function isInvalidInlineTarget(settings, elm) {
|
||||
return settings.inline && elm.tagName.toLowerCase() in invalidInlineTargets;
|
||||
}
|
||||
|
||||
function report(msg, elm) {
|
||||
// Log in a non test environment
|
||||
if (window.console && !window.test) {
|
||||
window.console.log(msg, elm);
|
||||
}
|
||||
}
|
||||
|
||||
function createId(elm) {
|
||||
var id = elm.id;
|
||||
@@ -39637,7 +39806,11 @@ define("tinymce/EditorManager", [
|
||||
});
|
||||
|
||||
each(targets, function(elm) {
|
||||
createEditor(createId(elm), settings, elm);
|
||||
if (isInvalidInlineTarget(settings, elm)) {
|
||||
report('Could not initialize inline editor on invalid inline target element', elm);
|
||||
} else {
|
||||
createEditor(createId(elm), settings, elm);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
26
src/wp-includes/js/tinymce/tinymce.min.js
vendored
26
src/wp-includes/js/tinymce/tinymce.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user