From ec4d3006f7cc3324de3f1284225cc1e8d8daf4d0 Mon Sep 17 00:00:00 2001 From: wangjiahao <1522128093@qq.com> Date: Thu, 18 Jan 2024 13:59:29 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E5=AF=8C=E6=96=87=E6=9C=AC?= =?UTF-8?q?=E8=A7=86=E5=9B=BE=E5=AF=8C=E6=96=87=E6=9C=AC=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=E8=BF=9B=E5=85=A5=E7=BC=96=E8=BE=91=E7=8A=B6=E6=80=81=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E8=81=9A=E7=84=A6=E5=9C=A8=E6=96=87=E6=A1=A3=E6=9C=AB?= =?UTF-8?q?=E5=B0=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../rich-text/DeRichTextView.vue | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/core/core-frontend/src/custom-component/rich-text/DeRichTextView.vue b/core/core-frontend/src/custom-component/rich-text/DeRichTextView.vue index 8d39d7496d..b3928e573d 100644 --- a/core/core-frontend/src/custom-component/rich-text/DeRichTextView.vue +++ b/core/core-frontend/src/custom-component/rich-text/DeRichTextView.vue @@ -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') {