I am trying to click on copy button on an editor using Javascript for automation purposes but the text not stored in the clipboard
tried the below codes
const button = document.getElementById("copy-1");
button.click();
and
const button = document.getElementById("copy-1");
const event = new Event("click");
button.dispatchEvent(event);
the HTML code
<button id="copy-1" type="button" tabindex="-1" role="button" class="fr-command fr-btn" data-cmd="copy" data-title="Copy" style="outline: 1px solid blue;">
<froalacopy_button class="hoverable"><i class="fas fa-copy"></i></froalacopy_button><span class="fr-sr-only">Copy</span>
</button>
also, I tried to copy it directly but the copied text was not formatted

According to Froala Editor you do not need to handle the custom button click event manually. You can add a button using its methods like
DefineIconandRegisterCommand.In
RegisterCommandyou will get thecallbackmethod which will handle theonclick eventof that button.You can check more from here