documents: GitHub alerts, a [toc] list of headings, front matter in a box, HTML blocks as text, a visible rule and bullets by depth

At the root a quote marked [!NOTE] and the rest, as GitHub's API reads it,
is an alert; a [toc] paragraph lists the headings and a press reveals one;
an HTML block shows its text with the inline tags, white space as a browser
lays it, scripts and styles dropped. The rule is 2px; bullets turn by depth.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
ZacharyZhang-NYandClaude Opus 5.5 committed 2026-10-13 23:08:51 -04:00
1 parent 9ff403df31
commit 2eec25140d
15 files changed
+810 -118

No files matched your search

+14 -2
View File
@@ -19,13 +19,18 @@ use gpui::{
ListState, Pixels, Subscription, Task, Window,
};
pub use crate::documents::tree::DocumentHeading;
pub use attach::Attachment;
pub use look::DocumentLook;
pub use parse::DocumentHeading;
use parse::{Parsed, alike, parsed};
pub use tables::{TableEdit, TableRefusal};
use super::{MarkdownMode, markdown::markdown_highlights, modes::joint, render::OnLink};
use super::{
MarkdownMode,
markdown::markdown_highlights,
modes::joint,
render::{OnHeading, OnLink},
};
use crate::{
editor::{CodeEditor, EditorEvent, LineNumbers},
forms::TextInput,
@@ -94,6 +99,7 @@ pub struct MarkdownDocument {
centered: Option<(usize, u64, u64, [u64; 2])>,
focus: FocusHandle,
on_link: Option<OnLink>,
on_heading: Option<OnHeading>,
_subscriptions: Vec<Subscription>,
}
@@ -132,6 +138,11 @@ impl MarkdownDocument {
cx.on_focus(&focus, window, Self::focused),
];
let overdraw = window.rem_size() * 40.0;
let this = cx.entity().downgrade();
let on_heading: OnHeading = Rc::new(move |at, window, cx| {
this.update(cx, |document, cx| document.reveal_at(at, window, cx))
.expect("a heading list lives in its document");
});
let mut document = Self {
editor,
mode,
@@ -151,6 +162,7 @@ impl MarkdownDocument {
room: Pixels::ZERO,
focus,
on_link: None,
on_heading: Some(on_heading),
_subscriptions: subscriptions,
};
document.reparse(true, cx);