MOBILE-4176 grades: Keep new lines
parent
3fa72b3a36
commit
324785f36a
|
@ -181,7 +181,7 @@ export class AddonModBBBIndexComponent extends CoreCourseModuleMainActivityCompo
|
|||
return {
|
||||
type: playbackAnchor?.innerText ??
|
||||
Translate.instant('addon.mod_bigbluebuttonbn.view_recording_format_presentation'),
|
||||
name: CoreTextUtils.cleanTags(String(recordingData.recording), true),
|
||||
name: CoreTextUtils.cleanTags(String(recordingData.recording), { singleLine: true }),
|
||||
url: playbackAnchor?.href ?? '',
|
||||
details,
|
||||
expanded: false,
|
||||
|
|
|
@ -87,7 +87,7 @@ export class AddonModWikiEditPage implements OnInit, OnDestroy, CanLeave {
|
|||
this.userId = CoreNavigator.getRouteNumberParam('userId');
|
||||
|
||||
let pageTitle = CoreNavigator.getRouteParam<string>('pageTitle');
|
||||
pageTitle = pageTitle ? CoreTextUtils.cleanTags(pageTitle.replace(/\+/g, ' '), true) : '';
|
||||
pageTitle = pageTitle ? CoreTextUtils.cleanTags(pageTitle.replace(/\+/g, ' '), { singleLine: true }) : '';
|
||||
|
||||
this.canEditTitle = !pageTitle;
|
||||
this.title = pageTitle ?
|
||||
|
|
|
@ -62,7 +62,7 @@ export class CoreMarkRequiredComponent implements OnInit, AfterViewInit {
|
|||
if (this.coreMarkRequired) {
|
||||
// Add the "required" to the aria-label.
|
||||
const ariaLabel = this.element.getAttribute('aria-label') ||
|
||||
CoreTextUtils.cleanTags(this.element.innerHTML, true);
|
||||
CoreTextUtils.cleanTags(this.element.innerHTML, { singleLine: true });
|
||||
if (ariaLabel) {
|
||||
this.element.setAttribute('aria-label', ariaLabel + ' ' + this.requiredLabel);
|
||||
}
|
||||
|
|
|
@ -222,7 +222,7 @@ export class CoreFilterProvider {
|
|||
}
|
||||
|
||||
if (options.clean) {
|
||||
text = CoreTextUtils.cleanTags(text, options.singleLine);
|
||||
text = CoreTextUtils.cleanTags(text, { singleLine: options.singleLine });
|
||||
}
|
||||
|
||||
if (options.shortenLength && options.shortenLength > 0) {
|
||||
|
|
|
@ -137,15 +137,13 @@ export class CoreGradesHelperProvider {
|
|||
row.rowclass += itemNameColumn.class.indexOf('hidden') >= 0 ? ' hidden' : '';
|
||||
row.rowclass += itemNameColumn.class.indexOf('dimmed_text') >= 0 ? ' dimmed_text' : '';
|
||||
|
||||
if (useLegacyLayout) {
|
||||
content = content.replace(/<\/span>/gi, '\n');
|
||||
content = CoreTextUtils.cleanTags(content);
|
||||
} else {
|
||||
// The activity type won't be included in the webservice response if behat is running.
|
||||
content = CoreAppProvider.isAutomated() ? content : content.replace(/<span[^>]+>.+?<\/span>/i, '');
|
||||
content = CoreTextUtils.cleanTags(content, true);
|
||||
if (!useLegacyLayout && !CoreAppProvider.isAutomated()) {
|
||||
// Activity name is only included in the webservice response from the latest version when behat is not running.
|
||||
content = content.replace(/<span[^>]+>.+?<\/span>/i, '');
|
||||
}
|
||||
|
||||
content = content.replace(/<\/span>/gi, '\n');
|
||||
content = CoreTextUtils.cleanTags(content, { trim: true });
|
||||
name = 'gradeitem';
|
||||
} else if (name === 'grade') {
|
||||
// Add the pass/fail class if present.
|
||||
|
|
|
@ -415,7 +415,7 @@ export class CoreQuestionHelperProvider {
|
|||
|
||||
// Check anchor is valid.
|
||||
if (anchor.href && content) {
|
||||
content = CoreTextUtils.cleanTags(content, true).trim();
|
||||
content = CoreTextUtils.cleanTags(content, { singleLine: true, trim: true });
|
||||
attachments.push({
|
||||
filename: content,
|
||||
fileurl: anchor.href,
|
||||
|
|
|
@ -277,10 +277,12 @@ export class CoreTextUtilsProvider {
|
|||
* Clean HTML tags.
|
||||
*
|
||||
* @param text The text to be cleaned.
|
||||
* @param singleLine True if new lines should be removed (all the text in a single line).
|
||||
* @param options Processing options.
|
||||
* @param options.singleLine True if new lines should be removed (all the text in a single line).
|
||||
* @param options.trim True if text should be trimmed.
|
||||
* @returns Clean text.
|
||||
*/
|
||||
cleanTags(text: string | undefined, singleLine?: boolean): string {
|
||||
cleanTags(text: string | undefined, options: { singleLine?: boolean; trim?: boolean } = {}): string {
|
||||
if (!text) {
|
||||
return '';
|
||||
}
|
||||
|
@ -289,8 +291,10 @@ export class CoreTextUtilsProvider {
|
|||
text = text.replace(/(<([^>]+)>)/ig, '');
|
||||
// Then, we rely on the browser. We need to wrap the text to be sure is HTML.
|
||||
text = this.convertToElement(text).textContent || '';
|
||||
// Trim text
|
||||
text = options.trim ? text.trim() : text;
|
||||
// Recover or remove new lines.
|
||||
text = this.replaceNewLines(text, singleLine ? ' ' : '<br>');
|
||||
text = this.replaceNewLines(text, options.singleLine ? ' ' : '<br>');
|
||||
|
||||
return text;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue