feat(viewer): Markdown and plain-text documents are drawn as text
check / check (push) Canceled after 0s
check / check (push) Canceled after 0s
A text/markdown file (or text/x-markdown) is drawn as formatted text by egui_commonmark, with no image loading, so a document never makes the viewer read a file or the network; any other text/* type as its selectable text. UTF-8 only (a leading byte-order mark dropped), at most 2 MiB; past that or not UTF-8, the viewer says why. The documents page's tile shows the text's first lines. The SHA-256 row is cut to its column (it ran off the panel and widened the page under it). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01T3gXMVt7XJPi6ens1or9Dj
This commit is contained in:
6 files changed
+263
-7
No files matched your search
@@ -631,6 +631,30 @@ pub fn render(ui: &mut Ui, b: &Books, a: &Attachment, shell: &mut Shell<'_>, wid
|
||||
.color(p.negative),
|
||||
);
|
||||
}
|
||||
Render::Text { text, markdown } => {
|
||||
let (text, markdown) = (text.clone(), *markdown);
|
||||
egui::Frame::new()
|
||||
.fill(p.surface)
|
||||
.stroke(Stroke::new(1.0, p.border))
|
||||
.corner_radius(CornerRadius::same(6))
|
||||
.inner_margin(egui::Margin::same(14))
|
||||
.show(ui, |ui| {
|
||||
ui.set_width(width - 30.0);
|
||||
if markdown {
|
||||
egui_commonmark::CommonMarkViewer::new()
|
||||
.max_image_width(Some((width - 30.0) as usize))
|
||||
.show(ui, &mut shell.receipts.markdown, &text);
|
||||
} else {
|
||||
ui.add(
|
||||
egui::Label::new(
|
||||
RichText::new(text).font(egui::FontId::monospace(12.0)),
|
||||
)
|
||||
.selectable(true)
|
||||
.wrap(),
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
Render::Ready(pages) => {
|
||||
for (i, tex) in pages.iter().enumerate() {
|
||||
let size = tex.size_vec2();
|
||||
|
||||
Reference in new issue
Block a user