TinyMCE:
- Update the 'paste' plugin including cb36a78e54
- Better filtering of WebKit inserted  .
- Remove empty paragraphs and all inline styles on pasting but preserve styles added in the editor. This brings back the WP 3.8 behavior and makes pasting in all browsers work the same.
See #28016
Built from https://develop.svn.wordpress.org/trunk@28932
git-svn-id: http://core.svn.wordpress.org/trunk@28730 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
b76d6afbbd
commit
99c9ef1a59
|
@ -182,10 +182,20 @@ define("tinymce/pasteplugin/Utils", [
|
|||
* @return {String} Html contents that got trimmed.
|
||||
*/
|
||||
function trimHtml(html) {
|
||||
var trimSpaces = function(all, s1, s2) {
|
||||
// WebKit meant to preserve multiple spaces but instead inserted around all inline tags,
|
||||
// including the spans with inline stypes 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
|
||||
/<!--StartFragment-->|<!--EndFragment-->/g, // Inner fragments (tables from excel on mac)
|
||||
[/<span class="Apple-converted-space">\u00a0<\/span>/g, '\u00a0'], // WebKit
|
||||
[/( ?)<span class="Apple-converted-space">\u00a0<\/span>( ?)/g, trimSpaces],
|
||||
/<br>$/i // Trailing BR elements
|
||||
]);
|
||||
|
||||
|
@ -409,22 +419,23 @@ define("tinymce/pasteplugin/Clipboard", [
|
|||
* @return {String} Get the contents of the paste bin.
|
||||
*/
|
||||
function getPasteBinHtml() {
|
||||
var html = pasteBinDefaultContent, pasteBinClones, i;
|
||||
var html = '', pasteBinClones, i, clone, cloneHtml;
|
||||
|
||||
// Since WebKit/Chrome might clone the paste bin when pasting
|
||||
// for example: <img style="float: right"> we need to check if any of them contains some useful html.
|
||||
// TODO: Man o man is this ugly. WebKit is the new IE! Remove this if they ever fix it!
|
||||
pasteBinClones = editor.dom.select('div[id=mcepastebin]');
|
||||
i = pasteBinClones.length;
|
||||
while (i--) {
|
||||
var cloneHtml = pasteBinClones[i].innerHTML;
|
||||
for (i = 0; i < pasteBinClones.length; i++) {
|
||||
clone = pasteBinClones[i];
|
||||
|
||||
if (html == pasteBinDefaultContent) {
|
||||
html = '';
|
||||
// Pasting plain text produces pastebins in pastebinds makes sence right!?
|
||||
if (clone.firstChild && clone.firstChild.id == 'mcepastebin') {
|
||||
clone = clone.firstChild;
|
||||
}
|
||||
|
||||
if (cloneHtml.length > html.length) {
|
||||
html = cloneHtml;
|
||||
cloneHtml = clone.innerHTML;
|
||||
if (html != pasteBinDefaultContent) {
|
||||
html += cloneHtml;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -640,7 +651,7 @@ define("tinymce/pasteplugin/Clipboard", [
|
|||
}
|
||||
}
|
||||
|
||||
content = Utils.trimHtml(getPasteBinHtml());
|
||||
content = Utils.trimHtml(content);
|
||||
|
||||
// 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
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -330,6 +330,28 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
if ( editor.getParam( 'wp_paste_filters', true ) ) {
|
||||
if ( ! tinymce.Env.webkit ) {
|
||||
// In WebKit handled by removeWebKitStyles()
|
||||
editor.on( 'PastePreProcess', function( event ) {
|
||||
// Remove all inline styles
|
||||
event.content = event.content.replace( /(<[^>]+) style="[^"]*"([^>]*>)/gi, '$1$2' );
|
||||
|
||||
// Put back the internal styles
|
||||
event.content = event.content.replace(/(<[^>]+) data-mce-style=([^>]+>)/gi, '$1 style=$2' );
|
||||
});
|
||||
}
|
||||
|
||||
editor.on( 'PastePostProcess', function( event ) {
|
||||
// Remove empty paragraphs
|
||||
tinymce.each( dom.select( 'p', event.node ), function( node ) {
|
||||
if ( dom.isEmpty( node ) ) {
|
||||
dom.remove( node );
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Word count
|
||||
|
|
File diff suppressed because one or more lines are too long
Binary file not shown.
|
@ -18,7 +18,7 @@ $wp_db_version = 27916;
|
|||
*
|
||||
* @global string $tinymce_version
|
||||
*/
|
||||
$tinymce_version = '4028-20140620';
|
||||
$tinymce_version = '4028-20140630';
|
||||
|
||||
/**
|
||||
* Holds the required PHP version
|
||||
|
|
Loading…
Reference in New Issue