A cross-platform UI framework for .NET
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

34 lines
1.1 KiB

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Avalonia.Input;
using Avalonia.Input.Platform;
using Microsoft.JSInterop;
namespace Avalonia.Web.Blazor
{
internal class ClipboardImpl : IClipboard
{
public async Task<string> GetTextAsync()
{
return await AvaloniaLocator.Current.GetRequiredService<IJSInProcessRuntime>().
InvokeAsync<string>("navigator.clipboard.readText");
}
public async Task SetTextAsync(string text)
{
await AvaloniaLocator.Current.GetRequiredService<IJSInProcessRuntime>().
InvokeAsync<string>("navigator.clipboard.writeText",text);
}
public async Task ClearAsync() => await SetTextAsync("");
public Task SetDataObjectAsync(IDataObject data) => Task.CompletedTask;
public Task<string[]> GetFormatsAsync() => Task.FromResult(Array.Empty<string>());
public Task<object> GetDataAsync(string format) => Task.FromResult<object>(new());
}
}