Completed
Last Updated: 01 Jun 2021 13:40 by ADMIN
Release Q2 2015
ADMIN
Nikolay
Created on: 18 Aug 2014 10:42
Category: Editor
Type: Bug Report
1
FIX: Inline formatting is discontinued when pressing Enter in Chrome
The issue is reproducible when NewLineMode is Br and the cursor is at the end of the formatting node in Chrome. 

The workaround is to check the position of the new inserted Br element and append it to the formatting node if it is necessary.

<telerik:RadEditor ID="RadEditor1" runat="server" NewLineMode="Br">
</telerik:RadEditor>

<script type="text/javascript">
	(function () {
		if (!$telerik.isChrome)
			return;
		var insertBr = Telerik.Web.UI.Editor.EnterNewLineCommand.prototype._insertBrElementSafari;
		Telerik.Web.UI.Editor.EnterNewLineCommand.prototype._insertBrElementSafari = function () {
			var utils = Telerik.Web.UI.Editor.Utils,
				command = this,
				selection = command.get_editor().getSelection(),
				range = selection.getRange();

			if (range.commonAncestorContainer != range.startContainer || range.commonAncestorContainer != range.endContainer)
				return insertBr.call(command);

			var commonElement = utils.isTextNode(range.commonAncestorContainer) ?
				range.commonAncestorContainer.parentNode : range.commonAncestorContainer;

			var commandResult = insertBr.call(command);
			range = selection.getRange();
			var br = range.commonAncestorContainer.childNodes[range.startOffset];

			if (!utils.isTag(br, "br"))
				return commandResult;

			if (!$telerik.$.contains(commonElement, br)) {
				commonElement.appendChild(br);
				range.selectNodeContents(commonElement);
				range.collapse(false);
				selection.selectRange(range);
			}

			return commandResult;
		}
	})();
</script>
0 comments