stash
This commit is contained in:
parent
e2cfe70af7
commit
2fd9ae4dbc
1 changed files with 4 additions and 4 deletions
|
@ -1,6 +1,5 @@
|
||||||
<template>
|
<template>
|
||||||
<div contenteditable @input="onchange" ref="text">
|
<div contenteditable @input="onchange" ref="text" v-html="rawhtml(value)">
|
||||||
<span v-html="rawhtml(value)"></span>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
@ -41,8 +40,9 @@ export default {
|
||||||
if (this.selection) {
|
if (this.selection) {
|
||||||
const div = this.$refs.text;
|
const div = this.$refs.text;
|
||||||
const range = document.createRange();
|
const range = document.createRange();
|
||||||
range.setStart(div.childNodes[0], Math.min(this.selection.anchorOffset, div.childNodes[0].length));
|
console.log(this.selection.anchorOffset, this.selection.focusOffset);
|
||||||
range.setEnd(div.childNodes[0], Math.min(this.selection.focusOffset, div.childNodes[0].length));
|
range.setStart(div, Math.min(this.selection.anchorOffset, div.childNodes[0].length));
|
||||||
|
range.setEnd(div, Math.min(this.selection.focusOffset, div.childNodes[0].length));
|
||||||
this.selection.removeAllRanges();
|
this.selection.removeAllRanges();
|
||||||
this.selection.addRange(range);
|
this.selection.addRange(range);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue