Fixed url-field bug with caret reset due to v-model update
This commit is contained in:
@@ -22,6 +22,7 @@ export default {
|
|||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
cacheValue: null,
|
||||||
unwatchValue: null,
|
unwatchValue: null,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -29,10 +30,13 @@ export default {
|
|||||||
this.$refs.editor.addEventListener("input", this.updateEditor)
|
this.$refs.editor.addEventListener("input", this.updateEditor)
|
||||||
this.$refs.editor.textContent = this.value || ""
|
this.$refs.editor.textContent = this.value || ""
|
||||||
|
|
||||||
|
this.cacheValue = this.value || ""
|
||||||
|
|
||||||
this.unwatchValue = this.$watch(
|
this.unwatchValue = this.$watch(
|
||||||
() => this.value,
|
() => this.value,
|
||||||
(newVal) => {
|
(newVal) => {
|
||||||
if (this.$refs.editor) this.$refs.editor.textContent = newVal || ""
|
if (this.$refs.editor && this.cacheValue !== newVal)
|
||||||
|
this.$refs.editor.textContent = newVal || ""
|
||||||
this.updateEditor()
|
this.updateEditor()
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@@ -117,6 +121,8 @@ export default {
|
|||||||
sel.setBaseAndExtent(anchorNode, anchorIndex, focusNode, focusIndex)
|
sel.setBaseAndExtent(anchorNode, anchorIndex, focusNode, focusIndex)
|
||||||
},
|
},
|
||||||
updateEditor() {
|
updateEditor() {
|
||||||
|
this.cacheValue = this.$refs.editor.textContent
|
||||||
|
|
||||||
const sel = window.getSelection()
|
const sel = window.getSelection()
|
||||||
const textSegments = this.getTextSegments(this.$refs.editor)
|
const textSegments = this.getTextSegments(this.$refs.editor)
|
||||||
const textContent = textSegments.map(({ text }) => text).join("")
|
const textContent = textSegments.map(({ text }) => text).join("")
|
||||||
|
|||||||
Reference in New Issue
Block a user