bugfix: 报告按钮位置
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user