From 3d455726976c02f59e8362c229cb94d6c559fde8 Mon Sep 17 00:00:00 2001 From: jedi Date: Thu, 6 Jun 2024 22:26:54 +0200 Subject: [PATCH] stash --- web/src/components/inputs/FormatedText.vue | 23 +++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/web/src/components/inputs/FormatedText.vue b/web/src/components/inputs/FormatedText.vue index 0529676..304150a 100644 --- a/web/src/components/inputs/FormatedText.vue +++ b/web/src/components/inputs/FormatedText.vue @@ -1,5 +1,5 @@ @@ -93,17 +93,18 @@ export default { if (this.selection) { console.log(this.selection); - 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)); + const div = this.$refs.text; + div.innerHTML = this.rawhtml(this.value); + + 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); - sel.removeAllRanges(); - sel.addRange(range); - console.log(range, sel); - }, 0); } } }