diff --git a/ghost/admin/app/components/modals/settings/signup-form-embed.hbs b/ghost/admin/app/components/modals/settings/signup-form-embed.hbs index b559ca144d..85ef55af0f 100644 --- a/ghost/admin/app/components/modals/settings/signup-form-embed.hbs +++ b/ghost/admin/app/components/modals/settings/signup-form-embed.hbs @@ -58,6 +58,7 @@ @class="gh-input gh-signup-form-embed-code-input" @value={{this.generatedCode}} readonly + {{on "mouseup" this.copyTextOnMouseUp}} />

Copy and paste this HTML code somewhere inside the <body> tag of your site.

diff --git a/ghost/admin/app/components/modals/settings/signup-form-embed.js b/ghost/admin/app/components/modals/settings/signup-form-embed.js index a3acd491f7..8d1bba193f 100644 --- a/ghost/admin/app/components/modals/settings/signup-form-embed.js +++ b/ghost/admin/app/components/modals/settings/signup-form-embed.js @@ -137,14 +137,31 @@ export default class SignupFormEmbedModal extends Component { return code; } - @task - *copyText() { + doCopy() { // Copy this.generatedCode tp the clipboard const el = document.getElementById('gh-signup-form-embed-code-input'); el.select(); document.execCommand('copy'); + } + + /** + * Calling this task will make the button green, so avoid using if you don't want that + */ + @task + *copyText() { + // Copy this.generatedCode tp the clipboard + this.doCopy(); yield true; return true; } + + @action + copyTextOnMouseUp() { + // Check if there is no current text selection anywhere on the page, otherwise skip copying + // This is so users can still select text manually without copying automatically + if (window.getSelection().toString() === '') { + this.doCopy(); + } + } }