feat: add search input field (#18409)

This commit is contained in:
allenZhang
2025-04-22 11:07:18 +08:00
committed by GitHub
parent 67eefd0ba1
commit 94e22ba0fd
3 changed files with 77 additions and 50 deletions

View File

@@ -37,14 +37,16 @@ const OnBlurBlock: FC<OnBlurBlockProps> = ({
),
editor.registerCommand(
BLUR_COMMAND,
() => {
ref.current = setTimeout(() => {
editor.dispatchCommand(KEY_ESCAPE_COMMAND, new KeyboardEvent('keydown', { key: 'Escape' }))
}, 200)
if (onBlur)
onBlur()
(event) => {
// Check if the clicked target element is var-search-input
const target = event?.relatedTarget as HTMLElement
if (!target?.classList?.contains('var-search-input')) {
ref.current = setTimeout(() => {
editor.dispatchCommand(KEY_ESCAPE_COMMAND, new KeyboardEvent('keydown', { key: 'Escape' }))
}, 200)
if (onBlur)
onBlur()
}
return true
},
COMMAND_PRIORITY_EDITOR,