As the title says. Currently when using an underline it adds "style="text-decoation:underline" to the span.
Can this be overriden or changed to instead change the tag to a <u></u>?
Or can a custom class be added instead of style?
Cheers in advance
|
<SfRichTextEditor @ref="rteObj">
<RichTextEditorEvents OnActionComplete="@OnActionComplete"></RichTextEditorEvents>
………
</SfRichTextEditor>
<style>
.e-custom-class {
background-color: red;
}
</style>
@code {
[Inject]
IJSRuntime JsRuntime { get; set; }
public async Task OnActionComplete(ActionCompleteEventArgs args)
{
if (args.RequestType == "Underline")
{
await JsRuntime.InvokeVoidAsync("RichTextEditor.addCustomClass");
}
}
} |
|
window.RichTextEditor = {
addCustomClass: function () {
if (window.getSelection().anchorNode.parentElement.style.textDecoration == "underline") {
window.getSelection().anchorNode.parentElement.style.textDecoration = "";
window.getSelection().anchorNode.parentElement.classList.add("e-custom-class");
}
}
} |
How would this handle toggling the style off? As its the same event argument.
Toggling the underline off or on is the same event: "underline"
|
<SfRichTextEditor @ref="rteObj">
…………..
<RichTextEditorToolbarSettings Items="@Tools">
<RichTextEditorCustomToolbarItems>
<RichTextEditorCustomToolbarItem Name="Symbol">
<Template>
<button class="e-btn e-tbar-btn" @onclick="ClickHandler">
<span class="e-underline e-icons e-btn-icon" style="font-weight: 500;"></span>
</button>
</Template>
</RichTextEditorCustomToolbarItem>
</RichTextEditorCustomToolbarItems>
</RichTextEditorToolbarSettings>
</SfRichTextEditor>
@code {
[Inject]
IJSRuntime JsRuntime { get; set; }
SfRichTextEditor rteObj;
private List<ToolbarItemModel> Tools = new List<ToolbarItemModel>()
{
new ToolbarItemModel() { Command = ToolbarCommand.Bold },
new ToolbarItemModel() { Command = ToolbarCommand.Italic },
new ToolbarItemModel() { Name = "Symbol", TooltipText = "Insert Underline" },………………
};
private async Task ClickHandler()
{
await JsRuntime.InvokeVoidAsync("RichTextEditor.executeCommand");
}
} |
|
window.RichTextEditor = {
executeCommand: function () {
document.execCommand("underline", false, "");
}
} |