TinyMCE: Improve the previews for shortcodes.

Merge of [41395] to the 4.5 branch.

Built from https://develop.svn.wordpress.org/branches/4.5@41438


git-svn-id: http://core.svn.wordpress.org/branches/4.5@41271 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Dominik Schilling 2017-09-19 12:43:08 +00:00
parent cda7d5bac0
commit c3844666a2
3 changed files with 13 additions and 4 deletions

View File

@ -155,8 +155,6 @@
encodedText,
instance;
text = tinymce.DOM.decode( text );
if ( ! force ) {
instance = this.getInstance( text );
@ -424,7 +422,7 @@
var selected = node === editor.selection.getNode(),
$viewNode;
if ( ! this.loader && $( node ).text() !== this.text ) {
if ( ! this.loader && $( node ).text() !== tinymce.DOM.decode( this.text ) ) {
editor.dom.setAttrib( node, 'data-wpview-marker', null );
return;
}
@ -496,6 +494,14 @@
var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver,
self = this;
if ( body.indexOf( '[' ) !== -1 && body.indexOf( ']' ) !== -1 ) {
var shortcodesRegExp = new RegExp( '\\[\\/?(?:' + window.mceViewL10n.shortcodes.join( '|' ) + ')[^\\]]*?\\]', 'g' );
// Escape tags inside shortcode previews.
body = body.replace( shortcodesRegExp, function( match ) {
return match.replace( /</g, '&lt;' ).replace( />/g, '&gt;' );
} );
}
this.getNodes( function( editor, node, contentNode ) {
var dom = editor.dom,
styles = '',

File diff suppressed because one or more lines are too long

View File

@ -842,6 +842,9 @@ function wp_just_in_time_script_localization() {
'blog_id' => get_current_blog_id(),
) );
wp_localize_script( 'mce-view', 'mceViewL10n', array(
'shortcodes' => ! empty( $GLOBALS['shortcode_tags'] ) ? array_keys( $GLOBALS['shortcode_tags'] ) : array()
) );
}
/**