stash
This commit is contained in:
parent
54b9cefc5d
commit
3d45572697
1 changed files with 12 additions and 11 deletions
|
@ -1,5 +1,5 @@
|
||||||
<template>
|
<template>
|
||||||
<div contenteditable @input="onchange" ref="text" v-html="rawhtml(value)">
|
<div contenteditable @input="onchange" ref="text">
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
@ -93,17 +93,18 @@ export default {
|
||||||
if (this.selection) {
|
if (this.selection) {
|
||||||
console.log(this.selection);
|
console.log(this.selection);
|
||||||
|
|
||||||
setTimeout(() => {
|
const div = this.$refs.text;
|
||||||
const div = this.$refs.text;
|
div.innerHTML = this.rawhtml(this.value);
|
||||||
const range = document.createRange();
|
|
||||||
const sel = window.getSelection();
|
const range = document.createRange();
|
||||||
range.setStart(...this.findNode(div, this.selection.start));
|
const sel = window.getSelection();
|
||||||
range.setEnd(...this.findNode(div, this.selection.end));
|
range.setStart(...this.findNode(div, this.selection.start));
|
||||||
|
range.setEnd(...this.findNode(div, this.selection.end));
|
||||||
|
|
||||||
|
sel.removeAllRanges();
|
||||||
|
sel.addRange(range);
|
||||||
|
console.log(range, sel);
|
||||||
|
|
||||||
sel.removeAllRanges();
|
|
||||||
sel.addRange(range);
|
|
||||||
console.log(range, sel);
|
|
||||||
}, 0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue