Pin notes to passages in a PDF, and put the notes control with the rest

The panel beside a PDF is for notes about the document; a note that belongs to
one paragraph is a different thing, and one that has to begin "on page 14, third
paragraph" has already lost its place. Click Randnotiz, click the passage, write.

Pins ride in the same per-page overlay as the drawings, in PDF points, so one
stays on its sentence at every zoom and in the exported file. Living outside the
note body has consequences that each needed handling: nothing else would index
them for search, so the viewer feeds them in with their page numbers; clearing a
page's ink must not take them; and "is this overlay empty?" was answered by
counting strokes — in the client *and* independently in the server, so an
overlay holding only pinned notes was stored as NULL and lost every note on it.

They are stamped into the annotated export as a numbered marker plus a box of
text, on whichever side of the pin has room. Standard PDF fonts are Latin-1, so
characters outside it are replaced rather than failing the whole export.

The Notizen control moves into the viewer's toolbar. A second row for one button
cost reading height on every screen and put one of the document's controls
somewhere none of the others were. On a phone, where the viewer is not on screen
while the notes are, the way back sits in the panel.

Renaming a separator no longer shifts the row: the two rules always share what is
left over equally and the middle keeps one width in both states.

215 unit tests, 206 browser checks across eleven suites.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
marcandClaude Opus 5 committed 2026-08-10 13:08:20 +02:00
1 parent 2cee00e38e
commit 6438648313
16 files changed
+1228 -170

No files matched your search

+49
View File
@@ -158,3 +158,52 @@ describe("contentToText", () => {
expect(search.contentToText("")).toBe("");
});
});
describe("notes pinned into a PDF", () => {
beforeEach(() => {
seed();
search.removeEntry("pdf");
});
it("are searchable, even though they live outside the note body", () => {
// They are stored in the page overlay, so nothing else puts them in the
// index — and a note written onto page 14 that cannot be found again is
// not much of a note.
search.setEntry("pdf", "Handbuch", body("Meine Anmerkungen."));
search.setPinnedText("pdf", "Handbuch", "S. 14: Achtung, Drehmoment beachten");
expect(search.search("drehmoment")?.map((h) => h.id)).toEqual(["pdf"]);
});
it("show the pinned text as the excerpt, with its page", () => {
search.setEntry("pdf", "Handbuch", body("Meine Anmerkungen."));
search.setPinnedText("pdf", "Handbuch", "S. 14: Achtung, Drehmoment beachten");
expect(search.search("drehmoment")?.[0]?.snippet).toContain("S. 14");
});
it("do not displace what the reader typed beside the document", () => {
search.setEntry("pdf", "Handbuch", body("Meine Anmerkungen."));
search.setPinnedText("pdf", "Handbuch", "Drehmoment");
expect(search.search("anmerkungen")?.map((h) => h.id)).toEqual(["pdf"]);
expect(search.search("drehmoment")?.map((h) => h.id)).toEqual(["pdf"]);
});
it("survive the document's own text being indexed afterwards", () => {
search.setPinnedText("pdf", "Handbuch", "Drehmoment");
search.setAttachedText("pdf", "Handbuch", "Der Hersteller empfiehlt regelmäßige Wartung.");
expect(search.search("drehmoment")?.map((h) => h.id)).toEqual(["pdf"]);
expect(search.search("wartung")?.map((h) => h.id)).toEqual(["pdf"]);
});
it("survive the note body being saved afterwards", () => {
// Typing in the panel beside the PDF must not wipe what is pinned into it.
search.setPinnedText("pdf", "Handbuch", "Drehmoment");
search.setEntry("pdf", "Handbuch", body("Später weiterlesen."));
expect(search.search("drehmoment")?.map((h) => h.id)).toEqual(["pdf"]);
});
it("are replaced wholesale, so a deleted pin stops being findable", () => {
search.setPinnedText("pdf", "Handbuch", "Drehmoment");
search.setPinnedText("pdf", "Handbuch", "");
expect(search.search("drehmoment")).toEqual([]);
});
});