WordPress.org

Make WordPress Core

Changeset 41435


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

TinyMCE: Improve the previews for shortcodes.

Merge of [41395] to the 4.8 branch.

Location:
branches/4.8
Files:
3 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 ) {
  • branches/4.8/src/wp-includes/script-loader.php

    r41053 r41435  
    950950        'blog_id' => get_current_blog_id(),
    951951    ) );
     952
     953    wp_localize_script( 'mce-view', 'mceViewL10n', array(
     954        'shortcodes' => ! empty( $GLOBALS['shortcode_tags'] ) ? array_keys( $GLOBALS['shortcode_tags'] ) : array()
     955    ) );
    952956}
    953957
Note: See TracChangeset for help on using the changeset viewer.