Headless CMS and Content Managment Hub
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

29 lines
682 B

/*
* Squidex Headless CMS
*
* @license
* Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved.
*/
// tslint:disable: no-pipe-impure
import { Pipe, PipeTransform } from '@angular/core';
import { Types } from '@app/framework/internal';
@Pipe({
name: 'sqxHighlight',
pure: false
})
export class HighlightPipe implements PipeTransform {
public transform(text: string, highlight: string | RegExp | undefined): string {
if (!highlight) {
return text;
}
if (Types.isString(highlight)) {
highlight = new RegExp(highlight, 'i');
}
return text.replace(highlight, s => `<b>${s}</b>`);
}
}