mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-23 17:48:01 +01:00
TinyMCE: improve removal of spaces from empty paragraphs when loading HTML in the editor.
Fixes #39437. Built from https://develop.svn.wordpress.org/trunk@39902 git-svn-id: http://core.svn.wordpress.org/trunk@39839 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
82e17902a9
commit
90f441e1b4
@ -129,19 +129,22 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) {
|
|||||||
'/>';
|
'/>';
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove spaces from empty paragraphs.
|
|
||||||
// Try to avoid a lot of backtracking, can freeze the editor. See #35890 and #38294.
|
|
||||||
event.content = event.content.replace( /<p>([^<>]+)<\/p>/gi, function( tag, text ) {
|
|
||||||
if ( text === ' ' || ! /\S/.test( text ) ) {
|
|
||||||
return '<p><br /></p>';
|
|
||||||
}
|
|
||||||
|
|
||||||
return tag;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
editor.on( 'setcontent', function() {
|
||||||
|
// Remove spaces from empty paragraphs.
|
||||||
|
editor.$( 'p' ).each( function( i, node ) {
|
||||||
|
if ( node.innerHTML && node.innerHTML.length < 10 ) {
|
||||||
|
var html = tinymce.trim( node.innerHTML );
|
||||||
|
|
||||||
|
if ( ! html || html === ' ' ) {
|
||||||
|
node.innerHTML = ( tinymce.Env.ie && tinymce.Env.ie < 11 ) ? '' : '<br data-mce-bogus="1">';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
});
|
||||||
|
|
||||||
editor.on( 'PostProcess', function( event ) {
|
editor.on( 'PostProcess', function( event ) {
|
||||||
if ( event.get ) {
|
if ( event.get ) {
|
||||||
event.content = event.content.replace(/<img[^>]+>/g, function( image ) {
|
event.content = event.content.replace(/<img[^>]+>/g, function( image ) {
|
||||||
|
File diff suppressed because one or more lines are too long
Binary file not shown.
@ -4,7 +4,7 @@
|
|||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '4.8-alpha-39901';
|
$wp_version = '4.8-alpha-39902';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
Loading…
Reference in New Issue
Block a user