Files
discord-decomp/modules/channel_text_area/slate/SlateUtils.tsx
T
2026-11-01 12:12:55 +02:00

89 lines
1.7 KiB
TypeScript

// Metro module 5970 (f5971).
function $mk77547() {
return (a0) => ({
type: "line",
children: [{
text: a0
}]
});
}
let c3766_0 = Object.freeze([Object.freeze({
type: "line",
children: Object.freeze([Object.freeze({
text: ""
})])
})]);
export function createEmptyState() {
return {
textValue: "",
richValue: [{
type: "line",
children: [{
text: ""
}]
}]
};
}
export function createState(a0) {
return {
textValue: a0,
richValue: a0 !== "" ? a0.split("\n").map($mk77547()) : c3766_0
};
}
export function toRichValue(a0) {
return a0 !== "" ? a0.split("\n").map($mk77547()) : c3766_0;
}
export function voidToOptionValue(a0) {
const type = a0.type;
if (type === "userMention") {
return {
type: "userMention",
userId: a0.userId
};
}
if (type === "channelMention") {
return {
type: "channelMention",
channelId: a0.channelId
};
}
if (type === "soundboard") {
return {
type: "soundboard",
guildId: a0.guildId,
soundId: a0.soundId
};
}
if (type === "roleMention") {
return {
type: "roleMention",
roleId: a0.roleId
};
}
if (type === "textMention") {
return {
type: "textMention",
text: a0.name
};
}
if (type === "emoji") {
return {
type: "emoji",
name: a0.emoji.name,
surrogate: a0.emoji.surrogate
};
}
if (type === "customEmoji") {
return {
type: "customEmoji",
emojiId: a0.emoji.emojiId,
name: a0.emoji.name,
animated: a0.emoji.animated
};
}
if (type === "testInlineVoid") {
throw new Error("Unable to convert test types");
}
return null;
}