Merge branch 'dev' into feat/usercss
This commit is contained in:
commit
0aa399c8ed
|
@ -128,8 +128,15 @@ export function initIpc(mainWindow: BrowserWindow) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ipcMain.handle(IpcEvents.OPEN_MONACO_EDITOR, async () => {
|
ipcMain.handle(IpcEvents.OPEN_MONACO_EDITOR, async () => {
|
||||||
|
const title = "Vencord QuickCSS Editor";
|
||||||
|
const existingWindow = BrowserWindow.getAllWindows().find(w => w.title === title);
|
||||||
|
if (existingWindow && !existingWindow.isDestroyed()) {
|
||||||
|
existingWindow.focus();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const win = new BrowserWindow({
|
const win = new BrowserWindow({
|
||||||
title: "Vencord QuickCSS Editor",
|
title,
|
||||||
autoHideMenuBar: true,
|
autoHideMenuBar: true,
|
||||||
darkTheme: true,
|
darkTheme: true,
|
||||||
webPreferences: {
|
webPreferences: {
|
||||||
|
|
|
@ -73,6 +73,8 @@ async function build() {
|
||||||
const command = isFlatpak ? "flatpak-spawn" : "node";
|
const command = isFlatpak ? "flatpak-spawn" : "node";
|
||||||
const args = isFlatpak ? ["--host", "node", "scripts/build/build.mjs"] : ["scripts/build/build.mjs"];
|
const args = isFlatpak ? ["--host", "node", "scripts/build/build.mjs"] : ["scripts/build/build.mjs"];
|
||||||
|
|
||||||
|
if (IS_DEV) args.push("--dev");
|
||||||
|
|
||||||
const res = await execFile(command, args, opts);
|
const res = await execFile(command, args, opts);
|
||||||
|
|
||||||
return !res.stderr.includes("Build failed");
|
return !res.stderr.includes("Build failed");
|
||||||
|
|
|
@ -126,7 +126,9 @@ function MenuItem(guildId: string, id?: string, type?: MenuItemParentType) {
|
||||||
|
|
||||||
function makeContextMenuPatch(childId: string | string[], type?: MenuItemParentType): NavContextMenuPatchCallback {
|
function makeContextMenuPatch(childId: string | string[], type?: MenuItemParentType): NavContextMenuPatchCallback {
|
||||||
return (children, props) => () => {
|
return (children, props) => () => {
|
||||||
if (!props || (type === MenuItemParentType.User && !props.user) || (type === MenuItemParentType.Guild && !props.guild)) return children;
|
if (!props) return;
|
||||||
|
if ((type === MenuItemParentType.User && !props.user) || (type === MenuItemParentType.Guild && !props.guild) || (type === MenuItemParentType.Channel && (!props.channel || !props.guild)))
|
||||||
|
return children;
|
||||||
|
|
||||||
const group = findGroupChildrenByChildId(childId, children);
|
const group = findGroupChildrenByChildId(childId, children);
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ import { Margins } from "@utils/margins";
|
||||||
import { copyWithToast } from "@utils/misc";
|
import { copyWithToast } from "@utils/misc";
|
||||||
import { closeModal, ModalCloseButton, ModalContent, ModalFooter, ModalHeader, ModalRoot, ModalSize, openModal } from "@utils/modal";
|
import { closeModal, ModalCloseButton, ModalContent, ModalFooter, ModalHeader, ModalRoot, ModalSize, openModal } from "@utils/modal";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
import { Button, ChannelStore, Forms, Menu, Text } from "@webpack/common";
|
import { Button, ChannelStore, Forms, i18n, Menu, Text } from "@webpack/common";
|
||||||
import { Message } from "discord-types/general";
|
import { Message } from "discord-types/general";
|
||||||
|
|
||||||
|
|
||||||
|
@ -117,22 +117,26 @@ const settings = definePluginSettings({
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
function MakeContextCallback(name: string) {
|
function MakeContextCallback(name: "Guild" | "User" | "Channel") {
|
||||||
const callback: NavContextMenuPatchCallback = (children, props) => () => {
|
const callback: NavContextMenuPatchCallback = (children, props) => () => {
|
||||||
if ((name === "Guild" && !props.guild) || (name === "User" && !props.user)) return;
|
const value = props[name.toLowerCase()];
|
||||||
|
if (!value) return;
|
||||||
|
if (props.label === i18n.Messages.CHANNEL_ACTIONS_MENU_LABEL) return; // random shit like notification settings
|
||||||
|
|
||||||
const lastChild = children.at(-1);
|
const lastChild = children.at(-1);
|
||||||
if (lastChild?.key === "developer-actions") {
|
if (lastChild?.key === "developer-actions") {
|
||||||
const p = lastChild.props;
|
const p = lastChild.props;
|
||||||
if (!Array.isArray(p.children))
|
if (!Array.isArray(p.children))
|
||||||
p.children = [p.children];
|
p.children = [p.children];
|
||||||
({ children } = p);
|
|
||||||
|
children = p.children;
|
||||||
}
|
}
|
||||||
|
|
||||||
children.splice(-1, 0,
|
children.splice(-1, 0,
|
||||||
<Menu.MenuItem
|
<Menu.MenuItem
|
||||||
id={`vc-view-${name.toLowerCase()}-raw`}
|
id={`vc-view-${name.toLowerCase()}-raw`}
|
||||||
label="View Raw"
|
label="View Raw"
|
||||||
action={() => openViewRawModal(JSON.stringify(props[name.toLowerCase()], null, 4), name)}
|
action={() => openViewRawModal(JSON.stringify(value, null, 4), name)}
|
||||||
icon={CopyIcon}
|
icon={CopyIcon}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|
|
@ -182,6 +182,12 @@ export default definePlugin({
|
||||||
],
|
],
|
||||||
|
|
||||||
async copyImage(url: string) {
|
async copyImage(url: string) {
|
||||||
|
if (IS_VESKTOP && VesktopNative.clipboard) {
|
||||||
|
const data = await fetch(url).then(r => r.arrayBuffer());
|
||||||
|
VesktopNative.clipboard.copyImage(data, url);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Clipboard only supports image/png, jpeg and similar won't work. Thus, we need to convert it to png
|
// Clipboard only supports image/png, jpeg and similar won't work. Thus, we need to convert it to png
|
||||||
// via canvas first
|
// via canvas first
|
||||||
const img = new Image();
|
const img = new Image();
|
||||||
|
|
Loading…
Reference in a new issue