mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-11-10 23:47:21 +00:00
Added the guided chat to the BeyondFacts Lab (#1177)
This commit is contained in:
1 parent
e77645f44c
commit
79e0c80031
55 files changed
+3481
-72
No files matched your search
@@ -0,0 +1,36 @@
|
||||
using Microsoft.AspNetCore.Components.Web;
|
||||
|
||||
namespace AIStudio.Settings.DataModel;
|
||||
|
||||
public static class SendBehaviorExtensions
|
||||
{
|
||||
/// <param name="behavior">The shortcut the person chose for sending.</param>
|
||||
extension(SendBehavior behavior)
|
||||
{
|
||||
/// <summary>
|
||||
/// Checks whether a key released in a message field sends the message.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Every message field of the app reads the keys this way, so that the shortcut chosen for the chat holds
|
||||
/// wherever the person writes to a model.
|
||||
/// </remarks>
|
||||
/// <param name="keyEvent">The key released.</param>
|
||||
/// <returns>True when the key sends the message.</returns>
|
||||
public bool IsSendShortcut(KeyboardEventArgs keyEvent)
|
||||
{
|
||||
// Either enter or numpad enter:
|
||||
var key = keyEvent.Code.ToLowerInvariant();
|
||||
if (key is not ("enter" or "numpadenter"))
|
||||
return false;
|
||||
|
||||
var isModifier = keyEvent.AltKey || keyEvent.CtrlKey || keyEvent.MetaKey || keyEvent.ShiftKey;
|
||||
return behavior switch
|
||||
{
|
||||
SendBehavior.ENTER_IS_SENDING => !isModifier,
|
||||
SendBehavior.MODIFER_ENTER_IS_SENDING => isModifier,
|
||||
|
||||
_ => false
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user