refactor: move body focus detection

This commit is contained in:
lix-2026
2026-05-25 02:19:57 +08:00
parent 6d0852e431
commit a3abeadfe8
5 changed files with 20 additions and 17 deletions
@@ -20,6 +20,14 @@ pub(crate) fn schedule_editor_focus(editor: TiptapEditorHandle) {
callback.forget();
}
pub(crate) fn body_has_focus() -> bool {
window()
.and_then(|win| win.document())
.and_then(|document| document.active_element())
.map(|element| element.tag_name().eq_ignore_ascii_case("body"))
.unwrap_or(false)
}
pub(crate) fn active_editor_stage() -> bool {
let active_element_inside_stage = window()
.and_then(|win| win.document())