stash
This commit is contained in:
parent
3a2a6328b0
commit
8f1cc0bba3
1 changed files with 6 additions and 1 deletions
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue