43 lines
1.7 kB
1
import { ExtensionWebpackModule, Patch } from "@moonlight-mod/types";
2
3
export const patches: Patch[] = [
4
{
5
find: "/^(¯\\\\_\\(ツ\\)_\\/¯)/.exec",
6
replace: [
7
{
8
match: /={newline:(.+?)},(.{1,2})=\(0,/,
9
replacement: (_, rules, RULES) => `=require("markdown_markdown")._addRules({newline:${rules}}),${RULES}=(0,`
10
},
11
{
12
match: /(?<=;(.{1,2}\.Z)={RULES:.+?})/,
13
replacement: (_, rulesets) => `;require("markdown_markdown")._applyRulesetBlacklist(${rulesets});`
14
}
15
]
16
},
17
{
18
find: "then you probably need to add it to this file so that the rich chat box understands it.",
19
replace: [
20
{
21
match: /(.)={link:{(.+?)},(.)=new Set/,
22
replacement: (_, rulesDef, rules, syntaxBefore) =>
23
`__slateRules,${rulesDef}=__slateRules=require("markdown_markdown")._addSlateRules({link:{${rules}}),${syntaxBefore}=new Set`
24
},
25
{
26
match: /(originalMatch:.}=(.);)(.+?)case"emoticon":(return .+?;)(.+?)case"subtext":{(.+?)}default:/,
27
replacement: (_, start, rule, body, plaintextReturn, otherRules, inlineStyleBody) =>
28
`${start}if(${rule}.type.startsWith("__moonlight_")){if(__slateRules[${rule}.type].type=="inlineStyle"){${inlineStyleBody}}else{${plaintextReturn}}}${body}case"emoticon":${plaintextReturn}${otherRules}case"subtext":{${inlineStyleBody}}default:`
29
}
30
]
31
},
32
{
33
find: '"Slate: Unknown decoration attribute: "',
34
replace: {
35
match: /=({strong:.+?});/,
36
replacement: (_, rules) => `=require("markdown_markdown")._addSlateDecorators(${rules});`
37
}
38
}
39
];
40
41
export const webpackModules: Record<string, ExtensionWebpackModule> = {
42
markdown: {}
43
};
44