-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: cristian.borelli <[email protected]>
- Loading branch information
Showing
9 changed files
with
222 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
projects/design-angular-kit/src/lib/pipes/mark-matching-text.pipe.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { Pipe, PipeTransform } from "@angular/core"; | ||
import { DomSanitizer } from "@angular/platform-browser"; | ||
|
||
@Pipe({ | ||
name: 'markMatchingText' | ||
}) | ||
export class MarkMatchingTextPipe implements PipeTransform { | ||
constructor(private domSanitizer: DomSanitizer) {} | ||
|
||
transform(allString: string, searchString: string): any { | ||
if (!searchString) { | ||
return allString; | ||
} else if(!allString) { | ||
return ""; | ||
} | ||
// Check if search string is a substring of pivot string (no case-sensitive) | ||
const idxOfMatchString = allString.toLowerCase().indexOf(searchString.toLowerCase()); | ||
if(idxOfMatchString !== -1) { | ||
// retrieve the exactly substring | ||
const matchingString = allString.substring(idxOfMatchString, idxOfMatchString + searchString.length); | ||
// Replace original string marking as <strong> (bold) the matchinng substring | ||
const regEx = new RegExp('(' + matchingString + ')', 'gi') | ||
const res = allString.replace(regEx, '<mark>$1</mark>'); | ||
return this.domSanitizer.bypassSecurityTrustHtml(res); | ||
} | ||
|
||
return allString; | ||
|
||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
f608d1a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
design-angular-kit – ./
design-angular-kit-git-main-dip-trasformazione-digitale.vercel.app
design-angular-kit-dip-trasformazione-digitale.vercel.app
design-angular-kit.vercel.app