fix(preview): live-reload DocumentArtefact routes, pin doc page width - #191
Open
ThatScalaGuy wants to merge 1 commit into
Open
fix(preview): live-reload DocumentArtefact routes, pin doc page width#191ThatScalaGuy wants to merge 1 commit into
ThatScalaGuy wants to merge 1 commit into
Conversation
The doc loop in refresh.Run only swapped the static route and never called BroadcastContent, so /doc/* views stayed stale until a manual reload, showed a false 'Refresh failed' pill on every refresh, and the /__preview/context endpoint 404'd for doc paths forever. Broadcast the styled doc HTML like the report loop does; swapContext already extracts the bn-context from a full page, so no pipeline change is needed. The --bn-doc-page-width custom property moves from a head style tag to an inline style attribute on bn-context so it participates in the attribute sync on SSE morphs (format/orientation edits update live). preview.css pins the doc container to the paper width: the generic bn-context min-width:100% beat the doc rule's max-width, so the previewed page tracked the browser window instead of the PDF geometry and embedded components validated against window-dependent widths. The no-payload toolbar pill is removed: selective refreshes legitimately skip unaffected views, and every real render failure already surfaces via path-scoped refresh-error events. The console warning stays.
| out = append(out, tag...) | ||
| out = append(out, doc[idx:]...) | ||
| insertAt := idx + len(openTag) | ||
| out := make([]byte, 0, len(doc)+len(attr)) |
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.
The preview never pushed content updates to
/doc/*routes. The doc loop inrefresh.Runonly swapped the static route, so editing a markdown source left the open browser tab stale, every refresh showed a false "Refresh failed" pill while a doc route was open, andGET /__preview/context?path=/doc/…returned 404 for the whole session.Changes:
swapContexton the client already extracts thebn-contextfrom a full page, so the existing morph machinery works unchanged — long documents keep their scroll position while editing.--bn-doc-page-widthmoved from an injected<head>style tag to an inlinestyleattribute onbn-context. The head is never touched by the morph, so a format/orientation change would have kept the old width; attributes are synced, so it updates live now.preview.csspins the document container to the paper width. The genericbn-context { min-width: 100% }rule was beating the doc rule'smax-width, so the previewed "page" followed the browser window — embedded components sized and validated against a width the built PDF does not have.refresh-errorevents; the console warning stays for debugging.refresh.Rungets its first test: it proves doc routes end up in the broadcast list and the context cache serves the rendered document (both failed before the fix). The width helper has a table-driven test for the format/orientation mapping.internal/web/static/preview.jsis regenerated from source.