feat(markdown-editor): Markdown-Editor mit Live-Preview für notes [tsc:fail]

This commit is contained in:
Dennis (via Claude+Gemma) 2026-05-23 06:50:18 +02:00
parent 09c7c6a6de
commit b1e58fd030
5 changed files with 274 additions and 1 deletions

View File

@ -6,6 +6,7 @@
"undo-toast", "undo-toast",
"breadcrumb-navigation", "breadcrumb-navigation",
"in-app-changelog", "in-app-changelog",
"aria-improvements" "aria-improvements",
"kpi-comparison"
] ]
} }

5
.phase14-state.json Normal file
View File

@ -0,0 +1,5 @@
{
"completed_features": [],
"current_feature": "markdown-editor",
"started_at": "2026-05-23T06:49:38.915806"
}

View File

@ -1652,3 +1652,27 @@ src/index.ts(27,25): error TS2769: No overload matches this call.
Overload 2 of 3, '(plugin: FastifyPluginAsync<{ limits: { fileSize: number; }; }, RawServerDefault, FastifyTypeProvider, FastifyBaseLogger>, opts?: FastifyRegisterOptions<...> | undefined): FastifyInstance<...> & PromiseLike<...>', gave the following error. Overload 2 of 3, '(plugin: FastifyPluginAsync<{ limits: { fileSize: number; }; }, RawServerDefault, FastifyTypeProvider, FastifyBaseLogger>, opts?: FastifyRegisterOptions<...> | undefined): FastifyInstance<...> & PromiseLike<...>', gave the following error.
Argument of type 'Promise<FastifyMultipartPlugin>' is not assignable to parameter of type 'FastifyPluginAsync<{ limits: { fileSize: number; }; }, RawServerDefault, FastifyTypeProvider, FastifyBaseLogger>'. Argument of type 'Promise<FastifyMultipartPlugin>' is not assignable to parameter of type 'FastifyPluginAsync<{ limits: { fileSize: number; }; }, RawServerDefault, FastifyTypeProvider, FastifyBaseLogger>'.
Type 'Promise<FastifyMultipartPlugin>' provides no match for the signature '(instance: FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, FastifyTy Type 'Promise<FastifyMultipartPlugin>' provides no match for the signature '(instance: FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, FastifyTy
- `06:47:56` **INFO** Committed feature kpi-comparison
- `06:47:57` **INFO** Pushed: rc=0
## Phase-13 Run beendet (2026-05-23 06:47:57)
- `06:47:57` **INFO** OK: 0, Attempted: 5, Total: 5
## 🚀 Phase-14 Codegen-Run gestartet (2026-05-23 06:49:38)
## Phase-3 Feature: markdown-editor (2026-05-23 06:49:38)
- `06:49:38` **INFO** Description: Markdown-Editor mit Live-Preview für notes
- `06:49:38` **INFO** Generating apps/web/src/components/MarkdownEditor.tsx (MarkdownEditor-Component. Props: value, onChange, placeholder. Split-V…)
- `06:50:16` **INFO** wrote 4122 chars in 37.6s (attempt 1)
- `06:50:16` **INFO** Running tsc --noEmit on api…
- `06:50:18` **WARN** tsc errors:
src/index.ts(27,25): error TS2769: No overload matches this call.
Overload 1 of 3, '(plugin: FastifyPluginCallback<{ limits: { fileSize: number; }; }, RawServerDefault, FastifyTypeProvider, FastifyBaseLogger>, opts?: FastifyRegisterOptions<...> | undefined): FastifyInstance<...> & PromiseLike<...>', gave the following error.
Argument of type 'Promise<FastifyMultipartPlugin>' is not assignable to parameter of type 'FastifyPluginCallback<{ limits: { fileSize: number; }; }, RawServerDefault, FastifyTypeProvider, FastifyBaseLogger>'.
Type 'Promise<FastifyMultipartPlugin>' provides no match for the signature '(instance: FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, FastifyTypeProvider>, opts: { ...; }, done: (err?: Error | undefined) => void): void'.
Overload 2 of 3, '(plugin: FastifyPluginAsync<{ limits: { fileSize: number; }; }, RawServerDefault, FastifyTypeProvider, FastifyBaseLogger>, opts?: FastifyRegisterOptions<...> | undefined): FastifyInstance<...> & PromiseLike<...>', gave the following error.
Argument of type 'Promise<FastifyMultipartPlugin>' is not assignable to parameter of type 'FastifyPluginAsync<{ limits: { fileSize: number; }; }, RawServerDefault, FastifyTypeProvider, FastifyBaseLogger>'.
Type 'Promise<FastifyMultipartPlugin>' provides no match for the signature '(instance: FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, FastifyTy

View File

@ -0,0 +1,101 @@
import React, { useState } from 'react';
import { LayoutPanelLeft, LayoutPanelRight, LayoutTemplate } from 'lucide-react';
interface MarkdownEditorProps {
value: string;
onChange: (val: string) => void;
placeholder?: string;
}
type ViewMode = 'edit' | 'preview' | 'split';
export default function MarkdownEditor({ value, onChange, placeholder }: MarkdownEditorProps) {
const [mode, setMode] = useState<ViewMode>('split');
const parseMarkdown = (text: string) => {
if (!text) return <p className="text-muted-foreground italic">No content...</p>;
return text.split('\n\n').map((paragraph, idx) => {
let content = paragraph;
// Headers
if (content.startsWith('## ')) {
return <h2 key={idx} className="text-xl font-bold mt-4 mb-2">{content.replace('## ', '')}</h2>;
}
if (content.startsWith('# ')) {
return <h1 key={idx} className="text-2xl font-bold mt-6 mb-3">{content.replace('# ', '')}</h1>;
}
// Lists
if (content.startsWith('- ')) {
const items = paragraph.split('\n').filter(line => line.startsWith('- '));
return (
<ul key={idx} className="list-disc pl-5 mb-4 space-y-1">
{items.map((item, i) => (
<li key={i} dangerouslySetInnerHTML={{ __html: applyInlineFormatting(item.replace('- ', '')) }} />
))}
</ul>
);
}
return <p key={idx} className="mb-4" dangerouslySetInnerHTML={{ __html: applyInlineFormatting(content) }} />;
});
};
const applyInlineFormatting = (text: string) => {
return text
.replace(/&/g, '&amp;')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/\*\*(.*?)\*\*/g, '<strong>$1</strong>')
.replace(/\*(.*?)\*/g, '<em>$1</em>')
.replace(/`(.*?)`/g, '<code class="bg-slate-100 dark:bg-slate-800 px-1 rounded font-mono text-sm">$1</code>');
};
return (
<div className="flex flex-col h-full border rounded-lg overflow-hidden bg-white dark:bg-slate-900 border-slate-200 dark:border-slate-800">
<div className="flex items-center justify-between px-3 py-2 border-b bg-slate-50 dark:bg-slate-950 border-slate-200 dark:border-slate-800">
<span className="text-xs font-medium text-slate-500 uppercase tracking-wider">Markdown Editor</span>
<div className="flex gap-1">
<button
onClick={() => setMode('edit')}
className={`p-1.5 rounded ${mode === 'edit' ? 'bg-slate-200 dark:bg-slate-800 text-slate-900 dark:text-slate-100' : 'text-slate-500 hover:bg-slate-100 dark:hover:bg-slate-800'}`}
title="Edit Mode"
>
<LayoutPanelLeft size={16} />
</button>
<button
onClick={() => setMode('split')}
className={`p-1.5 rounded ${mode === 'split' ? 'bg-slate-200 dark:bg-slate-800 text-slate-900 dark:text-slate-100' : 'text-slate-500 hover:bg-slate-100 dark:hover:bg-slate-800'}`}
title="Split Mode"
>
<LayoutTemplate size={16} />
</button>
<button
onClick={() => setMode('preview')}
className={`p-1.5 rounded ${mode === 'preview' ? 'bg-slate-200 dark:bg-slate-800 text-slate-900 dark:text-slate-100' : 'text-slate-500 hover:bg-slate-100 dark:hover:bg-slate-800'}`}
title="Preview Mode"
>
<LayoutPanelRight size={16} />
</button>
</div>
</div>
<div className="flex flex-1 overflow-hidden">
{(mode === 'edit' || mode === 'split') && (
<textarea
className="flex-1 p-4 resize-none outline-none font-mono text-sm bg-transparent border-r border-slate-200 dark:border-slate-800"
value={value}
onChange={(e) => onChange(e.target.value)}
placeholder={placeholder}
/>
)}
{(mode === 'preview' || mode === 'split') && (
<div className="flex-1 p-4 overflow-y-auto prose prose-sm max-w-none dark:prose-invert">
{parseMarkdown(value)}
</div>
)}
</div>
</div>
);
}

142
scripts/phase14_features.py Normal file
View File

@ -0,0 +1,142 @@
#!/usr/bin/env python3
"""Phase-14: markdown-editor, file-attach-to-entry, quick-add-popover, time-spent-widget, dashboard-customization."""
from __future__ import annotations
import asyncio
import datetime
import json
import sys
from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parent))
from phase2_features import Feature, FileGen, ROOT, log, log_section # noqa: E402
from phase3_features import run_feature_v2 # noqa: E402
PHASE14_STATE = ROOT / ".phase14-state.json"
FEATURES: list[Feature] = [
Feature(
name="markdown-editor",
description="Markdown-Editor mit Live-Preview für notes",
files=[
FileGen(
path="apps/web/src/components/MarkdownEditor.tsx",
purpose=(
"MarkdownEditor-Component. Props: value, onChange, placeholder. "
"Split-View: links Textarea (Markdown), rechts gerenderte Preview. "
"Toggle-Button für edit/preview/split-Mode. "
"Inline-Markdown-Parser: **bold**→<strong>, *italic*→<em>, `code`→<code>, ## headers, - lists, \\n\\n→<p>."
),
),
],
),
Feature(
name="quick-add-popover",
description="Quick-Add Popover (TimeEntry) im Nav-Bar via 'N'-Taste",
files=[
FileGen(
path="apps/web/src/components/QuickAdd.tsx",
purpose=(
"QuickAdd-Component. Trigger: 'N'-Hotkey (window-keydown, nicht in input/textarea). "
"Mini-Form: description (autofocus) + duration (z.B. '1h 30m'). "
"Submit → createTimeEntry(now-duration, now) → toast + close. Escape closes."
),
refs=["apps/web/src/lib/api.ts"],
),
FileGen(
path="apps/web/src/App.tsx",
purpose="ERWEITERT — mount <QuickAdd /> global im Root-Layout. Behalte alles.",
refs=["apps/web/src/App.tsx"],
),
],
),
Feature(
name="time-spent-widget",
description="Time-Spent-Summary-Widget (Today/Week/Month total) sidebar",
files=[
FileGen(
path="apps/web/src/components/TimeSpentSummary.tsx",
purpose=(
"TimeSpentSummary-Widget. Fetch entries + summarize per period (heute/woche/monat). "
"Drei kompakte Reihen mit progress-bar (relative zu daily-target z.B. 8h). "
"Tailwind w-64 sidebar-card."
),
),
],
),
Feature(
name="dashboard-customization",
description="Dashboard-Widget-Order via drag (oder simpler: visibility-toggles in Settings)",
files=[
FileGen(
path="apps/web/src/pages/Dashboard.tsx",
purpose=(
"ERWEITERT — behalte alles. Füge oben rechts ein 'Anpassen'-Button: öffnet Modal mit "
"Checkboxes für jedes Widget (Today-Stats, Week-Stats, Active-Projects, Chart, ActivityFeed). "
"Persist in localStorage 'dashboard_widgets'. Hidden widgets nicht gerendert."
),
refs=["apps/web/src/pages/Dashboard.tsx"],
),
],
),
Feature(
name="file-attach-to-entry",
description="TimeEntries kann Anhänge haben (Multi-Documents-Link)",
files=[
FileGen(
path="apps/api/src/db/schema.ts",
purpose=(
"ERWEITERT — füge `timeEntryAttachments` pgTable: id (uuid pk), entryId (uuid references timeEntries), "
"documentId (uuid references documents). M2M join-table. Behalte alle anderen Tabellen."
),
refs=["apps/api/src/db/schema.ts"],
),
FileGen(
path="apps/api/src/routes/time-entries.ts",
purpose=(
"ERWEITERT — behalte alles. Füge POST /:id/attachments (body: {documentIds: string[]}), "
"DELETE /:id/attachments/:docId. Auth required."
),
refs=["apps/api/src/routes/time-entries.ts"],
),
],
),
]
def load_state() -> dict:
if PHASE14_STATE.exists():
return json.loads(PHASE14_STATE.read_text())
return {"completed_features": [], "current_feature": None, "started_at": datetime.datetime.now().isoformat()}
def save_state(state: dict) -> None:
PHASE14_STATE.write_text(json.dumps(state, indent=2))
async def main() -> int:
log_section("🚀 Phase-14 Codegen-Run gestartet")
state = load_state()
for feature in FEATURES:
if feature.name in state.get("completed_features", []):
continue
state["current_feature"] = feature.name; save_state(state)
try:
success = await run_feature_v2(feature)
if success:
state.setdefault("completed_features", []).append(feature.name)
else:
state.setdefault("attempted_features", []).append(feature.name)
save_state(state)
except Exception as e:
log(f"{feature.name} crashed: {e}", level="ERROR")
state.setdefault("attempted_features", []).append(feature.name); save_state(state)
log_section("Phase-14 Run beendet")
log(f"OK: {len(state.get('completed_features', []))}, Attempted: {len(state.get('attempted_features', []))}, Total: {len(FEATURES)}")
return 0
if __name__ == "__main__":
sys.exit(asyncio.run(main()))