Files
classroomio/apps/dashboard/src/lib/utils/functions/toHtml.ts
T

17 lines
426 B
TypeScript
Raw Normal View History

2024-02-28 03:00:31 +01:00
import { browser } from '$app/environment';
export const isHtmlValueEmpty = (html: string) => {
if (!html || typeof html !== 'string') return true;
if (!document || !browser) return false;
return getTextFromHTML(html) === '';
};
export const getTextFromHTML = (html: string): string => {
const dummyDiv = document.createElement('div');
dummyDiv.innerHTML = html;
return dummyDiv.textContent?.trim() || '';
};