mirror of
https://github.com/WordPress/WordPress.git
synced 2024-09-27 06:42:56 +02:00
TinyMCE: Improve the previews for shortcodes.
Merge of [41395] to the 4.2 branch. Built from https://develop.svn.wordpress.org/branches/4.2@41441 git-svn-id: http://core.svn.wordpress.org/branches/4.2@41274 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
e7865eb9ae
commit
74df39530d
@ -156,7 +156,6 @@ window.wp = window.wp || {};
|
||||
encodedText,
|
||||
instance;
|
||||
|
||||
text = tinymce.DOM.decode( text );
|
||||
instance = this.getInstance( text );
|
||||
|
||||
if ( instance ) {
|
||||
@ -418,7 +417,7 @@ window.wp = window.wp || {};
|
||||
*/
|
||||
replaceMarkers: function() {
|
||||
this.getMarkers( function( editor, node ) {
|
||||
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;
|
||||
}
|
||||
@ -487,6 +486,14 @@ window.wp = window.wp || {};
|
||||
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, '<' ).replace( />/g, '>' );
|
||||
} );
|
||||
}
|
||||
|
||||
this.getNodes( function( editor, node, contentNode ) {
|
||||
var dom = editor.dom,
|
||||
styles = '',
|
||||
|
2
wp-includes/js/mce-view.min.js
vendored
2
wp-includes/js/mce-view.min.js
vendored
File diff suppressed because one or more lines are too long
@ -750,6 +750,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()
|
||||
) );
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user