How about a form?
Standard text boxes or the rich text editor support markdown, so you can put ``` before and after the code snippet to get it to format as code.
Substring the snippet into a text box in the form with componentName.value.substring(text1.value.indexOf("```")) (or just setValue the snippet from wherever it is coming from).
Then set the "submit" action for the form to execute utils.copyToClipboard(form1.data) and it pastes the snippet to the clipboard:
