mirror of
https://github.com/Vendicated/Vencord.git
synced 2025-01-10 01:46:23 +00:00
new plugin FullUserInChatbox (#2766)
This commit is contained in:
parent
0fd76ab15a
commit
20ed7dc96b
4 changed files with 59 additions and 2 deletions
|
@ -27,7 +27,7 @@ interface Props<T = any> {
|
||||||
/** Render nothing if an error occurs */
|
/** Render nothing if an error occurs */
|
||||||
noop?: boolean;
|
noop?: boolean;
|
||||||
/** Fallback component to render if an error occurs */
|
/** Fallback component to render if an error occurs */
|
||||||
fallback?: React.ComponentType<React.PropsWithChildren<{ error: any; message: string; stack: string; }>>;
|
fallback?: React.ComponentType<React.PropsWithChildren<{ error: any; message: string; stack: string; wrappedProps: T; }>>;
|
||||||
/** called when an error occurs. The props property is only available if using .wrap */
|
/** called when an error occurs. The props property is only available if using .wrap */
|
||||||
onError?(data: { error: Error, errorInfo: React.ErrorInfo, props: T; }): void;
|
onError?(data: { error: Error, errorInfo: React.ErrorInfo, props: T; }): void;
|
||||||
/** Custom error message */
|
/** Custom error message */
|
||||||
|
@ -81,6 +81,7 @@ const ErrorBoundary = LazyComponent(() => {
|
||||||
|
|
||||||
if (this.props.fallback)
|
if (this.props.fallback)
|
||||||
return <this.props.fallback
|
return <this.props.fallback
|
||||||
|
wrappedProps={this.props.wrappedProps}
|
||||||
children={this.props.children}
|
children={this.props.children}
|
||||||
{...this.state}
|
{...this.state}
|
||||||
/>;
|
/>;
|
||||||
|
|
|
@ -85,7 +85,7 @@ export default definePlugin({
|
||||||
replace: "$&onRequestClose:$self.onPopoutClose,"
|
replace: "$&onRequestClose:$self.onPopoutClose,"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
match: /(?<=.avatarWrapper,)/,
|
match: /(?<=\.avatarWrapper,)/,
|
||||||
replace: "ref:$self.accountPanelRef,onContextMenu:$self.openAccountPanelContextMenu,"
|
replace: "ref:$self.accountPanelRef,onContextMenu:$self.openAccountPanelContextMenu,"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
9
src/plugins/fullUserInChatbox/README.md
Normal file
9
src/plugins/fullUserInChatbox/README.md
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
# Full User In Chatbox
|
||||||
|
|
||||||
|
Adds the full user mention to the textbox
|
||||||
|
|
||||||
|
Adds the avatar if you have mentioned avatars enabled
|
||||||
|
|
||||||
|
Provides the full context menu to make it easy to access the users profile, and other common actions
|
||||||
|
|
||||||
|
https://github.com/user-attachments/assets/cd9edb33-99c8-4c8d-b669-8cddd05f4b45
|
47
src/plugins/fullUserInChatbox/index.tsx
Normal file
47
src/plugins/fullUserInChatbox/index.tsx
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
/*
|
||||||
|
* Vencord, a Discord client mod
|
||||||
|
* Copyright (c) 2024 Vendicated and contributors
|
||||||
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
*/
|
||||||
|
|
||||||
|
import ErrorBoundary from "@components/ErrorBoundary";
|
||||||
|
import { Devs } from "@utils/constants";
|
||||||
|
import definePlugin from "@utils/types";
|
||||||
|
import { findComponentByCodeLazy } from "@webpack";
|
||||||
|
import { ReactNode } from "react";
|
||||||
|
|
||||||
|
const UserMentionComponent = findComponentByCodeLazy(".USER_MENTION)");
|
||||||
|
|
||||||
|
interface UserMentionComponentProps {
|
||||||
|
id: string;
|
||||||
|
channelId: string;
|
||||||
|
guildId: string;
|
||||||
|
OriginalComponent: ReactNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default definePlugin({
|
||||||
|
name: "FullUserInChatbox",
|
||||||
|
description: "Makes the user mention in the chatbox have more functionalities, like left/right clicking",
|
||||||
|
authors: [Devs.sadan],
|
||||||
|
|
||||||
|
patches: [
|
||||||
|
{
|
||||||
|
find: ':"text":',
|
||||||
|
replacement: {
|
||||||
|
match: /(hidePersonalInformation\).+?)(if\(null!=\i\){.+?return \i)(?=})/,
|
||||||
|
replace: "$1return $self.UserMentionComponent({...arguments[0],OriginalComponent:(()=>{$2})()});"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
|
||||||
|
UserMentionComponent: ErrorBoundary.wrap((props: UserMentionComponentProps) => (
|
||||||
|
<UserMentionComponent
|
||||||
|
// This seems to be constant
|
||||||
|
className="mention"
|
||||||
|
userId={props.id}
|
||||||
|
channelId={props.channelId}
|
||||||
|
/>
|
||||||
|
), {
|
||||||
|
fallback: ({ wrappedProps }) => wrappedProps.OriginalComponent
|
||||||
|
})
|
||||||
|
});
|
Loading…
Reference in a new issue