Use an invisible div instead of an invisible pre element for the text copy.
Don't escape HTML characters in the text copy. If the text includes HTML, for example, the escaped HTML would be longer than the original text, causing discrepancies in the heights of the input textarea and the text copy.