feat: Updated the search result fly-out menu design (#8203)
Co-authored-by: Pranav Raj S <pranav@chatwoot.com>
This commit is contained in:
@@ -71,18 +71,11 @@ export default {
|
||||
},
|
||||
prepareContent(content = '') {
|
||||
const escapedText = this.escapeHtml(content);
|
||||
const plainTextContent = this.getPlainText(escapedText);
|
||||
const escapedSearchTerm = this.escapeRegExp(this.searchTerm);
|
||||
return plainTextContent
|
||||
.replace(
|
||||
new RegExp(`(${escapedSearchTerm})`, 'ig'),
|
||||
'<span class="searchkey--highlight">$1</span>'
|
||||
)
|
||||
.replace(/\s{2,}|\n|\r/g, ' ');
|
||||
},
|
||||
// from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#escaping
|
||||
escapeRegExp(string) {
|
||||
return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
||||
return this.highlightContent(
|
||||
escapedText,
|
||||
this.searchTerm,
|
||||
'searchkey--highlight'
|
||||
);
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user