This commit is contained in:
j3d1 2024-05-23 00:07:43 +02:00
parent 2bbfa1c437
commit 0a95e7dc5d

View file

@ -41,8 +41,8 @@ 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], this.selection.anchorOffset); range.setStart(div.childNodes[0], Math.min(this.selection.anchorOffset, div.childNodes[0].length));
range.setEnd(div.childNodes[0], Math.min(this.selection.anchorOffset, div.childNodes[0].length)); range.setEnd(div.childNodes[0], Math.min(this.selection.focusOffset, div.childNodes[0].length));
this.selection.removeAllRanges(); this.selection.removeAllRanges();
this.selection.addRange(range); this.selection.addRange(range);
} }