common/
format_runs_query.rs1use crate::database::Store;
8use crate::format_runs::{
9 FootnoteRefAnchor, FormatRun, ImageAnchor, InlineSegment, inline_segments_view,
10};
11use crate::types::EntityId;
12
13pub fn get_format_runs(store: &Store, block_id: EntityId) -> Vec<FormatRun> {
16 store
17 .format_runs
18 .read()
19 .get(&block_id)
20 .cloned()
21 .unwrap_or_default()
22}
23
24pub fn get_block_footnote_refs(store: &Store, block_id: EntityId) -> Vec<FootnoteRefAnchor> {
26 store
27 .block_footnote_refs
28 .read()
29 .get(&block_id)
30 .cloned()
31 .unwrap_or_default()
32}
33
34pub fn get_block_images(store: &Store, block_id: EntityId) -> Vec<ImageAnchor> {
36 store
37 .block_images
38 .read()
39 .get(&block_id)
40 .cloned()
41 .unwrap_or_default()
42}
43
44pub fn inline_segments_for_block(
52 store: &Store,
53 block_id: EntityId,
54 block_plain_text: &str,
55) -> Vec<InlineSegment> {
56 let runs = get_format_runs(store, block_id);
57 let images = get_block_images(store, block_id);
58 let notes = get_block_footnote_refs(store, block_id);
59 inline_segments_view(block_plain_text, &runs, &images, ¬es)
60}