this repo has no description
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat: render image cloze rects on inactive cards

Load sidecar rects for all cards at render time; display them as static
(non-interactive) yellow rects on inactive cards, mirroring how text
blank highlights are shown for all cards regardless of active state.

+57
+57
crates/tala/src/main.rs
··· 673 673 let active_sidecar_rects = sidecar_rects_sig.read().clone(); 674 674 let active_img_names = extract_img_names(&active_fragment); 675 675 let selected_rect = *selected_rect_sig.read(); 676 + // Load all sidecar image rects once for rendering inactive cards. 677 + let all_sidecar_rects: std::collections::HashMap<String, Vec<RectEntry>> = { 678 + let typ_path = cards_path(); 679 + Sidecar::load_or_empty_for(&typ_path).ok() 680 + .map(|sc| sc.cards.into_iter().filter_map(|(k, v)| { 681 + if let CardSchedule::Cloze { rects, .. } = v { Some((k, rects)) } else { None } 682 + }).collect()) 683 + .unwrap_or_default() 684 + }; 676 685 677 686 rsx! { 678 687 div { id: "editor", ··· 729 738 .and_then(|r| r.as_ref().ok()) 730 739 .map(|d| d.blank_rects.clone()) 731 740 .unwrap_or_default() 741 + }; 742 + let card_img_boxes_local: Vec<[f64; 4]> = if is_active { 743 + active_img_boxes.clone() 744 + } else { 745 + card_result.as_ref() 746 + .and_then(|r| r.as_ref().ok()) 747 + .map(|d| d.image_boxes.clone()) 748 + .unwrap_or_default() 749 + }; 750 + let card_sidecar_rects_local: Vec<RectEntry> = if is_active { 751 + active_sidecar_rects.clone() 752 + } else { 753 + let card_key = segs_snap[..=i] 754 + .iter() 755 + .filter(|s| s.kind == SegKind::Card) 756 + .count() 757 + .saturating_sub(1) 758 + .to_string(); 759 + all_sidecar_rects.get(&card_key).cloned().unwrap_or_default() 760 + }; 761 + let card_img_names_local: Vec<String> = if is_active { 762 + active_img_names.clone() 763 + } else { 764 + extract_img_names(&text_snap[seg.start..seg.end]) 732 765 }; 733 766 let render_err = card_result.and_then(|r| r.err()); 734 767 let preview_text = text_snap[seg.start..seg.end].to_string(); ··· 926 959 }, 927 960 } 928 961 } 962 + } 963 + } 964 + } 965 + } 966 + } 967 + if !is_active && seg.kind == SegKind::Card { 968 + for sr in &card_sidecar_rects_local { 969 + { 970 + let img_idx = card_img_names_local.iter().position(|n| n == &sr.src).unwrap_or(0); 971 + let ib = card_img_boxes_local.get(img_idx).copied().unwrap_or([0.0, 0.0, 1.0, 1.0]); 972 + let px = (ib[0] + sr.rect[0] as f64 * ib[2]) * iw; 973 + let py = (ib[1] + sr.rect[1] as f64 * ib[3]) * ih; 974 + let pw = sr.rect[2] as f64 * ib[2] * iw; 975 + let ph = sr.rect[3] as f64 * ib[3] * ih; 976 + let rid = sr.id.clone(); 977 + rsx! { 978 + rect { 979 + key: "{rid}", 980 + x: "{px}", y: "{py}", 981 + width: "{pw}", height: "{ph}", 982 + fill: "rgba(255,220,50,0.35)", 983 + stroke: "rgb(200,150,0)", 984 + stroke_width: "1.5", rx: "3", 985 + style: "pointer-events: none;", 929 986 } 930 987 } 931 988 }