refactor: extract table selection overlay style
This commit is contained in:
@@ -109,6 +109,32 @@ pub(crate) fn table_col_aux_style(anchor: &TableOverlayAnchor, index: usize) ->
|
||||
)
|
||||
}
|
||||
|
||||
pub(crate) fn table_selection_overlay_style(
|
||||
anchor: &TableOverlayAnchor,
|
||||
selection: &TableSelectionOverlayState,
|
||||
) -> String {
|
||||
match selection.kind {
|
||||
TableSelectionKind::Row => {
|
||||
let row_height = anchor.height / anchor.rows.max(1) as f64;
|
||||
format!(
|
||||
"left:0;top:{:.1}px;width:{:.1}px;height:{:.1}px;",
|
||||
row_height * selection.index as f64,
|
||||
anchor.width,
|
||||
row_height
|
||||
)
|
||||
}
|
||||
TableSelectionKind::Column => {
|
||||
let col_width = anchor.width / anchor.cols.max(1) as f64;
|
||||
format!(
|
||||
"left:{:.1}px;top:0;width:{:.1}px;height:{:.1}px;",
|
||||
col_width * selection.index as f64,
|
||||
col_width,
|
||||
anchor.height
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn floating_toolbar_anchor_from_selection() -> Option<FloatingToolbarAnchor> {
|
||||
let selection = active_editor_text_selection()?;
|
||||
let range = selection.get_range_at(0).ok()?;
|
||||
|
||||
Reference in New Issue
Block a user