feat: implement granular section visibility control

Introduce the ability to reveal specific sections of a document
rather than entire files. This includes:

- Updating `revealedPaths` to map normalized file paths to sets of
  revealed section slugs.
- Adding `isPathRevealed` to handle visibility logic for connected
  clients and GMs.
- Enhancing `extractHeadings` to calculate `startLine` and `endLine`
  for each TOC node to support precise section identification.
This commit is contained in:
2026-07-07 07:44:57 +08:00
parent 7cfc0fd4f3
commit c5e1167beb
3 changed files with 92 additions and 16 deletions
+10 -1
View File
@@ -83,7 +83,16 @@ registerMessageType<LinkPayload>({
reducer: (p) => {
journalSetState(
produce((s) => {
s.revealedPaths.add(p.path);
const key = p.path.replace(/^\.?\//, "").replace(/\.md$/, "");
if (!s.revealedPaths[key]) {
s.revealedPaths[key] = new Set();
}
if (p.section) {
s.revealedPaths[key].add(p.section);
} else {
// No section — reveal the whole article
s.revealedPaths[key].clear();
}
}),
);
},