如何为 RadEditor 控件实现增加/减少FontSize 按钮,然后应该<telerik:EditorTool Name="RealFontSize" />
在 RadEditor 工具栏中也包含的按钮中刷新新的字体大小
例如从图中如果单击增加按钮,realfontsize 下拉应该增加 1px 到 17px 以及所选文本的字体大小
更新: 感谢@rdmptn 回答:https ://stackoverflow.com/a/23365866/432424我得到了第一个方法功能,但我仍然无法获得所选文本的当前 fontSize:
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);
}
};
更新 2: 此功能运行良好:
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);
}
};