mirror of
https://github.com/nasa/openmct.git
synced 2025-04-12 21:53:07 +00:00
This commit is contained in:
parent
f39f8df4e2
commit
665ba6dae1
@ -49,9 +49,19 @@ export default {
|
||||
},
|
||||
computed: {
|
||||
highlightedText() {
|
||||
let regex = new RegExp(`(?<!<[^>]*)(${this.highlight})`, 'gi');
|
||||
const highlight = this.highlight;
|
||||
|
||||
return this.text.replace(regex, `<span class="${this.highlightClass}">${this.highlight}</span>`);
|
||||
const normalCharsRegex = /^[^A-Za-z0-9]+$/g;
|
||||
|
||||
const newHighLight = normalCharsRegex.test(highlight)
|
||||
? `\\${highlight}`
|
||||
: highlight;
|
||||
|
||||
const highlightRegex = new RegExp(`(?<!<[^>]*)(${newHighLight})`, 'gi');
|
||||
|
||||
const replacement = `<span class="${this.highlightClass}">${highlight}</span>`;
|
||||
|
||||
return this.text.replace(highlightRegex, replacement);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user