Skip to content

Commit

Permalink
fix copy to clipboard
Browse files Browse the repository at this point in the history
  • Loading branch information
lakhoune committed Nov 30, 2023
1 parent 590c876 commit 9c6edae
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 21 deletions.
10 changes: 3 additions & 7 deletions src/statistics/recommender/custom-improvements.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,14 +215,10 @@ class IntentImprovement extends LitElement {
this.shadowRoot.querySelector("#askGPTButton").disabled = false;
}
}

copyToClipboard() {
const copyText = this.shadowRoot.querySelector("#chatgptRes");
const textArea = document.createElement("textarea");
textArea.value = copyText.textContent;
document.body.appendChild(textArea);
textArea.select();
document.execCommand("Copy");
textArea.remove();
const resDiv = this.shadowRoot.querySelector("#chatgptRes");
navigator.clipboard.writeText(resDiv.innerText);
}
}

Expand Down
9 changes: 2 additions & 7 deletions src/statistics/recommender/general-improvements.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,8 @@ class GeneralImprovement extends LitElement {
}

copyToClipboard() {
const copyText = this.shadowRoot.querySelector("#chatgptRes");
const textArea = document.createElement("textarea");
textArea.value = copyText.textContent;
document.body.appendChild(textArea);
textArea.select();
document.execCommand("Copy");
textArea.remove();
const resDiv = this.shadowRoot.querySelector("#chatgptRes");
navigator.clipboard.writeText(resDiv.innerText);
}

async firstUpdated() {
Expand Down
9 changes: 2 additions & 7 deletions src/statistics/recommender/intent-improvements.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,8 @@ class IntentImprovement extends LitElement {
}

copyToClipboard() {
const copyText = this.shadowRoot.querySelector("#chatgptRes");
const textArea = document.createElement("textarea");
textArea.value = copyText.textContent;
document.body.appendChild(textArea);
textArea.select();
document.execCommand("Copy");
textArea.remove();
const resDiv = this.shadowRoot.querySelector("#chatgptRes");
navigator.clipboard.writeText(resDiv.innerText);
}

async askGPT() {
Expand Down

0 comments on commit 9c6edae

Please sign in to comment.