mirror of
https://github.com/Equicord/Equicord.git
synced 2025-06-08 22:23:02 -04:00
Clipboard Fixes
This commit is contained in:
parent
5d00294ee5
commit
506e3dcfd6
12 changed files with 38 additions and 34 deletions
|
@ -6,9 +6,10 @@
|
||||||
|
|
||||||
import { showNotification } from "@api/Notifications";
|
import { showNotification } from "@api/Notifications";
|
||||||
import { Settings } from "@api/Settings";
|
import { Settings } from "@api/Settings";
|
||||||
|
import { copyToClipboard } from "@utils/clipboard";
|
||||||
import { relaunch, showItemInFolder } from "@utils/native";
|
import { relaunch, showItemInFolder } from "@utils/native";
|
||||||
import { checkForUpdates, getRepo } from "@utils/updater";
|
import { checkForUpdates, getRepo } from "@utils/updater";
|
||||||
import { Clipboard, GuildStore, NavigationRouter, SettingsRouter, Toasts } from "@webpack/common";
|
import { GuildStore, NavigationRouter, SettingsRouter, Toasts } from "@webpack/common";
|
||||||
|
|
||||||
import gitHash from "~git-hash";
|
import gitHash from "~git-hash";
|
||||||
import gitRemote from "~git-remote";
|
import gitRemote from "~git-remote";
|
||||||
|
@ -89,7 +90,7 @@ export const actions: ButtonAction[] = [
|
||||||
const newUrl = url.replace(/(https?:\/\/)?([a-zA-Z0-9-]+)\.([a-zA-Z0-9-]+)/, "https://$2.$3");
|
const newUrl = url.replace(/(https?:\/\/)?([a-zA-Z0-9-]+)\.([a-zA-Z0-9-]+)/, "https://$2.$3");
|
||||||
const res = (await fetch(newUrl));
|
const res = (await fetch(newUrl));
|
||||||
const text = await res.text();
|
const text = await res.text();
|
||||||
Clipboard.copy(text);
|
copyToClipboard(text);
|
||||||
|
|
||||||
Toasts.show({
|
Toasts.show({
|
||||||
message: "Copied response to clipboard!",
|
message: "Copied response to clipboard!",
|
||||||
|
@ -115,7 +116,7 @@ export const actions: ButtonAction[] = [
|
||||||
|
|
||||||
{
|
{
|
||||||
id: "copyGitInfo", label: "Copy Git Info", callback: async () => {
|
id: "copyGitInfo", label: "Copy Git Info", callback: async () => {
|
||||||
Clipboard.copy(`gitHash: ${gitHash}\ngitRemote: ${gitRemote}`);
|
copyToClipboard(`gitHash: ${gitHash}\ngitRemote: ${gitRemote}`);
|
||||||
|
|
||||||
Toasts.show({
|
Toasts.show({
|
||||||
message: "Copied git info to clipboard!",
|
message: "Copied git info to clipboard!",
|
||||||
|
|
|
@ -5,9 +5,10 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { addContextMenuPatch, NavContextMenuPatchCallback, removeContextMenuPatch } from "@api/ContextMenu";
|
import { addContextMenuPatch, NavContextMenuPatchCallback, removeContextMenuPatch } from "@api/ContextMenu";
|
||||||
|
import { copyToClipboard } from "@utils/clipboard";
|
||||||
import { EquicordDevs } from "@utils/constants";
|
import { EquicordDevs } from "@utils/constants";
|
||||||
import definePlugin from "@utils/types";
|
import definePlugin from "@utils/types";
|
||||||
import { Clipboard, Menu, Toasts, UserProfileStore } from "@webpack/common";
|
import { Menu, Toasts, UserProfileStore } from "@webpack/common";
|
||||||
|
|
||||||
function getProfileColors(userId) {
|
function getProfileColors(userId) {
|
||||||
try {
|
try {
|
||||||
|
@ -46,7 +47,7 @@ function copyProfileColors(userId) {
|
||||||
const formattedColors = `Primary-color #${primaryColor}, Secondary-Color #${secondaryColor}`;
|
const formattedColors = `Primary-color #${primaryColor}, Secondary-Color #${secondaryColor}`;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Clipboard.copy(formattedColors);
|
copyToClipboard(formattedColors);
|
||||||
Toasts.show({
|
Toasts.show({
|
||||||
type: Toasts.Type.SUCCESS,
|
type: Toasts.Type.SUCCESS,
|
||||||
message: "Profile colors copied to clipboard!",
|
message: "Profile colors copied to clipboard!",
|
||||||
|
|
|
@ -5,9 +5,10 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { NavContextMenuPatchCallback } from "@api/ContextMenu";
|
import { NavContextMenuPatchCallback } from "@api/ContextMenu";
|
||||||
|
import { copyToClipboard } from "@utils/clipboard";
|
||||||
import { Devs, EquicordDevs } from "@utils/constants";
|
import { Devs, EquicordDevs } from "@utils/constants";
|
||||||
import definePlugin from "@utils/types";
|
import definePlugin from "@utils/types";
|
||||||
import { Clipboard, Menu } from "@webpack/common";
|
import { Menu } from "@webpack/common";
|
||||||
import type { Channel, User } from "discord-types/general";
|
import type { Channel, User } from "discord-types/general";
|
||||||
|
|
||||||
const MentionIcon = () => (
|
const MentionIcon = () => (
|
||||||
|
@ -37,7 +38,7 @@ const UserContextMenuPatch: NavContextMenuPatchCallback = (children, { user }: U
|
||||||
<Menu.MenuItem
|
<Menu.MenuItem
|
||||||
id="vc-copy-user-mention"
|
id="vc-copy-user-mention"
|
||||||
label="Copy User Mention"
|
label="Copy User Mention"
|
||||||
action={() => Clipboard.copy(`<@${user.id}>`)}
|
action={() => copyToClipboard(`<@${user.id}>`)}
|
||||||
icon={MentionIcon}
|
icon={MentionIcon}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|
|
@ -19,9 +19,10 @@
|
||||||
import "./styles.css";
|
import "./styles.css";
|
||||||
|
|
||||||
import ErrorBoundary from "@components/ErrorBoundary";
|
import ErrorBoundary from "@components/ErrorBoundary";
|
||||||
|
import { copyToClipboard } from "@utils/clipboard";
|
||||||
import { EquicordDevs } from "@utils/constants";
|
import { EquicordDevs } from "@utils/constants";
|
||||||
import definePlugin from "@utils/types";
|
import definePlugin from "@utils/types";
|
||||||
import { Clipboard, Toasts } from "@webpack/common";
|
import { Toasts } from "@webpack/common";
|
||||||
|
|
||||||
interface User {
|
interface User {
|
||||||
id: string;
|
id: string;
|
||||||
|
@ -97,7 +98,7 @@ export default definePlugin({
|
||||||
|
|
||||||
copyContactToClipboard() {
|
copyContactToClipboard() {
|
||||||
if (this.contactList) {
|
if (this.contactList) {
|
||||||
Clipboard.copy(JSON.stringify(this.contactList));
|
copyToClipboard(JSON.stringify(this.contactList));
|
||||||
Toasts.show({
|
Toasts.show({
|
||||||
message: "Contacts copied to clipboard successfully.",
|
message: "Contacts copied to clipboard successfully.",
|
||||||
type: Toasts.Type.SUCCESS,
|
type: Toasts.Type.SUCCESS,
|
||||||
|
|
|
@ -6,8 +6,9 @@
|
||||||
|
|
||||||
import "./styles.css";
|
import "./styles.css";
|
||||||
|
|
||||||
|
import { copyToClipboard } from "@utils/clipboard";
|
||||||
import { findByPropsLazy } from "@webpack";
|
import { findByPropsLazy } from "@webpack";
|
||||||
import { Button, Clipboard, Flex, Forms, Parser, Text, useEffect, useState } from "@webpack/common";
|
import { Button, Flex, Forms, Parser, Text, useEffect, useState } from "@webpack/common";
|
||||||
|
|
||||||
import { FriendInvite } from "./types";
|
import { FriendInvite } from "./types";
|
||||||
|
|
||||||
|
@ -51,7 +52,7 @@ function FriendInviteCard({ invite }: { invite: FriendInvite; }) {
|
||||||
<CopyButton
|
<CopyButton
|
||||||
copyText="Copy"
|
copyText="Copy"
|
||||||
copiedText="Copied!"
|
copiedText="Copied!"
|
||||||
onClick={() => Clipboard.copy(`https://discord.gg/${invite.code}`)}
|
onClick={() => copyToClipboard(`https://discord.gg/${invite.code}`)}
|
||||||
/>
|
/>
|
||||||
</Flex>
|
</Flex>
|
||||||
</Flex>
|
</Flex>
|
||||||
|
|
|
@ -10,10 +10,11 @@ import { findGroupChildrenByChildId, NavContextMenuPatchCallback } from "@api/Co
|
||||||
import { DataStore } from "@api/index";
|
import { DataStore } from "@api/index";
|
||||||
import { definePluginSettings } from "@api/Settings";
|
import { definePluginSettings } from "@api/Settings";
|
||||||
import { Flex } from "@components/Flex";
|
import { Flex } from "@components/Flex";
|
||||||
|
import { copyToClipboard } from "@utils/clipboard";
|
||||||
import { Devs, EquicordDevs } from "@utils/constants";
|
import { Devs, EquicordDevs } from "@utils/constants";
|
||||||
import { ModalContent, ModalFooter, ModalHeader, ModalRoot, ModalSize, openModal } from "@utils/modal";
|
import { ModalContent, ModalFooter, ModalHeader, ModalRoot, ModalSize, openModal } from "@utils/modal";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
import { Alerts, Button, Clipboard, ContextMenuApi, FluxDispatcher, Forms, Menu, React, showToast, TextInput, Toasts, useCallback, useState } from "@webpack/common";
|
import { Alerts, Button, ContextMenuApi, FluxDispatcher, Forms, Menu, React, showToast, TextInput, Toasts, useCallback, useState } from "@webpack/common";
|
||||||
|
|
||||||
import { addToCollection, cache_collections, createCollection, DATA_COLLECTION_NAME, deleteCollection, fixPrefix, getCollections, getGifById, getItemCollectionNameFromId, moveGifToCollection, refreshCacheCollection, removeFromCollection, renameCollection } from "./utils/collectionManager";
|
import { addToCollection, cache_collections, createCollection, DATA_COLLECTION_NAME, deleteCollection, fixPrefix, getCollections, getGifById, getItemCollectionNameFromId, moveGifToCollection, refreshCacheCollection, removeFromCollection, renameCollection } from "./utils/collectionManager";
|
||||||
import { getFormat } from "./utils/getFormat";
|
import { getFormat } from "./utils/getFormat";
|
||||||
|
@ -526,7 +527,7 @@ const RemoveItemContextMenu = ({ type, nameOrId, instance }) => (
|
||||||
action={() => {
|
action={() => {
|
||||||
const gifInfo = getGifById(nameOrId);
|
const gifInfo = getGifById(nameOrId);
|
||||||
if (!gifInfo) return;
|
if (!gifInfo) return;
|
||||||
Clipboard.copy(gifInfo.url);
|
copyToClipboard(gifInfo.url);
|
||||||
showToast("URL copied to clipboard", Toasts.Type.SUCCESS);
|
showToast("URL copied to clipboard", Toasts.Type.SUCCESS);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -5,10 +5,11 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { definePluginSettings, Settings } from "@api/Settings";
|
import { definePluginSettings, Settings } from "@api/Settings";
|
||||||
|
import { copyToClipboard } from "@utils/clipboard";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import definePlugin, { OptionType, StartAt } from "@utils/types";
|
import definePlugin, { OptionType, StartAt } from "@utils/types";
|
||||||
import { findComponentByCodeLazy } from "@webpack";
|
import { findComponentByCodeLazy } from "@webpack";
|
||||||
import { Button, Clipboard, Forms, TextInput, Toasts, useState } from "@webpack/common";
|
import { Button, Forms, TextInput, Toasts, useState } from "@webpack/common";
|
||||||
|
|
||||||
import { darkenColorHex, generateRandomColorHex, saturateColorHex } from "./generateTheme";
|
import { darkenColorHex, generateRandomColorHex, saturateColorHex } from "./generateTheme";
|
||||||
import { themes } from "./themeDefinitions";
|
import { themes } from "./themeDefinitions";
|
||||||
|
@ -58,10 +59,7 @@ function copyPreset(name: string) {
|
||||||
name: "${name}"
|
name: "${name}"
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
if (Clipboard.SUPPORTS_COPY) {
|
copyToClipboard(template);
|
||||||
Clipboard.copy(template);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function CopyPresetComponent() {
|
function CopyPresetComponent() {
|
||||||
|
@ -229,9 +227,7 @@ export function ColorPick({ propertyname }: { propertyname: string; }) {
|
||||||
|
|
||||||
|
|
||||||
function copyCSS() {
|
function copyCSS() {
|
||||||
if (Clipboard.SUPPORTS_COPY) {
|
copyToClipboard(getCSS(parseFontContent()));
|
||||||
Clipboard.copy(getCSS(parseFontContent()));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseFontContent() {
|
function parseFontContent() {
|
||||||
|
|
|
@ -4,10 +4,11 @@
|
||||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import { copyToClipboard } from "@utils/clipboard";
|
||||||
import { classes } from "@utils/misc";
|
import { classes } from "@utils/misc";
|
||||||
import { ModalProps } from "@utils/modal";
|
import { ModalProps } from "@utils/modal";
|
||||||
import { findByCode, findByCodeLazy, findByProps, findComponentByCodeLazy } from "@webpack";
|
import { findByCode, findByCodeLazy, findByProps, findComponentByCodeLazy } from "@webpack";
|
||||||
import { Clipboard, ContextMenuApi, FluxDispatcher, Menu, NavigationRouter, React } from "@webpack/common";
|
import { ContextMenuApi, FluxDispatcher, Menu, NavigationRouter, React } from "@webpack/common";
|
||||||
|
|
||||||
import noteHandler from "../../NoteHandler";
|
import noteHandler from "../../NoteHandler";
|
||||||
import { HolyNotes } from "../../types";
|
import { HolyNotes } from "../../types";
|
||||||
|
@ -139,13 +140,13 @@ const NoteContextMenu = (
|
||||||
<Menu.MenuItem
|
<Menu.MenuItem
|
||||||
label="Copy Text"
|
label="Copy Text"
|
||||||
id="copy-text"
|
id="copy-text"
|
||||||
action={() => Clipboard.copy(note.content)}
|
action={() => copyToClipboard(note.content)}
|
||||||
/>
|
/>
|
||||||
{note?.attachments.length ? (
|
{note?.attachments.length ? (
|
||||||
<Menu.MenuItem
|
<Menu.MenuItem
|
||||||
label="Copy Attachment URL"
|
label="Copy Attachment URL"
|
||||||
id="copy-url"
|
id="copy-url"
|
||||||
action={() => Clipboard.copy(note.attachments[0].url)}
|
action={() => copyToClipboard(note.attachments[0].url)}
|
||||||
/>) : null}
|
/>) : null}
|
||||||
<Menu.MenuItem
|
<Menu.MenuItem
|
||||||
color="danger"
|
color="danger"
|
||||||
|
@ -181,7 +182,7 @@ const NoteContextMenu = (
|
||||||
<Menu.MenuItem
|
<Menu.MenuItem
|
||||||
label="Copy ID"
|
label="Copy ID"
|
||||||
id="copy-id"
|
id="copy-id"
|
||||||
action={() => Clipboard.copy(note.id)}
|
action={() => copyToClipboard(note.id)}
|
||||||
/>
|
/>
|
||||||
</Menu.Menu>
|
</Menu.Menu>
|
||||||
);
|
);
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { CodeBlock } from "@components/CodeBlock";
|
import { CodeBlock } from "@components/CodeBlock";
|
||||||
|
import { copyToClipboard } from "@utils/clipboard";
|
||||||
import { Margins } from "@utils/margins";
|
import { Margins } from "@utils/margins";
|
||||||
import { classes } from "@utils/misc";
|
import { classes } from "@utils/misc";
|
||||||
import {
|
import {
|
||||||
|
@ -41,9 +42,7 @@ function ModalComponent(props: { func: Function; iconName: string; color: number
|
||||||
color={Button.Colors.PRIMARY}
|
color={Button.Colors.PRIMARY}
|
||||||
className={"vc-iv-raw-modal-copy-button"}
|
className={"vc-iv-raw-modal-copy-button"}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
// silly typescript
|
copyToClipboard(String(func));
|
||||||
// @ts-ignore
|
|
||||||
Clipboard.copy(String(func));
|
|
||||||
Toasts.show({
|
Toasts.show({
|
||||||
id: Toasts.genId(),
|
id: Toasts.genId(),
|
||||||
message: `Copied raw \`${iconName}\` to clipboard`,
|
message: `Copied raw \`${iconName}\` to clipboard`,
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import { copyToClipboard } from "@utils/clipboard";
|
||||||
import { getIntlMessage } from "@utils/discord";
|
import { getIntlMessage } from "@utils/discord";
|
||||||
import { Margins } from "@utils/margins";
|
import { Margins } from "@utils/margins";
|
||||||
import { classes } from "@utils/misc";
|
import { classes } from "@utils/misc";
|
||||||
|
@ -27,8 +28,7 @@ export type ClickableProps<T extends "a" | "div" | "span" | "li" = "div"> = Prop
|
||||||
export function IconTooltip({ children, copy, className, ...props }: ClickableProps & { children: string; copy: string; }) {
|
export function IconTooltip({ children, copy, className, ...props }: ClickableProps & { children: string; copy: string; }) {
|
||||||
return <TooltipContainer text={"Click to copy"} className={className}>
|
return <TooltipContainer text={"Click to copy"} className={className}>
|
||||||
<Clickable onClick={() => {
|
<Clickable onClick={() => {
|
||||||
// @ts-ignore
|
copyToClipboard(copy);
|
||||||
Clipboard.copy(copy);
|
|
||||||
}} {...props}>{children}</Clickable>
|
}} {...props}>{children}</Clickable>
|
||||||
</TooltipContainer>;
|
</TooltipContainer>;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,13 +6,14 @@
|
||||||
|
|
||||||
import { CodeBlock } from "@components/CodeBlock";
|
import { CodeBlock } from "@components/CodeBlock";
|
||||||
import { Heart } from "@components/Heart";
|
import { Heart } from "@components/Heart";
|
||||||
|
import { copyToClipboard } from "@utils/clipboard";
|
||||||
import { openInviteModal } from "@utils/discord";
|
import { openInviteModal } from "@utils/discord";
|
||||||
import { Margins } from "@utils/margins";
|
import { Margins } from "@utils/margins";
|
||||||
import { classes } from "@utils/misc";
|
import { classes } from "@utils/misc";
|
||||||
import { ModalContent, ModalFooter, ModalHeader, ModalRoot, ModalSize, openModal } from "@utils/modal";
|
import { ModalContent, ModalFooter, ModalHeader, ModalRoot, ModalSize, openModal } from "@utils/modal";
|
||||||
import type { PluginNative } from "@utils/types";
|
import type { PluginNative } from "@utils/types";
|
||||||
import { findComponentByCodeLazy } from "@webpack";
|
import { findComponentByCodeLazy } from "@webpack";
|
||||||
import { Button, Clipboard, Forms, Parser, React, showToast, Toasts } from "@webpack/common";
|
import { Button, Forms, Parser, React, showToast, Toasts } from "@webpack/common";
|
||||||
|
|
||||||
import { Theme, ThemeInfoModalProps } from "../types";
|
import { Theme, ThemeInfoModalProps } from "../types";
|
||||||
import { ClockIcon, DownloadIcon, WarningIcon } from "../utils/Icons";
|
import { ClockIcon, DownloadIcon, WarningIcon } from "../utils/Icons";
|
||||||
|
@ -145,7 +146,7 @@ export const ThemeInfoModal: React.FC<ThemeInfoModalProps> = ({ author, theme, .
|
||||||
</Button>
|
</Button>
|
||||||
<Button className={Margins.right8}
|
<Button className={Margins.right8}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
Clipboard.copy(themeContent);
|
copyToClipboard(themeContent);
|
||||||
showToast("Copied to Clipboard", Toasts.Type.SUCCESS);
|
showToast("Copied to Clipboard", Toasts.Type.SUCCESS);
|
||||||
}}>Copy to Clipboard</Button>
|
}}>Copy to Clipboard</Button>
|
||||||
</ModalFooter>
|
</ModalFooter>
|
||||||
|
|
|
@ -8,8 +8,9 @@ import * as DataStore from "@api/DataStore";
|
||||||
import { definePluginSettings } from "@api/Settings";
|
import { definePluginSettings } from "@api/Settings";
|
||||||
import { classNameFactory } from "@api/Styles";
|
import { classNameFactory } from "@api/Styles";
|
||||||
import { OpenExternalIcon } from "@components/Icons";
|
import { OpenExternalIcon } from "@components/Icons";
|
||||||
|
import { copyToClipboard } from "@utils/clipboard";
|
||||||
import { OptionType } from "@utils/types";
|
import { OptionType } from "@utils/types";
|
||||||
import { Button, Clipboard, Forms, Toasts } from "@webpack/common";
|
import { Button, Forms, Toasts } from "@webpack/common";
|
||||||
|
|
||||||
import { authorizeUser, deauthorizeUser } from "./auth";
|
import { authorizeUser, deauthorizeUser } from "./auth";
|
||||||
|
|
||||||
|
@ -39,7 +40,7 @@ export const settings = definePluginSettings({
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Clipboard.copy(token);
|
copyToClipboard(token);
|
||||||
|
|
||||||
Toasts.show({
|
Toasts.show({
|
||||||
message: "Copied to Clipboard!",
|
message: "Copied to Clipboard!",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue