How could I implement increase/decrease FontSize buttons for RadEditor control, the new font size should then be refreshed in the <telerik:EditorTool Name="RealFontSize" />
button also included in the RadEditor Toolbar
for example from the figure if Click in increase button, the realfontsize dropdown should increase in 1px to 17px as well as the font size of the selected text
Update:
Thanks to @rdmptn answer : https://stackoverflow.com/a/23365866/432424 I got this first approach function, but I still don´t manage to get the current fontSize of selected text:
Telerik.Web.UI.Editor.CommandList["IncreaseFontSize"] = function (commandName, editor, args)
{
if (editor.getSelectionHtml() != "")
{
var selection = editor.getSelection();
var theSelectedElement = selection.getParentElement();
var currentFontSize = parseInt(theSelectedElement.style.fontSize);
currentFontSize++;
editor.fire("FontSize", { value: currentFontSize.toString() }); }); //fire the FontSize command
}
else
{
alert("Please, select some text!");
args.set_cancel(true);
}
};
Update 2:
this function works well:
Telerik.Web.UI.Editor.CommandList["IncreaseFontSize"] = function (commandName, editor, args)
{
if (editor.getSelectionHtml() != "")
{
var selection = editor.getSelection();
var theSelectedElement = selection.getParentElement().firstElementChild;
var currentFontSize = parseInt(theSelectedElement.size);
currentFontSize++;
var strNewFontSize = currentFontSize.toString();
editor.fire("FontSize", { value: strNewFontSize }); //fire the FontSize command
}
else
{
alert("Please, select some text!");
args.set_cancel(true);
}
};