refactor: remove dead selection bridge helpers
This commit is contained in:
@@ -3529,34 +3529,6 @@ fn runtime_event_target() -> Option<EventTarget> {
|
||||
.map(|body| body.into())
|
||||
}
|
||||
|
||||
fn current_runtime_block_info() -> CurrentBlockInfo {
|
||||
hovered_block_from_selection()
|
||||
.and_then(|block| {
|
||||
Some(CurrentBlockInfo {
|
||||
index: Some(block.index),
|
||||
block_id: runtime_block_id_from_index(block.index),
|
||||
})
|
||||
})
|
||||
.unwrap_or(CurrentBlockInfo {
|
||||
index: None,
|
||||
block_id: None,
|
||||
})
|
||||
}
|
||||
|
||||
fn current_runtime_block_info_from_hovered(
|
||||
hovered_block: Option<HoveredBlockState>,
|
||||
) -> CurrentBlockInfo {
|
||||
hovered_block
|
||||
.map(|block| CurrentBlockInfo {
|
||||
index: Some(block.index),
|
||||
block_id: runtime_block_id_from_index(block.index),
|
||||
})
|
||||
.unwrap_or(CurrentBlockInfo {
|
||||
index: None,
|
||||
block_id: None,
|
||||
})
|
||||
}
|
||||
|
||||
fn editor_block_by_id(block_id: &str) -> Option<Element> {
|
||||
find_mnote_block_anchor(block_id)
|
||||
}
|
||||
@@ -4826,81 +4798,6 @@ fn current_workspace_id() -> Option<String> {
|
||||
current_query_param("workspaceId")
|
||||
}
|
||||
|
||||
fn selection_event_payload(
|
||||
selection: &TiptapSelectionState,
|
||||
editor_focused: bool,
|
||||
hovered_block: Option<HoveredBlockState>,
|
||||
) -> SelectionPayload {
|
||||
SelectionPayload {
|
||||
selection: selection.clone(),
|
||||
summary: selection_summary(selection),
|
||||
editor_focused,
|
||||
current_block_index: hovered_block.as_ref().map(|block| block.index),
|
||||
current_block_id: hovered_block.and_then(|block| runtime_block_id_from_index(block.index)),
|
||||
}
|
||||
}
|
||||
|
||||
fn runtime_state_payload(
|
||||
document_id: Option<String>,
|
||||
workspace_id: Option<String>,
|
||||
title: String,
|
||||
dirty_count: u32,
|
||||
hovered_block: Option<HoveredBlockState>,
|
||||
editor_focused: bool,
|
||||
slash_open: bool,
|
||||
turn_into_open: bool,
|
||||
color_menu_open: bool,
|
||||
more_menu_open: bool,
|
||||
read_only: bool,
|
||||
) -> StatePayload {
|
||||
StatePayload {
|
||||
document_id,
|
||||
workspace_id,
|
||||
title,
|
||||
dirty_count,
|
||||
selected_block_index: hovered_block.map(|block| block.index),
|
||||
editor_focused,
|
||||
slash_open,
|
||||
toolbar_open: toolbar_overlay_locked(turn_into_open, color_menu_open, more_menu_open),
|
||||
read_only,
|
||||
}
|
||||
}
|
||||
|
||||
fn runtime_status_payload(
|
||||
document_id: Option<String>,
|
||||
workspace_id: Option<String>,
|
||||
title: String,
|
||||
dirty_count: u32,
|
||||
hovered_block: Option<HoveredBlockState>,
|
||||
editor_focused: bool,
|
||||
slash_open: bool,
|
||||
turn_into_open: bool,
|
||||
color_menu_open: bool,
|
||||
more_menu_open: bool,
|
||||
read_only: bool,
|
||||
) -> HostStatusPayload {
|
||||
let current_block_index = hovered_block.as_ref().map(|block| block.index);
|
||||
HostStatusPayload {
|
||||
document_id,
|
||||
workspace_id,
|
||||
title,
|
||||
dirty_count,
|
||||
selected_block_index: current_block_index,
|
||||
current_block_id: current_block_index.and_then(runtime_block_id_from_index),
|
||||
editor_focused,
|
||||
read_only,
|
||||
slash_open,
|
||||
toolbar_open: toolbar_overlay_locked(turn_into_open, color_menu_open, more_menu_open),
|
||||
}
|
||||
}
|
||||
|
||||
fn dispatch_bridge_event<T>(event_name: &'static str, payload: &T)
|
||||
where
|
||||
T: Serialize,
|
||||
{
|
||||
dispatch_runtime_event(event_name, payload);
|
||||
}
|
||||
|
||||
pub(crate) fn editor_root_element() -> Option<Element> {
|
||||
window()
|
||||
.and_then(|win| win.document())
|
||||
@@ -5952,18 +5849,6 @@ fn dispatch_runtime_state_to_target(
|
||||
);
|
||||
}
|
||||
|
||||
fn send_selection_state(
|
||||
selection: &TiptapSelectionState,
|
||||
editor_focused: bool,
|
||||
current_block_index: Option<usize>,
|
||||
) {
|
||||
dispatch_selection_event(&selection_payload(
|
||||
selection,
|
||||
editor_focused,
|
||||
current_block_index,
|
||||
));
|
||||
}
|
||||
|
||||
fn send_selection_state_to_target(
|
||||
target: &EventTarget,
|
||||
selection: &TiptapSelectionState,
|
||||
|
||||
Reference in New Issue
Block a user