Skip to content

feat: render html in quick preview with local assets - #130

Merged
mattenarle10 merged 1 commit into
mattenarle10:mainfrom
amazing-project:feat/html-quick-preview
Aug 8, 2026
Merged

feat: render html in quick preview with local assets#130
mattenarle10 merged 1 commit into
mattenarle10:mainfrom
amazing-project:feat/html-quick-preview

Conversation

@beihai23

@beihai23 beihai23 commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

what

Quick preview now renders .html / .htm files instead of showing raw source:

  • new html preview kind in src/lib/preview.ts (moved out of the text bucket)
  • rendered in a sandboxed iframe (sandbox="allow-scripts" — scripts run in an opaque origin, no same-origin/local-file access)
  • htmlDocWithBase() injects a <base> pointing at the file's directory via convertFileSrc(), so relative images/css/scripts resolve
  • asset protocol enabled (scope: ["**"], same surface as the existing fs:allow-read-file ** permission) + protocol-asset cargo feature
  • white canvas background (pages assume white, independent of app theme)
  • "open as text" button stays available for viewing source

security notes

  • iframe is sandboxed: opaque origin, no top navigation, no popups
  • asset protocol scope matches what the fs plugin can already read, so no new privilege

verification

  • bun test — 73 pass (incl. new htmlDocWithBase cases)
  • tsc --noEmit clean
  • cargo check clean

.html/.htm files previously previewed as raw source. Classify them as a
new "html" preview kind and render in a sandboxed iframe (allow-scripts)
with a <base> pointing at the file's directory, so relative images/css/
scripts resolve through the asset protocol (enabled with scope **,
matching the existing fs read scope). "open as text" stays available
for viewing the source.
@mattenarle10
mattenarle10 merged commit d3ff20e into mattenarle10:main Aug 8, 2026
2 checks passed
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.

2 participants