/**
* This file is part of the TinyMCE Advanced WordPress plugin and is released under the same license.
* For more information please see tinymce-advanced.php.
*
* Copyright (c) 2007-2018 Andrew Ozz. All rights reserved.
*/
( function( tinymce ) {
tinymce.PluginManager.add( 'wptadv', function( editor ) {
var noAutop = ( ! editor.settings.wpautop && editor.settings.tadv_noautop );
function addLineBreaks( html ) {
var blocklist = 'table|thead|tfoot|caption|col|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre' +
'|form|map|area|blockquote|address|math|style|p|h[1-6]|hr|fieldset|legend|section' +
'|article|aside|hgroup|header|footer|nav|figure|figcaption|details|menu|summary';
html = html.replace( new RegExp( '<(?:' + blocklist + ')(?: [^>]*)?>', 'gi' ), '\n$&' );
html = html.replace( new RegExp( '(?:' + blocklist + ')>', 'gi' ), '$&\n' );
html = html.replace( /(
]*)?>)[\r\n\t]*/gi, '$1\n' );
html = html.replace( />\n[\r\n\t]+\n<' );
html = html.replace( /^
<\/p>)*\[caption/g, 'caption] [caption' ); event.content = event.content.replace( /<(object|audio|video)[\s\S]+?<\/\1>/g, function( match ) { return match.replace( /[\r\n\t ]+/g, ' ' ); }); event.content = event.content.replace( /
]*)?>[\s\S]+?<\/pre>/g, function( match ) { match = match.replace( /
(\r\n|\n)?/g, '\n' ); return match.replace( /<\/?p( [^>]*)?>(\r\n|\n)?/g, '\n' ); }); event.content = addLineBreaks( event.content ); }); } try { if ( editor.plugins.searchreplace && ! editor.controlManager.buttons.searchreplace ) { editor.shortcuts.remove( 'meta+f' ); } } catch ( er ) {} editor.formatter.register({ mark: { inline: 'mark' } }); }); if ( noAutop ) { editor.on( 'beforeSetContent', function( event ) { var autop = typeof window.wp !== 'undefined' && window.wp.editor && window.wp.editor.autop; if ( event.load && autop && event.content && event.content.indexOf( '\n' ) > -1 && ! //i.test( event.content ) ) { event.content = autop( event.content ); } }, true ); } return { addLineBreaks: addLineBreaks }; }); }( window.tinymce ));