Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 57 additions & 13 deletions web/app/(site)/webtools/html/page.tsx
Original file line number Diff line number Diff line change
@@ -1,41 +1,85 @@
"use client";

import { useState } from "react";
import { useEffect, useState } from "react";

// import Prism from "prismjs";
// import "prismjs/themes/prism-tomorrow.css";
// import "prismjs/components/prism-markup";
// import "prismjs/components/prism-css";
// import "prismjs/components/prism-javascript";

import Editor from "@monaco-editor/react";

export default function HtmlPreviewPage() {
const [html, setHtml] = useState(`<!DOCTYPE html>
<html>
<head>
<title>Preview</title>
</head>
<style>
* {
background-color: white; }
</style>
<body>
<h1>Hello World</h1>
<p>HTML hier einfügen...</p>
</body>
</html>`);

const [previewOnly, setPreviewOnly] = useState(false);

useEffect(() => {
const handleKeyDown = (e: KeyboardEvent) => {
if (e.key === "F9") {
e.preventDefault();
setPreviewOnly((v) => !v);
}
};

window.addEventListener("keydown", handleKeyDown);
return () => window.removeEventListener("keydown", handleKeyDown);
}, []);

if (previewOnly) {
return (
<iframe
title="HTML Preview"
srcDoc={html}
className="fixed inset-0 w-screen h-screen border-0 bg-white z-50"
sandbox="allow-scripts allow-forms allow-modals"
/>
);
}

return (
<div className="h-[calc(100vh-60px)] flex flex-col">
<div className="h-[calc(100vh-60px)] flex flex-col bg-zinc-950">
{/* Toolbar */}
<div className="flex items-center justify-between px-4 py-2 border-b border-zinc-800 bg-zinc-900">
<h1 className="text-sm font-semibold text-zinc-200">
HTML Live Preview
</h1>

<button
onClick={() => setPreviewOnly(true)}
className="px-3 py-1.5 rounded-md bg-zinc-800 hover:bg-zinc-700 text-zinc-200 text-sm transition"
>
Preview Fullscreen (F9)
</button>
</div>

{/* Editor */}
<div className="h-1/3 border-b">
<textarea
<div className="relative h-1/3 border-b border-zinc-800">
<Editor
height="100%"
defaultLanguage="html"
value={html}
onChange={(e) => setHtml(e.target.value)}
className="w-full h-full p-4 font-mono text-sm resize-none outline-none"
placeholder="HTML hier einfügen..."
onChange={(value) => setHtml(value || "")}
theme="vs-dark"
/>
</div>

{/* Preview */}
<div className="flex-1">
<div className="flex-1 bg-white">
<iframe
title="HTML Preview"
srcDoc={html}
className="w-full h-full border-0 text-white"
className="w-full h-full border-0"
sandbox="allow-scripts allow-forms allow-modals"
/>
</div>
Expand Down
18 changes: 18 additions & 0 deletions web/bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

90 changes: 90 additions & 0 deletions web/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@
"tauri": "NEXT_CONFIG_FILE=next.config.tauri.ts tauri"
},
"dependencies": {
"@monaco-editor/react": "^4.7.0",
"@tailwindcss/typography": "^0.5.19",
"geist": "^1.7.2",
"gray-matter": "^4.0.3",
"next": "16.2.4",
"next-mdx-remote": "^6.0.0",
"prismjs": "^1.30.0",
"react": "19.2.4",
"react-diff-viewer-continued": "^4.2.2",
"react-dom": "19.2.4",
Expand All @@ -29,6 +31,7 @@
"@tailwindcss/postcss": "^4",
"@tauri-apps/cli": "^2",
"@types/node": "^20",
"@types/prismjs": "^1.26.6",
"@types/react": "^19",
"@types/react-dom": "^19",
"eslint": "^9",
Expand Down
Loading