2024-05-04 08:47:42 +00:00
|
|
|
// ReSharper disable ClassNeverInstantiated.Global
|
|
|
|
|
2024-08-21 06:30:01 +00:00
|
|
|
namespace AIStudio.Tools.Services;
|
2024-05-04 08:47:42 +00:00
|
|
|
|
|
|
|
/// <summary>
|
2024-08-21 06:30:01 +00:00
|
|
|
/// Wire up the clipboard service to copy Markdown to the clipboard.
|
2024-05-04 08:47:42 +00:00
|
|
|
/// 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);
|
|
|
|
}
|