[122] Kern: verstecktes zweites Dokument abgeschafft (Fang mit Ausschluss, withDocument für abgewandelte Projekte)

documentFor findet nur offene Dokumente (Store, CLI, withDocument); kein sync/Differenz-Abgleich mehr.
Fang beim Ziehen: excludeIds -> doc_snap_hold(..., skip). Export/Publikation/Legende/Vorschau/Standards/
Stifte/Schnitt auf älterem Stand: kurzlebiges Dokument. Fremdes Projekt neben dem Store wirft in Dev/Tests.
This commit is contained in:
Claude committed 2026-11-03 19:36:01 +00:00
1 parent bc02b30a55
commit 3433d49c24
20 files changed
+277 -135

No files matched your search

+13 -3
View File
@@ -11,6 +11,7 @@
import { applyOps } from "../core/ops";
import type { CoreOp } from "../core/ops";
import type { ProjectMutation } from "../core";
import { withDocument } from "../core";
import type { LoadFileResult, ProjectDocument } from "../core/document";
import {
addItems,
@@ -1002,7 +1003,7 @@ export function createProjectSlice(
setActivePenSet: (id) =>
applyChange((p) => {
const stateOps = [setField("activePenSetId", id)];
return [...stateOps, ...rebakePenOps(applyOps(p, stateOps))];
return [...stateOps, ...rebakeAfter(p, stateOps)];
}),
patchPenSetColor: (setId, penId, color) =>
@@ -1014,7 +1015,7 @@ export function createProjectSlice(
[penId]: { ...(s.pens[penId] ?? { color: PEN_FALLBACK_COLOR, weight: PEN_FALLBACK_WEIGHT }), color },
},
}));
return setId === p.activePenSetId ? [...stateOps, ...rebakePenOps(applyOps(p, stateOps))] : stateOps;
return setId === p.activePenSetId ? [...stateOps, ...rebakeAfter(p, stateOps)] : stateOps;
}),
patchPenSetWeight: (setId, penId, weight) =>
@@ -1026,7 +1027,7 @@ export function createProjectSlice(
[penId]: { ...(s.pens[penId] ?? { color: PEN_FALLBACK_COLOR, weight: PEN_FALLBACK_WEIGHT }), weight },
},
}));
return setId === p.activePenSetId ? [...stateOps, ...rebakePenOps(applyOps(p, stateOps))] : stateOps;
return setId === p.activePenSetId ? [...stateOps, ...rebakeAfter(p, stateOps)] : stateOps;
}),
seedStandardPenSet: () => applyChange((p) => seedStandardPenSetOps(p)),
@@ -1260,6 +1261,15 @@ export function createProjectSlice(
}
/** Immutabler Map über einen Raum (per ID); No-op ohne Treffer. */
/**
* Ops, die die Stifte nach `stateOps` neu einbrennen: gerechnet auf dem Stand danach, in einem eigenen,
* kurzlebigen Dokument (der Stand ist noch nicht übernommen, [122]).
*/
function rebakeAfter(p: Project, stateOps: CoreOp[]): CoreOp[] {
const next = applyOps(p, stateOps);
return withDocument(next, () => rebakePenOps(next));
}
function mapRoom(
project: Project,
roomId: string,
+15 -8
View File
@@ -5,7 +5,7 @@
//
// Extrahiert aus App.tsx. Bezeichner englisch, Kommentare deutsch (CONVENTIONS.md).
import { generatePlan } from "../core";
import { generatePlan, withDocument } from "../core";
import type { CategoryDisplayResolver } from "../core";
import type { DetailLevel } from "../model/viewTypes";
import type { DisplayResolver } from "../viewport/Viewport3D";
@@ -56,9 +56,12 @@ export function useExportHandlers(opts: {
const scopedProject = (selectionOnly: boolean): Project =>
selectionOnly ? filterProjectToSelection(project, selectionMembers) : project;
// Gefilterte/verschobene Kopie = eigenes, kurzlebiges Kern-Dokument ([122]); das ganze Projekt läuft
// direkt über das Dokument des Stores.
const onExportPdf = async (decision: ExportPdfDecision) => {
const plan = generatePlan(
scopedProject(decision.selectionOnly),
const scoped = scopedProject(decision.selectionOnly);
const plan = withDocument(scoped, () => generatePlan(
scoped,
activeLevelId,
visibleCodes,
categoryDisplay,
@@ -68,7 +71,7 @@ export function useExportHandlers(opts: {
true, // includeGlobal (Default, explizit weil forPrint danach folgt)
decision.scaleDenominator, // Export-Massstab: Bemassung in Papier-mm, Strichstärken nach Massstab
true, // forPrint: `Drawing2D.noPrint`-Elemente ausschliessen
);
));
await savePlanPdf(plan, {
scaleDenominator: decision.scaleDenominator,
paper: decision.paper,
@@ -84,8 +87,9 @@ export function useExportHandlers(opts: {
// Ausrichtung wie der PDF-Export (Nutzer-Wunsch „Kein SVG-Export"), nur
// ohne den jsPDF/svg2pdf-Umweg — reiner Download des Druck-SVG.
const onExportSvg = (decision: ExportPdfDecision) => {
const plan = generatePlan(
scopedProject(decision.selectionOnly),
const scoped = scopedProject(decision.selectionOnly);
const plan = withDocument(scoped, () => generatePlan(
scoped,
activeLevelId,
visibleCodes,
categoryDisplay,
@@ -95,7 +99,7 @@ export function useExportHandlers(opts: {
true, // includeGlobal (Default)
decision.scaleDenominator, // wie PDF
true, // forPrint: `Drawing2D.noPrint`-Elemente ausschliessen
);
));
savePlanSvg(plan, {
scaleDenominator: decision.scaleDenominator,
paper: decision.paper,
@@ -115,7 +119,9 @@ export function useExportHandlers(opts: {
// damit die Datei in anderer CAD-Software lagerichtig ankommt — auch wenn
// lokal nahe (0,0) gezeichnet wurde. Ohne Bezug bleibt alles lokal.
// (Der Papier-/Layout-Export bleibt bewusst in lokalen Koordinaten.)
const exportProject = projectToWorldCoords(scopedProject(decision.selectionOnly));
const scoped = scopedProject(decision.selectionOnly);
const exportProject = withDocument(scoped, () => projectToWorldCoords(scoped));
await withDocument(exportProject, async () => {
const plan = generatePlan(
exportProject,
activeLevelId,
@@ -142,6 +148,7 @@ export function useExportHandlers(opts: {
} catch (err) {
getState().notify(`${t("exportDxf.failed")}: ${err instanceof Error ? err.message : String(err)}`, "error");
}
});
setExportDxfOpen(false);
};
+4 -10
View File
@@ -1317,15 +1317,8 @@ export function useGripEditing(opts: {
// das singuläre selectedDrawingId/selectedWallId) — von den eigenen
// Snap-Kandidaten ausschließen (sonst fängt der Punkt an sich selbst).
const owner = gripOwners[index];
const snapProject: Project = selectedRoomId
? { ...project, rooms: (project.rooms ?? []).filter((r) => r.id !== selectedRoomId) }
: selectedCeilingId
? { ...project, ceilings: (project.ceilings ?? []).filter((c) => c.id !== selectedCeilingId) }
: owner?.drawingId
? { ...project, drawings2d: project.drawings2d.filter((d) => d.id !== owner.drawingId) }
: owner?.wallId
? { ...project, walls: project.walls.filter((w) => w.id !== owner.wallId) }
: project;
const snapSkip = selectedRoomId || selectedCeilingId || owner?.drawingId || owner?.wallId;
const excludeIds = snapSkip ? [snapSkip] : [];
// Bezugspunkt für Shift-Ortho: ein Nachbar-Griff DESSELBEN Elements
// (festes Ende), relativ zu dem die Bewegung auf H/V eingerastet wird.
const refIndex = neighborGripIndex(index);
@@ -1361,7 +1354,8 @@ export function useGripEditing(opts: {
// laufende Werkzeug-Zustand (kein aktives Zeichenwerkzeug während des Drags).
const snapResult = computeSnap({
raw,
project: snapProject,
project,
excludeIds,
levelId,
visibleCodes,
settings: snap,