Files
Marcos Paulo 15d7f5e873 feat: editor blocks and lint, vault knowledge, calendar plugin, macOS menu
- notescraft-lint (rules, safe fixes, learned style) and notescraft-blocks (block model and edits); engine lint.* and block.* commands with CLI and MCP parity
- Lint tab, underlines, slash menu with preview in Source and Visual, block grip and menu, Settings > Editor and lint, Vim block keys
- Visual view: tables, note embeds, %% comments, wrapping property chips
- Vault knowledge (Related tab, assistant sources, Settings) and calendar plugin
- Sidebar top padding fixed, dot grid follows PaperCraft spacing, right-card tabs no longer cover the collapse button

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-18 12:36:00 -03:00

59 lines
2.5 KiB
Rust

//! Renders the Lint tab offscreen (for example at phone width) and saves a PNG.
//!
//! ```sh
//! cargo run -p notescraft-ui-egui --example lint_panel -- --size 390x844 --out lint.png
//! ```
use notescraft_lint::{Context, check};
use notescraft_ui_egui::lint_panel::{self, LintData, StyleRow};
use notescraft_ui_egui::theme::Tokens;
const NOTE: &str =
"# 2026-10-17\n\nPlan the day and capture notes.\n\nSee [[Releas notes]] for details.\n\n### Next steps\n\n* Draft the post\n- Send to team\n";
fn main() {
let args: Vec<String> = std::env::args().collect();
let arg = |name: &str| args.iter().position(|a| a == name).and_then(|i| args.get(i + 1).cloned());
let Some(theme) = notescraft_themes::builtin(&arg("--theme").unwrap_or_else(|| "catppuccin-mocha".into())) else {
eprintln!("unknown theme");
return;
};
let size =
arg("--size").and_then(|s| s.split_once('x').and_then(|(w, h)| Some(egui::vec2(w.parse().ok()?, h.parse().ok()?)))).unwrap_or(egui::vec2(420.0, 900.0));
let out = arg("--out").unwrap_or_else(|| "/tmp/notescraft-lint-panel.png".to_owned());
let context = Context { titles: vec![("Release notes.md".to_owned(), "Release notes".to_owned())], ..Context::default() };
let data = LintData {
issues: check(NOTE, &context),
checked: true,
enabled: true,
learn_style: true,
styles: vec![
StyleRow { aspect: "list_marker", value: "-".to_owned(), percent: 94, total: 212 },
StyleRow { aspect: "date_format", value: "YYYY-MM-DD".to_owned(), percent: 98, total: 80 },
],
..LintData::default()
};
let tokens = Tokens::new(theme);
let mut ready = false;
let mut harness = egui_kittest::Harness::builder().with_size(size).with_pixels_per_point(1.0).with_max_steps(8).wgpu().build_ui(|ui| {
if !ready {
egui_extras::install_image_loaders(ui.ctx());
notescraft_ui_egui::fonts::install(ui.ctx());
notescraft_ui_egui::style::apply(ui.ctx(), &tokens);
ready = true;
ui.ctx().request_repaint();
return;
}
let _ = lint_panel::show(ui, &tokens, &data);
});
harness.run();
match harness.render() {
Ok(image) => {
if let Err(error) = image.save(&out) {
eprintln!("could not save screenshot: {error}");
}
}
Err(error) => eprintln!("could not render screenshot: {error}"),
}
}