Files
discord-decomp/i18n/native/updateRules.tsx
T
2026-11-01 12:12:55 +02:00

94 lines
2.6 KiB
TypeScript

// Metro module 16097 (f16098).
import { useContext, useMemo } from "react";
import { Fonts } from "../../Constants";
import { AccessibilityPreferencesContext } from "../../_bundle/Module3908";
import { useToken } from "../../design/tokens/native/useToken";
import Module712 from "../../_bundle/Module712";
import Linking from "../../lib/native/Linking";
import Module3888 from "../../_bundle/Module3888";
import { LegacyText } from "../../design/void/native";
let c11522_5;
const I18nLink = function I18nLink(props) {
let r9, memo, output, state;
let node, alwaysShowLinkDecorations, token;
L5: {
node = props.node;
output = props.output;
state = props.state;
alwaysShowLinkDecorations = void 0;
token = void 0;
r9 = {};
alwaysShowLinkDecorations = useContext(AccessibilityPreferencesContext).alwaysShowLinkDecorations;
token = useToken(Module712.colors.TEXT_LINK);
memo = useMemo(() => ({
color: token,
textDecorationLine: alwaysShowLinkDecorations ? "underline" : "none"
}), [token, alwaysShowLinkDecorations]);
if (node.context != null) {
const onClick = node.context[node.target];
if (onClick && onClick.onClick) {
r9.onClick = onClick.onClick;
break L5;
}
r9.onClick = onClick;
}
}
if (r9.onClick == null) {
r9.onClick = () => Linking.openURL(Module3888.sanitizeUrl(node.target));
}
return <LegacyText accessible accessibilityRole="link" onPress={r9.onClick} style={memo}>
{output(node.content, state)}
</LegacyText>;
};
c11522_5 = {
strong: {
fontFamily: Fonts.PRIMARY_SEMIBOLD
},
italic: {
fontStyle: "italic"
},
underline: {
textDecorationLine: "underline"
}
};
export default function updateRules(a0) {
a0.paragraph = {
...a0.paragraph,
react: function react(a0, a1, a2) {
return <LegacyText key={a2.key}>
{a1(a0.content, a2)}
</LegacyText>;
}
};
a0.strong = {
...a0.strong,
react: function react(a0, a1, a2) {
return <LegacyText key={a2.key} style={c11522_5.strong}>
{a1(a0.content, a2)}
</LegacyText>;
}
};
a0.em = {
...a0.em,
react: function react(a0, a1, a2) {
return <LegacyText key={a2.key} style={c11522_5.italic}>
{a1(a0.content, a2)}
</LegacyText>;
}
};
a0.u = {
...a0.u,
react: function react(a0, a1, a2) {
return <LegacyText key={a2.key} style={c11522_5.underline}>
{a1(a0.content, a2)}
</LegacyText>;
}
};
a0.link = {
...a0.link,
react: (a0, a1, a2) => <I18nLink key={a2.key} node={a0} output={a1} state={a2} />
};
return a0;
};
export { I18nLink };