use crate::database::Store;
use crate::format_runs::{FormatRun, ImageAnchor, InlineSegment, inline_segments_view};
use crate::types::EntityId;
pub fn get_format_runs(store: &Store, block_id: EntityId) -> Vec<FormatRun> {
store
.format_runs
.read()
.unwrap()
.get(&block_id)
.cloned()
.unwrap_or_default()
}
pub fn get_block_images(store: &Store, block_id: EntityId) -> Vec<ImageAnchor> {
store
.block_images
.read()
.unwrap()
.get(&block_id)
.cloned()
.unwrap_or_default()
}
pub fn inline_segments_for_block(
store: &Store,
block_id: EntityId,
block_plain_text: &str,
) -> Vec<InlineSegment> {
let runs = get_format_runs(store, block_id);
let images = get_block_images(store, block_id);
inline_segments_view(block_plain_text, &runs, &images)
}