feat(editor): support preview mode in code block (#11805)

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit

- **New Features**
  - Introduced a preview mode for code blocks, allowing users to toggle between code and rendered previews (e.g., HTML output) directly within the editor.
  - Added a preview toggle button to the code block toolbar for supported languages.
  - Enabled dynamic rendering of code block previews using a shared WebContainer, allowing live HTML previews in an embedded iframe.
  - Added HTML preview support with loading and error states for enhanced user feedback.
  - Integrated the preview feature as a view extension provider for seamless framework support.

- **Bug Fixes**
  - Improved toolbar layout and button alignment for a cleaner user interface.

- **Tests**
  - Added end-to-end tests to verify the new code block preview functionality and language switching behavior.

- **Chores**
  - Updated development server configuration to include enhanced security headers.
  - Added a new runtime dependency for WebContainer support.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
Flrande
2025-05-06 09:14:12 +00:00
parent 1e89aa48cb
commit f79dfe837f
18 changed files with 520 additions and 7 deletions
+8
View File
@@ -431,6 +431,7 @@ __metadata:
"@types/lodash-es": "npm:^4.17.12"
"@vanilla-extract/css": "npm:^1.17.0"
"@vanilla-extract/dynamic": "npm:^2.1.2"
"@webcontainer/api": "npm:^1.6.1"
animejs: "npm:^4.0.0"
bytes: "npm:^3.1.2"
clsx: "npm:^2.1.1"
@@ -16444,6 +16445,13 @@ __metadata:
languageName: node
linkType: hard
"@webcontainer/api@npm:^1.6.1":
version: 1.6.1
resolution: "@webcontainer/api@npm:1.6.1"
checksum: 10/c5502da3a86425199f1171665f4c32bdb73cc5b8291abdee3a934023c2f276bb35382e0a36b067f9bd41d96a722419048ee89847852dcc3f60cba70bccf51ca6
languageName: node
linkType: hard
"@whatwg-node/disposablestack@npm:^0.0.6":
version: 0.0.6
resolution: "@whatwg-node/disposablestack@npm:0.0.6"