PromucFlow_constructor/app/client/src/components/editorComponents/utils.ts
Ayangade Adeoluwa 2f862ac8db
fix: properly render html responses (#11853)
* properly render html responses

* My empty commit with a message

* My empty commit with a message

* Remove package, use custom function

Co-authored-by: Adeoluwa Ayangade <adeoluwaayangade@Adeoluwas-MacBook-Pro.local>
2022-03-16 14:25:56 +00:00

12 lines
362 B
TypeScript

export const isHtml = (str: string) => {
const fragment = document.createRange().createContextualFragment(str);
// remove all non text nodes from fragment
fragment
.querySelectorAll("*")
.forEach((el: any) => el.parentNode.removeChild(el));
// if there is textContent, then its not a pure HTML
return !(fragment.textContent || "").trim();
};