mirror of
https://github.com/discourse/discourse.git
synced 2025-01-27 12:42:02 +08:00
0791d740a6
- also fixes phrase highlighting
9 lines
341 B
JavaScript
9 lines
341 B
JavaScript
export default function($elem, term) {
|
|
if(!_.isEmpty(term)) {
|
|
// special case ignore "l" which is used for magic sorting
|
|
let words = _.reject(term.match(/"[^"]+"|[^\s]+/g), t => t === 'l');
|
|
words = words.map(w => w.replace(/^"(.*)"$/, "$1"));
|
|
$elem.highlight(words, {className: 'search-highlight', wordsOnly: true});
|
|
}
|
|
}
|