Skip to content

Conversation

@zeelsheladiya
Copy link
Contributor

Pull Request

This PR adds a highly requested feature: Live HTML/CSS Preview directly within the editor. It addresses issue #156 by allowing developers to view rendered HTML files in real-time as they edit, without needing to save the file or open an external browser. Crucially, it solves the problem of relative file paths (like <link href="style.css">) in unsaved buffers by leveraging Tauri's asset protocol.

Description

  • New HtmlPreview Component: Implemented a dedicated preview component using an iframe with srcDoc for instant rendering of editor content.
  • Asset Protocol Integration: Developed a mechanism to dynamically inject a <base href="..."> tag into the preview's HTML. This points to the file's actual directory on disk using the secure asset:// protocol, ensuring that relative resources (CSS, JS, Images) load correctly.
  • Store Updates: Updated buffer-store.ts to include an isHtmlPreview state, allowing the editor to manage HTML preview tabs alongside Markdown and code buffers.
  • Toolbar Integration: Added a "Preview" (Eye icon) toggle button to the breadcrumb bar that automatically appears when editing .html or .htm files.
  • Live Reloading: The preview updates automatically on every keystroke, providing an immediate feedback loop for frontend development.

Screenshots/Videos

demo.mp4

Related Issues

Closes #156

@mehmetozguldev mehmetozguldev self-requested a review December 29, 2025 15:03
Copy link
Member

@mehmetozguldev mehmetozguldev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mehmetozguldev mehmetozguldev merged commit 9386feb into athasdev:master Dec 29, 2025
2 checks passed
@zeelsheladiya zeelsheladiya deleted the feat/html-preview branch December 29, 2025 15:16
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.

"Open HTML Preview" to the side

2 participants