chore: code refactoring (#5928)

* chore: de dupe code splitting

* chore: code refactor
This commit is contained in:
Anmol Singh Bhatia 2024-10-29 19:39:55 +05:30 committed by GitHub
parent 4bc751b7ab
commit 57eb08c8a2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
21 changed files with 664 additions and 250 deletions

View file

@ -265,3 +265,11 @@ export const replaceCustomComponentsFromMarkdownContent = (props: {
parsedMarkdownContent = parsedMarkdownContent.replace(issueEmbedRegex, "");
return parsedMarkdownContent;
};
export const getTextContent = (jsx: JSX.Element | React.ReactNode | null | undefined): string => {
if (!jsx) return "";
const div = document.createElement("div");
div.innerHTML = jsx.toString();
return div.textContent?.trim() ?? "";
};