Files
clip2md/index.html
T
till f2793a34c3 ux: Redesign-Pass (impeccable)
- Editor als Hero mit Empty-State-Affordance (Paste-Glyph + Key-Hints)
- Dateiname mit auto/eigen-Indikator und Flash bei Auto-Update
- Live-Statusbadge 'HTML->Markdown konvertiert' mit Puls
- Verfeinerte OKLCH-Palette (getoente Neutrals, ein Accent), Type-Hierarchie
- Header-Wordmark + Keyboard-Legende
- Motion (ease-out-quint) mit prefers-reduced-motion, :focus-visible, aria-live Toast
- Responsive (Mobile-Layout), Danger-Flash bei leerem Speichern
- PRODUCT.md + DESIGN.md (HD Design-System dokumentiert)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-08-11 11:13:42 +00:00

665 lines
21 KiB
HTML

<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="color-scheme" content="dark" />
<meta name="description" content="clip2md — reinpasten, ein Klick, als Markdown speichern. Clientseitig, privat." />
<meta name="theme-color" content="#22262f" />
<title>clip2md — Paste to Markdown</title>
<style>
:root {
color-scheme: dark;
/* Neutrals tinted toward a cool 265 hue — never pure black/white. */
--bg: oklch(0.17 0.014 265);
--surface: oklch(0.215 0.016 265);
--raised: oklch(0.255 0.018 265);
--raised-hi: oklch(0.31 0.02 265);
--line: oklch(0.32 0.02 265);
--line-strong: oklch(0.42 0.024 265);
--text: oklch(0.95 0.006 265);
--muted: oklch(0.68 0.012 265);
--faint: oklch(0.52 0.012 265);
--accent: oklch(0.74 0.15 152);
--accent-dim: oklch(0.74 0.15 152 / 0.16);
--accent-ink: oklch(0.22 0.05 152);
--danger: oklch(0.66 0.16 25);
--r-sm: 8px;
--r: 11px;
--r-lg: 14px;
--ease: cubic-bezier(0.22, 1, 0.36, 1);
--font-ui: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
--font-mono: ui-monospace, "JetBrains Mono", "SF Mono", "Fira Code", Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
margin: 0;
background:
radial-gradient(120% 80% at 50% -20%, oklch(0.24 0.02 265) 0%, transparent 60%),
var(--bg);
color: var(--text);
font-family: var(--font-ui);
font-size: 14px;
-webkit-font-smoothing: antialiased;
display: flex;
flex-direction: column;
min-height: 100dvh;
}
:focus-visible {
outline: 2px solid var(--accent);
outline-offset: 2px;
border-radius: var(--r-sm);
}
/* ---------- Header ---------- */
header {
display: flex;
align-items: center;
gap: 12px;
padding: 16px 24px;
border-bottom: 1px solid var(--line);
}
.mark {
width: 26px; height: 26px;
border-radius: 7px;
display: grid; place-items: center;
background: var(--accent);
color: var(--accent-ink);
font-family: var(--font-mono);
font-weight: 700;
font-size: 14px;
letter-spacing: -0.03em;
flex: none;
}
.wordmark {
font-size: 18px;
font-weight: 640;
letter-spacing: -0.02em;
margin: 0;
}
.wordmark b { color: var(--accent); font-weight: 640; }
.tagline {
font-size: 12.5px;
color: var(--muted);
margin-left: 2px;
}
.tagline code {
font-family: var(--font-mono);
font-size: 11.5px;
color: var(--text);
background: var(--raised);
padding: 1px 5px;
border-radius: 5px;
}
header .spacer { flex: 1; }
.legend {
display: flex;
gap: 16px;
font-size: 12px;
color: var(--faint);
}
.legend span { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
kbd {
font-family: var(--font-mono);
font-size: 11px;
color: var(--muted);
background: var(--raised);
border: 1px solid var(--line);
border-bottom-width: 2px;
border-radius: 5px;
padding: 1px 5px;
min-width: 18px;
text-align: center;
}
/* ---------- Toolbar ---------- */
.bar {
display: flex;
align-items: center;
gap: 10px;
padding: 14px 24px;
}
.fname {
flex: 1;
min-width: 200px;
display: flex;
align-items: center;
gap: 10px;
background: var(--raised);
border: 1px solid var(--line);
border-radius: var(--r);
padding: 0 6px 0 14px;
transition: border-color .18s var(--ease), box-shadow .18s var(--ease);
}
.fname:focus-within {
border-color: var(--line-strong);
box-shadow: 0 0 0 3px var(--accent-dim);
}
.fname.flash { animation: flash .5s var(--ease); }
@keyframes flash {
0% { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }
100% { border-color: var(--line); box-shadow: 0 0 0 3px transparent; }
}
.fname .lbl {
font-size: 11px;
text-transform: uppercase;
letter-spacing: 0.06em;
color: var(--faint);
white-space: nowrap;
}
.fname input {
flex: 1;
min-width: 40px;
background: transparent;
border: none;
outline: none;
color: var(--text);
font-family: var(--font-mono);
font-size: 14px;
padding: 12px 0;
}
.fname .ext {
font-family: var(--font-mono);
font-size: 14px;
color: var(--muted);
}
.fname .tag {
font-size: 10.5px;
letter-spacing: 0.04em;
text-transform: uppercase;
color: var(--faint);
border: 1px solid var(--line);
border-radius: 999px;
padding: 3px 9px;
white-space: nowrap;
transition: color .18s, border-color .18s;
}
.fname .tag.auto { color: var(--accent); border-color: var(--accent-dim); }
button {
font-family: var(--font-ui);
font-size: 15px;
font-weight: 560;
border: 1px solid var(--line);
background: var(--raised);
color: var(--text);
border-radius: var(--r);
padding: 11px 18px;
cursor: pointer;
transition: background .16s var(--ease), border-color .16s, transform .05s;
white-space: nowrap;
}
button:hover { background: var(--raised-hi); border-color: var(--line-strong); }
button:active { transform: translateY(1px); }
button.primary {
background: var(--accent);
color: var(--accent-ink);
border-color: var(--accent);
font-weight: 660;
box-shadow: 0 1px 0 oklch(0.6 0.13 152) inset;
}
button.primary:hover { filter: brightness(1.05); background: var(--accent); border-color: var(--accent); }
button.icon {
padding: 11px 13px;
background: transparent;
color: var(--muted);
}
button.icon:hover { color: var(--text); background: var(--raised); }
/* ---------- Editor ---------- */
main {
flex: 1;
display: flex;
min-height: 0;
padding: 4px 24px 18px;
position: relative;
}
.editor-wrap {
flex: 1;
position: relative;
display: flex;
min-height: 0;
}
#editor {
flex: 1;
width: 100%;
resize: none;
background: var(--surface);
color: var(--text);
border: 1px solid var(--line);
border-radius: var(--r-lg);
padding: 22px 24px;
font-family: var(--font-mono);
font-size: 14px;
line-height: 1.65;
outline: none;
tab-size: 2;
transition: border-color .18s var(--ease), box-shadow .18s var(--ease);
}
#editor:focus { border-color: var(--line-strong); box-shadow: 0 0 0 3px var(--accent-dim); }
#editor::placeholder { color: transparent; } /* empty-state overlay handles this */
/* Empty state — invites the paste, disappears once there's content. */
.empty {
position: absolute;
inset: 0;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 18px;
text-align: center;
pointer-events: none;
padding: 24px;
opacity: 1;
transition: opacity .24s var(--ease);
}
main.has-content .empty { opacity: 0; }
.empty .glyph {
width: 60px; height: 60px;
border-radius: 16px;
display: grid; place-items: center;
background: var(--raised);
border: 1px solid var(--line);
color: var(--accent);
}
.empty .glyph svg { width: 28px; height: 28px; }
.empty h2 {
margin: 0;
font-size: 17px;
font-weight: 600;
letter-spacing: -0.01em;
color: var(--text);
}
.empty p {
margin: 0;
max-width: 46ch;
font-size: 13.5px;
line-height: 1.6;
color: var(--muted);
}
.empty .keys {
display: flex;
gap: 10px;
align-items: center;
color: var(--faint);
font-size: 12.5px;
}
/* ---------- Status bar ---------- */
footer {
display: flex;
align-items: center;
gap: 16px;
padding: 11px 24px 16px;
font-size: 12.5px;
color: var(--faint);
flex-wrap: wrap;
}
footer .count { font-family: var(--font-mono); color: var(--muted); }
footer .spacer { flex: 1; }
.badge {
display: inline-flex;
align-items: center;
gap: 7px;
font-size: 12px;
color: var(--muted);
opacity: 0;
transform: translateY(2px);
transition: opacity .2s var(--ease), transform .2s var(--ease);
}
.badge.show { opacity: 1; transform: none; }
.badge .led {
width: 7px; height: 7px; border-radius: 50%;
background: var(--faint);
}
.badge.ok .led { background: var(--accent); }
.badge.pulse .led { animation: pulse .6s var(--ease); }
@keyframes pulse {
0% { box-shadow: 0 0 0 0 var(--accent-dim); }
100% { box-shadow: 0 0 0 9px transparent; }
}
/* ---------- Toast ---------- */
.toast {
position: fixed;
left: 50%;
bottom: 28px;
transform: translateX(-50%) translateY(16px);
background: var(--raised-hi);
border: 1px solid var(--line-strong);
color: var(--text);
padding: 11px 18px;
border-radius: 10px;
font-size: 13.5px;
opacity: 0;
pointer-events: none;
transition: opacity .2s var(--ease), transform .24s var(--ease);
box-shadow: 0 12px 40px oklch(0 0 0 / 0.5);
z-index: 50;
max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { border-color: var(--danger); }
/* ---------- Responsive ---------- */
@media (max-width: 760px) {
header { padding: 14px 16px; }
.legend { display: none; }
.tagline { display: none; }
.bar { padding: 12px 16px; gap: 8px; flex-wrap: wrap; }
.fname { order: -1; flex-basis: 100%; }
main { padding: 2px 16px 14px; }
footer { padding: 10px 16px 14px; gap: 12px; }
}
@media (prefers-reduced-motion: reduce) {
*, *::before, *::after { transition: none !important; animation: none !important; }
}
</style>
</head>
<body>
<header>
<div class="mark">m↓</div>
<h1 class="wordmark">clip<b>2</b>md</h1>
<span class="tagline">reinpasten → <code>.md</code></span>
<span class="spacer"></span>
<nav class="legend" aria-hidden="true">
<span><kbd></kbd><kbd>V</kbd> einfügen</span>
<span><kbd></kbd><kbd>S</kbd> speichern</span>
<span><kbd></kbd><kbd></kbd><kbd>V</kbd> roh</span>
</nav>
</header>
<div class="bar">
<label class="fname" id="fnameBox">
<span class="lbl">Datei</span>
<input id="filename" type="text" spellcheck="false" autocomplete="off" aria-label="Dateiname" />
<span class="ext">.md</span>
<span class="tag auto" id="fnameTag">auto</span>
</label>
<button id="save" class="primary">Speichern</button>
<button id="copy" class="icon" title="Markdown kopieren" aria-label="Markdown kopieren">Kopieren</button>
<button id="clear" class="icon" title="Editor leeren" aria-label="Editor leeren">Leeren</button>
</div>
<main id="main">
<div class="editor-wrap">
<textarea id="editor" spellcheck="false" autocapitalize="off" autocorrect="off"
aria-label="Markdown-Editor"></textarea>
<div class="empty" id="empty" aria-hidden="true">
<div class="glyph">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round">
<rect x="8" y="3" width="8" height="4" rx="1.4"/>
<path d="M16 5h2a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V7a2 2 0 0 1 2-2h2"/>
<path d="M9 13h6M9 16.5h4"/>
</svg>
</div>
<h2>Reinpasten</h2>
<p>Langen Reddit-Thread, eine Website oder formatierten Text hier einfügen.
Formatiertes HTML wird automatisch zu sauberem Markdown, reiner Text bleibt roh.</p>
<div class="keys"><kbd></kbd><kbd>V</kbd><span>einfügen</span> · <kbd></kbd><kbd>S</kbd><span>speichern</span></div>
</div>
</div>
</main>
<footer>
<span class="count"><span id="words">0</span> Wörter · <span id="chars">0</span> Zeichen</span>
<span class="badge" id="srcBadge"><span class="led"></span><span id="srcText"></span></span>
<span class="spacer"></span>
<span>clientseitig · nichts wird gesendet</span>
</footer>
<div id="toast" class="toast" role="status" aria-live="polite"></div>
<script src="vendor/turndown.js"></script>
<script src="vendor/turndown-plugin-gfm.js"></script>
<script>
(function () {
"use strict";
// ---- Turndown setup -------------------------------------------------
var turndown = new TurndownService({
headingStyle: "atx",
hr: "---",
bulletListMarker: "-",
codeBlockStyle: "fenced",
emDelimiter: "*",
strongDelimiter: "**",
linkStyle: "inlined"
});
try {
if (window.turndownPluginGfm && window.turndownPluginGfm.gfm) {
turndown.use(window.turndownPluginGfm.gfm);
}
} catch (e) { /* gfm optional */ }
turndown.remove(["script", "style", "noscript", "iframe", "svg"]);
var editor = document.getElementById("editor");
var main = document.getElementById("main");
var filename = document.getElementById("filename");
var fnameBox = document.getElementById("fnameBox");
var fnameTag = document.getElementById("fnameTag");
var wordsEl = document.getElementById("words");
var charsEl = document.getElementById("chars");
var srcBadge = document.getElementById("srcBadge");
var srcText = document.getElementById("srcText");
var toastEl = document.getElementById("toast");
var filenameEdited = false;
var toastTimer = null;
// ---- Helpers --------------------------------------------------------
function toast(msg, isErr) {
toastEl.textContent = msg;
toastEl.classList.toggle("err", !!isErr);
toastEl.classList.add("show");
clearTimeout(toastTimer);
toastTimer = setTimeout(function () { toastEl.classList.remove("show"); }, 2200);
}
function pad(n) { return n < 10 ? "0" + n : "" + n; }
function today() {
var d = new Date();
return d.getFullYear() + "-" + pad(d.getMonth() + 1) + "-" + pad(d.getDate());
}
var UMLAUT = { "ä":"ae","ö":"oe","ü":"ue","ß":"ss","Ä":"ae","Ö":"oe","Ü":"ue" };
function slugify(s) {
if (!s) return "";
s = s.replace(/[äöüßÄÖÜ]/g, function (c) { return UMLAUT[c] || c; });
s = s.normalize("NFKD").replace(/[̀-ͯ]/g, "");
s = s.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
return s.slice(0, 60).replace(/-+$/g, "");
}
function deriveTitle(md) {
var lines = md.split(/\r?\n/);
for (var i = 0; i < lines.length; i++) {
var m = lines[i].match(/^\s{0,3}#{1,6}\s+(.+?)\s*#*\s*$/);
if (m && m[1].trim()) return m[1].trim();
}
for (var j = 0; j < lines.length; j++) {
var t = lines[j].trim();
if (!t) continue;
if (/^([-*_=#>`|]{1,}|\[.*\])$/.test(t)) continue;
return t.replace(/^[#>*\-\s]+/, "").trim();
}
return "";
}
function computeFilename(md) {
var slug = slugify(deriveTitle(md));
return today() + (slug ? "-" + slug : "-clip");
}
function refreshFilename(flash) {
if (filenameEdited) return;
var next = computeFilename(editor.value);
if (next !== filename.value) {
filename.value = next;
if (flash) {
fnameBox.classList.remove("flash");
void fnameBox.offsetWidth; // reflow to restart animation
fnameBox.classList.add("flash");
}
}
}
function setFnameTag() {
if (filenameEdited) { fnameTag.textContent = "eigen"; fnameTag.classList.remove("auto"); }
else { fnameTag.textContent = "auto"; fnameTag.classList.add("auto"); }
}
function updateCounts() {
var v = editor.value;
charsEl.textContent = v.length.toLocaleString("de-DE");
var w = v.trim() ? v.trim().split(/\s+/).length : 0;
wordsEl.textContent = w.toLocaleString("de-DE");
}
function updateEmpty() {
main.classList.toggle("has-content", editor.value.length > 0);
}
function showSource(text, ok, pulse) {
srcText.textContent = text;
srcBadge.classList.toggle("ok", !!ok);
srcBadge.classList.add("show");
if (pulse) {
srcBadge.classList.remove("pulse");
void srcBadge.offsetWidth;
srcBadge.classList.add("pulse");
}
}
function hideSource() { srcBadge.classList.remove("show", "ok", "pulse"); }
function refreshAll(flash) { updateCounts(); refreshFilename(flash); updateEmpty(); }
// ---- Smart paste ----------------------------------------------------
var forceRaw = false;
editor.addEventListener("paste", function (e) {
var cd = e.clipboardData || window.clipboardData;
if (!cd) return;
var html = cd.getData("text/html");
var text = cd.getData("text/plain");
var out, badge, ok;
if (!forceRaw && html && html.trim()) {
try {
out = turndown.turndown(html).replace(/\n{3,}/g, "\n\n").trim();
badge = "HTML → Markdown konvertiert"; ok = true;
} catch (err) {
out = text; badge = "Roh eingefügt (Konvertierung fehlgeschlagen)"; ok = false;
}
} else {
out = text;
badge = forceRaw ? "Roh eingefügt (erzwungen)" : "Roh eingefügt";
ok = false;
}
forceRaw = false;
if (out == null) return;
e.preventDefault();
insertAtCursor(out);
showSource(badge, ok, true);
refreshAll(true);
});
function insertAtCursor(str) {
var start = editor.selectionStart, end = editor.selectionEnd;
editor.value = editor.value.slice(0, start) + str + editor.value.slice(end);
var pos = start + str.length;
editor.selectionStart = editor.selectionEnd = pos;
}
editor.addEventListener("input", function () {
hideSource();
refreshAll(false);
});
// ---- Filename field -------------------------------------------------
filename.addEventListener("input", function () {
filenameEdited = filename.value.trim().length > 0;
setFnameTag();
});
// Empty field → hand control back to auto.
filename.addEventListener("blur", function () {
if (!filename.value.trim()) { filenameEdited = false; setFnameTag(); refreshFilename(false); }
});
// ---- Save -----------------------------------------------------------
function save() {
var content = editor.value;
if (!content.trim()) { toast("Nichts zu speichern.", true); flashEditor(); return; }
var name = (filename.value.trim() || computeFilename(content));
name = name.replace(/[\/\\:*?"<>|]+/g, "-").replace(/\s+/g, "-");
if (!/\.md$/i.test(name)) name += ".md";
var blob = new Blob([content], { type: "text/markdown;charset=utf-8" });
var url = URL.createObjectURL(blob);
var a = document.createElement("a");
a.href = url; a.download = name;
document.body.appendChild(a); a.click(); document.body.removeChild(a);
setTimeout(function () { URL.revokeObjectURL(url); }, 1000);
toast("Gespeichert · " + name);
}
function flashEditor() {
editor.style.borderColor = "var(--danger)";
setTimeout(function () { editor.style.borderColor = ""; }, 500);
}
document.getElementById("save").addEventListener("click", save);
// ---- Copy -----------------------------------------------------------
document.getElementById("copy").addEventListener("click", function () {
var v = editor.value;
if (!v.trim()) { toast("Nichts zu kopieren.", true); return; }
if (navigator.clipboard && navigator.clipboard.writeText) {
navigator.clipboard.writeText(v).then(
function () { toast("Markdown kopiert."); },
function () { legacyCopy(v); }
);
} else { legacyCopy(v); }
});
function legacyCopy(v) {
editor.focus(); editor.select();
try { document.execCommand("copy"); toast("Markdown kopiert."); }
catch (e) { toast("Kopieren nicht möglich.", true); }
editor.selectionStart = editor.selectionEnd = editor.value.length;
}
// ---- Clear ----------------------------------------------------------
document.getElementById("clear").addEventListener("click", function () {
if (editor.value && !confirm("Editor wirklich leeren?")) return;
editor.value = "";
filenameEdited = false;
hideSource(); setFnameTag(); refreshAll(false);
editor.focus();
});
// ---- Keyboard -------------------------------------------------------
document.addEventListener("keydown", function (e) {
var mod = e.metaKey || e.ctrlKey;
if (mod && !e.shiftKey && !e.altKey && (e.key === "s" || e.key === "S")) {
e.preventDefault(); save(); return;
}
if (mod && e.shiftKey && (e.key === "v" || e.key === "V")) {
forceRaw = true;
}
});
// ---- Init -----------------------------------------------------------
setFnameTag();
refreshAll(false);
editor.focus();
})();
</script>
</body>
</html>