Completed
Last Updated: 03 May 2016 14:08 by ADMIN
ADMIN
Nikolay
Created on: 15 Feb 2016 11:03
Category: UI for ASP.NET AJAX
Type: Bug Report
1
get_html function returns the HTML without space characters
Steps to reproduce:

Use the following markup and click set html button:

<telerik:RadEditor ID="RadEditor1" runat="server" NewLineMode="Div">
<Content>
<div><span style="font-family: 'Courier New';">test</span></div>
<div><span style="font-family: 'Courier New';">&nbsp;</span></div>
<div><span style="font-family: 'Courier New';">test</span></div>
</Content>
</telerik:RadEditor>

<button type="button" onclick="getSetHtml();return false;">set html</button>

<script>
function getSetHtml() {
var editor = $find("RadEditor1");
var html = editor.get_html(true);
editor.set_html(html);
}
</script>

Actual: The white space character in the empty line is removed and the empty line is not rendered

Expected: The space is not removed and the new line is rendered

Workaround:

<script>
	(function ($E) {
		var utils = $E.Utils;
		Telerik.Web.UI.Editor.TrackerBase.prototype.removeZeroWidthNodes = 
			function () {
				var that = this,
					nodes = that.nodes,
					reZeroWidthChar = new RegExp("^[" + that._zeroWidthCharacter + "]+$");

				var nodeValuePairs = that.nodeValuePairs = [];
				for (var i = 0; i < nodes.length; i++) {
					var node = nodes[i];
					if (utils.isTextNode(node) && !that._isNodeRemoved(node)) {
						var nodeValue = node.nodeValue;
						if (reZeroWidthChar.test(nodeValue)) {
							nodeValuePairs.push({ node: node, value: node.nodeValue });
							var parentBlockElement = utils.getBlockParent(node);
							var isInEmptyBlockElement = parentBlockElement && utils.isNodeEmptyRecursive(parentBlockElement);
							node.nodeValue = isInEmptyBlockElement ? "\u00A0" : "";
						}
						else {
							that.removeFirstZeroWidthChar(node);
						}
					}
				}
			}
	})(Telerik.Web.UI.Editor);
</script>
0 comments