TinyMCE wpView: decode HTML entities before trying to match the wpView text string. Props iseulde. See #31412.

Built from https://develop.svn.wordpress.org/trunk@31689


git-svn-id: http://core.svn.wordpress.org/trunk@31670 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrew Ozz 2015-03-09 19:09:27 +00:00
parent 4815bfc2a0
commit 15ec9441cb
3 changed files with 15 additions and 16 deletions

View File

@ -91,6 +91,7 @@ window.wp = window.wp || {};
setMarkers: function( content ) { setMarkers: function( content ) {
var pieces = [ { content: content } ], var pieces = [ { content: content } ],
self = this, self = this,
instance,
current; current;
_.each( views, function( view, type ) { _.each( views, function( view, type ) {
@ -115,11 +116,11 @@ window.wp = window.wp || {};
pieces.push( { content: remaining.substring( 0, result.index ) } ); pieces.push( { content: remaining.substring( 0, result.index ) } );
} }
self.createInstance( type, result.content, result.options ); instance = self.createInstance( type, result.content, result.options );
// Add the processed piece for the match. // Add the processed piece for the match.
pieces.push( { pieces.push( {
content: '<p data-wpview-marker="' + encodeURIComponent( result.content ) + '">' + result.content + '</p>', content: '<p data-wpview-marker="' + instance.encodedText + '">' + instance.text + '</p>',
processed: true processed: true
} ); } );
@ -149,6 +150,10 @@ window.wp = window.wp || {};
*/ */
createInstance: function( type, text, options ) { createInstance: function( type, text, options ) {
var View = this.get( type ), var View = this.get( type ),
encodedText,
instance;
text = tinymce.DOM.decode( text ),
encodedText = encodeURIComponent( text ), encodedText = encodeURIComponent( text ),
instance = this.getInstance( encodedText ); instance = this.getInstance( encodedText );
@ -754,7 +759,7 @@ window.wp = window.wp || {};
if ( this.url ) { if ( this.url ) {
this.loader = false; this.loader = false;
this.shortcode = wp.media.embed.shortcode( { this.shortcode = wp.media.embed.shortcode( {
url: this.url url: this.text
} ); } );
} }
@ -804,7 +809,7 @@ window.wp = window.wp || {};
edit: function( text, update ) { edit: function( text, update ) {
var media = wp.media.embed, var media = wp.media.embed,
frame = media.edit( text, !! this.url ), frame = media.edit( text, this.url ),
self = this, self = this,
events = 'change:url change:width change:height'; events = 'change:url change:width change:height';
@ -819,13 +824,7 @@ window.wp = window.wp || {};
frame.state( 'embed' ).on( 'select', function() { frame.state( 'embed' ).on( 'select', function() {
var data = frame.state( 'embed' ).metadata; var data = frame.state( 'embed' ).metadata;
if ( data.width ) { if ( self.url && ! data.width ) {
delete self.url;
} else {
self.url = data.url;
}
if ( self.url ) {
update( data.url ); update( data.url );
} else { } else {
update( media.shortcode( data ).string() ); update( media.shortcode( data ).string() );
@ -866,7 +865,7 @@ window.wp = window.wp || {};
index: match.index + match[1].length, index: match.index + match[1].length,
content: match[2], content: match[2],
options: { options: {
url: match[2] url: true
} }
}; };
} }

File diff suppressed because one or more lines are too long

View File

@ -4,7 +4,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '4.2-alpha-31688'; $wp_version = '4.2-alpha-31689';
/** /**
* 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.