fix: 斜杠命令菜单 Esc 取消后清除输入字符

This commit is contained in:
MikiVL 2026-05-05 03:42:16 +08:00
parent cffaedb297
commit 8ce1072b0c

View File

@ -184,7 +184,14 @@ export function Editor() {
return true return true
} }
if (event.key === 'Escape') { if (event.key === 'Escape') {
if (slashStartPos.current !== null && editor) {
const { state, dispatch } = editor.view
const { from } = state.selection
const tr = state.tr.delete(slashStartPos.current, from)
dispatch(tr)
}
setSlashOpen(false) setSlashOpen(false)
slashStartPos.current = null
return true return true
} }
} }