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

git-svn-id: https://develop.svn.wordpress.org/trunk@28685 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Ozz 2014-06-06 04:19:09 +00:00
parent 73e4f3e13b
commit 319299d42b

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' );