diff --git a/src/core/features/block/components/side-blocks/side-blocks.ts b/src/core/features/block/components/side-blocks/side-blocks.ts index 9df174d08..736ad9422 100644 --- a/src/core/features/block/components/side-blocks/side-blocks.ts +++ b/src/core/features/block/components/side-blocks/side-blocks.ts @@ -21,6 +21,7 @@ import { CoreBlockComponent } from '../block/block'; import { CoreUtils } from '@services/utils/utils'; import { IonRefresher } from '@ionic/angular'; import { CoreCoursesDashboard } from '@features/courses/services/dashboard'; +import { CoreTextUtils } from '@services/utils/text'; /** * Component that displays the list of side blocks. @@ -95,11 +96,7 @@ export class CoreBlockSideBlocksComponent implements OnInit { } this.blocks = this.blocks.filter(block => - block.name !== 'html' || - ( - block.name === 'html' && - !!block.contents?.content.trim().replace(/(\r\n|\n|\r)/, '').length - )); + block.name !== 'html' || (block.contents && !CoreTextUtils.htmlIsBlank(block.contents.content))); } /** diff --git a/src/core/services/utils/text.ts b/src/core/services/utils/text.ts index 55c2b5fb5..f58e0bf99 100644 --- a/src/core/services/utils/text.ts +++ b/src/core/services/utils/text.ts @@ -622,9 +622,12 @@ export class CoreTextUtilsProvider { return true; } - this.template.innerHTML = content; + this.template.innerHTML = content.trim().replace(/(\r\n|\n|\r)/g, ''); + const tags = this.template.content.querySelectorAll( + 'img, audio, video, object, iframe, canvas, svg, input, select, textarea, frame, embed', + ); - return this.template.content.textContent == '' && this.template.content.querySelector('img, object, hr') === null; + return this.template.content.textContent === '' && tags.length === 0; } /**