diff options
author | Vendicated <vendicated@riseup.net> | 2022-11-03 19:12:50 +0100 |
---|---|---|
committer | Vendicated <vendicated@riseup.net> | 2022-11-03 19:12:50 +0100 |
commit | 2c3dee41201d0a6c778c002b19c349cdd62470fb (patch) | |
tree | 2f621807f3eda7fd346cd247a5b58f3b864bc153 /src/components/PatchHelper.tsx | |
parent | c20dc269d27414c140be305a827c3a20fd94bacc (diff) | |
download | Vencord-2c3dee41201d0a6c778c002b19c349cdd62470fb.tar.gz Vencord-2c3dee41201d0a6c778c002b19c349cdd62470fb.tar.bz2 Vencord-2c3dee41201d0a6c778c002b19c349cdd62470fb.zip |
qol improvements
Diffstat (limited to 'src/components/PatchHelper.tsx')
-rw-r--r-- | src/components/PatchHelper.tsx | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/src/components/PatchHelper.tsx b/src/components/PatchHelper.tsx index 853febc..391be9d 100644 --- a/src/components/PatchHelper.tsx +++ b/src/components/PatchHelper.tsx @@ -80,7 +80,7 @@ function ReplacementComponent({ module, match, replacement, setReplacementError const fullMatch = matchResult[0] ? makeCodeblock(matchResult[0], "js") : ""; const groups = matchResult.length > 1 - ? makeCodeblock(matchResult.slice(1).map((g, i) => `Group ${i}: ${g}`).join("\n"), "yml") + ? makeCodeblock(matchResult.slice(1).map((g, i) => `Group ${i + 1}: ${g}`).join("\n"), "yml") : ""; return ( @@ -172,6 +172,22 @@ function ReplacementInput({ replacement, setReplacement, replacementError }) { onChange={onChange} error={error ?? replacementError} /> + {!isFunc && ( + <> + <Forms.FormTitle>Cheat Sheet</Forms.FormTitle> + {Object.entries({ + "$$": "Insert a $", + "$&": "Insert the entire match", + "$\\`": "Insert the substring before the match", + "$'": "Insert the substring after the match", + "$n": "Insert the nth capturing group ($1, $2...)" + }).map(([placeholder, desc]) => ( + <Forms.FormText key={placeholder}> + {Parser.parse("`" + placeholder + "`")}: {desc} + </Forms.FormText> + ))} + </> + )} <Switch className={Margins.marginTop8} @@ -202,7 +218,7 @@ function PatchHelper() { find: ${JSON.stringify(find)}, replacement: { match: /${match.replace(/(?<!\\)\//g, "\\/")}/, - replacement: ${typeof replacement === "function" ? replacement.toString() : JSON.stringify(replacement)} + replace: ${typeof replacement === "function" ? replacement.toString() : JSON.stringify(replacement)} } } `.trim(); |