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; 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()"> <MudButton Variant="Variant.Filled" Color="Color.Warning" StartIcon="@Icons.Material.Filled.Refresh" OnClick="() => this.InnerResetForm()">
Reset Reset
</MudButton> </MudButton>

View File

@ -35,6 +35,12 @@ public abstract partial class AssistantBase : ComponentBase
protected abstract string Description { get; } protected abstract string Description { get; }
protected abstract string SystemPrompt { get; } 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 void ResetFrom();
@ -154,9 +160,9 @@ public abstract partial class AssistantBase : ComponentBase
return aiText.Text; 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) private static string? GetButtonIcon(string icon)

View File

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

View File

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

View File

@ -1,6 +1,7 @@
# v0.8.12, build 174 # v0.8.12, build 174
- Added an e-mail writing assistant. - Added an e-mail writing assistant.
- Added the possibility to preselect some e-mail writing assistant options. - 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 content validation for the agenda assistant.
- Improved the language handling of the agenda assistant. - Improved the language handling of the agenda assistant.
- Refactored the "send to" implementation of assistants. - Refactored the "send to" implementation of assistants.