Skip to content

Commit 7784538

Browse files
committed
Use more efficient copy method for clipboard service
1 parent ef4fcf7 commit 7784538

File tree

1 file changed

+1
-11
lines changed

1 file changed

+1
-11
lines changed

Diff for: frontend/app/services/clipboard-service.js

+1-11
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,6 @@ import Service from "@ember/service";
22

33
export default class ClipboardService extends Service {
44
copy(text) {
5-
// Copying to clipboard is not possible in another way. Even libraries do it with a fake element.
6-
// We don't use the addon ember-cli-clipboard, as we need to wait for a async call to finish.
7-
const fakeEl = document.createElement("textarea");
8-
fakeEl.value = text;
9-
fakeEl.setAttribute("readonly", "");
10-
fakeEl.style.position = "absolute";
11-
fakeEl.style.left = "-9999px";
12-
document.body.appendChild(fakeEl);
13-
fakeEl.select();
14-
document.execCommand("copy");
15-
document.body.removeChild(fakeEl);
5+
navigator.clipboard.writeText(text);
166
}
177
}

0 commit comments

Comments
 (0)