From 7d954f9adea6e624665e653c2d0897aaff18a2be Mon Sep 17 00:00:00 2001 From: V Date: Tue, 5 Sep 2023 21:20:13 +0200 Subject: [PATCH] ViewRaw: Fix ugly copy icon & context menu position --- src/plugins/viewRaw.tsx | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/plugins/viewRaw.tsx b/src/plugins/viewRaw.tsx index babd88f6b..d625eeab6 100644 --- a/src/plugins/viewRaw.tsx +++ b/src/plugins/viewRaw.tsx @@ -26,9 +26,11 @@ import { Margins } from "@utils/margins"; import { copyWithToast } from "@utils/misc"; import { closeModal, ModalCloseButton, ModalContent, ModalFooter, ModalHeader, ModalRoot, ModalSize, openModal } from "@utils/modal"; import definePlugin, { OptionType } from "@utils/types"; +import { findByPropsLazy } from "@webpack"; import { Button, ChannelStore, Forms, Menu, Parser, Text } from "@webpack/common"; import { Message } from "discord-types/general"; +const CodeContainerClasses = findByPropsLazy("markup", "codeContainer"); const CopyIcon = () => { return
+
{Parser.defaultRules.codeBlock.react(props, null, {})}
); @@ -127,7 +128,15 @@ const settings = definePluginSettings({ function MakeContextCallback(name: string) { const callback: NavContextMenuPatchCallback = (children, props) => () => { - children.push( + const lastChild = children.at(-1); + if (lastChild?.key === "developer-actions") { + const p = lastChild.props; + if (!Array.isArray(p.children)) + p.children = [p.children]; + ({ children } = p); + } + + children.splice(-1, 0,