refactor: 富文本视图富文本组件进入编辑状态自动聚焦在文档末尾

This commit is contained in:
wangjiahao 2024-01-18 13:59:29 +08:00
parent 45858792f7
commit ec4d3006f7

View File

@ -293,9 +293,29 @@ const reShow = () => {
editShow.value = false
nextTick(() => {
editShow.value = true
editCursor()
})
}
const editCursor = () => {
setTimeout(() => {
const myDiv = document.getElementById(tinymceId)
//
const range = document.createRange()
const sel = window.getSelection()
if (myDiv.childNodes) {
range.setStart(myDiv.childNodes[myDiv.childNodes.length - 1], 1)
range.collapse(false)
sel.removeAllRanges()
sel.addRange(range)
}
//
if (myDiv.focus) {
myDiv.focus()
}
}, 100)
}
const calcData = (view: Chart, callback) => {
isError.value = false
if (view.tableId || view['dataFrom'] === 'template') {