Skip to content

Commit

Permalink
Merge pull request #3773 from alfonso-salces/MOBILE-4385
Browse files Browse the repository at this point in the history
MOBILE-4385 side-blocks: Check if the html contain some tags
  • Loading branch information
crazyserver authored Aug 23, 2023
2 parents a4d2af2 + 55d7dc6 commit 47af5a2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
7 changes: 2 additions & 5 deletions src/core/features/block/components/side-blocks/side-blocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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)));
}

/**
Expand Down
7 changes: 5 additions & 2 deletions src/core/services/utils/text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down

0 comments on commit 47af5a2

Please sign in to comment.