fix: handle playground mode as HTML mode in preview rendering

Playground mode was falling through to the CSS branch, wrapping user code
in a <style> tag. This prevented HTML elements and font styles from rendering
correctly. Now playground mode is treated like HTML mode, allowing templates
with <style> blocks and HTML content to work properly.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
This commit is contained in:
2026-01-15 12:26:44 +01:00
parent 50605e6939
commit a2f998195c

View File

@@ -206,8 +206,8 @@ export class LessonEngine {
const iframeDoc = iframe.contentDocument || iframe.contentWindow.document; const iframeDoc = iframe.contentDocument || iframe.contentWindow.document;
iframeDoc.open(); iframeDoc.open();
if (mode === "html") { if (mode === "html" || mode === "playground") {
// For HTML mode, user code IS the HTML content // For HTML/playground mode, user code IS the HTML content (may include <style> blocks)
const userHtml = this.userCode || ""; const userHtml = this.userCode || "";
iframeDoc.write(` iframeDoc.write(`
<!DOCTYPE html> <!DOCTYPE html>
@@ -301,8 +301,8 @@ export class LessonEngine {
const iframeDoc = iframe.contentDocument || iframe.contentWindow.document; const iframeDoc = iframe.contentDocument || iframe.contentWindow.document;
iframeDoc.open(); iframeDoc.open();
if (mode === "html") { if (mode === "html" || mode === "playground") {
// For HTML mode, solution code IS the HTML content // For HTML/playground mode, solution code IS the HTML content
iframeDoc.write(` iframeDoc.write(`
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>