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 { Settings } from "@api/Settings";
|
||||
import { copyToClipboard } from "@utils/clipboard";
|
||||
import { relaunch, showItemInFolder } from "@utils/native";
|
||||
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 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 res = (await fetch(newUrl));
|
||||
const text = await res.text();
|
||||
Clipboard.copy(text);
|
||||
copyToClipboard(text);
|
||||
|
||||
Toasts.show({
|
||||
message: "Copied response to clipboard!",
|
||||
|
@ -115,7 +116,7 @@ export const actions: ButtonAction[] = [
|
|||
|
||||
{
|
||||
id: "copyGitInfo", label: "Copy Git Info", callback: async () => {
|
||||
Clipboard.copy(`gitHash: ${gitHash}\ngitRemote: ${gitRemote}`);
|
||||
copyToClipboard(`gitHash: ${gitHash}\ngitRemote: ${gitRemote}`);
|
||||
|
||||
Toasts.show({
|
||||
message: "Copied git info to clipboard!",
|
||||
|
|
|
@ -5,9 +5,10 @@
|
|||
*/
|
||||
|
||||
import { addContextMenuPatch, NavContextMenuPatchCallback, removeContextMenuPatch } from "@api/ContextMenu";
|
||||
import { copyToClipboard } from "@utils/clipboard";
|
||||
import { EquicordDevs } from "@utils/constants";
|
||||
import definePlugin from "@utils/types";
|
||||
import { Clipboard, Menu, Toasts, UserProfileStore } from "@webpack/common";
|
||||
import { Menu, Toasts, UserProfileStore } from "@webpack/common";
|
||||
|
||||
function getProfileColors(userId) {
|
||||
try {
|
||||
|
@ -46,7 +47,7 @@ function copyProfileColors(userId) {
|
|||
const formattedColors = `Primary-color #${primaryColor}, Secondary-Color #${secondaryColor}`;
|
||||
|
||||
try {
|
||||
Clipboard.copy(formattedColors);
|
||||
copyToClipboard(formattedColors);
|
||||
Toasts.show({
|
||||
type: Toasts.Type.SUCCESS,
|
||||
message: "Profile colors copied to clipboard!",
|
||||
|
|
|
@ -5,9 +5,10 @@
|
|||
*/
|
||||
|
||||
import { NavContextMenuPatchCallback } from "@api/ContextMenu";
|
||||
import { copyToClipboard } from "@utils/clipboard";
|
||||
import { Devs, EquicordDevs } from "@utils/constants";
|
||||
import definePlugin from "@utils/types";
|
||||
import { Clipboard, Menu } from "@webpack/common";
|
||||
import { Menu } from "@webpack/common";
|
||||
import type { Channel, User } from "discord-types/general";
|
||||
|
||||
const MentionIcon = () => (
|
||||
|
@ -37,7 +38,7 @@ const UserContextMenuPatch: NavContextMenuPatchCallback = (children, { user }: U
|
|||
<Menu.MenuItem
|
||||
id="vc-copy-user-mention"
|
||||
label="Copy User Mention"
|
||||
action={() => Clipboard.copy(`<@${user.id}>`)}
|
||||
action={() => copyToClipboard(`<@${user.id}>`)}
|
||||
icon={MentionIcon}
|
||||
/>
|
||||
);
|
||||
|
|
|
@ -19,9 +19,10 @@
|
|||
import "./styles.css";
|
||||
|
||||
import ErrorBoundary from "@components/ErrorBoundary";
|
||||
import { copyToClipboard } from "@utils/clipboard";
|
||||
import { EquicordDevs } from "@utils/constants";
|
||||
import definePlugin from "@utils/types";
|
||||
import { Clipboard, Toasts } from "@webpack/common";
|
||||
import { Toasts } from "@webpack/common";
|
||||
|
||||
interface User {
|
||||
id: string;
|
||||
|
@ -97,7 +98,7 @@ export default definePlugin({
|
|||
|
||||
copyContactToClipboard() {
|
||||
if (this.contactList) {
|
||||
Clipboard.copy(JSON.stringify(this.contactList));
|
||||
copyToClipboard(JSON.stringify(this.contactList));
|
||||
Toasts.show({
|
||||
message: "Contacts copied to clipboard successfully.",
|
||||
type: Toasts.Type.SUCCESS,
|
||||
|
|
|
@ -6,8 +6,9 @@
|
|||
|
||||
import "./styles.css";
|
||||
|
||||
import { copyToClipboard } from "@utils/clipboard";
|
||||
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";
|
||||
|
||||
|
@ -51,7 +52,7 @@ function FriendInviteCard({ invite }: { invite: FriendInvite; }) {
|
|||
<CopyButton
|
||||
copyText="Copy"
|
||||
copiedText="Copied!"
|
||||
onClick={() => Clipboard.copy(`https://discord.gg/${invite.code}`)}
|
||||
onClick={() => copyToClipboard(`https://discord.gg/${invite.code}`)}
|
||||
/>
|
||||
</Flex>
|
||||
</Flex>
|
||||
|
|
|
@ -10,10 +10,11 @@ import { findGroupChildrenByChildId, NavContextMenuPatchCallback } from "@api/Co
|
|||
import { DataStore } from "@api/index";
|
||||
import { definePluginSettings } from "@api/Settings";
|
||||
import { Flex } from "@components/Flex";
|
||||
import { copyToClipboard } from "@utils/clipboard";
|
||||
import { Devs, EquicordDevs } from "@utils/constants";
|
||||
import { ModalContent, ModalFooter, ModalHeader, ModalRoot, ModalSize, openModal } from "@utils/modal";
|
||||
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 { getFormat } from "./utils/getFormat";
|
||||
|
@ -526,7 +527,7 @@ const RemoveItemContextMenu = ({ type, nameOrId, instance }) => (
|
|||
action={() => {
|
||||
const gifInfo = getGifById(nameOrId);
|
||||
if (!gifInfo) return;
|
||||
Clipboard.copy(gifInfo.url);
|
||||
copyToClipboard(gifInfo.url);
|
||||
showToast("URL copied to clipboard", Toasts.Type.SUCCESS);
|
||||
}}
|
||||
/>
|
||||
|
|
|
@ -5,10 +5,11 @@
|
|||
*/
|
||||
|
||||
import { definePluginSettings, Settings } from "@api/Settings";
|
||||
import { copyToClipboard } from "@utils/clipboard";
|
||||
import { Devs } from "@utils/constants";
|
||||
import definePlugin, { OptionType, StartAt } from "@utils/types";
|
||||
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 { themes } from "./themeDefinitions";
|
||||
|
@ -58,10 +59,7 @@ function copyPreset(name: string) {
|
|||
name: "${name}"
|
||||
}
|
||||
`;
|
||||
if (Clipboard.SUPPORTS_COPY) {
|
||||
Clipboard.copy(template);
|
||||
}
|
||||
|
||||
copyToClipboard(template);
|
||||
}
|
||||
|
||||
function CopyPresetComponent() {
|
||||
|
@ -229,9 +227,7 @@ export function ColorPick({ propertyname }: { propertyname: string; }) {
|
|||
|
||||
|
||||
function copyCSS() {
|
||||
if (Clipboard.SUPPORTS_COPY) {
|
||||
Clipboard.copy(getCSS(parseFontContent()));
|
||||
}
|
||||
copyToClipboard(getCSS(parseFontContent()));
|
||||
}
|
||||
|
||||
function parseFontContent() {
|
||||
|
|
|
@ -4,10 +4,11 @@
|
|||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
import { copyToClipboard } from "@utils/clipboard";
|
||||
import { classes } from "@utils/misc";
|
||||
import { ModalProps } from "@utils/modal";
|
||||
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 { HolyNotes } from "../../types";
|
||||
|
@ -139,13 +140,13 @@ const NoteContextMenu = (
|
|||
<Menu.MenuItem
|
||||
label="Copy Text"
|
||||
id="copy-text"
|
||||
action={() => Clipboard.copy(note.content)}
|
||||
action={() => copyToClipboard(note.content)}
|
||||
/>
|
||||
{note?.attachments.length ? (
|
||||
<Menu.MenuItem
|
||||
label="Copy Attachment URL"
|
||||
id="copy-url"
|
||||
action={() => Clipboard.copy(note.attachments[0].url)}
|
||||
action={() => copyToClipboard(note.attachments[0].url)}
|
||||
/>) : null}
|
||||
<Menu.MenuItem
|
||||
color="danger"
|
||||
|
@ -181,7 +182,7 @@ const NoteContextMenu = (
|
|||
<Menu.MenuItem
|
||||
label="Copy ID"
|
||||
id="copy-id"
|
||||
action={() => Clipboard.copy(note.id)}
|
||||
action={() => copyToClipboard(note.id)}
|
||||
/>
|
||||
</Menu.Menu>
|
||||
);
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
*/
|
||||
|
||||
import { CodeBlock } from "@components/CodeBlock";
|
||||
import { copyToClipboard } from "@utils/clipboard";
|
||||
import { Margins } from "@utils/margins";
|
||||
import { classes } from "@utils/misc";
|
||||
import {
|
||||
|
@ -41,9 +42,7 @@ function ModalComponent(props: { func: Function; iconName: string; color: number
|
|||
color={Button.Colors.PRIMARY}
|
||||
className={"vc-iv-raw-modal-copy-button"}
|
||||
onClick={() => {
|
||||
// silly typescript
|
||||
// @ts-ignore
|
||||
Clipboard.copy(String(func));
|
||||
copyToClipboard(String(func));
|
||||
Toasts.show({
|
||||
id: Toasts.genId(),
|
||||
message: `Copied raw \`${iconName}\` to clipboard`,
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
import { copyToClipboard } from "@utils/clipboard";
|
||||
import { getIntlMessage } from "@utils/discord";
|
||||
import { Margins } from "@utils/margins";
|
||||
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; }) {
|
||||
return <TooltipContainer text={"Click to copy"} className={className}>
|
||||
<Clickable onClick={() => {
|
||||
// @ts-ignore
|
||||
Clipboard.copy(copy);
|
||||
copyToClipboard(copy);
|
||||
}} {...props}>{children}</Clickable>
|
||||
</TooltipContainer>;
|
||||
}
|
||||
|
|
|
@ -6,13 +6,14 @@
|
|||
|
||||
import { CodeBlock } from "@components/CodeBlock";
|
||||
import { Heart } from "@components/Heart";
|
||||
import { copyToClipboard } from "@utils/clipboard";
|
||||
import { openInviteModal } from "@utils/discord";
|
||||
import { Margins } from "@utils/margins";
|
||||
import { classes } from "@utils/misc";
|
||||
import { ModalContent, ModalFooter, ModalHeader, ModalRoot, ModalSize, openModal } from "@utils/modal";
|
||||
import type { PluginNative } from "@utils/types";
|
||||
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 { ClockIcon, DownloadIcon, WarningIcon } from "../utils/Icons";
|
||||
|
@ -145,7 +146,7 @@ export const ThemeInfoModal: React.FC<ThemeInfoModalProps> = ({ author, theme, .
|
|||
</Button>
|
||||
<Button className={Margins.right8}
|
||||
onClick={() => {
|
||||
Clipboard.copy(themeContent);
|
||||
copyToClipboard(themeContent);
|
||||
showToast("Copied to Clipboard", Toasts.Type.SUCCESS);
|
||||
}}>Copy to Clipboard</Button>
|
||||
</ModalFooter>
|
||||
|
|
|
@ -8,8 +8,9 @@ import * as DataStore from "@api/DataStore";
|
|||
import { definePluginSettings } from "@api/Settings";
|
||||
import { classNameFactory } from "@api/Styles";
|
||||
import { OpenExternalIcon } from "@components/Icons";
|
||||
import { copyToClipboard } from "@utils/clipboard";
|
||||
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";
|
||||
|
||||
|
@ -39,7 +40,7 @@ export const settings = definePluginSettings({
|
|||
}
|
||||
});
|
||||
|
||||
Clipboard.copy(token);
|
||||
copyToClipboard(token);
|
||||
|
||||
Toasts.show({
|
||||
message: "Copied to Clipboard!",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue