mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2025-02-05 19:49:06 +00:00
Added Markdown clipboard service
This commit is contained in:
parent
f11b9e0299
commit
0b9bf32a84
28
app/MindWork AI Studio/MarkdownClipboardService.cs
Normal file
28
app/MindWork AI Studio/MarkdownClipboardService.cs
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
using AIStudio.Tools;
|
||||||
|
|
||||||
|
using Microsoft.JSInterop;
|
||||||
|
|
||||||
|
using MudBlazor;
|
||||||
|
|
||||||
|
// ReSharper disable ClassNeverInstantiated.Global
|
||||||
|
|
||||||
|
namespace AIStudio;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Wire up the clipboard service to copy markdown to the clipboard.
|
||||||
|
/// We use our own Rust-based clipboard service for this.
|
||||||
|
/// </summary>
|
||||||
|
public sealed class MarkdownClipboardService(Rust rust, IJSRuntime jsRuntime, ISnackbar snackbar) : IMudMarkdownClipboardService
|
||||||
|
{
|
||||||
|
private IJSRuntime JsRuntime { get; } = jsRuntime;
|
||||||
|
|
||||||
|
private ISnackbar Snackbar { get; } = snackbar;
|
||||||
|
|
||||||
|
private Rust Rust { get; } = rust;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets called when the user wants to copy the markdown to the clipboard.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="text">The Markdown text to copy.</param>
|
||||||
|
public async ValueTask CopyToClipboardAsync(string text) => await this.Rust.CopyText2Clipboard(this.JsRuntime, this.Snackbar, text);
|
||||||
|
}
|
@ -1,3 +1,4 @@
|
|||||||
|
using AIStudio;
|
||||||
using AIStudio.Components;
|
using AIStudio.Components;
|
||||||
using AIStudio.Settings;
|
using AIStudio.Settings;
|
||||||
|
|
||||||
@ -18,6 +19,8 @@ builder.Services.AddMudServices(config =>
|
|||||||
});
|
});
|
||||||
|
|
||||||
builder.Services.AddMudMarkdownServices();
|
builder.Services.AddMudMarkdownServices();
|
||||||
|
builder.Services.AddSingleton<Rust>();
|
||||||
|
builder.Services.AddMudMarkdownClipboardService<MarkdownClipboardService>();
|
||||||
builder.Services.AddSingleton<SettingsManager>();
|
builder.Services.AddSingleton<SettingsManager>();
|
||||||
builder.Services.AddRazorComponents()
|
builder.Services.AddRazorComponents()
|
||||||
.AddInteractiveServerComponents()
|
.AddInteractiveServerComponents()
|
||||||
|
Loading…
Reference in New Issue
Block a user