TinyMCE: remove &nbsp from empty paragraphs inside the visual editor, props avryl, fixes #28282

Built from https://develop.svn.wordpress.org/trunk@28685


git-svn-id: http://core.svn.wordpress.org/trunk@28503 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrew Ozz 2014-06-06 04:20:14 +00:00
parent 60e323d911
commit a59cf45c4d
3 changed files with 9 additions and 2 deletions

View File

@ -355,13 +355,20 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) {
}
// Keep empty paragraphs :(
e.content = e.content.replace( /<p>(<br ?\/?>|\u00a0|\uFEFF)?<\/p>/g, '<p>&nbsp;</p>' );
e.content = e.content.replace( /<p>(?:<br ?\/?>|\u00a0|\uFEFF| )*<\/p>/g, '<p>&nbsp;</p>' );
if ( editor.getParam( 'wpautop', true ) && typeof window.switchEditors !== 'undefined' ) {
e.content = window.switchEditors.pre_wpautop( e.content );
}
});
// Remove spaces from empty paragraphs.
editor.on( 'BeforeSetContent', function( event ) {
if ( event.content ) {
event.content = event.content.replace( /<p>(?:&nbsp;|\u00a0|\uFEFF| )+<\/p>/gi, '<p></p>' );
}
});
editor.on( 'preInit', function() {
// Don't replace <i> with <em> and <b> with <strong> and don't remove them when empty
editor.schema.addValidElements( '@[id|accesskey|class|dir|lang|style|tabindex|title|contenteditable|draggable|dropzone|hidden|spellcheck|translate],i,b' );

File diff suppressed because one or more lines are too long