mirror of
https://gitee.com/ant-design-blazor/ant-design-blazor.git
synced 2024-12-05 21:47:38 +08:00
33 lines
827 B
C#
33 lines
827 B
C#
@using System.Net
|
|
@using AntDesign.Docs.Utils
|
|
@inherits ComponentBase
|
|
@inject HtmlRenderService HtmlRenderService
|
|
|
|
@((MarkupString)$"<style>{Styles}</style>")
|
|
|
|
@code {
|
|
|
|
[Parameter]
|
|
public RenderFragment ChildContent { get; set; }
|
|
|
|
[Parameter]
|
|
public string ScopeId { get; set; }
|
|
|
|
protected string Styles { get; set; }
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
if (ChildContent != null)
|
|
{
|
|
var text = await HtmlRenderService.RenderAsync(ChildContent);
|
|
var style = WebUtility.HtmlDecode(text)?.Replace("<style>", "").Replace("</style>", "");
|
|
if (!string.IsNullOrEmpty(style))
|
|
{
|
|
var parser = new CSSParser(style);
|
|
Styles = parser.AddScopeIdToString(ScopeId);
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|