bClipboard 1.0.1
dotnet add package bClipboard --version 1.0.1
NuGet\Install-Package bClipboard -Version 1.0.1
<PackageReference Include="bClipboard" Version="1.0.1" />
paket add bClipboard --version 1.0.1
#r "nuget: bClipboard, 1.0.1"
// Install bClipboard as a Cake Addin #addin nuget:?package=bClipboard&version=1.0.1 // Install bClipboard as a Cake Tool #tool nuget:?package=bClipboard&version=1.0.1
<p align="center"> <img src="https://github.com/mabroukmahdhi/bClipboard/blob/main/clipboard.png"> </p>
bClipboard
bClipboard is a Blazor library that simplifies clipboard operations for Blazor applications. It provides methods to copy text to and read text from the clipboard using JavaScript interop.
Features
- Copy to Clipboard: Easily copy text to the clipboard.
- Read from Clipboard: Read text from the clipboard.
Installation
To install bClipboard, you need to add the NuGet package to your Blazor project:
dotnet add package bClipboard
Usage
Register the Clipboard Service
In your Program.cs
file, register the ClipboardService
with the dependency injection container.
[...]
using bClipboard.Extensions;
var builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.RootComponents.Add<App>("#app");
builder.Services.AddBClipboardService();
await builder.Build().RunAsync();
Use the Clipboard Service in Your Blazor Component
Inject the IClipboardService
into your Blazor component and use its methods to copy to and read from the clipboard.
@page "/clipboard"
@inject IClipboardService ClipboardService
<h3>Clipboard Example</h3>
<input @bind="textToCopy" placeholder="Enter text to copy" />
<button @onclick="CopyToClipboard">Copy Text</button>
<p>Clipboard Content: @clipboardContent</p>
<button @onclick="ReadFromClipboard">Read Clipboard</button>
@code {
private string textToCopy;
private string clipboardContent;
private async Task CopyToClipboard()
{
await ClipboardService.CopyToClipboardAsync(textToCopy);
}
private async Task ReadFromClipboard()
{
clipboardContent = await ClipboardService.ReadFromClipboardAsync();
}
}
JavaScript Interop
The library uses a JavaScript file (bclipboard.js
) for clipboard operations.
Contributing
We welcome contributions! Please see our contributing guidelines for more details.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net6.0
- Microsoft.AspNetCore.Components.Web (>= 6.0.32)
-
net7.0
- Microsoft.AspNetCore.Components.Web (>= 7.0.20)
-
net8.0
- Microsoft.AspNetCore.Components.Web (>= 8.0.7)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.0.1 | 218 | 7/26/2024 |