Files
lemonspace_app/components/canvas/canvas-node-template-picker.tsx
Matthias f3c5c2d8f1 Enhance canvas functionality with new node types and validation
- Added support for new canvas node types: curves, color-adjust, light-adjust, detail-adjust, and render.
- Implemented validation for adjustment nodes to restrict incoming edges to one.
- Updated canvas connection validation to improve user feedback on invalid connections.
- Enhanced node creation and rendering logic to accommodate new node types and their properties.
- Refactored related components and utilities for better maintainability and performance.
2026-04-02 11:39:05 +02:00

92 lines
2.3 KiB
TypeScript

"use client";
import {
FolderOpen,
Frame,
Focus,
GitCompare,
ImageDown,
Image,
Package,
Palette,
Sparkles,
StickyNote,
Sun,
Type,
Video,
type LucideIcon,
} from "lucide-react";
import { CommandGroup, CommandItem } from "@/components/ui/command";
import {
CANVAS_NODE_TEMPLATES,
type CanvasNodeTemplate,
} from "@/lib/canvas-node-templates";
const NODE_ICONS: Record<CanvasNodeTemplate["type"], LucideIcon> = {
image: Image,
text: Type,
prompt: Sparkles,
note: StickyNote,
frame: Frame,
compare: GitCompare,
group: FolderOpen,
asset: Package,
video: Video,
curves: Sparkles,
"color-adjust": Palette,
"light-adjust": Sun,
"detail-adjust": Focus,
render: ImageDown,
};
const NODE_SEARCH_KEYWORDS: Partial<
Record<CanvasNodeTemplate["type"], string[]>
> = {
image: ["image", "photo", "foto"],
text: ["text", "typo"],
prompt: ["prompt", "ai", "generate", "ki-bild", "ki", "bild"],
note: ["note", "sticky", "notiz"],
frame: ["frame", "artboard"],
compare: ["compare", "before", "after", "vergleich"],
group: ["group", "gruppe", "folder"],
asset: ["asset", "freepik", "stock"],
video: ["video", "pexels", "clip"],
curves: ["curves", "tone", "contrast"],
"color-adjust": ["color", "hue", "saturation"],
"light-adjust": ["light", "exposure", "brightness"],
"detail-adjust": ["detail", "sharp", "grain"],
render: ["render", "export", "download"],
};
export type CanvasNodeTemplatePickerProps = {
onPick: (template: CanvasNodeTemplate) => void;
groupHeading?: string;
};
/**
* Knoten-Template-Liste für cmdk. Eltern: `<Command><CommandInput/><CommandList><CommandEmpty/> <CanvasNodeTemplatePicker /> …`.
*/
export function CanvasNodeTemplatePicker({
onPick,
groupHeading = "Knoten",
}: CanvasNodeTemplatePickerProps) {
return (
<CommandGroup heading={groupHeading}>
{CANVAS_NODE_TEMPLATES.map((template) => {
const Icon = NODE_ICONS[template.type];
return (
<CommandItem
key={template.type}
keywords={NODE_SEARCH_KEYWORDS[template.type] ?? []}
onSelect={() => onPick(template)}
>
<Icon className="size-4" />
{template.label}
</CommandItem>
);
})}
</CommandGroup>
);
}