enabled && setShown(true)}>
{!shown ? undefined :
{
if(enabled) {
settings.setValue(Settings.KEY_CHAT_LAST_USED_EMOJI, emoji.id as string);
props.events.fire("action_insert_text", { text: emoji.native, focus: true });
}
}}
/>
}
);
};
const pasteTextTransformElement = document.createElement("div");
const nodeToText = (element: Node) => {
if(element instanceof Text) {
return element.textContent;
} else if(element instanceof HTMLElement) {
if(element instanceof HTMLImageElement) {
return element.alt || element.title;
} else if(element instanceof HTMLBRElement) {
return '\n';
} else if(element instanceof HTMLAnchorElement) {
const content = [...element.childNodes].map(nodeToText).join("");
if(element.href) {
if(settings.getValue(Settings.KEY_CHAT_ENABLE_MARKDOWN)) {
if(content && element.title) {
return `[${content}](${element.href} "${element.title}")`;
} else if(content) {
return `[${content}](${element.href})`;
} else {
return `[${element.href}](${element.href})`;
}
} else if(settings.getValue(Settings.KEY_CHAT_ENABLE_BBCODE)) {
if(content) {
return `[url=${element.href}]${content}"[/url]`;
} else {
return `[url]${element.href}"[/url]`;
}
} else {
return element.href;
}
} else {
return content;
}
}
if(element.children.length > 0) {
return [...element.childNodes].map(nodeToText).join("");
}
return typeof(element.innerText) === "string" ? element.innerText : "";
} else {
return "";
}
};
const htmlEscape = (message: string) => {
pasteTextTransformElement.innerText = message;
message = pasteTextTransformElement.innerHTML;
return message.replace(/ /g, ' ');
};
const TextInput = (props: { events: Registry