Completed
Last Updated: 14 Sep 2021 11:56 by ADMIN
Release R3 2016
ADMIN
Nikolay
Created on: 06 Feb 2014 12:37
Category: Editor
Type: Bug Report
0
When object is inserted by Media Manager, the cursor is placed inside it in Chrome
The RadEditor's Media Manager dialog uses pasteHtml functionality to insert Object elements in the contentArea. The pasteHtml functionality do not position the cursor correctly for this case (pasted content ends with a object).

The issue can be workarounded by appending a character after the object. Then using a content filter the additional characters will be removed.

<telerik:RadEditor ID="RadEditor1" runat="server" OnClientLoad="OnClientLoad" OnClientPasteHtml="OnClientPasteHtml">
</telerik:RadEditor>

<script type="text/javascript">
	function OnClientPasteHtml(editor, args) {
		if ($telerik.isChrome && args.get_commandName() == "MediaManager") {
			args.set_value(args.get_value() + String.fromCharCode(8203));
		}
	}

	function OnClientLoad(editor, args) {
		if ($telerik.isChrome) {
			editor.get_filtersManager().add(new MyFilter());
		}
	}

	MyFilter = function() {
		MyFilter.initializeBase(this);
		this.set_isDom(false);
		this.set_enabled(true);
		this.set_name("RadEditor filter");
		this.set_description("RadEditor filter description");
	}
	MyFilter.prototype =
	{
		getHtmlContent: function(content) {
			return content.replace(/(object>)[\u200b]/gm, "$1"); // or content.replace(/[\u200b]/gm, "")
		},
		getDesignContent: function(content) {
			return content;
		}
	}
	MyFilter.registerClass('MyFilter', Telerik.Web.UI.Editor.Filter);
</script>
0 comments