Skip to content

Commit baedebb

Browse files
committed
implement copying functionality
1 parent e640996 commit baedebb

1 file changed

Lines changed: 19 additions & 1 deletion

File tree

app/js/crmapi.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5681,7 +5681,25 @@ export type CRMAPIMessage = {
56815681
* @see {@link https://tampermonkey.net/documentation.php#GM_setClipboard}
56825682
* @param {any} ignoredArguments - An argument that is ignored
56835683
*/
5684-
GM_setClipboard: CrmAPIInstance._helpers.emptyFn,
5684+
GM_setClipboard(this: CrmAPIInstance, content: string): void {
5685+
const element = document.createElement('span');
5686+
element.innerText = content;
5687+
document.body.appendChild(element);
5688+
5689+
const snipRange = document.createRange();
5690+
snipRange.selectNode(element);
5691+
const selection = window.getSelection();
5692+
selection.removeAllRanges();
5693+
selection.addRange(snipRange);
5694+
try {
5695+
document.execCommand('copy');
5696+
} catch(e) {
5697+
console.log(e);
5698+
}
5699+
5700+
selection.removeAllRanges();
5701+
element.remove();
5702+
},
56855703
/**
56865704
* Sends an xmlhttpRequest with given parameters
56875705
*

0 commit comments

Comments
 (0)