ng-zorro-antd
Version:
An enterprise-class UI components based on Ant Design and Angular
41 lines (40 loc) • 1.37 kB
JavaScript
import * as i0 from "@angular/core";
import { Pipe } from "@angular/core";
import { encodeEntities } from "ng-zorro-antd/core/util";
var NzHighlightPipe = class NzHighlightPipe {
UNIQUE_WRAPPERS = ["##==-open_tag-==##", "##==-close_tag-==##"];
transform(value, highlightValue, flags, klass) {
if (!highlightValue) return value;
const searchValue = new RegExp(highlightValue.replace(/([.*+?^=!:${}()|[\]/\\])/g, "\\$&"), flags);
const wrapValue = value.replace(searchValue, `${this.UNIQUE_WRAPPERS[0]}$&${this.UNIQUE_WRAPPERS[1]}`);
return encodeEntities(wrapValue).replace(new RegExp(this.UNIQUE_WRAPPERS[0], "g"), klass ? `<span class="${klass}">` : "<span>").replace(new RegExp(this.UNIQUE_WRAPPERS[1], "g"), "</span>");
}
static ɵfac = i0.ɵɵngDeclareFactory({
minVersion: "12.0.0",
version: "22.2.2",
ngImport: i0,
type: NzHighlightPipe,
deps: [],
target: i0.ɵɵFactoryTarget.Pipe
});
static ɵpipe = i0.ɵɵngDeclarePipe({
minVersion: "14.0.0",
version: "22.2.2",
ngImport: i0,
type: NzHighlightPipe,
isStandalone: true,
name: "nzHighlight"
});
};
i0.ɵɵngDeclareClassMetadata({
minVersion: "12.0.0",
version: "22.2.2",
ngImport: i0,
type: NzHighlightPipe,
decorators: [{
type: Pipe,
args: [{ name: "nzHighlight" }]
}]
});
export { NzHighlightPipe };
//# sourceMappingURL=ng-zorro-antd-core-highlight.mjs.map