Copy from clipboard to a text area

I want to create a text area, and upon creation, to copy text from the clipboard into it, if there’s text in the clipboard.
What would be the bast way to achieve this?

It is a bit a challenge to make it so that works all the browsers. The example below is using the new API to readText from clipboard, and it is supported by Chrome and other modern browsers. For some reason Chrome does not support the older document.execCommand('paste') JavaScript method, which on the other hand is supported by IE11. Note Chrome will ask user permission to access the clipboard before first time used on the page.

public class CopyFromClipboard extends VerticalLayout {

    TextArea textArea = new TextArea("Copy to");

    public CopyFromClipboard() {
        Span text = new Span("This is some example text that you can copy to your clipboard.");

        Button button = new Button("Copy fro m clipboard", VaadinIcon.COPY.create());
        button.addClickListener(
            e -> {
                UI.getCurrent().getPage().executeJs("navigator.clipboard.readText().then(clipText => $0.$server.doPaste(clipText)) ", getElement());
            }
        );
        add(text, textArea, button);
    }
    
    @ClientCallable
    public void doPaste(String clipText) {
        textArea.setValue(clipText);
    }
}

Works like a charm.
For some reason it does not work when setting a break point in the line that executes the JS.
Thanks very much for your help.