diff --git a/web/src/screens/filters/list.tsx b/web/src/screens/filters/list.tsx index bf6913e..f680eae 100644 --- a/web/src/screens/filters/list.tsx +++ b/web/src/screens/filters/list.tsx @@ -405,14 +405,41 @@ const FilterItemDropdown = ({ filter, onToggle }: FilterItemDropdownProps) => { ); const finalJson = discordFormat ? "```JSON\n" + json + "\n```" : json; - + + const copyTextToClipboard = (text: string) => { + const textarea = document.createElement("textarea"); + textarea.style.position = "fixed"; + textarea.style.opacity = "0"; + textarea.value = text; + document.body.appendChild(textarea); + textarea.focus(); + textarea.select(); + + try { + const successful = document.execCommand("copy"); + if (successful) { + toast.custom((t) => ); + } else { + toast.custom((t) => ); + } + } catch (err) { + console.error("Unable to copy text", err); + toast.custom((t) => ); + } + + document.body.removeChild(textarea); + }; + + if (navigator.clipboard) { + navigator.clipboard.writeText(finalJson).then(() => { + toast.custom((t) => ); + }, () => { + toast.custom((t) => ); + }); + } else { + copyTextToClipboard(finalJson); + } - navigator.clipboard.writeText(finalJson).then(() => { - toast.custom((t) => ); - }, () => { - toast.custom((t) => ); - }); - } catch (error) { console.error(error); toast.custom((t) => );