This commit is contained in:
j3d1 2024-06-06 22:00:03 +02:00
parent 8f1cc0bba3
commit 54b9cefc5d

View file

@ -91,19 +91,19 @@ export default {
watch: { watch: {
value() { value() {
if (this.selection) { if (this.selection) {
const div = this.$refs.text;
const sel = window.getSelection();
sel.removeAllRanges();
const range = document.createRange();
console.log(this.selection); console.log(this.selection);
range.setStart(...this.findNode(div, this.selection.start));
range.setEnd(...this.findNode(div, this.selection.end)); setTimeout(() => {
console.log(range); const div = this.$refs.text;
sel.addRange(range); const range = document.createRange();
sel.type = this.selection.type; const sel = window.getSelection();
sel.direction = this.selection.direction; range.setStart(...this.findNode(div, this.selection.start));
//this.selection.removeAllRanges(); range.setEnd(...this.findNode(div, this.selection.end));
//this.selection.addRange(range);
sel.removeAllRanges();
sel.addRange(range);
console.log(range, sel);
}, 0);
} }
} }
} }