Merge pull request #7812 from dataease/pr@dev@refactor_rich-text

refactor: 优化富文本光标定位
This commit is contained in:
王嘉豪
2024-01-25 09:50:45 +08:00
committed by GitHub
2 changed files with 5 additions and 2 deletions

View File

@@ -175,7 +175,8 @@ export default {
const range = document.createRange()
const sel = window.getSelection()
if (myDiv.childNodes) {
range.setStart(myDiv.childNodes[myDiv.childNodes.length - 1], 1)
range.setStart(myDiv.childNodes[myDiv.childNodes.length - 1]
.childNodes[myDiv.childNodes[myDiv.childNodes.length - 1].childNodes.length - 1], 1)
range.collapse(false)
sel.removeAllRanges()
sel.addRange(range)

View File

@@ -250,7 +250,9 @@ export default {
const range = document.createRange()
const sel = window.getSelection()
if (myDiv.childNodes) {
range.setStart(myDiv.childNodes[myDiv.childNodes.length - 1], 1)
range.setStart(myDiv.childNodes[myDiv.childNodes.length - 1]
.childNodes[myDiv.childNodes[myDiv.childNodes.length - 1].childNodes.length - 1],
myDiv.childNodes[myDiv.childNodes.length - 1].childNodes[myDiv.childNodes[myDiv.childNodes.length - 1].childNodes.length - 1].length)
range.collapse(false)
sel.removeAllRanges()
sel.addRange(range)