The component I'm working on shall, when its finished , be a textarea or contenteditable div, where text followed by a hashtag is highlighted/ or in something like a chip.
At the moment I'm working with a contenteditable div, surrounded by another component that suggests keywords. In that component is a v-model
My goal is to put the text after the #, in a span.
<template>
<at :ats=['#'] v-model="vmodel">
<div contenteditable @keypress.enter="highlight"></div>
</at>
<template>
This does not what I want, since it adds the text at the beginning of the div. So for example when I write: "Hello #Something" I get: "#Something Hello"
<script>
import At from 'vue-at'
export default {
components: { At },
data() {
return { vmodel: '', };
},
methods: {
highlight(){
this.vmodel = this.vmodel.replace(/\B#([^ ]+)/g,"<span class='highlight-Text'>$&</span>")
}
}
</script>
How do I manipulate the vmodel, for example add a span to the text while typing, that it doesnt output gibberish?