SciPost Code Repository

Skip to content
Snippets Groups Projects
Commit f672241e authored by Jean-Sébastien Caux's avatar Jean-Sébastien Caux
Browse files

Add missing component

parent e77a7a38
No related branches found
No related tags found
No related merge requests found
<template>
<span v-html="highlightedText"></span>
</template>
<script>
import { ref, computed } from '@vue/composition-api'
export default {
name: "highlight-text",
props: {
text: String,
queries: {
type: Array,
default() {
return [{ query: "", caseSensitive: false },]
}
}
},
setup(props) {
const highlightedText = computed(() => {
let tempText = props.text
props.queries.forEach( (query) => {
if (query.query) {
tempText = tempText.replace(
new RegExp(query.query, query.caseSensitive ? "g" : "ig"),
function(match) {
return (`<mark>${match}</mark>`)
})
}
})
return tempText
})
return {
highlightedText
}
}
}
</script>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment