aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorV <vendicated@riseup.net>2023-09-05 21:20:13 +0200
committerV <vendicated@riseup.net>2023-09-05 21:20:13 +0200
commit7d954f9adea6e624665e653c2d0897aaff18a2be (patch)
treef4d5e71b4b31ec2caeca727c946f691c78208729 /src
parent860d6edc7b0adbea7849c815c4c8404dd8b5095e (diff)
downloadVencord-7d954f9adea6e624665e653c2d0897aaff18a2be.tar.gz
Vencord-7d954f9adea6e624665e653c2d0897aaff18a2be.tar.bz2
Vencord-7d954f9adea6e624665e653c2d0897aaff18a2be.zip
ViewRaw: Fix ugly copy icon & context menu position
Diffstat (limited to 'src')
-rw-r--r--src/plugins/viewRaw.tsx15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/plugins/viewRaw.tsx b/src/plugins/viewRaw.tsx
index babd88f..d625eea 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 <svg viewBox="0 0 20 20" fill="currentColor" aria-hidden="true" width="22" height="22">
@@ -61,8 +63,7 @@ function cleanMessage(msg: Message) {
function CodeBlock(props: { content: string, lang: string; }) {
return (
- // make text selectable
- <div style={{ userSelect: "text" }}>
+ <div className={CodeContainerClasses.markup}>
{Parser.defaultRules.codeBlock.react(props, null, {})}
</div>
);
@@ -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,
<Menu.MenuItem
id={`vc-view-${name.toLowerCase()}-raw`}
label="View Raw"