We have a button on our toolbar that should simply surround selected content with a <div> tag.
Telerik.Web.UI.Editor.CommandList["Test"] = function (commandName, editor, args) {
if (editor.getSelectionHtml() !== "") {
var content = editor.getSelectionHtml();
editor.pasteHtml("<
div
>" + content + "</
div
>");
args.set_cancel(true);
}
else {
alert("Please, select some text!");
args.set_cancel(true);
}
};
But when this is applied to anything that starts with an HTML tag, specifically <em>, <strong>, or <sup>, then it applies the <div> tag, but then surrounds the entire div with whatever the starting HTML tag is.
For Example,
<em>gnomes</em>: imaginary creatures
should become:
<div><em>gnomes</em>: imaginary creatures</div>
but instead becomes:
<em>
<div><em>gnomes</em>: imaginary creatures
</div>
</em>
We really don't want the entire phrase in italics. This is especially annoying with superscripts since it places everything in a superscript.
We are using the latest version of the tools. This happens consistently across Firefox, Chrome, and Opera.
How can we just surround the selected text with a <div> without surrounding the entire thing with additional HTML tags?