Compare commits

...

2 commits

Author SHA1 Message Date
b3df41a46f stash 2024-05-23 00:39:22 +02:00
730c156b11 stash 2024-05-23 00:07:43 +02:00

View file

@ -1,6 +1,5 @@
<template>
<div contenteditable @input="onchange" ref="text">
<span v-html="rawhtml(value)"></span>
<div contenteditable @input="onchange" ref="text" v-html="rawhtml(value)">
</div>
</template>
@ -41,8 +40,9 @@ export default {
if (this.selection) {
const div = this.$refs.text;
const range = document.createRange();
range.setStart(div.childNodes[0], this.selection.anchorOffset);
range.setEnd(div.childNodes[0], Math.min(this.selection.anchorOffset, div.childNodes[0].length));
console.log(this.selection.anchorOffset, this.selection.focusOffset);
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.addRange(range);
}