Merge pull request #3773 from alfonso-salces/MOBILE-4385
MOBILE-4385 side-blocks: Check if the html contain some tagsmain
commit
47af5a252e
|
@ -21,6 +21,7 @@ import { CoreBlockComponent } from '../block/block';
|
||||||
import { CoreUtils } from '@services/utils/utils';
|
import { CoreUtils } from '@services/utils/utils';
|
||||||
import { IonRefresher } from '@ionic/angular';
|
import { IonRefresher } from '@ionic/angular';
|
||||||
import { CoreCoursesDashboard } from '@features/courses/services/dashboard';
|
import { CoreCoursesDashboard } from '@features/courses/services/dashboard';
|
||||||
|
import { CoreTextUtils } from '@services/utils/text';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Component that displays the list of side blocks.
|
* Component that displays the list of side blocks.
|
||||||
|
@ -95,11 +96,7 @@ export class CoreBlockSideBlocksComponent implements OnInit {
|
||||||
}
|
}
|
||||||
|
|
||||||
this.blocks = this.blocks.filter(block =>
|
this.blocks = this.blocks.filter(block =>
|
||||||
block.name !== 'html' ||
|
block.name !== 'html' || (block.contents && !CoreTextUtils.htmlIsBlank(block.contents.content)));
|
||||||
(
|
|
||||||
block.name === 'html' &&
|
|
||||||
!!block.contents?.content.trim().replace(/(\r\n|\n|\r)/, '').length
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -622,9 +622,12 @@ export class CoreTextUtilsProvider {
|
||||||
return true;
|
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