Files
tubestation/browser/extensions/screenshots/webextension/clipboard.js
Mark Banner d2d9626164 Bug 1346825 - Import Screenshots version 6.3.0 into mozilla-central. rs=Mossop.
This is imported from https://github.com/mozilla-services/screenshots/.
It has been reviewed as patches landed, but also reviewed by Mossop and kmag.
This also includes the patch from bug 1356394

MozReview-Commit-ID: FXIVw7WjxlN
2017-04-13 09:49:17 +01:00

24 lines
473 B
JavaScript

/* globals catcher */
"use strict";
this.clipboard = (function () {
let exports = {};
exports.copy = function (text) {
let el = document.createElement("textarea");
document.body.appendChild(el);
el.value = text;
el.select();
const copied = document.execCommand("copy");
document.body.removeChild(el);
if (!copied) {
catcher.unhandled(new Error("Clipboard copy failed"));
}
return copied;
};
return exports;
})();
null;