WordPress.org

Make WordPress Core

Changeset 41395


Ignore:
Timestamp:
09/19/2017 08:18:15 AM (20 months ago)
Author:
ocean90
Message:

TinyMCE: Improve the previews for shortcodes.

Location:
trunk/src/wp-includes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/js/mce-view.js

    r41351 r41395  
    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 ) {
  • trunk/src/wp-includes/script-loader.php

    r41390 r41395  
    10591059        'blog_id' => get_current_blog_id(),
    10601060    ) );
     1061
     1062    wp_localize_script( 'mce-view', 'mceViewL10n', array(
     1063        'shortcodes' => ! empty( $GLOBALS['shortcode_tags'] ) ? array_keys( $GLOBALS['shortcode_tags'] ) : array()
     1064    ) );
    10611065}
    10621066
Note: See TracChangeset for help on using the changeset viewer.