feat: Updated the search result fly-out menu design (#8203)

Co-authored-by: Pranav Raj S <pranav@chatwoot.com>
This commit is contained in:
Sivin Varghese
2023-10-25 19:16:49 -07:00
committed by GitHub
co-authored by Pranav Raj S
parent b6831d464e
commit 3e54d3654b
13 changed files with 67 additions and 592 deletions
@@ -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'
);
},
},
};