MOBILE-4385 side-blocks: Check if the html contain some tags
parent
813f731fa9
commit
55d7dc6c72
|
@ -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)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue