Make WordPress Core


Ignore:
Timestamp:
09/19/2017 12:40:06 PM (7 years ago)
Author:
ocean90
Message:

TinyMCE: Improve the previews for shortcodes.

Merge of [41395] to the 4.8 branch.

Location:
branches/4.8
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/4.8

  • branches/4.8/src/wp-includes/js/mce-view.js

    r40481 r41435  
    156156                instance;
    157157
    158             text = tinymce.DOM.decode( text );
    159 
    160158            if ( text.indexOf( '[' ) !== -1 && text.indexOf( ']' ) !== -1 ) {
    161159                // Looks like a shortcode? Remove any line breaks from inside of shortcodes
     
    432430                var $viewNode;
    433431
    434                 if ( ! this.loader && $( node ).text() !== this.text ) {
     432                if ( ! this.loader && $( node ).text() !== tinymce.DOM.decode( this.text ) ) {
    435433                    editor.dom.setAttrib( node, 'data-wpview-marker', null );
    436434                    return;
     
    502500        setIframes: function( head, body, callback, rendered ) {
    503501            var self = this;
     502
     503            if ( body.indexOf( '[' ) !== -1 && body.indexOf( ']' ) !== -1 ) {
     504                var shortcodesRegExp = new RegExp( '\\[\\/?(?:' + window.mceViewL10n.shortcodes.join( '|' ) + ')[^\\]]*?\\]', 'g' );
     505                // Escape tags inside shortcode previews.
     506                body = body.replace( shortcodesRegExp, function( match ) {
     507                    return match.replace( /</g, '&lt;' ).replace( />/g, '&gt;' );
     508                } );
     509            }
    504510
    505511            this.getNodes( function( editor, node ) {
Note: See TracChangeset for help on using the changeset viewer.