feat: support footnotes in the full-screen table view (1.2.0) - #31
feat: support footnotes in the full-screen table view (1.2.0)#31jphan32 wants to merge 4 commits into
Conversation
A footnote marker in a table cell survived into the full-screen view as a dead "[1]": the definitions live in the note's `.footnotes` list, outside the `<table>` the overlay clones, so there was nothing to show and nothing to jump to. The overlay now carries in a copy of every definition the clone's markers actually point at, lists it under the table, and re-points each footnote id and `#`-anchor into an overlay-local namespace — so the marker jumps to its definition and the "↩︎" back-reference jumps back, without leaving full screen and without disturbing the note's own footnote navigation. The numbering is carried over explicitly, so a table referencing only footnote 3 still reads "3.", and the section is laid out at a readable measure instead of the table's width. Every failure path degrades to the overlay as it was built before: no markers, no note root, no rendered definition list (Live Preview renders a table in isolation; Reading view virtualises off-screen sections away), or nothing that resolves. An individually unresolvable marker in an otherwise resolved note stays visible but is made inert — the same thing the note itself shows in those modes. Clone hygiene also drops the `id` attributes the clone copied over, keeping only the footnote identity nodes that get re-minted. A table carrying a `^block-id` previously appeared twice under the same id while the overlay was open. Closes #28 Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
manifest.json, versions.json and CHANGELOG.md in lockstep, per scripts/validate.mjs. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
A workflow-backed review at xhigh effort raised 15 findings against the
footnote work. Eleven were adjudicated real and are fixed here; four were
rejected with evidence (see below).
Clone hygiene
- `_scrub` no longer strips ids inside an SVG subtree. Removing them broke
id-scoped `<style>`, `<use>` and gradient/marker/clip-path references
outright — a Mermaid diagram in a cell rendered unstyled in the overlay —
whereas a duplicated svg-internal id is benign. The test is on
`namespaceURI`, not `closest("svg")`, so HTML inside a `<foreignObject>`
is still stripped.
- `_scrub` now also clears the inline sizing `DiagramView` stamps on a wrapped
svg before unwrapping the viewport that clipped it. A 1600px diagram inside
a cloned footnote definition used to render unscaled and overflow the
overlay.
Anchors
- The "cannot be resolved here" treatment is now a single site, `_makeInert`,
reached only through `_hardenAnchors`, which sweeps every footnote anchor —
back-references included. A definition carries one back-ref per reference
occurrence, including occurrences outside the table, so those extra
back-refs are always dead in the overlay; left live they looked clickable,
did nothing, and let the browser dirty the window URL and push a history
entry.
- The degradation paths (no definition list at all, nothing resolvable) now
run `_degradeFootnotes`, which strips the footnote identities `_scrub` was
holding for `_namespace` and makes the markers inert. Previously that clone
reached the document carrying the note's own ids — duplicate ids for as long
as the overlay was open — and a click fell through to the note behind it.
- `onFsAnchorClick` ignores the secondary button on `auxclick`. A right-click
on a marker used to get the context menu *and* a scroll and focus steal.
- The definition list is emitted in the note's document order, not
first-reference order, so a table referencing [^2] before [^1] no longer
renders "2." above "1.".
Focus, and accessibility
- Focus returns to the inline trigger only when the view was closed from the
keyboard. After a mouse close the trigger was focused while
`:focus-visible` did not match — invisible at `opacity: 0` — so the next
Space re-opened the overlay instead of scrolling the note. A focused trigger
is now always visible as well.
- An inert marker keeps an accessible name: an href-less `<a>` computes role
`generic`, where `aria-label` is prohibited, so `role="link"` is restored.
The name contains the visible "[1]" rather than replacing it, and a
back-ref — whose visible text is a glyph that names nothing — says what is
missing instead.
- The inert state no longer rests on colour alone (dotted underline), and a
keyboard-driven jump keeps a focus ring after the 1400ms highlight expires.
- Footnote prose is capped at 70ch, so a 2200px table no longer lays a
one-sentence footnote out as a single 2200px line.
Consistency
- The new code uses `classList` like the rest of the file; `addClass` is no
longer called. The e2e stub gained the polyfill anyway, since its absence is
what let the jump path throw under test while working in the app.
Rejected, with evidence: the widened backdrop-close test (those strips already
closed the overlay before this change — only the 20px gap band is new);
duplicate ids from a repeated reference (Obsidian mints a distinct
`data-footnote-id` per occurrence, and the preview post-processor sets each
element's id equal to it); a block id landing on a definition `<li>` (that
post-processor overwrites any pre-existing id, and the block-id transformer
does not reach a synthesized footnote list item); and `(ol.start || 1)`
mishandling `start="0"` (the renderer hard-codes `start: 1`).
Tests: the table suite now drives the behaviour instead of only measuring
layout — it clicks markers and back-references, asserts no page errors, and
covers the degraded, mixed, out-of-order, svg-in-cell and diagram-in-footnote
shapes. 51 table checks + 9 diagram checks.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Review remediationA workflow-backed review at 11 fixed, 4 rejected with evidence.
Rejected
Note on the fixtureAdjudicating F1 surfaced something the first pass had wrong: beyond the markdown transformer, Obsidian's preview post-processor suffixes every footnote id and VerificationThe table suite now drives behaviour rather than only measuring layout: it clicks markers and back-references, fails on any uncaught page error, and covers the degraded, mixed, out-of-order, svg-in-cell and diagram-in-footnote shapes. Every fixed finding was proved closed by measuring the failure against a pre-fix bundle and then against the current one. Known, deliberately deferred
Important Still not verified in a real vault. Reading view and Live Preview both need a manual pass before merge. |
… DOM Real-vault testing showed the feature never worked. The overlay read the note's rendered `.footnotes` list, but Obsidian does not render off-screen sections: the definition list sits at the very bottom of a note and the table is above it, so the lookup found nothing and every marker fell into the degradation path. The only footnote that worked belonged to the note's last table, where the list happened to be on screen. The e2e suite passed 51 checks throughout, because its fixture always had a rendered `.footnotes` section — the harness encoded the very assumption that is false. Definitions now come from the note's source. The marker's `data-footref` joins to `metadataCache.getFileCache(file).footnotes`, the definition's `position` slices `vault.cachedRead(file)`, and the result is rendered with `MarkdownRenderer.render` into the overlay. Nothing depends on what Obsidian happens to have rendered, so a table resolves its footnotes wherever it sits. Slicing is where this silently breaks, so it is validated on both sides: - a reference-style slice carries its own `[^id]:` label, which is stripped; an inline slice is the body alone and is left untouched; - continuation lines are dedented by exactly one indent unit, or a fenced block inside a definition parses as indented code and a mermaid diagram renders as a grey blob; - a slice that does not match the shape its id implies is dropped rather than rendered — a cache indexing mid-update would otherwise paste somebody else's text under the marker. Live Preview is not supported, and this is deliberate. Obsidian parses each block there on its own: a reference-style marker is not rendered inside a table widget at all, and an inline marker's id is positional within its parse unit, so a widget's `[inline0` need not be the note's `[inline0`. Joining on it would render a different footnote's body under the right marker. Those markers are left visible but inert instead — wrong text is worse than none. Rendering is async, so `openFullscreen` shows the table immediately and appends the section when it arrives. One `Component` per overlay owns every MarkdownRenderChild and is assigned before the first await, so a close during rendering unloads it; a render that returns to find the field holding a different component bails without touching the DOM. Back-references are now built rather than cloned, one per marker occurrence present in the clone, so a dead back-ref cannot exist by construction. minAppVersion moves to 1.6.6, the release that exposes footnotes in the metadata cache. The version stays 1.2.0. Tests: the suite is rebuilt on the measured reality, led by the case this redesign exists for — a note with no `.footnotes` anywhere that still produces a correct definition list. 109 table checks. Verified by mutation that they discriminate: neutralising the dedent fails the mermaid-fence check, and corrupting the source lookup fails the central regression. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Closes #28.
The problem
A footnote in a table cell — inline
^[note]or referenced[^1]— renders fine in the note but arrives in Lookout's full-screen table view as a dead[1].TableView.openFullscreen()clones the<table>into a fixed overlay, and the definitions live in the note's.footnoteslist outside that subtree, along with the#fn-…/#fnref-…anchors and Obsidian's own note-scoped click handling. So there was nothing to show and nothing to jump to.The change
The overlay now carries the footnotes in:
<section class="footnotes">under the table. The scroll container already carries.markdown-rendered, so the theme styles them exactly as in the note.li.valuefrom the source list's index), so a table referencing only footnote 3 reads "3." rather than "1." under a marker reading[3].#-href is re-pointed tolookout-fs-<n>-…, so the marker jumps to its definition and the "↩︎" back-reference jumps back — inside the overlay, never touching the note's own footnote navigation, and never putting a duplicate id in the document, not even for a frame.Degradation
Every failure path rebuilds the overlay exactly as it was before footnote support existed — no wrapper, no namespacing, no click handling: no markers, no note root, no rendered definition list, or nothing that resolves. That covers Live Preview (the table widget renders its slice in isolation and no definition list exists in the DOM) and a Reading view section Obsidian has virtualised away. An individually unresolvable marker in an otherwise-resolved note stays visible but is made inert, with a Korean label — deliberately no
Notice, because in those modes the note itself cannot show the text either. Parity with the note is the acceptance criterion, not absolutes.Also fixed
The clone no longer copies the live table's
idattributes into the document. A table carrying a^block-id, or anything id-bearing inside a cell, previously appeared twice under the same id for as long as the overlay was open — invalid DOM, and enough to send an in-note#…link to the clone instead of the note.Verification
The selector assumptions were checked against Obsidian's own renderer (the footnote transformer in
obsidian.asar), not inferred: the<sup class="footnote-ref">and the definition<li>carrydata-footnote-idand noid; the anchors carry only the#fn-…/#fnref-…href; the marker's href names the definition'sdata-footnote-id.tests/e2e/fixtures/table-harness.htmlmirrors that markup exactly.New e2e coverage: definition carried into full screen, marker re-pointed to an overlay-local anchor, footnote text laid out at a readable measure (not the narrow table's width), text not stacked into a sliver, centring preserved, no duplicate ids introduced by the clone, and the note's own definition left untouched.
Important
Not yet verified in a real vault. Per
CLAUDE.mdthis needs a manual pass in both Reading view and Live Preview before merge — the headless harness reproduces Obsidian's footnote markup but not Obsidian.Release
Version bumped to 1.2.0 (new feature) in lockstep across
manifest.json,versions.jsonandCHANGELOG.md.🤖 Generated with Claude Code