Using the Clipboard in TXTextControl.Web
TX Text Control integrates powerful, unique clipboard features that enable users to paste content from client applications such as MS Word. You can copy and paste content from MS Word into TX Text Control without losing features. This article shows how to use the two clipboard modes.

TX Text Control integrates powerful, unique clipboard features that enable users to paste content from client applications such as MS Word. You can copy and paste content from MS Word into TX Text Control without losing features. Document elements such as headers and footers, text frames and even merge fields are maintained.
Two Clipboards
TX Text Control provides two clipboards the local and the server clipboard. The reason is quite simple: Browsers are very limited and restrictive when it comes to client clipboard access for security reasons.
-
Local Clipboard
If the Local Clipboard is activated (ribbon bar button or via JavaScript), you can copy and paste content from your local machine to TX Text Control. Accepted formats are RTF, HTML, plain text and images. Other than HTML-based editors, TX Text Control is rendering the rich text format (RTF) directly without converting content to HTML. This maintains sophisticated formatting and features. -
Server Clipboard
If the Local Clipboard is deactivated, the Server Clipboard is automatically active. The server clipboard is an internal clipboard that handles all features of TX Text Control. It is using another clipboard stack and can be used for internal clipboard actions.
The clipboard mode can be set using JavaScript with the clipboard
TXTextControl.clipboardMode = TXTextControl.ClipboardMode.Client;
Our online demo Clipboard implements a progress bar that indicates whether selected content is ready to be copied.
If the Local Clipboard is activated, monitor the demo clipboard progress bar that uses the clipboard JavaScript events of TX Text Control to show whether the clipboard is ready for a copy action or not.
|
Content is ready for Copy. Use CTRL-C to copy selected content. |
|
Content is being prepared for Copy. Wait until you see the green bar before copying the selected content. |
The events clipboardDataTransferStart, clipboardDataTransferComplete, clipboardDataTransferProgress and clipboardDataTransferAborted are used to update the progress bar state.
TXTextControl.addEventListener("clipboardDataTransferStart", clipboardDataTransferStartHandler);
TXTextControl.addEventListener("clipboardDataTransferComplete", clipboardDataTransferCompleteHandler);
TXTextControl.addEventListener("clipboardDataTransferProgress", clipboardDataTransferProgressHandler);
TXTextControl.addEventListener("clipboardDataTransferAborted", clipboardDataTransferAbortedHandler);
function clipboardDataTransferStartHandler() {
$(".progress-bar").attr("aria-valuenow", 0);
$(".progress-bar").css("width", "0%");
$(".progress-bar").removeClass("bg-success");
$(".progress-bar").addClass("progress-bar-striped progress-bar-animated bg-danger");
}
function clipboardDataTransferCompleteHandler() {
$(".progress-bar").removeClass("progress-bar-striped progress-bar-animated bg-danger");
$(".progress-bar").addClass("bg-success");
$(".progress-bar").attr("aria-valuenow", 100);
$(".progress-bar").css("width", "100%");
}
function clipboardDataTransferProgressHandler(e) {
$(".progress-bar").attr("aria-valuenow", e.progress);
$(".progress-bar").css("width", e.progress + "%");
}
function clipboardDataTransferAbortedHandler() {
clipboardDataTransferCompleteHandler();
}
Test this functionality using our online demos:
Also See
This post references the following in the documentation:
- Javascript: Clipboard
Data Transfer Start Callback Function - Javascript: TXText
Control.clipboard Mode Property
Related Posts
Add JavaScript to PDFs with TX Text Control in C# .NET: Time-Based Alerts…
In this article, we explore how to enrich PDF documents with JavaScript using TX Text Control in C# .NET. Read on to learn how to create time-based alerts that trigger actions based on specific…
Using the Document Editor in SPA Applications using the removeFromDom Method
This article shows how to use the removeFromDom method to remove the Document Editor from the DOM when it is no longer needed. This is useful when the Document Editor is used in a Single Page…
Observe When the Reporting Preview Tab is Active Using MutationObserver
This article shows how to observe when the Reporting Preview tab is active using MutationObserver. The Reporting Preview tab is a feature of the TX Text Control Document Editor that allows you to…
ASP.NETJavaScriptDocument Editor
Removing Empty Pages in TX Text Control with JavaScript
TX Text Control offers a C# solution for removing empty pages already. However, implementing this in JavaScript provides more flexibility for web environments. By using JavaScript methods to…
Document Editor: Useful JavaScript Functions for Tables
This article shows how to use JavaScript functions to manipulate tables in the Document Editor. It demonstrates how to set and get text in a table cell, and how to export a table to JSON.