Migrate CharacterCounter

This commit is contained in:
thororen1234 2026-03-28 12:05:09 -04:00
parent 6fee3aedcb
commit 15c1eed682
No known key found for this signature in database
7 changed files with 0 additions and 100 deletions

View file

@ -1,71 +0,0 @@
/*
* Vencord, a Discord client mod
* Copyright (c) 2024 Vendicated and contributors
* SPDX-License-Identifier: GPL-3.0-or-later
*/
import "./style.css";
import { definePluginSettings } from "@api/Settings";
import ErrorBoundary from "@components/ErrorBoundary";
import { Devs, EquicordDevs } from "@utils/constants";
import { classNameFactory } from "@utils/css";
import definePlugin, { OptionType } from "@utils/types";
import { UserStore } from "@webpack/common";
const cl = classNameFactory("vc-char-counter-");
const settings = definePluginSettings({
colorEffects: {
type: OptionType.BOOLEAN,
description: "Turn on or off color effects for getting close to the character limit",
default: true,
},
});
export default definePlugin({
name: "CharacterCounter",
description: "Adds a character counter to the chat input",
authors: [EquicordDevs.creations, EquicordDevs.Panniku, Devs.thororen],
settings,
patches: [
{
find: ".CREATE_FORUM_POST||",
replacement: [
{
match: /(textValue:.{0,50}channelId:\i\.id\}\),)\i/,
replace: "$1$self.renderCharCounter(arguments[0].textValue)"
}
]
},
{
find: "#{intl::PREMIUM_MESSAGE_LENGTH_UPSELL_TOOLTIP}",
replacement: {
match: /return \i\?\i\(\):\i\(\)/,
replace: "return null"
}
}
],
renderCharCounter: ErrorBoundary.wrap(text => {
const premiumType = (UserStore.getCurrentUser()?.premiumType ?? 0);
const charMax = premiumType === 2 ? 4000 : 2000;
const { length } = text;
let color = "var(--primary-330)";
if (settings.store.colorEffects) {
const percentage = (length / charMax) * 100;
if (percentage < 50) color = "var(--text-muted)";
else if (percentage < 75) color = "var(--yellow-330)";
else if (percentage < 90) color = "var(--orange-330)";
else color = "var(--red-360)";
}
if (!length) return null;
return (
<div className={cl("counter")} style={{ color }}>
<span className={cl("count")} >{length}</span>/
<span className={cl("max")} >{charMax}</span>
</div>
);
}, { noop: true })
});

View file

@ -1,16 +0,0 @@
.vc-char-counter-counter {
font-size: 12px;
color: var(--text-muted);
position: absolute;
bottom: 4px;
right: 6px;
pointer-events: none;
z-index: 2;
background: transparent;
transition: color 0.3s ease;
margin-right: 5px;
}
.vc-char-counter-counter .vc-char-counter-count {
transition: color 0.3s ease;
}

View file

@ -33,11 +33,8 @@ export default definePlugin({
Component: ComponentsTab,
Icon: ComponentsIcon
});
SettingsPlugin.settingsSectionMap.push(["EquicordDiscordComponents", "equicord_components"]);
},
stop() {
removeFromArray(SettingsPlugin.customEntries, e => e.key === "equicord_components");
removeFromArray(SettingsPlugin.settingsSectionMap, entry => entry[1] === "equicord_components");
},
});

View file

@ -31,7 +31,6 @@ export default definePlugin({
Component: () => <DataUI usersCollection={data.usersCollection} />,
Icon: EyeIcon
});
SettingsPlugin.settingsSectionMap.push(["EquicordIRememberYou", "equicord_i_remember_you"]);
const data = (this.dataManager = await new Data().withStart());
@ -46,7 +45,6 @@ export default definePlugin({
stop() {
removeFromArray(SettingsPlugin.customEntries, e => e.key === "equicord_i_remember_you");
removeFromArray(SettingsPlugin.settingsSectionMap, entry => entry[1] === "equicord_i_remember_you");
const dataManager = this.dataManager as Data;
removeMessagePreSendListener(dataManager._onMessagePreSend_preSend);

View file

@ -35,11 +35,8 @@ export default definePlugin({
Component: IconsTab,
Icon: MagnifyingGlassIcon
});
SettingsPlugin.settingsSectionMap.push(["EquicordDiscordIcons", "equicord_icon_viewer"]);
},
stop() {
removeFromArray(SettingsPlugin.customEntries, e => e.key === "equicord_icon_viewer");
removeFromArray(SettingsPlugin.settingsSectionMap, entry => entry[1] === "equicord_icon_viewer");
},
});

View file

@ -66,13 +66,11 @@ export default definePlugin({
Component: openQrModal,
Icon: QrCodeIcon
});
SettingsPlugin.settingsSectionMap.push(["EquicordLoginWithQR", "equicord_login_with_qr"]);
preload();
},
stop() {
removeFromArray(SettingsPlugin.customEntries, e => e.key === "equicord_login_with_qr");
removeFromArray(SettingsPlugin.settingsSectionMap, entry => entry[1] === "equicord_login_with_qr");
unload();
},
});

View file

@ -31,12 +31,9 @@ export default definePlugin({
Component: require("./components/ThemeTab").default,
Icon: ColorPaletteIcon
});
SettingsPlugin.settingsSectionMap.push(["EquicordThemeLibrary", "equicord_theme_library"]);
},
stop() {
removeFromArray(SettingsPlugin.customEntries, e => e.key === "equicord_theme_library");
removeFromArray(SettingsPlugin.settingsSectionMap, entry => entry[1] === "equicord_theme_library");
},
});