refactor: extract block hover state types

This commit is contained in:
lix-2026
2026-05-25 02:34:01 +08:00
parent 6e8eacc929
commit 9d1ec75c6f
7 changed files with 63 additions and 39 deletions
+3 -37
View File
@@ -24,6 +24,9 @@ use editor_runtime::attachment_upload::dispatch_editor_upload_request;
use editor_runtime::block_menu_legacy_html::{
duplicate_top_level_block_html, reorder_top_level_block_html,
};
use editor_runtime::block_hover_state::{
BlockMenuLayout, DropIndicatorState, DropPlacement, HoveredBlockState, PendingDragState,
};
use editor_runtime::command_sync::{
read_editor_snapshot, sync_editor_outputs, sync_persisted_editor_command,
};
@@ -4783,14 +4786,6 @@ fn build_command_listener(mount_id: u32) -> Closure<dyn FnMut(Event)> {
}))
}
#[derive(Clone, Debug, PartialEq)]
struct HoveredBlockState {
index: usize,
label: String,
top: f64,
height: f64,
}
#[derive(Clone, Debug, PartialEq)]
struct ImageToolbarAnchor {
top: f64,
@@ -4829,35 +4824,6 @@ struct TableSelectionOverlayState {
index: usize,
}
#[derive(Clone, Debug, PartialEq)]
struct BlockMenuLayout {
max_height: f64,
open_upward: bool,
top: f64,
left: f64,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub(crate) enum DropPlacement {
Before,
After,
}
#[derive(Clone, Debug, PartialEq)]
struct DropIndicatorState {
index: usize,
top: f64,
placement: DropPlacement,
}
#[derive(Clone, Debug, PartialEq)]
struct PendingDragState {
index: usize,
anchor: HoveredBlockState,
start_x: i32,
start_y: i32,
}
fn default_title() -> String {
"Leptos Tiptap 主编辑器 P0".to_string()
}