From a95bdaa5a4f4d164c192f3cd97242d9d91775d36 Mon Sep 17 00:00:00 2001 From: jedi Date: Thu, 6 Jun 2024 22:00:03 +0200 Subject: [PATCH] stash --- web/src/components/inputs/FormatedText.vue | 24 +++++++++++----------- 1 file changed, 12 insertions(+), 12 deletions(-) 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); } } }