mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
96399c7112
* feat: filters in plane deploy implemented multi-level dropdown for plane deploy * style: spacing and fonts * feat: plane deploy implemented authentication/theming, created/modified all the required store & services * devL reactions, voting, comments and theme
32 lines
960 B
TypeScript
32 lines
960 B
TypeScript
export const addSpaceIfCamelCase = (str: string) => str.replace(/([a-z])([A-Z])/g, "$1 $2");
|
|
|
|
const fallbackCopyTextToClipboard = (text: string) => {
|
|
var textArea = document.createElement("textarea");
|
|
textArea.value = text;
|
|
|
|
// Avoid scrolling to bottom
|
|
textArea.style.top = "0";
|
|
textArea.style.left = "0";
|
|
textArea.style.position = "fixed";
|
|
|
|
document.body.appendChild(textArea);
|
|
textArea.focus();
|
|
textArea.select();
|
|
|
|
try {
|
|
// FIXME: Even though we are using this as a fallback, execCommand is deprecated 👎. We should find a better way to do this.
|
|
// https://developer.mozilla.org/en-US/docs/Web/API/Document/execCommand
|
|
var successful = document.execCommand("copy");
|
|
} catch (err) {}
|
|
|
|
document.body.removeChild(textArea);
|
|
};
|
|
|
|
export const copyTextToClipboard = async (text: string) => {
|
|
if (!navigator.clipboard) {
|
|
fallbackCopyTextToClipboard(text);
|
|
return;
|
|
}
|
|
await navigator.clipboard.writeText(text);
|
|
};
|