mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2025-02-11 11:09:07 +00:00
Added a text info lines component
This commit is contained in:
parent
1e32ae6723
commit
be8fd18975
20
app/MindWork AI Studio/Components/TextInfoLines.razor
Normal file
20
app/MindWork AI Studio/Components/TextInfoLines.razor
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
<MudStack Row="@true" AlignItems="AlignItems.Start">
|
||||||
|
<MudTextField
|
||||||
|
T="string"
|
||||||
|
ReadOnly="@true"
|
||||||
|
Label="@this.Label"
|
||||||
|
Text="@this.Value"
|
||||||
|
Variant="Variant.Outlined"
|
||||||
|
Margin="Margin.Dense"
|
||||||
|
Lines="3"
|
||||||
|
MaxLines="@this.MaxLines"
|
||||||
|
AutoGrow="@true"
|
||||||
|
UserAttributes="@USER_INPUT_ATTRIBUTES" />
|
||||||
|
|
||||||
|
@if (this.ShowingCopyButton)
|
||||||
|
{
|
||||||
|
<MudTooltip Text="@this.ClipboardTooltip">
|
||||||
|
<MudIconButton Icon="@Icons.Material.Filled.ContentCopy" Size="Size.Medium" OnClick="@(() => this.CopyToClipboard(this.Value))"/>
|
||||||
|
</MudTooltip>
|
||||||
|
}
|
||||||
|
</MudStack>
|
50
app/MindWork AI Studio/Components/TextInfoLines.razor.cs
Normal file
50
app/MindWork AI Studio/Components/TextInfoLines.razor.cs
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
using AIStudio.Settings;
|
||||||
|
|
||||||
|
using Microsoft.AspNetCore.Components;
|
||||||
|
|
||||||
|
namespace AIStudio.Components;
|
||||||
|
|
||||||
|
public partial class TextInfoLines : ComponentBase
|
||||||
|
{
|
||||||
|
[Parameter]
|
||||||
|
public string Label { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
|
public string Value { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
|
public string ClipboardTooltipSubject { get; set; } = "the text";
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
|
public int MaxLines { get; set; } = 30;
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
|
public bool ShowingCopyButton { get; set; } = true;
|
||||||
|
|
||||||
|
[Inject]
|
||||||
|
private RustService RustService { get; init; } = null!;
|
||||||
|
|
||||||
|
[Inject]
|
||||||
|
private ISnackbar Snackbar { get; init; } = null!;
|
||||||
|
|
||||||
|
[Inject]
|
||||||
|
private SettingsManager SettingsManager { get; init; } = null!;
|
||||||
|
|
||||||
|
#region Overrides of ComponentBase
|
||||||
|
|
||||||
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
// Configure the spellchecking for the user input:
|
||||||
|
this.SettingsManager.InjectSpellchecking(USER_INPUT_ATTRIBUTES);
|
||||||
|
|
||||||
|
await base.OnInitializedAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private static readonly Dictionary<string, object?> USER_INPUT_ATTRIBUTES = new();
|
||||||
|
|
||||||
|
private string ClipboardTooltip => $"Copy {this.ClipboardTooltipSubject} to the clipboard";
|
||||||
|
|
||||||
|
private async Task CopyToClipboard(string content) => await this.RustService.CopyText2Clipboard(this.Snackbar, content);
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user