namespace WebSite.Docus.Inputs.RichTexts;
class RichText1 : BaseComponent
{
protected override void BuildRenderTree(RenderTreeBuilder builder)
{
builder.Field<RichText>("内容:", "RichText1").Value("<h1>孙膑是辅助和法师。</h1>")
.Set(f => f.Option, new
{
Height = 200,
Placeholder = "请输入通知内容"
})
.Build();
}
}
namespace WebSite.Docus.Inputs.RichTexts;
class RichText2 : BaseComponent
{
private string? message;
protected override void BuildRenderTree(RenderTreeBuilder builder)
{
builder.Field<RichText>("内容:", "RichText2")
.ValueChanged(OnValueChanged)
.Set(f => f.Option, new
{
Placeholder = "请输入通知内容",
UploadImgShowBase64 = true //支持贴图
}).Build();
builder.Div("tips", message);
}
private void OnValueChanged(string value)
{
message = value;
StateChanged();
}
}
namespace WebSite.Docus.Inputs.RichTexts;
class RichText3 : BaseComponent
{
private RichText? richText;
protected override void BuildRenderTree(RenderTreeBuilder builder)
{
builder.Component<FieldControl>()
.Set(c => c.OnVisibleChanged, OnVisibleChanged)
.Set(c => c.OnEnabledChanged, OnEnabledChanged)
.Set(c => c.OnReadOnlyChanged, OnReadOnlyChanged)
.Set(c => c.SetValue, SetValue)
.Set(c => c.GetValue, GetValue)
.Build();
builder.Field<RichText>("内容:", "RichText3").Build(value => richText = value);
}
private void OnVisibleChanged(bool value) => richText?.SetVisible(value);
private void OnEnabledChanged(bool value) => richText?.SetEnabled(value);
private void OnReadOnlyChanged(bool value) => richText?.SetReadOnly(value);
private void SetValue() => richText?.SetValue("<h1>孙膑</h1>");
private string? GetValue() => richText?.Value;
}
namespace WebSite.Docus.Inputs.RichTexts;
class RichText4 : BaseComponent
{
protected override void BuildRenderTree(RenderTreeBuilder builder)
{
builder.Field<RichText>("内容:", "RichText4")
.Set(f => f.Option, new
{
Height = 200,
Placeholder = "请输入通知内容"
})
.Set(f => f.Storage, new StorageOption
{
Type = StorageType.Server,//默认本地服务器,支持阿里云OSS和腾讯云COS
KeyId = "accessKeyId",
KeySecret = "accessKeySecret",
Region = "your region",
Bucket = "your bucket name"
})
.Build();
}
}