mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-11 12:20:22 +00:00
TinyMCE: update to 4.0.28. Also includes https://github.com/tinymce/tinymce/commit/43fff5b45344e0101d7d75d8e3c01e9758f0d20f. Part-props avryl for the patch on #27941, fixes #28391, #27941.
git-svn-id: https://develop.svn.wordpress.org/trunk@28606 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -98,17 +98,25 @@ tinymce.PluginManager.add('image', function(editor) {
|
||||
}
|
||||
|
||||
function buildImageList() {
|
||||
var imageListItems = [{text: 'None', value: ''}];
|
||||
function appendItems(values, output) {
|
||||
output = output || [];
|
||||
|
||||
tinymce.each(imageList, function(image) {
|
||||
imageListItems.push({
|
||||
text: image.text || image.title,
|
||||
value: editor.convertURL(image.value || image.url, 'src'),
|
||||
menu: image.menu
|
||||
tinymce.each(values, function(value) {
|
||||
var item = {text: value.text || value.title};
|
||||
|
||||
if (value.menu) {
|
||||
item.menu = appendItems(value.menu);
|
||||
} else {
|
||||
item.value = editor.convertURL(value.value || value.url, 'src');
|
||||
}
|
||||
|
||||
output.push(item);
|
||||
});
|
||||
});
|
||||
|
||||
return imageListItems;
|
||||
return output;
|
||||
}
|
||||
|
||||
return appendItems(imageList, [{text: 'None', value: ''}]);
|
||||
}
|
||||
|
||||
function recalcSize() {
|
||||
@@ -284,7 +292,7 @@ tinymce.PluginManager.add('image', function(editor) {
|
||||
altCtrl.value(e.control.text());
|
||||
}
|
||||
|
||||
win.find('#src').value(e.control.value());
|
||||
win.find('#src').value(e.control.value()).fire('change');
|
||||
},
|
||||
onPostRender: function() {
|
||||
imageListCtrl = this;
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
@@ -175,9 +175,27 @@ define("tinymce/pasteplugin/Utils", [
|
||||
return text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Trims the specified HTML by removing all WebKit fragments, all elements wrapping the body trailing BR elements etc.
|
||||
*
|
||||
* @param {String} html Html string to trim contents on.
|
||||
* @return {String} Html contents that got trimmed.
|
||||
*/
|
||||
function trimHtml(html) {
|
||||
html = filter(html, [
|
||||
/^[\s\S]*<body[^>]*>\s*|\s*<\/body[^>]*>[\s\S]*$/g, // Remove anything but the contents within the BODY element
|
||||
/<!--StartFragment-->|<!--EndFragment-->/g, // Inner fragments (tables from excel on mac)
|
||||
[/<span class="Apple-converted-space">\u00a0<\/span>/g, '\u00a0'], // WebKit
|
||||
/<br>$/i // Trailing BR elements
|
||||
]);
|
||||
|
||||
return html;
|
||||
}
|
||||
|
||||
return {
|
||||
filter: filter,
|
||||
innerText: innerText
|
||||
innerText: innerText,
|
||||
trimHtml: trimHtml
|
||||
};
|
||||
});
|
||||
|
||||
@@ -248,7 +266,7 @@ define("tinymce/pasteplugin/Clipboard", [
|
||||
}
|
||||
|
||||
if (!args.isDefaultPrevented()) {
|
||||
editor.insertContent(html);
|
||||
editor.insertContent(html, {merge: editor.settings.paste_merge_formats !== false});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -382,7 +400,6 @@ define("tinymce/pasteplugin/Clipboard", [
|
||||
}
|
||||
}
|
||||
|
||||
keyboardPastePlainTextState = false;
|
||||
pasteBinElm = lastRng = null;
|
||||
}
|
||||
|
||||
@@ -492,6 +509,18 @@ define("tinymce/pasteplugin/Clipboard", [
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Chrome on Andoid doesn't support proper clipboard access so we have no choice but to allow the browser default behavior.
|
||||
*
|
||||
* @param {Event} e Paste event object to check if it contains any data.
|
||||
* @return {Boolean} true/false if the clipboard is empty or not.
|
||||
*/
|
||||
function isBrokenAndoidClipboardEvent(e) {
|
||||
var clipboardData = e.clipboardData;
|
||||
|
||||
return navigator.userAgent.indexOf('Android') != -1 && clipboardData && clipboardData.items && clipboardData.items.length === 0;
|
||||
}
|
||||
|
||||
function getCaretRangeFromEvent(e) {
|
||||
var doc = editor.getDoc(), rng;
|
||||
|
||||
@@ -511,16 +540,22 @@ define("tinymce/pasteplugin/Clipboard", [
|
||||
return mimeType in clipboardContent && clipboardContent[mimeType].length > 0;
|
||||
}
|
||||
|
||||
function isKeyboardPasteEvent(e) {
|
||||
return (VK.metaKeyPressed(e) && e.keyCode == 86) || (e.shiftKey && e.keyCode == 45);
|
||||
}
|
||||
|
||||
function registerEventHandlers() {
|
||||
editor.on('keydown', function(e) {
|
||||
if (e.isDefaultPrevented()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Ctrl+V or Shift+Insert
|
||||
if ((VK.metaKeyPressed(e) && e.keyCode == 86) || (e.shiftKey && e.keyCode == 45)) {
|
||||
if (isKeyboardPasteEvent(e) && !e.isDefaultPrevented()) {
|
||||
keyboardPastePlainTextState = e.shiftKey && e.keyCode == 86;
|
||||
|
||||
// Edge case on Safari on Mac where it doesn't handle Cmd+Shift+V correctly
|
||||
// it fires the keydown but no paste or keyup so we are left with a paste bin
|
||||
if (keyboardPastePlainTextState && Env.webkit && navigator.userAgent.indexOf('Version/') != -1) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Prevent undoManager keydown handler from making an undo level with the pastebin in it
|
||||
e.stopImmediatePropagation();
|
||||
|
||||
@@ -539,12 +574,21 @@ define("tinymce/pasteplugin/Clipboard", [
|
||||
}
|
||||
});
|
||||
|
||||
editor.on('keyup', function(e) {
|
||||
// Ctrl+V or Shift+Insert
|
||||
if (isKeyboardPasteEvent(e) && !e.isDefaultPrevented()) {
|
||||
removePasteBin();
|
||||
}
|
||||
});
|
||||
|
||||
editor.on('paste', function(e) {
|
||||
var clipboardContent = getClipboardContent(e);
|
||||
var isKeyBoardPaste = new Date().getTime() - keyboardPasteTimeStamp < 1000;
|
||||
var plainTextMode = self.pasteFormat == "text" || keyboardPastePlainTextState;
|
||||
|
||||
if (e.isDefaultPrevented()) {
|
||||
keyboardPastePlainTextState = false;
|
||||
|
||||
if (e.isDefaultPrevented() || isBrokenAndoidClipboardEvent(e)) {
|
||||
removePasteBin();
|
||||
return;
|
||||
}
|
||||
@@ -572,41 +616,56 @@ define("tinymce/pasteplugin/Clipboard", [
|
||||
}
|
||||
|
||||
setTimeout(function() {
|
||||
var html = getPasteBinHtml();
|
||||
var content;
|
||||
|
||||
// Grab HTML from Clipboard API or paste bin as a fallback
|
||||
if (hasContentType(clipboardContent, 'text/html')) {
|
||||
content = clipboardContent['text/html'];
|
||||
} else {
|
||||
content = getPasteBinHtml();
|
||||
|
||||
// If paste bin is empty try using plain text mode
|
||||
// since that is better than nothing right
|
||||
if (content == pasteBinDefaultContent) {
|
||||
plainTextMode = true;
|
||||
}
|
||||
}
|
||||
|
||||
content = Utils.trimHtml(getPasteBinHtml());
|
||||
|
||||
// WebKit has a nice bug where it clones the paste bin if you paste from for example notepad
|
||||
// so we need to force plain text mode in this case
|
||||
if (pasteBinElm && pasteBinElm.firstChild && pasteBinElm.firstChild.id === 'mcepastebin') {
|
||||
plainTextMode = true;
|
||||
}
|
||||
|
||||
removePasteBin();
|
||||
|
||||
// Always use pastebin HTML if it's available since it contains Word contents
|
||||
if (!plainTextMode && isKeyBoardPaste && html && html != pasteBinDefaultContent) {
|
||||
clipboardContent['text/html'] = html;
|
||||
}
|
||||
|
||||
if (html == pasteBinDefaultContent || !isKeyBoardPaste) {
|
||||
html = clipboardContent['text/html'] || clipboardContent['text/plain'] || pasteBinDefaultContent;
|
||||
|
||||
if (html == pasteBinDefaultContent) {
|
||||
if (!isKeyBoardPaste) {
|
||||
editor.windowManager.alert('Please use Ctrl+V/Cmd+V keyboard shortcuts to paste contents.');
|
||||
}
|
||||
|
||||
return;
|
||||
// Grab plain text from Clipboard API or convert existing HTML to plain text
|
||||
if (plainTextMode) {
|
||||
// Use plain text contents from Clipboard API unless the HTML contains paragraphs then
|
||||
// we should convert the HTML to plain text since works better when pasting HTML/Word contents as plain text
|
||||
if (hasContentType(clipboardContent, 'text/plain') && content.indexOf('</p>') == -1) {
|
||||
content = clipboardContent['text/plain'];
|
||||
} else {
|
||||
content = Utils.innerText(content);
|
||||
}
|
||||
}
|
||||
|
||||
// Force plain text mode if we only got a text/plain content type
|
||||
if (!hasContentType(clipboardContent, 'text/html') && hasContentType(clipboardContent, 'text/plain')) {
|
||||
plainTextMode = true;
|
||||
// If the content is the paste bin default HTML then it was
|
||||
// impossible to get the cliboard data out.
|
||||
if (content == pasteBinDefaultContent) {
|
||||
if (!isKeyBoardPaste) {
|
||||
editor.windowManager.alert('Please use Ctrl+V/Cmd+V keyboard shortcuts to paste contents.');
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (plainTextMode) {
|
||||
pasteText(clipboardContent['text/plain'] || Utils.innerText(html));
|
||||
pasteText(content);
|
||||
} else {
|
||||
pasteHtml(html);
|
||||
pasteHtml(content);
|
||||
}
|
||||
}, 0);
|
||||
});
|
||||
@@ -673,9 +732,12 @@ define("tinymce/pasteplugin/Clipboard", [
|
||||
});
|
||||
});
|
||||
|
||||
// Fix for #6504 we need to remove the paste bin on IE if the user paste in a file
|
||||
editor.on('PreProcess', function() {
|
||||
editor.dom.remove(editor.dom.get('mcepastebin'));
|
||||
editor.on('BeforeAddUndo', function(e) {
|
||||
// Remove pastebin HTML incase it should be added to an undo
|
||||
// level for example when you paste a file on older IE
|
||||
if (e.level.content) {
|
||||
e.level.content = e.level.content.replace(/<div id="?mcepastebin"?[^>]+>%MCEPASTEBIN%<\/div>/gi, '');
|
||||
}
|
||||
});
|
||||
};
|
||||
});
|
||||
@@ -1104,26 +1166,6 @@ define("tinymce/pasteplugin/Quirks", [
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes WebKit fragment comments and converted-space spans.
|
||||
*
|
||||
* This:
|
||||
* <!--StartFragment-->a<span class="Apple-converted-space"> </span>b<!--EndFragment-->
|
||||
*
|
||||
* Becomes:
|
||||
* a b
|
||||
*/
|
||||
function removeWebKitFragments(html) {
|
||||
html = Utils.filter(html, [
|
||||
/^[\s\S]*<body[^>]*>\s*<!--StartFragment-->|<!--EndFragment-->\s*<\/body[^>]*>[\s\S]*$/g, // WebKit fragment body
|
||||
/<!--StartFragment-->|<!--EndFragment-->/g, // Inner fragments (tables from excel on mac)
|
||||
[/<span class="Apple-converted-space">\u00a0<\/span>/g, '\u00a0'], // WebKit
|
||||
/<br>$/i // Traling BR elements
|
||||
]);
|
||||
|
||||
return html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes BR elements after block elements. IE9 has a nasty bug where it puts a BR element after each
|
||||
* block element when pasting from word. This removes those elements.
|
||||
@@ -1243,7 +1285,6 @@ define("tinymce/pasteplugin/Quirks", [
|
||||
// Sniff browsers and apply fixes since we can't feature detect
|
||||
if (Env.webkit) {
|
||||
addPreProcessFilter(removeWebKitStyles);
|
||||
addPreProcessFilter(removeWebKitFragments);
|
||||
}
|
||||
|
||||
if (Env.ie) {
|
||||
@@ -1366,4 +1407,4 @@ define("tinymce/pasteplugin/Plugin", [
|
||||
});
|
||||
|
||||
expose(["tinymce/pasteplugin/Utils","tinymce/pasteplugin/Clipboard","tinymce/pasteplugin/WordFilter","tinymce/pasteplugin/Quirks","tinymce/pasteplugin/Plugin"]);
|
||||
})(this);
|
||||
})(this);
|
||||
+1
-1
File diff suppressed because one or more lines are too long
@@ -342,7 +342,7 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) {
|
||||
|
||||
editor.on( 'SaveContent', function( e ) {
|
||||
// If editor is hidden, we just want the textarea's value to be saved
|
||||
if ( ! editor.inline && ! tinymce.DOM.isHidden( editor.id ) ) {
|
||||
if ( ! editor.inline && editor.isHidden() ) {
|
||||
e.content = e.element.value;
|
||||
return;
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
+1
-1
File diff suppressed because one or more lines are too long
+1191
-698
File diff suppressed because it is too large
Load Diff
+11
-10
File diff suppressed because one or more lines are too long
@@ -18,7 +18,7 @@ $wp_db_version = 27916;
|
||||
*
|
||||
* @global string $tinymce_version
|
||||
*/
|
||||
$tinymce_version = '4026-20140523';
|
||||
$tinymce_version = '4028-20140528';
|
||||
|
||||
/**
|
||||
* Holds the required PHP version
|
||||
|
||||
Reference in New Issue
Block a user