feat(preview): cmd/ctrl-click jumps from document previews to their sources - #196
Open
ThatScalaGuy wants to merge 1 commit into
Open
feat(preview): cmd/ctrl-click jumps from document previews to their sources#196ThatScalaGuy wants to merge 1 commit into
ThatScalaGuy wants to merge 1 commit into
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #195.
Cmd/ctrl-click (reveal source in the VS Code embedded preview) was inert on
/doc/*routes: document content carried none of thedata-bino-*attributes the preview tooling keys on — neither the embedded:refcomponents nor the prose.:refcontainers getdata-bino-kind/data-bino-namenext to the existingdata-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 noidattribute: a component:ref'd twice in one document would produce duplicate ids.<section class='bn-doc-source' data-bino-file='<root-relative path>'>(newFullRenderOptions.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.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;handleRevealSourceopens file messages against the workspace root.vscode-bino compiled;
internal/web/static/preview.jsregenerated.Known limitation (pre-existing): the embedded-artefact panel has no revealSource bridge — this works in the full preview webview.