How do I add a custom "copy" button to PrizmDoc

Modified on Wed, Oct 2, 2024 at 4:28 PM

Once I have some text selected in PrizmDoc, I would like to add a button to copy the the text content. Is this possible?


When there is text selected, you can access that text programmatically, using the "TextSelected" Event. This event is fired when text is selected.


For example:

let selectedText = "";  
viewerControl.on("TextSelected", event => {  
    selectedText = event.textSelection.text;  
});

Then currentSelection will contain the text that was just selected. Then you can display a button to copy the text whether that is in a custom context menu, or a menu on the toolbar or wherever. You can then programmatically copy the text to the clipboard using the following code:

// Custom button to copy text  
$("#copyText").click(async function() {  
    await navigator.clipboard.writeText(selectedText);  
});

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article