mirror of
https://gitee.com/ant-design-blazor/ant-design-blazor.git
synced 2024-12-16 01:41:14 +08:00
28 lines
787 B
C#
28 lines
787 B
C#
using System.Threading.Tasks;
|
|
using Microsoft.AspNetCore.Components;
|
|
using Microsoft.JSInterop;
|
|
|
|
namespace AntDesign.Docs.Highlight
|
|
{
|
|
public class PrismHighlighter : IPrismHighlighter
|
|
{
|
|
private readonly IJSRuntime jsRuntime;
|
|
|
|
public PrismHighlighter(IJSRuntime jsRuntime)
|
|
{
|
|
this.jsRuntime = jsRuntime;
|
|
}
|
|
|
|
public async ValueTask<MarkupString> HighlightAsync(string code, string language)
|
|
{
|
|
string highlighted = await jsRuntime.InvokeAsync<string>("AntDesign.Prism.highlight", code, language);
|
|
|
|
return new MarkupString(highlighted);
|
|
}
|
|
|
|
public async Task HighlightAllAsync()
|
|
{
|
|
await jsRuntime.InvokeVoidAsync("AntDesign.Prism.highlightAll");
|
|
}
|
|
}
|
|
} |