use eframe::{egui, App, Frame};
use egui_commonmark::{CommonMarkCache, CommonMarkViewer};
pub struct PreviewApp {
content: String,
cache: CommonMarkCache,
}
impl PreviewApp {
pub fn new(content: String) -> Self {
Self {
content,
cache: CommonMarkCache::default(),
}
}
}
impl App for PreviewApp {
fn update(&mut self, ctx: &egui::Context, _frame: &mut Frame) {
egui::CentralPanel::default().show(ctx, |ui| {
egui::ScrollArea::vertical().show(ui, |ui| {
CommonMarkViewer::new().show(ui, &mut self.cache, &self.content);
});
});
}
}