mirror of
https://github.com/System-End/Vencord.git
synced 2026-04-19 16:28:16 +00:00
TextReplace: fix rule section closing when changing find
This commit is contained in:
parent
4f629294c3
commit
d99b84c7ce
1 changed files with 10 additions and 4 deletions
|
|
@ -34,7 +34,7 @@ import { React, TextInput, useState } from "@webpack/common";
|
|||
|
||||
const cl = classNameFactory("vc-textReplace-");
|
||||
|
||||
type Rule = Record<"find" | "replace" | "onlyIfIncludes", string>;
|
||||
type Rule = Record<"find" | "replace" | "onlyIfIncludes" | "id", string>;
|
||||
|
||||
interface TextReplaceProps {
|
||||
title: string;
|
||||
|
|
@ -46,7 +46,8 @@ interface TextReplaceProps {
|
|||
const makeEmptyRule: () => Rule = () => ({
|
||||
find: "",
|
||||
replace: "",
|
||||
onlyIfIncludes: ""
|
||||
onlyIfIncludes: "",
|
||||
id: crypto.randomUUID()
|
||||
});
|
||||
const makeEmptyRuleArray = () => [makeEmptyRule()];
|
||||
|
||||
|
|
@ -123,7 +124,7 @@ function Input({ initialValue, onChange, placeholder }: {
|
|||
value={value}
|
||||
onChange={setValue}
|
||||
spellCheck={false}
|
||||
onBlur={() => value !== initialValue && onChange(value)}
|
||||
onBlur={() => value !== initialValue && setTimeout(() => onChange(value), 0)}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
|
@ -168,7 +169,7 @@ function TextReplace({ title, description, rulesArray, isRegex = false }: TextRe
|
|||
<Flex flexDirection="column" style={{ gap: "0.5em" }}>
|
||||
{rulesArray.map((rule, index) =>
|
||||
<ExpandableSection
|
||||
key={`${rule.find}-${index}`}
|
||||
key={rule.id}
|
||||
renderContent={() => (
|
||||
<>
|
||||
<div className={cl("input-grid")}>
|
||||
|
|
@ -272,6 +273,11 @@ export default definePlugin({
|
|||
|
||||
settings,
|
||||
|
||||
start() {
|
||||
settings.store.regexRules.forEach(rule => rule.id ??= crypto.randomUUID());
|
||||
settings.store.stringRules.forEach(rule => rule.id ??= crypto.randomUUID());
|
||||
},
|
||||
|
||||
onBeforeMessageSend(channelId, msg) {
|
||||
// Channel used for sharing rules, applying rules here would be messy
|
||||
if (channelId === TEXT_REPLACE_RULES_CHANNEL_ID) return;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue