bugfix: 报告按钮位置

This commit is contained in:
2026-03-13 14:25:44 +08:00
parent 6596208c11
commit 2f094ab332

View File

@@ -378,7 +378,12 @@
// Insert tag at the current cursor position
const selection = window.getSelection()
if (selection && selection.rangeCount > 0) {
// 检查selection是否在editorRef内部不在则强制使用editorRef
const isInEditor =
editorRef.value && selection && editorRef.value.contains(selection.anchorNode)
if (isInEditor && selection && selection.rangeCount > 0) {
const range = selection.getRangeAt(0)
range.insertNode(tag)
@@ -397,7 +402,7 @@
// ensure editor has focus
editorRef.value && (editorRef.value as HTMLElement).focus()
} else if (editorRef.value) {
// If no selection, append directly to editor and place caret after
// If no selection in editor, append directly to editor and place caret after
editorRef.value.appendChild(tag)
const zwsp = document.createTextNode('\u200B')
editorRef.value.appendChild(zwsp)