diff --git a/web/src/components/inputs/FormatedText.vue b/web/src/components/inputs/FormatedText.vue index 4f7d92d..0529676 100644 --- a/web/src/components/inputs/FormatedText.vue +++ b/web/src/components/inputs/FormatedText.vue @@ -91,19 +91,19 @@ export default { watch: { value() { if (this.selection) { - const div = this.$refs.text; - const sel = window.getSelection(); - sel.removeAllRanges(); - const range = document.createRange(); console.log(this.selection); - range.setStart(...this.findNode(div, this.selection.start)); - range.setEnd(...this.findNode(div, this.selection.end)); - console.log(range); - sel.addRange(range); - sel.type = this.selection.type; - sel.direction = this.selection.direction; - //this.selection.removeAllRanges(); - //this.selection.addRange(range); + + setTimeout(() => { + const div = this.$refs.text; + const range = document.createRange(); + const sel = window.getSelection(); + range.setStart(...this.findNode(div, this.selection.start)); + range.setEnd(...this.findNode(div, this.selection.end)); + + sel.removeAllRanges(); + sel.addRange(range); + console.log(range, sel); + }, 0); } } }