MOBILE-4385 side-blocks: Check if the html contain some tags

main
Alfonso Salces 2023-08-23 08:34:59 +02:00
parent 813f731fa9
commit 55d7dc6c72
2 changed files with 7 additions and 7 deletions

View File

@ -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)));
}
/**

View File

@ -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;
}
/**