From be8fd189757144f79b57ada4423fa92761663795 Mon Sep 17 00:00:00 2001 From: Thorsten Sommer Date: Thu, 23 Jan 2025 13:41:36 +0100 Subject: [PATCH] Added a text info lines component --- .../Components/TextInfoLines.razor | 20 ++++++++ .../Components/TextInfoLines.razor.cs | 50 +++++++++++++++++++ 2 files changed, 70 insertions(+) create mode 100644 app/MindWork AI Studio/Components/TextInfoLines.razor create mode 100644 app/MindWork AI Studio/Components/TextInfoLines.razor.cs diff --git a/app/MindWork AI Studio/Components/TextInfoLines.razor b/app/MindWork AI Studio/Components/TextInfoLines.razor new file mode 100644 index 0000000..02dadb4 --- /dev/null +++ b/app/MindWork AI Studio/Components/TextInfoLines.razor @@ -0,0 +1,20 @@ + + + + @if (this.ShowingCopyButton) + { + + + + } + \ No newline at end of file diff --git a/app/MindWork AI Studio/Components/TextInfoLines.razor.cs b/app/MindWork AI Studio/Components/TextInfoLines.razor.cs new file mode 100644 index 0000000..64d5924 --- /dev/null +++ b/app/MindWork AI Studio/Components/TextInfoLines.razor.cs @@ -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 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); +} \ No newline at end of file