God-Files aufgeteilt (ResourceManager/generatePlan/toWalls3d/App.tsx-Handler), Totcode entfernt (geometry-Crate, OCCT/HLR-Spike), PDF/Bild-Import ergänzt.
ResourceManager.tsx, generatePlan.ts und toWalls3d.ts sind nach Bauteil- Domäne in src/ui/resourceManager/, src/plan/generatePlan/ und src/plan/toWalls3d/ aufgeteilt (reine Verschiebung, keine Verhaltens- änderung). App.tsx verliert weitere Handler-Gruppen an eigene Hooks (useExportHandlers, useImportHandling, useKeyboardShortcuts) sowie Hit-Testing an src/viewport/planHitTest.ts. Unbenutzte Rust-geometry-Crate (durch WASM-Joins abgelöst) sowie der alte OCCT/HLR-Schnitt-Spike (hlr.ts/occt.ts, vite occt-Aliases) entfernt. Neu: PDF-Import als Rasterbild (src/io/pdfImport.ts) + gemeinsamer Bild-Asset-Helfer (src/io/imageAsset.ts) für Plan- und Layout-Bilder. tsc -b sauber, vitest 891/891 grün.
This commit is contained in:
1 parent
06c0143d32
commit
1507c2bf00
85 files changed
+12461
-11280
No files matched your search
@@ -0,0 +1,58 @@
|
||||
// Tests für wrapDocToLines: Wortumbruch auf feste Breite unter Erhalt der
|
||||
// Run-Grenzen (gemischte Formatierung pro Zeile bleibt möglich).
|
||||
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { docFromText, makeRun, type RichTextDoc } from "./richText";
|
||||
import { docToLines, wrapDocToLines } from "./renderHtml";
|
||||
|
||||
const OPTS = { x: 0, y: 0, lineHeight: 10, unitPerPt: 1, basePt: 10, color: "#000000" };
|
||||
|
||||
describe("wrapDocToLines", () => {
|
||||
it("ohne wrapWidthUnits identisch zu docToLines (eine Zeile je Absatz)", () => {
|
||||
const doc = docFromText("hallo welt");
|
||||
expect(wrapDocToLines(doc, OPTS)).toEqual(docToLines(doc, OPTS));
|
||||
});
|
||||
|
||||
it("bricht lange Absätze wortweise auf mehrere Zeilen um", () => {
|
||||
const doc = docFromText("eins zwei drei vier fünf");
|
||||
const lines = wrapDocToLines(doc, { ...OPTS, wrapWidthUnits: 30 });
|
||||
expect(lines.length).toBeGreaterThan(1);
|
||||
const joined = lines.map((l) => l.tspans.map((t) => t.text).join("")).join(" ");
|
||||
expect(joined.replace(/\s+/g, " ").trim()).toBe("eins zwei drei vier fünf");
|
||||
});
|
||||
|
||||
it("respektiert Run-Grenzen: ein fett formatiertes Wort bleibt in einem eigenen Tspan", () => {
|
||||
const doc: RichTextDoc = {
|
||||
version: 1,
|
||||
paragraphs: [
|
||||
{
|
||||
runs: [
|
||||
makeRun("normal ", {}),
|
||||
makeRun("fett", { bold: true }),
|
||||
makeRun(" weiter", {}),
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
const lines = wrapDocToLines(doc, { ...OPTS, wrapWidthUnits: 1000 });
|
||||
expect(lines).toHaveLength(1);
|
||||
const boldTspan = lines[0].tspans.find((t) => t.text === "fett");
|
||||
expect(boldTspan?.fontWeight).toBe("700");
|
||||
const otherTspans = lines[0].tspans.filter((t) => t.text !== "fett");
|
||||
expect(otherTspans.every((t) => t.fontWeight === undefined)).toBe(true);
|
||||
});
|
||||
|
||||
it("leerer Absatz erzeugt eine leere Zeile (Vorschub bleibt erhalten)", () => {
|
||||
const doc: RichTextDoc = { version: 1, paragraphs: [{ runs: [] }, { runs: [makeRun("x")] }] };
|
||||
const lines = wrapDocToLines(doc, { ...OPTS, wrapWidthUnits: 100 });
|
||||
expect(lines).toHaveLength(2);
|
||||
expect(lines[0].tspans).toHaveLength(0);
|
||||
});
|
||||
|
||||
it("sehr schmale Breite bricht auf ein Wort je Zeile um, ohne Wörter zu verlieren", () => {
|
||||
const doc = docFromText("aa bb cc");
|
||||
const lines = wrapDocToLines(doc, { ...OPTS, wrapWidthUnits: 1 });
|
||||
const words = lines.map((l) => l.tspans.map((t) => t.text).join("").trim());
|
||||
expect(words).toEqual(["aa", "bb", "cc"]);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user