Commit e9026158 authored by Phil Hughes's avatar Phil Hughes

changed data into a array of objects

this saves a load of computational stuff happening in the template
the data the template recieves is the data that should be rendered
parent f50c6977
......@@ -25,16 +25,19 @@ export default {
},
computed: {
allLines() {
return this.text.replace(/\n$/g, '\n\n').split('\n');
return this.text.split('\n').map((line, i) => ({
text: line.substr(0, this.getLineLength(i)) || ' ',
highlightedText: line.substr(this.getLineLength(i)),
}));
},
},
methods: {
handleScroll() {
this.$nextTick(() => {
if (this.$refs.textarea) {
if (this.$refs.textarea) {
this.$nextTick(() => {
this.scrollTop = this.$refs.textarea.scrollTop;
}
});
});
}
},
getLineLength(i) {
return i === 0 ? MAX_TITLE_LENGTH : MAX_BODY_LENGTH;
......@@ -99,11 +102,11 @@ export default {
:key="index"
>
<span
v-text="line.substr(0, getLineLength(index)) || ' '"
v-text="line.text"
>
</span><mark
v-show="line.length > getLineLength(index)"
v-text="line.substr(getLineLength(index))"
v-show="line.highlightedText"
v-text="line.highlightedText"
>
</mark>
</div>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment