From 84c9d922cee23a1031b8648b387b4eb00e766e44 Mon Sep 17 00:00:00 2001 From: jedi Date: Thu, 6 Jun 2024 21:19:36 +0200 Subject: [PATCH] stash --- web/src/components/inputs/FormatedText.vue | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/web/src/components/inputs/FormatedText.vue b/web/src/components/inputs/FormatedText.vue index 80940f5..4f7d92d 100644 --- a/web/src/components/inputs/FormatedText.vue +++ b/web/src/components/inputs/FormatedText.vue @@ -18,7 +18,7 @@ export default { }, data() { return { - selection: {start: 0, end: 0} + selection: {start: 0, end: 0, direction: 'forward', type: 'Caret'} }; }, emits: ['input'], @@ -36,6 +36,8 @@ export default { if (sel.rangeCount > 0) { this.selection.start = this.calculateOffset(div, sel.anchorNode, sel.anchorOffset); this.selection.end = this.calculateOffset(div, sel.focusNode, sel.focusOffset); + this.selection.direction = sel.direction; + this.selection.type = sel.type; } this.$emit('input', event.target.innerText); }, @@ -96,7 +98,10 @@ export default { 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); }