All assistants now have a button to copy their respective result to the clipboard (#86)

This commit is contained in:
Thorsten Sommer 2024-08-23 08:59:30 +02:00 committed by GitHub
parent 18718a6c47
commit 3409872090
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 16 additions and 4 deletions

View File

@ -70,6 +70,9 @@
break;
}
}
<MudButton Variant="Variant.Filled" StartIcon="@Icons.Material.Filled.ContentCopy" OnClick="() => this.CopyToClipboard()">
Copy result
</MudButton>
<MudButton Variant="Variant.Filled" Color="Color.Warning" StartIcon="@Icons.Material.Filled.Refresh" OnClick="() => this.InnerResetForm()">
Reset
</MudButton>

View File

@ -36,6 +36,12 @@ public abstract partial class AssistantBase : ComponentBase
protected abstract string SystemPrompt { get; }
protected virtual Func<string> Result2Copy => () => this.resultingContentBlock is null ? string.Empty : this.resultingContentBlock.Content switch
{
ContentText textBlock => textBlock.Text,
_ => string.Empty,
};
protected abstract void ResetFrom();
protected abstract bool MightPreselectValues();
@ -154,9 +160,9 @@ public abstract partial class AssistantBase : ComponentBase
return aiText.Text;
}
protected async Task CopyToClipboard(string text)
protected async Task CopyToClipboard()
{
await this.Rust.CopyText2Clipboard(this.JsRuntime, this.Snackbar, text);
await this.Rust.CopyText2Clipboard(this.JsRuntime, this.Snackbar, this.Result2Copy());
}
private static string? GetButtonIcon(string icon)

View File

@ -26,9 +26,10 @@ public partial class AssistantGrammarSpelling : AssistantBaseCore
protected override bool ShowDedicatedProgress => true;
protected override Func<string> Result2Copy => () => this.correctedText;
protected override IReadOnlyList<IButtonData> FooterButtons =>
[
new ButtonData("Copy result", Icons.Material.Filled.ContentCopy, Color.Default, string.Empty, () => this.CopyToClipboard(this.correctedText)),
new SendToButton
{
Self = SendTo.GRAMMAR_SPELLING_ASSISTANT,

View File

@ -27,9 +27,10 @@ public partial class AssistantRewriteImprove : AssistantBaseCore
protected override bool ShowDedicatedProgress => true;
protected override Func<string> Result2Copy => () => this.rewrittenText;
protected override IReadOnlyList<IButtonData> FooterButtons =>
[
new ButtonData("Copy result", Icons.Material.Filled.ContentCopy, Color.Default, string.Empty, () => this.CopyToClipboard(this.rewrittenText)),
new SendToButton
{
Self = SendTo.REWRITE_ASSISTANT,

View File

@ -1,6 +1,7 @@
# v0.8.12, build 174
- Added an e-mail writing assistant.
- Added the possibility to preselect some e-mail writing assistant options.
- Improved: all assistants now have a button to copy their respective result to the clipboard.
- Improved the content validation for the agenda assistant.
- Improved the language handling of the agenda assistant.
- Refactored the "send to" implementation of assistants.