2 Commits

Author SHA1 Message Date
b0a3890db4 Merge branch 'two-way-binding' into new 2022-07-09 20:11:16 +03:00
2bbd11a7ed Fixed two way binding 2022-07-09 19:49:29 +03:00
7 changed files with 37 additions and 25 deletions

View File

@@ -1751,16 +1751,21 @@ function src_autoLink (text, options) {
}, },
data () { data () {
return { return {
focused: false, focused: false
body: ''
} }
}, },
computed: { computed: {
valueModel: {
get () { return this.value },
set (value) {
this.$emit('input', value)
}
},
showPlaceholder () { showPlaceholder () {
return !this.body.replace(/^\s*\n/gm, '').length return !this.valueModel.replace(/^\s*\n/gm, '').length
}, },
computedBody () { computedBody () {
return highlight(this.body, { return highlight(this.valueModel, {
extractUrlsWithoutProtocol: this.extractUrlsWithoutProtocol, extractUrlsWithoutProtocol: this.extractUrlsWithoutProtocol,
mentionsWithDots: this.mentionsWithDots mentionsWithDots: this.mentionsWithDots
}) })
@@ -1789,7 +1794,7 @@ function src_autoLink (text, options) {
}, },
clear () { clear () {
this.$refs.mbody.innerText = '' this.$refs.mbody.innerText = ''
this.body = '' this.valueModel = ''
}, },
onKeyUp (e) { onKeyUp (e) {
const keysToIgnore = ['Shift', 'Meta', 'Control', 'Alt', 'ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight'] const keysToIgnore = ['Shift', 'Meta', 'Control', 'Alt', 'ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight']
@@ -1799,8 +1804,7 @@ function src_autoLink (text, options) {
if (e.key === 'Enter') { if (e.key === 'Enter') {
caretPosition++ caretPosition++
} }
this.body = e.target.innerText this.valueModel = e.target.innerText
this.$emit('input', this.body)
this.$nextTick(() => { this.$nextTick(() => {
this.setCaretPos(caretPosition) this.setCaretPos(caretPosition)
}) })

File diff suppressed because one or more lines are too long

View File

@@ -1760,16 +1760,21 @@ function src_autoLink (text, options) {
}, },
data () { data () {
return { return {
focused: false, focused: false
body: ''
} }
}, },
computed: { computed: {
valueModel: {
get () { return this.value },
set (value) {
this.$emit('input', value)
}
},
showPlaceholder () { showPlaceholder () {
return !this.body.replace(/^\s*\n/gm, '').length return !this.valueModel.replace(/^\s*\n/gm, '').length
}, },
computedBody () { computedBody () {
return highlight(this.body, { return highlight(this.valueModel, {
extractUrlsWithoutProtocol: this.extractUrlsWithoutProtocol, extractUrlsWithoutProtocol: this.extractUrlsWithoutProtocol,
mentionsWithDots: this.mentionsWithDots mentionsWithDots: this.mentionsWithDots
}) })
@@ -1798,7 +1803,7 @@ function src_autoLink (text, options) {
}, },
clear () { clear () {
this.$refs.mbody.innerText = '' this.$refs.mbody.innerText = ''
this.body = '' this.valueModel = ''
}, },
onKeyUp (e) { onKeyUp (e) {
const keysToIgnore = ['Shift', 'Meta', 'Control', 'Alt', 'ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight'] const keysToIgnore = ['Shift', 'Meta', 'Control', 'Alt', 'ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight']
@@ -1808,8 +1813,7 @@ function src_autoLink (text, options) {
if (e.key === 'Enter') { if (e.key === 'Enter') {
caretPosition++ caretPosition++
} }
this.body = e.target.innerText this.valueModel = e.target.innerText
this.$emit('input', this.body)
this.$nextTick(() => { this.$nextTick(() => {
this.setCaretPos(caretPosition) this.setCaretPos(caretPosition)
}) })

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -31,16 +31,21 @@ export default {
}, },
data () { data () {
return { return {
focused: false, focused: false
body: ''
} }
}, },
computed: { computed: {
valueModel: {
get () { return this.value },
set (value) {
this.$emit('input', value)
}
},
showPlaceholder () { showPlaceholder () {
return !this.body.replace(/^\s*\n/gm, '').length return !this.valueModel.replace(/^\s*\n/gm, '').length
}, },
computedBody () { computedBody () {
return highlight(this.body, { return highlight(this.valueModel, {
extractUrlsWithoutProtocol: this.extractUrlsWithoutProtocol, extractUrlsWithoutProtocol: this.extractUrlsWithoutProtocol,
mentionsWithDots: this.mentionsWithDots mentionsWithDots: this.mentionsWithDots
}) })
@@ -69,7 +74,7 @@ export default {
}, },
clear () { clear () {
this.$refs.mbody.innerText = '' this.$refs.mbody.innerText = ''
this.body = '' this.valueModel = ''
}, },
onKeyUp (e) { onKeyUp (e) {
const keysToIgnore = ['Shift', 'Meta', 'Control', 'Alt', 'ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight'] const keysToIgnore = ['Shift', 'Meta', 'Control', 'Alt', 'ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight']
@@ -79,8 +84,7 @@ export default {
if (e.key === 'Enter') { if (e.key === 'Enter') {
caretPosition++ caretPosition++
} }
this.body = e.target.innerText this.valueModel = e.target.innerText
this.$emit('input', this.body)
this.$nextTick(() => { this.$nextTick(() => {
this.setCaretPos(caretPosition) this.setCaretPos(caretPosition)
}) })