How to copy the content of a “textArea” flowui component to the client’s clipboard using Jmix 2?
It would be copied after this line of code: xvspellconverter/src/main/java/com/company/xvspellconverter/view/anonymousmainviewtopmenu/AnonymousMainViewTopMenu.java at 20dbea0804436d6793c379e64b69ec24f0bd2f7f · edurbs/xvspellconverter · GitHub
Solved with javascript:
…
String textAreaFinal = "textAreaFinal";
textAreaTo.setId(textAreaFinal);
textAreaTo.focus();
String script = String.format("""
let vaadinTextArea = document.getElementById('%s');
let htmlTextArea = vaadinTextArea.getElementsByTagName('textarea')
htmlTextArea[0].select();
document.execCommand('copy');""",
textAreaFinal);
textAreaTo.getUI().ifPresent(ui -> {
ui.getPage().executeJs(script);
});