@coolon/angular-ui-powerups 14.47.3 → 14.47.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm2020/lib/directives/highlight.pipe.mjs +9 -8
- package/fesm2015/coolon-angular-ui-powerups.mjs +8 -7
- package/fesm2015/coolon-angular-ui-powerups.mjs.map +1 -1
- package/fesm2020/coolon-angular-ui-powerups.mjs +8 -7
- package/fesm2020/coolon-angular-ui-powerups.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -43,7 +43,7 @@ import { GarbageCollector, DelegatingValueModel, assert, UnaryCommand, lang, Dsl
|
|
|
43
43
|
import { __decorate, __param, __metadata } from 'tslib';
|
|
44
44
|
import * as i1 from '@angular/platform-browser';
|
|
45
45
|
import escapeStringRegexp from 'escape-string-regexp';
|
|
46
|
-
import { isEmpty, isString, isFunction, isNil, isInteger, isObject, isEqual, join, first, uniq, last as last$1, isNumber, isNaN as isNaN$1 } from 'lodash';
|
|
46
|
+
import { escape, isEmpty, isString, isFunction, isNil, isInteger, isObject, isEqual, join, first, uniq, last as last$1, isNumber, isNaN as isNaN$1 } from 'lodash';
|
|
47
47
|
import { marked } from 'marked';
|
|
48
48
|
import { Memoize } from '@typescript-plus/fast-memoize-decorator';
|
|
49
49
|
import { Enum } from 'typescript-string-enums';
|
|
@@ -382,19 +382,20 @@ class HighlightPipe extends GarbageCollector {
|
|
|
382
382
|
this.dispose();
|
|
383
383
|
}
|
|
384
384
|
transform(value, searchModel) {
|
|
385
|
+
const sanitisedValue = escape(value);
|
|
385
386
|
const model = searchModel ?? this.highlightContext?.aupHighlightTextModel;
|
|
386
|
-
const searchText = model?.value;
|
|
387
|
-
if (isEmpty(searchText) || !isString(
|
|
388
|
-
return
|
|
387
|
+
const searchText = escape(model?.value);
|
|
388
|
+
if (isEmpty(searchText) || !isString(sanitisedValue)) {
|
|
389
|
+
return sanitisedValue;
|
|
389
390
|
}
|
|
390
391
|
// Match in a case insensitive manner
|
|
391
392
|
const re = new RegExp(escapeStringRegexp(searchText), 'gi');
|
|
392
|
-
const match =
|
|
393
|
+
const match = sanitisedValue.match(re);
|
|
393
394
|
// If there's no match, just return the original value.
|
|
394
395
|
if (!match) {
|
|
395
|
-
return
|
|
396
|
+
return sanitisedValue;
|
|
396
397
|
}
|
|
397
|
-
const result =
|
|
398
|
+
const result = sanitisedValue.replace(re, '<mark>' + match[0] + '</mark>');
|
|
398
399
|
return this.sanitizer.bypassSecurityTrustHtml(result);
|
|
399
400
|
}
|
|
400
401
|
}
|