Using clipboard in ingameUI panel code

I am trying to extract and import some data from my app that is using the
ingameUI popup panel from the flying menu. I am not allowed to use the
JavaScript access avigator.clipboard.writeText function. I have seen other
apps that do post to the clipboard but I am not sure how it is being done. Any
help?

To copy some text without a text field selected:

var dummy = document.createElement("textarea");
document.body.appendChild(dummy);
dummy.value = text;
dummy.select();
document.execCommand("copy")
document.body.removeChild(dummy);

Paste:

document.execCommand("paste")