mirror of
https://github.com/Vendicated/Vencord.git
synced 2025-01-26 17:26:22 +00:00
Add Clipboard import and update ContextMenuApi.openContextMenu
This commit is contained in:
parent
2f086e993b
commit
14fc2d9b25
1 changed files with 64 additions and 29 deletions
|
@ -7,7 +7,7 @@
|
||||||
import { classes } from "@utils/misc";
|
import { classes } from "@utils/misc";
|
||||||
import { ModalProps } from "@utils/modal";
|
import { ModalProps } from "@utils/modal";
|
||||||
import { findByCode, findByProps } from "@webpack";
|
import { findByCode, findByProps } from "@webpack";
|
||||||
import { ContextMenuApi, FluxDispatcher, Menu, NavigationRouter, React } from "@webpack/common";
|
import { Clipboard, ContextMenuApi, FluxDispatcher, Menu, NavigationRouter, React } from "@webpack/common";
|
||||||
import noteHandler from "plugins/holynotes/noteHandler";
|
import noteHandler from "plugins/holynotes/noteHandler";
|
||||||
import { HolyNotes } from "plugins/holynotes/types";
|
import { HolyNotes } from "plugins/holynotes/types";
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ export const RenderMessage = ({
|
||||||
onContextMenu={(event: any) => {
|
onContextMenu={(event: any) => {
|
||||||
if (!fromDeleteModal)
|
if (!fromDeleteModal)
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
return open(event, (props: any) => (
|
return ContextMenuApi.openContextMenu(event, (props: any) => (
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
<NoteContextMenu
|
<NoteContextMenu
|
||||||
{...Object.assign({}, props, { onClose: close })}
|
{...Object.assign({}, props, { onClose: close })}
|
||||||
|
@ -94,11 +94,11 @@ export const RenderMessage = ({
|
||||||
{
|
{
|
||||||
author: new User({ ...note.author }),
|
author: new User({ ...note.author }),
|
||||||
timestamp: new Date(note.timestamp),
|
timestamp: new Date(note.timestamp),
|
||||||
|
// @ts-ignore
|
||||||
embeds: note.embeds.map((embed: { timestamp: string | number | Date; }) =>
|
embeds: note.embeds.map((embed: { timestamp: string | number | Date; }) =>
|
||||||
embed.timestamp
|
embed.timestamp
|
||||||
? Object.assign(embed, {
|
? Object.assign(embed, {
|
||||||
// @ts-ignore
|
timestamp: new Date(embed.timestamp),
|
||||||
timestamp: new Moment(new Date(embed.timestamp)),
|
|
||||||
})
|
})
|
||||||
: embed,
|
: embed,
|
||||||
),
|
),
|
||||||
|
@ -122,31 +122,66 @@ const NoteContextMenu = (
|
||||||
const { note, notebook, updateParent, closeModal } = props;
|
const { note, notebook, updateParent, closeModal } = props;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div onContextMenu={e => {
|
<Menu.Menu
|
||||||
ContextMenuApi.openContextMenu(e, () =>
|
navId="holynotes"
|
||||||
<Menu.Menu
|
onClose={() => FluxDispatcher.dispatch({ type: "CONTEXT_MENU_CLOSE" })}
|
||||||
navId="holynotes"
|
aria-label="Holy Notes"
|
||||||
onClose={() => FluxDispatcher.dispatch({ type: "CONTEXT_MENU_CLOSE" })}
|
>
|
||||||
aria-label="Holy Notes"
|
<Menu.MenuItem
|
||||||
|
label="Jump To Message"
|
||||||
|
id="jump"
|
||||||
|
action={() => {
|
||||||
|
NavigationRouter.transitionTo(`/channels/${note.guild_id ?? "@me"}/${note.channel_id}/${note.id}`);
|
||||||
|
closeModal?.();
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<Menu.MenuItem
|
||||||
|
label="Copy Text"
|
||||||
|
id="copy-text"
|
||||||
|
action={() => Clipboard.copy(note.content)}
|
||||||
|
/>
|
||||||
|
{note?.attachments.length ? (
|
||||||
|
<Menu.MenuItem
|
||||||
|
label="Copy Attachment URL"
|
||||||
|
id="copy-url"
|
||||||
|
action={() => Clipboard.copy(note.attachments[0].url)}
|
||||||
|
/>) : null}
|
||||||
|
<Menu.MenuItem
|
||||||
|
color="danger"
|
||||||
|
label="Delete Note"
|
||||||
|
id="delete"
|
||||||
|
action={() => {
|
||||||
|
noteHandler.deleteNote(note.id, notebook);
|
||||||
|
updateParent?.();
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
{Object.keys(noteHandler.getAllNotes()).length !== 1 ? (
|
||||||
|
<Menu.MenuItem
|
||||||
|
label="Move Note"
|
||||||
|
id="move-note"
|
||||||
>
|
>
|
||||||
<Menu.MenuItem
|
{Object.keys(noteHandler.getAllNotes()).map((key: string) => {
|
||||||
label="Jump To Message"
|
if (key !== notebook) {
|
||||||
id="jump"
|
return (
|
||||||
action={() => {
|
<Menu.MenuItem
|
||||||
NavigationRouter.transitionTo(`/channels/${note.guild_id ?? "@me"}/${note.channel_id}/${note.id}`);
|
label={`Move to ${key}`}
|
||||||
closeModal?.();
|
id={key}
|
||||||
}}
|
action={() => {
|
||||||
/>
|
noteHandler.moveNote(note, notebook, key);
|
||||||
<Menu.MenuItem
|
updateParent?.();
|
||||||
label="Delete Note"
|
}}
|
||||||
id="delete"
|
/>
|
||||||
action={() => {
|
);
|
||||||
noteHandler.deleteNote(note.id, notebook);
|
}
|
||||||
updateParent?.();
|
})}
|
||||||
}}
|
</Menu.MenuItem>
|
||||||
/>
|
) : null}
|
||||||
</Menu.Menu>
|
<Menu.MenuItem
|
||||||
);
|
label="Copy ID"
|
||||||
}}></div>
|
id="copy-id"
|
||||||
|
action={() => Clipboard.copy(note.id)}
|
||||||
|
/>
|
||||||
|
</Menu.Menu>
|
||||||
);
|
);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue