MOBILE-2611 utils: Function to check whether HTML content is blank
parent
6547bcf541
commit
c770fb9014
|
@ -427,6 +427,23 @@ export class CoreTextUtilsProvider {
|
||||||
return /<[a-z][\s\S]*>/i.test(text);
|
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.
|
* Check if a text contains Unicode long chars.
|
||||||
* Using as threshold Hex value D800
|
* Using as threshold Hex value D800
|
||||||
|
|
Loading…
Reference in New Issue