refactor: extract drop indicator geometry

This commit is contained in:
lix-2026
2026-05-25 05:06:28 +08:00
parent 63d1ea7e47
commit dddf9eb9c1
5 changed files with 61 additions and 12 deletions
+9 -10
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_top, drop_placement_from_block_point, event_target_from_point,
pointer_in_handle_corridor_geometry, HandleCorridorGeometry,
drop_indicator_from_geometry, event_target_from_point, pointer_in_handle_corridor_geometry,
HandleCorridorGeometry,
};
use editor_runtime::block_menu_overlay;
use editor_runtime::block_menu_legacy_html::{
@@ -5419,14 +5419,13 @@ fn drop_indicator_from_target(
let stage = editor_stage_element()?;
let block_rect = block.get_bounding_client_rect();
let stage_rect = stage.get_bounding_client_rect();
let placement = drop_placement_from_block_point(client_y, block_rect.top(), block_rect.height());
let top = drop_indicator_top(stage_rect.top(), block_rect.top(), block_rect.bottom(), placement);
Some(DropIndicatorState {
index: hovered.index,
top,
placement,
})
Some(drop_indicator_from_geometry(
hovered.index,
block_rect.top(),
block_rect.height(),
stage_rect.top(),
client_y,
))
}
fn drop_indicator_from_point(client_x: i32, client_y: i32) -> Option<DropIndicatorState> {