mirror of
https://github.com/anatolykopyl/vue-highlights.git
synced 2026-03-26 21:05:35 +00:00
Compare commits
1 Commits
ad6f22dfde
...
two-way-bi
| Author | SHA1 | Date | |
|---|---|---|---|
| 2bbd11a7ed |
18
src/index.js
18
src/index.js
@@ -27,16 +27,21 @@ export default {
|
||||
},
|
||||
data () {
|
||||
return {
|
||||
focused: false,
|
||||
body: ''
|
||||
focused: false
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
valueModel: {
|
||||
get () { return this.value },
|
||||
set (value) {
|
||||
this.$emit('input', value)
|
||||
}
|
||||
},
|
||||
showPlaceholder () {
|
||||
return !this.body.replace(/^\s*\n/gm, '').length
|
||||
return !this.valueModel.replace(/^\s*\n/gm, '').length
|
||||
},
|
||||
computedBody () {
|
||||
return highlight(this.body, {
|
||||
return highlight(this.valueModel, {
|
||||
extractUrlsWithoutProtocol: this.extractUrlsWithoutProtocol
|
||||
})
|
||||
}
|
||||
@@ -64,15 +69,14 @@ export default {
|
||||
},
|
||||
clear () {
|
||||
this.$refs.mbody.innerText = ''
|
||||
this.body = ''
|
||||
this.valueModel = ''
|
||||
},
|
||||
onKeyUp (e) {
|
||||
let caretPosition = this.getCaretPos()
|
||||
if (e.keyCode === 13) { // Enter key
|
||||
caretPosition++
|
||||
}
|
||||
this.body = e.target.innerText
|
||||
this.$emit('input', this.body)
|
||||
this.valueModel = e.target.innerText
|
||||
this.$nextTick(() => {
|
||||
this.setCaretPos(caretPosition)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user