Replace unused vector clocks with a conflict check that works, drop the rest

The vector clocks in the server were never reached: no client sent one,
so the branch was dead and every write was a blind overwrite. Not "the
newer edit wins" — "the request that arrives last wins", which is worse:
a phone that was offline all day buries the laptop's newer work simply by
reconnecting late.

Each write now carries baseUpdatedAt, the revision it was written on top
of. If the note has moved on since, the incoming edit still wins — a
rejection would throw away what was just typed — but the state it
replaces is kept as a version marked "conflict", so both exist and the
history is where you choose. Clocks could have told a real conflict from
a device catching up, but that precision only pays off with a merge
interface, and this reuses the version history already built.

adoptRevision() stores the revision the server reports back, or the
second save in a row would be flagged as conflicting with the first.

Also removed, as agreed:
- POST /api/notes/pdf — accepted PDFs that nothing could ever read back,
  with no retrieval route and no viewer. The readme advertised "PDF
  Import & Annotation"; that claim is gone too.
- POST /api/sync — a batch endpoint the client never called.
- the tags column — notebooks, starring and search already cover it.

Columns on existing databases are left in place. Dropping them buys
nothing and is not worth touching a live database for.

Tables now have a right-click menu (editor/tableMenu.js) for rows,
columns, header and merging. It needs stopPropagation: without it the
same event reaches window, where the menu that is mounting reads it as a
click elsewhere and closes instantly — the reason the other context menus
in App.jsx already do this.

92 browser checks across seven suites, 125 unit tests.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
marcandClaude Opus 5 committed 2026-08-08 18:59:08 +02:00
1 parent 8c36c6121b
commit df279a5d36
10 files changed
+367 -152

No files matched your search

+57
View File
@@ -0,0 +1,57 @@
/**
* The right-click menu on a table.
*
* The toolbar carries the same commands, but reaching them means leaving the
* cell you are working in, finding the button and reading a list — for shaping
* a table, where the target is the cell under the pointer, that is the long way
* round. This puts the commands where the cursor already is.
*
* Only the entries that apply are built: merge appears when several cells are
* selected, split when the cell was merged, and nothing at all outside a table
* so the browser's own menu stays available for ordinary text.
*/
/** True when the caret or selection sits inside a table cell. */
export const inTable = (editor) => !!editor?.isActive("table");
/**
* Menu items for `ContextMenu`, or null when there is no table under the click.
*
* Returning null rather than an empty list lets the caller tell "no menu" from
* "a menu with nothing in it" and fall through to the browser's own.
*/
export function tableMenuItems(editor) {
if (!inTable(editor)) return null;
const run = (fn) => () => fn(editor.chain().focus()).run();
const can = (name) => {
try {
return editor.can()[name]();
} catch {
return false;
}
};
const items = [
{ label: "Zeile darüber einfügen", action: run((c) => c.addRowBefore()) },
{ label: "Zeile darunter einfügen", action: run((c) => c.addRowAfter()) },
{ label: "Spalte links einfügen", action: run((c) => c.addColumnBefore()) },
{ label: "Spalte rechts einfügen", action: run((c) => c.addColumnAfter()) },
{ divider: true },
{ label: "Kopfzeile an/aus", action: run((c) => c.toggleHeaderRow()) },
];
// mergeCells and splitCell are mutually exclusive in practice: one needs a
// multi-cell selection, the other a cell that was merged earlier.
if (can("mergeCells")) items.push({ label: "Zellen verbinden", action: run((c) => c.mergeCells()) });
if (can("splitCell")) items.push({ label: "Zelle teilen", action: run((c) => c.splitCell()) });
items.push(
{ divider: true },
{ label: "Zeile löschen", danger: true, action: run((c) => c.deleteRow()) },
{ label: "Spalte löschen", danger: true, action: run((c) => c.deleteColumn()) },
{ label: "Tabelle löschen", danger: true, action: run((c) => c.deleteTable()) }
);
return items;
}