diff --git a/src/providers/utils/text.ts b/src/providers/utils/text.ts index 6fa91d8be..3ee32224e 100644 --- a/src/providers/utils/text.ts +++ b/src/providers/utils/text.ts @@ -427,6 +427,23 @@ export class CoreTextUtilsProvider { return /<[a-z][\s\S]*>/i.test(text); } + /** + * Check if HTML content is blank. + * + * @param {string} content HTML content. + * @return {boolean} True if the string does not contain actual content: text, images, etc. + */ + htmlIsBlank(content: string): boolean { + if (!content) { + return true; + } + + const div = document.createElement('div'); + div.innerHTML = content; + + return div.textContent === '' && div.querySelector('img, object, hr') === null; + } + /** * Check if a text contains Unicode long chars. * Using as threshold Hex value D800