Make WordPress Core

Ticket #27915: 27915.patch

File 27915.patch, 1.3 KB (added by azaozz, 11 years ago)
  • src/wp-includes/js/tinymce/plugins/wpview/plugin.js

     
    332332                tinymce.each( dom.select( 'div[data-wpview-text]', event.node ), function( node ) {
    333333                        // Empty the wrap node
    334334                        if ( 'textContent' in node ) {
    335                                 node.textContent = '';
     335                                node.textContent = '\u00a0';
    336336                        } else {
    337                                 node.innerText = '';
     337                                node.innerText = '\u00a0';
    338338                        }
    339 
    340                         // This makes all views into block tags (as we use <div>).
    341                         // Can use 'PostProcess' and a regex instead.
    342                         dom.replace( dom.create( 'p', null, window.decodeURIComponent( dom.getAttrib( node, 'data-wpview-text' ) ) ), node );
    343339                });
    344340    });
    345341
     342    editor.on( 'PostProcess', function( event ) {
     343                if ( event.content ) {
     344                        event.content = event.content.replace( /<div [^>]*?data-wpview-text="([^"]*)"[^>]*>[\s\S]*?<\/div>/g, function( match, shortcode ) {
     345                                if ( shortcode ) {
     346                                        return '<p>' + window.decodeURIComponent( shortcode ) + '</p>';
     347                                }
     348                                return ''; // If error, remove the view wrapper
     349                        });
     350                }
     351        });
     352
    346353        editor.on( 'keydown', function( event ) {
    347354                var keyCode = event.keyCode,
    348355                        body = editor.getBody(),