Fix a permanent black line in the note list, and add separators
The drop indicator was a `borderTop` set in the same style object as a `border` shorthand. Clearing the longhand resets its width and colour to the defaults while the shorthand's `solid` stays, so a row kept a 2px black line for good — measured at rest, before any drag. It is now its own element, which also stops the list twitching as a row grows and shrinks by a pixel. That element then turned out to be a dead strip of its own: it pushes the row down as it appears, so the pointer ended up over the line rather than over the row and releasing there dropped on nothing. The drag handlers moved to the whole row and the indicator no longer takes pointer events. A strip below the last row means "put it at the end", which otherwise needs a drop onto the final note. Separators are lines drawn between notes, optionally named, stored on the notebook beside its sort mode. They drag like notes do, and their position is "how many notes come before me", so they hold their place as the notes around them are renamed or edited. Shown only in the manual order — in "newest first" the notes would slide past the line on every edit. "All Notes" and "Starred" no longer offer a hand-made order: they are questions asked of every notebook, so there is nothing for an arrangement to belong to. 199 unit tests, 190 browser checks across eleven suites. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
0a0864c58b
commit
2cee00e38e
10 files changed
+731
-125
No files matched your search
+33
-1
@@ -347,6 +347,15 @@ if (!tableColumns("notebooks").includes("sort_mode")) {
|
||||
db.exec("ALTER TABLE notebooks ADD COLUMN sort_mode TEXT");
|
||||
}
|
||||
|
||||
/* Lines the user drew between notes in the manual order, as JSON.
|
||||
*
|
||||
* A column rather than a table: they are a handful of labels that only mean
|
||||
* anything as an ordered list, they are always read and written whole with the
|
||||
* notebook, and nothing ever queries across them. */
|
||||
if (!tableColumns("notebooks").includes("separators")) {
|
||||
db.exec("ALTER TABLE notebooks ADD COLUMN separators TEXT");
|
||||
}
|
||||
|
||||
if (!tableColumns("notes").includes("pdf_attachment_id")) {
|
||||
db.exec("ALTER TABLE notes ADD COLUMN pdf_attachment_id TEXT");
|
||||
}
|
||||
@@ -780,8 +789,26 @@ app.post("/api/notebooks", authMiddleware, (req, res) => {
|
||||
/** The orders the note list offers. Anything else is refused rather than stored. */
|
||||
const SORT_MODES = ["manual", "updated", "oldest", "created", "title"];
|
||||
|
||||
/* An upper bound on the arrangement, so a malformed client cannot store an
|
||||
* unbounded blob on a notebook. */
|
||||
const MAX_SEPARATORS = 200;
|
||||
const MAX_SEPARATOR_LABEL = 80;
|
||||
|
||||
/** Keeps only what a separator is allowed to be. */
|
||||
function cleanSeparators(input) {
|
||||
if (!Array.isArray(input)) return null;
|
||||
return input
|
||||
.slice(0, MAX_SEPARATORS)
|
||||
.filter((s) => s && typeof s.id === "string" && s.id)
|
||||
.map((s) => ({
|
||||
id: s.id.slice(0, 64),
|
||||
label: typeof s.label === "string" ? s.label.slice(0, MAX_SEPARATOR_LABEL) : "",
|
||||
order: Number.isFinite(Number(s.order)) ? Math.max(0, Math.round(Number(s.order))) : 0,
|
||||
}));
|
||||
}
|
||||
|
||||
app.put("/api/notebooks/:id", authMiddleware, (req, res) => {
|
||||
const { name, coverIndex, sortOrder, maxVersions, sortMode } = req.body;
|
||||
const { name, coverIndex, sortOrder, maxVersions, sortMode, separators } = req.body;
|
||||
const nb = db.prepare("SELECT * FROM notebooks WHERE id = ? AND user_id = ?").get(req.params.id, req.userId);
|
||||
if (!nb) return res.status(404).json({ error: "Not found" });
|
||||
|
||||
@@ -807,6 +834,11 @@ app.put("/api/notebooks/:id", authMiddleware, (req, res) => {
|
||||
if (sortMode !== undefined) {
|
||||
db.prepare("UPDATE notebooks SET sort_mode = ? WHERE id = ?").run(sortMode, req.params.id);
|
||||
}
|
||||
if (separators !== undefined) {
|
||||
const cleaned = cleanSeparators(separators);
|
||||
if (!cleaned) return res.status(400).json({ error: "separators must be an array" });
|
||||
db.prepare("UPDATE notebooks SET separators = ? WHERE id = ?").run(JSON.stringify(cleaned), req.params.id);
|
||||
}
|
||||
|
||||
broadcastToUser(req.userId, { type: "notebook_updated", data: { id: req.params.id, name, coverIndex } }, req.deviceId);
|
||||
res.json({ success: true, defaultMaxVersions: MAX_VERSIONS_PER_NOTE });
|
||||
|
||||
Reference in new issue
Block a user