refactor: extract block dnd handle predicate

This commit is contained in:
lix-2026
2026-05-25 06:09:42 +08:00
parent 4d08b69d2e
commit 6017a0ad7c
6 changed files with 70 additions and 13 deletions
+6 -11
View File
@@ -22,8 +22,8 @@ use web_sys::{
use editor_runtime::attachment_upload::dispatch_editor_upload_request;
use editor_runtime::block_dnd::{
drop_indicator_from_geometry, event_target_from_point, pointer_in_handle_corridor_geometry,
HandleCorridorGeometry,
drop_indicator_from_geometry, element_within_handle_shell, event_target_from_point,
pointer_in_handle_corridor_geometry, HandleCorridorGeometry,
};
use editor_runtime::block_menu_overlay;
use editor_runtime::block_menu_legacy_html::{
@@ -4914,12 +4914,7 @@ fn hovered_block_from_target(target: web_sys::EventTarget) -> Option<HoveredBloc
let root = editor_root_element()?;
let element = target_element(target)?;
if element
.closest(HANDLE_SHELL_SELECTOR)
.ok()
.flatten()
.is_some()
{
if element_within_handle_shell(&element, HANDLE_SHELL_SELECTOR) {
return None;
}
@@ -8103,7 +8098,7 @@ fn App(mount_options: MountOptions) -> impl IntoView {
};
if let Some(element) = target_element(target.clone()) {
if element.closest(HANDLE_SHELL_SELECTOR).ok().flatten().is_some() {
if element_within_handle_shell(&element, HANDLE_SHELL_SELECTOR) {
return;
}
}
@@ -8155,7 +8150,7 @@ fn App(mount_options: MountOptions) -> impl IntoView {
};
if let Some(element) = target_element(target.clone()) {
if element.closest(HANDLE_SHELL_SELECTOR).ok().flatten().is_some() {
if element_within_handle_shell(&element, HANDLE_SHELL_SELECTOR) {
return;
}
}
@@ -8208,7 +8203,7 @@ fn App(mount_options: MountOptions) -> impl IntoView {
};
if let Some(element) = target_element(target.clone()) {
if element.closest(HANDLE_SHELL_SELECTOR).ok().flatten().is_some() {
if element_within_handle_shell(&element, HANDLE_SHELL_SELECTOR) {
return;
}
}