Files
DOSSIER/src/ui/RoomStampEditorHost.tsx
T
Claude 0165f31b55 [121] Inline-Editoren und Stempel-Editor aus App.tsx, TODO nachgeführt
menus/InlineEditors (Ebene/Zeichnungsebene) und ui/RoomStampEditorHost lesen das Projekt
selbst aus dem Store. App.tsx 4003 → 3232 Zeilen. npm run check --fast grün, e2e 68/68.
2026-11-03 21:19:05 +00:00

58 lines
1.9 KiB
TypeScript

// Stempel-Editor eines Raums als schwebendes Fenster ([121] aus App.tsx herausgelöst): Doppelklick
// auf einen Raumstempel bzw. Button in der Objekt-Info öffnet ihn. Strukturierter Stempel für neue
// Räume, freier Rich-Text nur noch als Fallback für Alt-Räume. Liest die Räume selbst aus dem Store.
//
// Bezeichner englisch, Kommentare deutsch (CONVENTIONS.md).
import { defaultRoomStamp } from "../model/roomStamp";
import type { Room } from "../model/types";
import { RoomStampEditor } from "../panels/RoomStampEditor";
import { useStore } from "../state/appStore";
import { docFromText, type RichTextDoc } from "../text/richText";
import { TextEditorDialog } from "./TextEditorDialog";
const NO_ROOMS: Room[] = [];
export function RoomStampEditorHost({
roomId,
onClose,
setRoomStamp,
setRoomStampDoc,
}: {
roomId: string;
onClose: () => void;
setRoomStamp: (id: string, stamp: NonNullable<Room["stamp"]>) => void;
setRoomStampDoc: (id: string, doc: RichTextDoc) => void;
}) {
const rooms = useStore((s) => s.project.rooms) ?? NO_ROOMS;
const room = rooms.find((r) => r.id === roomId);
if (!room) return null;
// Strukturierter Stempel für neue Räume (kein Alt-Rich-Text) bzw. sobald
// einer gesetzt ist; freier Text nur noch als Fallback für Alt-Räume,
// die einen stampDoc, aber keinen strukturierten Stempel tragen.
const useStructured = Boolean(room.stamp) || !room.stampDoc;
if (useStructured) {
return (
<RoomStampEditor
value={room.stamp ?? defaultRoomStamp(room)}
onApply={(edited) => {
setRoomStamp(room.id, edited);
onClose();
}}
onCancel={() => onClose()}
/>
);
}
const doc = room.stampDoc ?? docFromText(room.name);
return (
<TextEditorDialog
value={doc}
onApply={(edited) => {
setRoomStampDoc(room.id, edited);
onClose();
}}
onCancel={() => onClose()}
/>
);
}