This commit is contained in:
j3d1 2024-06-06 21:19:36 +02:00
parent 4c16f67b49
commit a331022f30

View file

@ -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);
}