Skip to content

feat(preview): cmd/ctrl-click jumps from document previews to their sources - #196

Open
ThatScalaGuy wants to merge 1 commit into
feat/doc-preview-affordancesfrom
feat/doc-click-to-source
Open

feat(preview): cmd/ctrl-click jumps from document previews to their sources#196
ThatScalaGuy wants to merge 1 commit into
feat/doc-preview-affordancesfrom
feat/doc-click-to-source

Conversation

@ThatScalaGuy

Copy link
Copy Markdown
Contributor

Stacked on #195.

Cmd/ctrl-click (reveal source in the VS Code embedded preview) was inert on /doc/* routes: document content carried none of the data-bino-* attributes the preview tooling keys on — neither the embedded :ref components nor the prose.

  • Resolved :ref containers get data-bino-kind/data-bino-name next to the existing data-ref-* attributes. The existing click handler and the extension's kind+name lookup work for embedded components with no further changes — and as free side effects the containers join the search palette and the inspector's source attribution. Deliberately no id attribute: a component :ref'd twice in one document would produce duplicate ids.
  • Each source file's rendered output is wrapped in <section class='bn-doc-source' data-bino-file='<root-relative path>'> (new FullRenderOptions.ProjectRoot, set from the pipeline workdir — empty disables, TOC-only renders stay wrapper-free). Chapter numbering and heading ids derive from the TOC AST, not the HTML structure, so the wrappers change nothing there; page breaks stay between sections. Paths are relative and forward-slashed — no local filesystem layout leaks into built HTML.
  • The click handler now resolves closest('[data-bino-kind], [data-bino-file]') — nearest ancestor wins, so clicks inside an embedded component beat the surrounding prose section — and sends {type: 'bino:revealSource', file} for prose. Same message type, so the webview forwarding bridge needed no change; handleRevealSource opens file messages against the workspace root.

vscode-bino compiled; internal/web/static/preview.js regenerated.

Known limitation (pre-existing): the embedded-artefact panel has no revealSource bridge — this works in the full preview webview.

…ources

Document content carried none of the data-bino-* attributes the preview
tooling keys on, so cmd/ctrl-click (reveal source in the VS Code
embedded preview) was inert on /doc/* routes — for embedded components
and for prose alike.

- Resolved :ref containers now carry data-bino-kind/name next to the
  existing data-ref-* attributes. The existing click handler and the
  extension's kind+name lookup work unchanged for components, and the
  containers become visible to the search palette and the inspector's
  source attribution. No id attribute: a component ref'd twice in one
  document would produce duplicate ids.
- Each source file's output is wrapped in <section class='bn-doc-source'
  data-bino-file='<root-relative path>'> (FullRenderOptions.ProjectRoot,
  set from the pipeline workdir; empty disables). Chapter numbering and
  heading ids derive from the TOC AST, not the HTML, so the wrappers are
  inert for numbering; page breaks stay between the sections.
- The click handler resolves closest('[data-bino-kind], [data-bino-file]')
  — nearest ancestor wins, so component clicks beat their surrounding
  prose section — and sends the file path in the same bino:revealSource
  message; the webview forwarding bridge needed no change. The extension
  opens file messages against the workspace root.

Known limitation (pre-existing): the embedded-artefact panel has no
revealSource bridge; this works in the full preview webview.
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.

1 participant