refactor: share editor content layout helpers

This commit is contained in:
lix-2026
2026-05-25 09:19:49 +08:00
parent 563e64e5de
commit e8e59dc473
3 changed files with 12 additions and 22 deletions
+2 -20
View File
@@ -43,8 +43,8 @@ use editor_runtime::command_sync::{
use editor_runtime::content_layout::{content_column_left, content_text_left};
use editor_runtime::dom_events::{event_target_matches_selector, target_element};
use editor_runtime::dom_selection::{
block_index_from_selection, runtime_block_id_from_index, selection_payload,
selection_summary, SelectionPayload,
block_index_from_selection, current_block_info_from_index, runtime_block_id_from_index,
selection_payload, selection_summary, SelectionPayload,
};
use editor_runtime::editor_focus::{active_editor_stage, body_has_focus, schedule_editor_focus};
use editor_runtime::overlays::{
@@ -3224,12 +3224,6 @@ impl HostCommandKind {
}
}
#[derive(Clone, Debug, PartialEq, Eq)]
struct CurrentBlockInfo {
index: Option<usize>,
block_id: Option<String>,
}
#[cfg(test)]
mod tests {
use super::*;
@@ -5188,18 +5182,6 @@ fn p0_extensions() -> Vec<TiptapExtension> {
]
}
fn current_block_info_from_index(index: Option<usize>) -> CurrentBlockInfo {
index
.map(|value| CurrentBlockInfo {
index: Some(value),
block_id: runtime_block_id_from_index(value),
})
.unwrap_or(CurrentBlockInfo {
index: None,
block_id: None,
})
}
fn state_payload(
document_id: Option<String>,
workspace_id: Option<String>,