TinyMCE: Improve the previews for shortcodes.
Merge of [41395] to the 4.8 branch. Built from https://develop.svn.wordpress.org/branches/4.8@41435 git-svn-id: http://core.svn.wordpress.org/branches/4.8@41268 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
460edb5519
commit
40074d31a0
|
@ -155,8 +155,6 @@
|
||||||
encodedText,
|
encodedText,
|
||||||
instance;
|
instance;
|
||||||
|
|
||||||
text = tinymce.DOM.decode( text );
|
|
||||||
|
|
||||||
if ( text.indexOf( '[' ) !== -1 && text.indexOf( ']' ) !== -1 ) {
|
if ( text.indexOf( '[' ) !== -1 && text.indexOf( ']' ) !== -1 ) {
|
||||||
// Looks like a shortcode? Remove any line breaks from inside of shortcodes
|
// Looks like a shortcode? Remove any line breaks from inside of shortcodes
|
||||||
// or autop will replace them with <p> and <br> later and the string won't match.
|
// or autop will replace them with <p> and <br> later and the string won't match.
|
||||||
|
@ -431,7 +429,7 @@
|
||||||
var selected = node === editor.selection.getNode();
|
var selected = node === editor.selection.getNode();
|
||||||
var $viewNode;
|
var $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 );
|
editor.dom.setAttrib( node, 'data-wpview-marker', null );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -502,6 +500,14 @@
|
||||||
setIframes: function( head, body, callback, rendered ) {
|
setIframes: function( head, body, callback, rendered ) {
|
||||||
var self = this;
|
var 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 ) {
|
this.getNodes( function( editor, node ) {
|
||||||
var dom = editor.dom,
|
var dom = editor.dom,
|
||||||
styles = '',
|
styles = '',
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -949,6 +949,10 @@ function wp_just_in_time_script_localization() {
|
||||||
'autosaveInterval' => AUTOSAVE_INTERVAL,
|
'autosaveInterval' => AUTOSAVE_INTERVAL,
|
||||||
'blog_id' => get_current_blog_id(),
|
'blog_id' => get_current_blog_id(),
|
||||||
) );
|
) );
|
||||||
|
|
||||||
|
wp_localize_script( 'mce-view', 'mceViewL10n', array(
|
||||||
|
'shortcodes' => ! empty( $GLOBALS['shortcode_tags'] ) ? array_keys( $GLOBALS['shortcode_tags'] ) : array()
|
||||||
|
) );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '4.8.2-alpha-41429';
|
$wp_version = '4.8.2-alpha-41435';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
Loading…
Reference in New Issue