Merge branch 'main' into 303-update-notifications
This commit is contained in:
@@ -77,7 +77,10 @@ export const maybeWithBearerAuth = (headers, token) => {
|
||||
return headers;
|
||||
};
|
||||
|
||||
export const withBasicAuth = (headers, username, password) => ({ ...headers, Authorization: basicAuth(username, password) });
|
||||
export const withBasicAuth = (headers, username, password) => ({
|
||||
...headers,
|
||||
Authorization: basicAuth(username, password),
|
||||
});
|
||||
|
||||
export const maybeWithAuth = (headers, user) => {
|
||||
if (user?.password) {
|
||||
@@ -270,3 +273,21 @@ export const urlB64ToUint8Array = (base64String) => {
|
||||
}
|
||||
return outputArray;
|
||||
};
|
||||
|
||||
export const copyToClipboard = (text) => {
|
||||
if (navigator.clipboard && window.isSecureContext) {
|
||||
return navigator.clipboard.writeText(text);
|
||||
}
|
||||
// Fallback to the older method if clipboard API is not supported (or on HTTP)
|
||||
const textarea = document.createElement("textarea");
|
||||
textarea.value = text;
|
||||
textarea.setAttribute("readonly", ""); // Avoid mobile keyboards from popping up
|
||||
textarea.style.position = "fixed"; // Avoid scroll jump
|
||||
textarea.style.left = "-9999px";
|
||||
document.body.appendChild(textarea);
|
||||
textarea.focus();
|
||||
textarea.select();
|
||||
document.execCommand("copy");
|
||||
document.body.removeChild(textarea);
|
||||
return Promise.resolve();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user