This commit is contained in:
j3d1 2024-06-06 22:26:54 +02:00
parent 54b9cefc5d
commit 3d45572697

View file

@ -1,5 +1,5 @@
<template>
<div contenteditable @input="onchange" ref="text" v-html="rawhtml(value)">
<div contenteditable @input="onchange" ref="text">
</div>
</template>
@ -93,17 +93,18 @@ export default {
if (this.selection) {
console.log(this.selection);
setTimeout(() => {
const div = this.$refs.text;
const range = document.createRange();
const sel = window.getSelection();
range.setStart(...this.findNode(div, this.selection.start));
range.setEnd(...this.findNode(div, this.selection.end));
const div = this.$refs.text;
div.innerHTML = this.rawhtml(this.value);
const range = document.createRange();
const sel = window.getSelection();
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);
}
}
}