2020-04-23 17:13:56 +08:00
|
|
|
|
using Microsoft.AspNetCore.Components;
|
2020-03-10 13:29:03 +08:00
|
|
|
|
using System;
|
2020-03-12 16:35:23 +08:00
|
|
|
|
using System.Threading.Tasks;
|
2020-03-10 13:29:03 +08:00
|
|
|
|
|
2020-05-29 00:33:49 +08:00
|
|
|
|
namespace AntDesign
|
2020-03-10 13:29:03 +08:00
|
|
|
|
{
|
|
|
|
|
public abstract class AntTypographyBase : AntDomComponentBase
|
|
|
|
|
{
|
2020-03-12 16:35:23 +08:00
|
|
|
|
[Inject]
|
2020-04-23 17:13:56 +08:00
|
|
|
|
public HtmlRenderService Service { get; set; }
|
|
|
|
|
|
2020-03-10 13:29:03 +08:00
|
|
|
|
[Parameter]
|
2020-04-23 17:13:56 +08:00
|
|
|
|
public bool Copyable { get; set; } = false;
|
2020-03-10 13:29:03 +08:00
|
|
|
|
[Parameter]
|
2020-04-23 17:13:56 +08:00
|
|
|
|
public TypographyCopyableConfig CopyConfig { get; set; }
|
|
|
|
|
|
2020-03-10 13:29:03 +08:00
|
|
|
|
[Parameter]
|
2020-04-23 17:13:56 +08:00
|
|
|
|
public bool Delete { get; set; } = false;
|
|
|
|
|
|
2020-03-10 13:29:03 +08:00
|
|
|
|
[Parameter]
|
2020-04-23 17:13:56 +08:00
|
|
|
|
public bool Disabled { get; set; } = false;
|
|
|
|
|
|
2020-03-10 13:29:03 +08:00
|
|
|
|
[Parameter]
|
2020-04-23 17:13:56 +08:00
|
|
|
|
public bool Editable { get; set; } = false;
|
|
|
|
|
|
2020-03-10 13:29:03 +08:00
|
|
|
|
[Parameter]
|
2020-04-23 17:13:56 +08:00
|
|
|
|
public TypographyEditableConfig EditConfig { get; set; }
|
|
|
|
|
|
2020-03-10 13:29:03 +08:00
|
|
|
|
[Parameter]
|
2020-04-23 17:13:56 +08:00
|
|
|
|
public bool Ellipsis { get; set; } = false;
|
|
|
|
|
|
2020-03-10 13:29:03 +08:00
|
|
|
|
[Parameter]
|
2020-04-23 17:13:56 +08:00
|
|
|
|
public TypographyEllipsisConfig EllipsisConfig { get; set; }
|
|
|
|
|
|
2020-03-10 13:29:03 +08:00
|
|
|
|
[Parameter]
|
2020-04-23 17:13:56 +08:00
|
|
|
|
public bool Mark { get; set; } = false;
|
|
|
|
|
|
2020-03-10 13:29:03 +08:00
|
|
|
|
[Parameter]
|
2020-04-23 17:13:56 +08:00
|
|
|
|
public bool Underline { get; set; } = false;
|
|
|
|
|
|
2020-03-10 13:29:03 +08:00
|
|
|
|
[Parameter]
|
2020-04-23 17:13:56 +08:00
|
|
|
|
public bool Strong { get; set; } = false;
|
|
|
|
|
|
2020-03-10 13:29:03 +08:00
|
|
|
|
[Parameter]
|
2020-04-23 17:13:56 +08:00
|
|
|
|
public Action OnChange { get; set; }
|
|
|
|
|
|
2020-03-10 13:29:03 +08:00
|
|
|
|
[Parameter]
|
2020-04-23 17:13:56 +08:00
|
|
|
|
public string Type { get; set; } = string.Empty;
|
2020-03-12 16:35:23 +08:00
|
|
|
|
|
|
|
|
|
[Parameter]
|
|
|
|
|
public RenderFragment ChildContent { get; set; }
|
|
|
|
|
|
|
|
|
|
public async Task Copy()
|
|
|
|
|
{
|
2020-04-23 17:13:56 +08:00
|
|
|
|
if (!Copyable)
|
2020-03-12 16:35:23 +08:00
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
2020-04-23 17:13:56 +08:00
|
|
|
|
else if (CopyConfig is null)
|
2020-03-12 16:35:23 +08:00
|
|
|
|
{
|
2020-04-23 17:13:56 +08:00
|
|
|
|
await this.JsInvokeAsync<object>(JSInteropConstants.copy, await Service.RenderAsync(ChildContent));
|
2020-03-12 16:35:23 +08:00
|
|
|
|
}
|
2020-04-23 17:13:56 +08:00
|
|
|
|
else if (CopyConfig.OnCopy is null)
|
2020-03-12 16:35:23 +08:00
|
|
|
|
{
|
2020-04-23 17:13:56 +08:00
|
|
|
|
if (string.IsNullOrEmpty(CopyConfig.Text))
|
2020-03-12 16:35:23 +08:00
|
|
|
|
{
|
2020-04-23 17:13:56 +08:00
|
|
|
|
await this.JsInvokeAsync<object>(JSInteropConstants.copy, await Service.RenderAsync(ChildContent));
|
2020-03-12 16:35:23 +08:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2020-04-23 17:13:56 +08:00
|
|
|
|
await this.JsInvokeAsync<object>(JSInteropConstants.copy, CopyConfig.Text);
|
2020-03-12 16:35:23 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2020-04-23 17:13:56 +08:00
|
|
|
|
CopyConfig.OnCopy.Invoke();
|
2020-03-12 16:35:23 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2020-03-10 13:29:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class TypographyCopyableConfig
|
|
|
|
|
{
|
2020-04-23 17:13:56 +08:00
|
|
|
|
public string Text { get; set; } = string.Empty;
|
|
|
|
|
|
|
|
|
|
public Action OnCopy { get; set; } = null;
|
2020-03-10 13:29:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class TypographyEditableConfig
|
|
|
|
|
{
|
2020-04-23 17:13:56 +08:00
|
|
|
|
public Action OnStart { get; set; }
|
|
|
|
|
|
|
|
|
|
public Action<string> OnChange { get; set; }
|
2020-03-10 13:29:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class TypographyEllipsisConfig
|
|
|
|
|
{
|
2020-04-23 17:13:56 +08:00
|
|
|
|
public string Suffix { get; set; } = "...";
|
|
|
|
|
|
|
|
|
|
public int Rows { get; set; }
|
|
|
|
|
|
|
|
|
|
public Action OnExpand { get; set; }
|
2020-03-10 13:29:03 +08:00
|
|
|
|
}
|
|
|
|
|
}
|