Fixed spellchecking config for single line dialog (#49)

This commit is contained in:
Thorsten Sommer 2024-07-26 13:41:22 +02:00 committed by GitHub
parent d6bd0dc45b
commit 0f06b96943
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 19 additions and 1 deletions

View File

@ -1,7 +1,7 @@
<MudDialog> <MudDialog>
<DialogContent> <DialogContent>
<MudText Typo="Typo.body1">@this.Message</MudText> <MudText Typo="Typo.body1">@this.Message</MudText>
<MudTextField T="string" @bind-Text="@this.UserInput" Variant="Variant.Outlined" AutoGrow="@false" Lines="1" Label="Chat name" AutoFocus="@true"/> <MudTextField T="string" @bind-Text="@this.UserInput" Variant="Variant.Outlined" AutoGrow="@false" Lines="1" Label="Chat name" AutoFocus="@true" UserAttributes="@USER_INPUT_ATTRIBUTES"/>
</DialogContent> </DialogContent>
<DialogActions> <DialogActions>
<MudButton OnClick="@this.Cancel" Variant="Variant.Filled">Cancel</MudButton> <MudButton OnClick="@this.Cancel" Variant="Variant.Filled">Cancel</MudButton>

View File

@ -1,3 +1,5 @@
using AIStudio.Settings;
using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components;
namespace AIStudio.Components.CommonDialogs; namespace AIStudio.Components.CommonDialogs;
@ -19,6 +21,22 @@ public partial class SingleInputDialog : ComponentBase
[Parameter] [Parameter]
public Color ConfirmColor { get; set; } = Color.Error; public Color ConfirmColor { get; set; } = Color.Error;
[Inject]
private SettingsManager SettingsManager { get; set; } = null!;
private static readonly Dictionary<string, object?> USER_INPUT_ATTRIBUTES = new();
#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 void Cancel() => this.MudDialog.Cancel(); private void Cancel() => this.MudDialog.Cancel();
private void Confirm() => this.MudDialog.Close(DialogResult.Ok(this.UserInput)); private void Confirm() => this.MudDialog.Close(DialogResult.Ok(this.UserInput));