refactor: move body focus detection
This commit is contained in:
@@ -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())
|
||||
|
||||
Reference in New Issue
Block a user