mirror of https://github.com/Squidex/squidex.git
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.
27 lines
656 B
27 lines
656 B
/*
|
|
* Squidex Headless CMS
|
|
*
|
|
* @license
|
|
* Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved.
|
|
*/
|
|
|
|
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 | null): string {
|
|
if (!highlight) {
|
|
return text;
|
|
}
|
|
|
|
if (Types.isString(highlight)) {
|
|
highlight = new RegExp(highlight, 'i');
|
|
}
|
|
|
|
return text.replace(highlight, s => `<b>${s}</b>`);
|
|
}
|
|
}
|
|
|