bClipboard 1.0.1

dotnet add package bClipboard --version 1.0.1                
NuGet\Install-Package bClipboard -Version 1.0.1                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="bClipboard" Version="1.0.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add bClipboard --version 1.0.1                
#r "nuget: bClipboard, 1.0.1"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// 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.

Nuget Nuget .NET 6 .NET 7 .NET 8

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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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 167 7/26/2024