Skip to content
This repository has been archived by the owner on May 24, 2021. It is now read-only.

Commit

Permalink
fix(transcripts): Fixes text highlighting
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-heimbuch committed Jul 23, 2018
1 parent 542d16d commit 6d98ef8
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/components/tabs/transcripts/Entry.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,19 @@
...children
])
const highlightText = (h, c, text) => {
if (!c.query) {
return text
}
return text
.replace(c.searchQuery, matched => `|||${matched}|||`)
.split('|||')
.map(text =>
text.match(c.searchQuery) ? h('span', {class: { highlight: true }}, text) : text)
}
const text = (h, c) => (transcript, index) =>
h('span', {
class: {
Expand All @@ -47,7 +60,7 @@
mouseover: () => c.onMouseOver(transcript),
mouseleave: () => c.onMouseLeave(transcript)
}
}, [c.searchText(transcript.text)])
}, [highlightText(h, c, transcript.text)])
export default {
data: mapState('theme', 'transcripts'),
Expand Down

0 comments on commit 6d98ef8

Please sign in to comment.