Added copy on click to textarea in signup form embed modal
no issue
This commit is contained in:
parent
fc5af7e7f8
commit
d4f82f8b88
@ -58,6 +58,7 @@
|
||||
@class="gh-input gh-signup-form-embed-code-input"
|
||||
@value={{this.generatedCode}}
|
||||
readonly
|
||||
{{on "mouseup" this.copyTextOnMouseUp}}
|
||||
/>
|
||||
<p>Copy and paste this HTML code somewhere inside the <code><body></code> tag of your site.</p>
|
||||
</div>
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user