mirror of
https://github.com/Vendicated/Vencord.git
synced 2025-02-04 05:36:23 +00:00
Force-load color picker and fix other stuff
This commit is contained in:
parent
8e660bad9f
commit
3df388be83
6 changed files with 33 additions and 16 deletions
|
@ -18,6 +18,7 @@ interface ColorPickerProps {
|
||||||
showEyeDropper?: boolean;
|
showEyeDropper?: boolean;
|
||||||
onChange(value: number | null): void;
|
onChange(value: number | null): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ColorPicker = findComponentByCodeLazy<ColorPickerProps>(".BACKGROUND_PRIMARY).hex");
|
const ColorPicker = findComponentByCodeLazy<ColorPickerProps>(".BACKGROUND_PRIMARY).hex");
|
||||||
|
|
||||||
const cl = classNameFactory("vc-remix-settings-color-");
|
const cl = classNameFactory("vc-remix-settings-color-");
|
||||||
|
|
|
@ -4,14 +4,17 @@
|
||||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { brushCanvas, render } from "../components/Canvas";
|
import { brushCanvas, ctx, render } from "../components/Canvas";
|
||||||
import { currentSize, ToolDefinition } from "../components/Toolbar";
|
import { currentSize, ToolDefinition } from "../components/Toolbar";
|
||||||
import { Mouse } from "../input";
|
import { Mouse } from "../input";
|
||||||
import { line } from "../utils/canvas";
|
import { line } from "../utils/canvas";
|
||||||
|
|
||||||
export const BrushTool: ToolDefinition = {
|
export const BrushTool: ToolDefinition = {
|
||||||
onMouseMove() {
|
onMouseMove() {
|
||||||
if (!Mouse.down) return;
|
if (!Mouse.down || !ctx) return;
|
||||||
|
|
||||||
|
ctx.lineCap = "round";
|
||||||
|
ctx.lineJoin = "round";
|
||||||
|
|
||||||
brushCanvas.lineWidth = currentSize;
|
brushCanvas.lineWidth = currentSize;
|
||||||
|
|
||||||
|
|
|
@ -109,10 +109,10 @@ export const CropTool: ToolDefinition = {
|
||||||
|
|
||||||
cropCanvas.strokeRect(bounds.left, bounds.top, bounds.right - bounds.left, bounds.bottom - bounds.top);
|
cropCanvas.strokeRect(bounds.left, bounds.top, bounds.right - bounds.left, bounds.bottom - bounds.top);
|
||||||
|
|
||||||
fillCircle(bounds.left, bounds.top, 15, cropCanvas);
|
fillCircle(bounds.left, bounds.top, 10, cropCanvas);
|
||||||
fillCircle(bounds.right, bounds.top, 15, cropCanvas);
|
fillCircle(bounds.right, bounds.top, 10, cropCanvas);
|
||||||
fillCircle(bounds.left, bounds.bottom, 15, cropCanvas);
|
fillCircle(bounds.left, bounds.bottom, 10, cropCanvas);
|
||||||
fillCircle(bounds.right, bounds.bottom, 15, cropCanvas);
|
fillCircle(bounds.right, bounds.bottom, 10, cropCanvas);
|
||||||
|
|
||||||
render();
|
render();
|
||||||
},
|
},
|
||||||
|
|
|
@ -90,9 +90,6 @@ export const ShapeTool: ToolDefinition = {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
canvas.lineCap = "butt";
|
|
||||||
canvas.lineJoin = "miter";
|
|
||||||
|
|
||||||
render();
|
render();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { addContextMenuPatch, NavContextMenuPatchCallback, removeContextMenuPatch } from "@api/ContextMenu";
|
import { addContextMenuPatch, findGroupChildrenByChildId, NavContextMenuPatchCallback, removeContextMenuPatch } from "@api/ContextMenu";
|
||||||
import { definePluginSettings } from "@api/Settings";
|
import { definePluginSettings } from "@api/Settings";
|
||||||
import { disableStyle, enableStyle } from "@api/Styles";
|
import { disableStyle, enableStyle } from "@api/Styles";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
|
@ -19,10 +19,15 @@ import css from "./styles.css?managed";
|
||||||
|
|
||||||
// so FileUpload is loaded
|
// so FileUpload is loaded
|
||||||
export const requireCreateStickerModal = extractAndLoadChunksLazy(["stickerInspected]:"]);
|
export const requireCreateStickerModal = extractAndLoadChunksLazy(["stickerInspected]:"]);
|
||||||
|
// so ColorPicker is loaded
|
||||||
|
export const requireSettingsMenu = extractAndLoadChunksLazy(['name:"UserSettings"'], /createPromise:.{0,20}el\("(.+?)"\).{0,50}"UserSettings"/);
|
||||||
|
|
||||||
const CloudUtils = findByPropsLazy("CloudUpload");
|
const CloudUtils = findByPropsLazy("CloudUpload");
|
||||||
const PendingReplyStore = findStoreLazy("PendingReplyStore");
|
const PendingReplyStore = findStoreLazy("PendingReplyStore");
|
||||||
|
|
||||||
|
|
||||||
|
const validMediaTypes = ["image/png", "image/jpeg", "image/jpg", "image/webp"];
|
||||||
|
|
||||||
const UploadContextMenuPatch: NavContextMenuPatchCallback = (children, props) => {
|
const UploadContextMenuPatch: NavContextMenuPatchCallback = (children, props) => {
|
||||||
if (children.find(c => c?.props?.id === "vc-remix")) return;
|
if (children.find(c => c?.props?.id === "vc-remix")) return;
|
||||||
|
|
||||||
|
@ -37,15 +42,23 @@ const UploadContextMenuPatch: NavContextMenuPatchCallback = (children, props) =>
|
||||||
/>);
|
/>);
|
||||||
};
|
};
|
||||||
|
|
||||||
const ImageContextMenuPatch: NavContextMenuPatchCallback = (children, props) => {
|
const MessageContextMenuPatch: NavContextMenuPatchCallback = (children, props) => {
|
||||||
if (!props.attachment || children.find(c => c?.props?.id === "vc-remix")) return;
|
const url = props.itemHref ?? props.itemSrc;
|
||||||
|
if (!url) return;
|
||||||
|
if (props.attachment && !validMediaTypes.includes(props.attachment.content_type)) return;
|
||||||
|
|
||||||
children.push(<Menu.MenuItem
|
const group = findGroupChildrenByChildId("copy-text", children);
|
||||||
|
if (!group) return;
|
||||||
|
if (group.find(c => c?.props?.id === "vc-remix")) return;
|
||||||
|
|
||||||
|
const index = group.findIndex(c => c?.props?.id === "copy-text");
|
||||||
|
|
||||||
|
group.splice(index + 1, 0, <Menu.MenuItem
|
||||||
id="vc-remix"
|
id="vc-remix"
|
||||||
label="Remix"
|
label="Remix"
|
||||||
action={() => {
|
action={() => {
|
||||||
const key = openModal(modalProps =>
|
const key = openModal(modalProps =>
|
||||||
<RemixModal modalProps={modalProps} close={() => closeModal(key)} url={props.attachment.url} />
|
<RemixModal modalProps={modalProps} close={() => closeModal(key)} url={url} />
|
||||||
);
|
);
|
||||||
}}
|
}}
|
||||||
/>);
|
/>);
|
||||||
|
@ -103,16 +116,17 @@ export default definePlugin({
|
||||||
|
|
||||||
async start() {
|
async start() {
|
||||||
addContextMenuPatch("channel-attach", UploadContextMenuPatch);
|
addContextMenuPatch("channel-attach", UploadContextMenuPatch);
|
||||||
addContextMenuPatch("message", ImageContextMenuPatch);
|
addContextMenuPatch("message", MessageContextMenuPatch);
|
||||||
|
|
||||||
await requireCreateStickerModal();
|
await requireCreateStickerModal();
|
||||||
|
await requireSettingsMenu();
|
||||||
|
|
||||||
enableStyle(css);
|
enableStyle(css);
|
||||||
},
|
},
|
||||||
|
|
||||||
stop() {
|
stop() {
|
||||||
removeContextMenuPatch("channel-attach", UploadContextMenuPatch);
|
removeContextMenuPatch("channel-attach", UploadContextMenuPatch);
|
||||||
removeContextMenuPatch("message", ImageContextMenuPatch);
|
removeContextMenuPatch("message", MessageContextMenuPatch);
|
||||||
|
|
||||||
disableStyle(css);
|
disableStyle(css);
|
||||||
},
|
},
|
||||||
|
|
|
@ -42,6 +42,8 @@
|
||||||
.vc-remix-canvas {
|
.vc-remix-canvas {
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
max-height: 100%;
|
max-height: 100%;
|
||||||
|
min-width: 50%;
|
||||||
|
min-height: 50%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.vc-remix-editor {
|
.vc-remix-editor {
|
||||||
|
|
Loading…
Reference in a new issue