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

git-svn-id: https://develop.svn.wordpress.org/trunk@31612 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Ozz 2015-03-04 20:34:35 +00:00
parent 6b94742b72
commit 5433303166
1 changed files with 18 additions and 3 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;
}