TinyMCE wpView: decode HTML entities before trying to insert view markers. Props iseulde. See #31412.

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


git-svn-id: http://core.svn.wordpress.org/trunk@31593 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrew Ozz 2015-03-04 20:35:27 +00:00
parent 77f3f6943d
commit 810df170e7
3 changed files with 20 additions and 5 deletions

View File

@ -28,10 +28,25 @@ window.wp = window.wp || {};
'use strict';
var views = {},
instances = {};
instances = {},
textarea = document.createElement( 'textarea' );
wp.mce = wp.mce || {};
/**
* Decode HTML entities in a givin string.
*
* @param {String} html The string to decode.
*/
function decodeHTML( html ) {
textarea.innerHTML = html;
html = textarea.value;
textarea.innerHTML = textarea.value = '';
return html;
}
/**
* wp.mce.views
*
@ -89,7 +104,7 @@ window.wp = window.wp || {};
* @param {String} content The string to scan.
*/
setMarkers: function( content ) {
var pieces = [ { content: content } ],
var pieces = [ { content: decodeHTML( content ) } ],
self = this,
current;
@ -390,7 +405,7 @@ window.wp = window.wp || {};
*/
replaceMarkers: function() {
this.getMarkers( function( editor, node ) {
if ( $( node ).html() !== this.text ) {
if ( $( node ).text() !== this.text ) {
editor.dom.setAttrib( node, 'data-wpview-marker', null );
return;
}

File diff suppressed because one or more lines are too long

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.2-alpha-31611';
$wp_version = '4.2-alpha-31612';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.