stash
This commit is contained in:
parent
f4884da562
commit
84c9d922ce
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