Skip to content

Commit

Permalink
Remove TinyMCE shim what was shimmed in WP 4.9.7 (#8832)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielbachhuber committed Aug 10, 2018
1 parent 2d1e3e0 commit e95528d
Showing 1 changed file with 0 additions and 33 deletions.
33 changes: 0 additions & 33 deletions lib/compat.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,39 +87,6 @@ function gutenberg_disable_editor_settings_wpautop( $settings, $editor_id ) {
}
add_filter( 'wp_editor_settings', 'gutenberg_disable_editor_settings_wpautop', 10, 2 );

/**
* Add TinyMCE fixes for the Classic Editor.
*
* @see https://core.trac.wordpress.org/ticket/44308
*/
function gutenberg_add_classic_editor_fixes() {
// Temp add the fix for not creating paragraphs from HTML comments.
// TODO: remove after 4.9.7, this should be in core.
$script = <<<JS
jQuery( document ).on( 'tinymce-editor-setup', function( event, editor ) {
var hasWpautop = ( window.wp && window.wp.editor && window.wp.editor.autop && editor.getParam( 'wpautop', true ) );
editor.on( 'BeforeSetContent', function( event ) {
if ( event.load && event.format !== 'raw' && ! hasWpautop ) {
// Prevent creation of paragraphs out of multiple HTML comments.
event.content = event.content.replace( /-->\s+<!--/g, '--><!--' );
}
});
editor.on( 'SaveContent', function( event ) {
if ( ! hasWpautop ) {
// Restore formatting of block boundaries.
event.content = event.content.replace( /-->\s*<!-- wp:/g, '-->\\n\\n<!-- wp:' );
}
});
});
JS;

wp_add_inline_script( 'editor', $script, 'before' );

}
add_action( 'init', 'gutenberg_add_classic_editor_fixes' );

/**
* Add rest nonce to the heartbeat response.
*
Expand Down

0 comments on commit e95528d

Please sign in to comment.