Skip to content

feat: support footnotes in the full-screen table view (1.2.0) - #31

Open
jphan32 wants to merge 4 commits into
devfrom
feat/fullscreen-table-footnotes
Open

feat: support footnotes in the full-screen table view (1.2.0)#31
jphan32 wants to merge 4 commits into
devfrom
feat/fullscreen-table-footnotes

Conversation

@jphan32

@jphan32 jphan32 commented Jul 27, 2026

Copy link
Copy Markdown
Member

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 .footnotes list 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:

  • Definitions are cloned in. Only the ones the clone's markers actually point at, in first-reference order, into a <section class="footnotes"> under the table. The scroll container already carries .markdown-rendered, so the theme styles them exactly as in the note.
  • Numbering is carried over explicitly (li.value from the source list's index), so a table referencing only footnote 3 reads "3." rather than "1." under a marker reading [3].
  • Ids are namespaced while the subtree is still detached. Every footnote identity and #-href is re-pointed to lookout-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.
  • Delegated click handling is scoped to those anchors only. A fragment that does not resolve in the overlay's own map is left alone, so an internal or external link in a cell keeps the behaviour it had before.

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 id attributes 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> carry data-footnote-id and no id; the anchors carry only the #fn-…/#fnref-… href; the marker's href names the definition's data-footnote-id. tests/e2e/fixtures/table-harness.html mirrors that markup exactly.

npm run lint            PASS
npm run build           PASS   (tsc --noEmit + esbuild)
node --check main.js    PASS
node scripts/validate.mjs   PASS  (13 checks, versions.json has 1.2.0)
npm run test:e2e        PASS   table 12/12, diagram 9/9

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.md this 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.json and CHANGELOG.md.

🤖 Generated with Claude Code

jphan32 and others added 3 commits July 27, 2026 22:32
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]>
@jphan32

jphan32 commented Jul 27, 2026

Copy link
Copy Markdown
Member Author

Review remediation

A workflow-backed review at xhigh effort raised 15 findings. Each was independently adjudicated against the code and against Obsidian's own renderer extracted from the app bundle, with the empirically testable ones reproduced in headless Chromium driving the real bundled main.js.

11 fixed, 4 rejected with evidence.

Finding Outcome
F0 _scrub wiped SVG-internal ids, breaking url(#…) / id-scoped <style> fixed — namespace test, not closest("svg"), so <foreignObject> HTML is still stripped
F1 Degradation paths shipped the note's live hrefs and ids, with no handler fixed — _degradeFootnotes
F2 Out-of-table back-refs stayed clickable and dirtied the URL fixed — hardening sweeps FN_ANCHOR, not just markers
F3 auxclick jumped on right-click fixed — secondary button ignored
F4 Mouse close parked focus on an invisible button; Space re-opened fixed — keyboard-only restore, and a focused trigger is visible
F6 Cloned diagram kept DiagramView's inline sizing after unwrap fixed
F7 Definition list could render in descending order fixed — emitted in the note's document order
F8 e2e stub lacked addClass; the jump path threw only under test fixed — classList throughout, polyfill added anyway
F9 Inert marker exposed no accessible name fixed — role="link" restored, name contains the visible [1]
F10 outline: none left a focused <li> with no lasting indicator fixed — :focus-visible ring
F11 A wide table stretched footnote prose to the table's measure fixed — capped at 70ch

Rejected

  • F5 (backdrop-close on the wrapper) — the geometric premise is right, but those side strips belonged to scroll before this change and the condition already closed on them. Only the 20px gap band is new; the comment that wrongly claimed the wrapper "hugs the table" was corrected.
  • F12 (duplicate ids from a repeated reference) — Obsidian mints a distinct data-footnote-id per occurrence (fnref-1, fnref-1-1, …) and the preview post-processor sets each element's id equal to its own, so two markers can never collide. Probed with realistic markup: zero duplicates.
  • F13 (a block id on a definition <li>) — that same post-processor unconditionally overwrites any pre-existing id with data-footnote-id + docId, and the block-id transformer only reaches root-level nodes and real list items, never the synthesized footnote item.
  • F14 ((ol.start || 1) vs start="0") — the arithmetic consequence is real, but the renderer hard-codes start: 1; only markup Obsidian cannot produce reaches it.

Note on the fixture

Adjudicating F1 surfaced something the first pass had wrong: beyond the markdown transformer, Obsidian's preview post-processor suffixes every footnote id and #-href with the note's docId and copies data-footnote-id onto the element as a real id. The e2e fixture now mirrors that, which is why the degraded clone genuinely carried duplicate ids.

Verification

npm run lint            PASS
npm run build           PASS
node --check main.js    PASS
node scripts/validate.mjs   PASS
npm run test:e2e        PASS   table 51/51, diagram 9/9

The 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

  • The full-screen overlay has no modal semantics and no focus trap, so Tab can leave it. This predates the footnote work and applies to the diagram overlay too — a proper fix belongs in its own change.
  • The highlight timer uses window.setTimeout, consistent with the rest of the file; switching the file to activeWindow is a separate sweep.

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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support inline footnotes in full-screen table view

1 participant