Web editor: a typed #tag shows as a chip, and # suggests existing tags (#5913, #5914)

The tag row under the text was a copy of the note's labels taken when the
editor opened. A #tag in the body becomes a tag on the server's side of a
save, so the copy never learned of it until the note was reopened. Every
save now hands its note back, and the row is refreshed from it.

Typing # in a prose block or a checklist item opens the tags that already
exist: prefix matches first, busiest first. Arrows move, Enter or Tab puts
the tag in, Esc closes only the menu. The grammar and ranking live in
notes/tags.ts with tests, so the menu never offers a tag the server would
not derive.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-16 13:38:49 -04:00
co-authored by Claude Opus 5.5
parent 67df94350c
commit 8d67fc0da5
4 changed files with 296 additions and 14 deletions
+8 -4
View File
@@ -158,8 +158,10 @@ export const useNotesStore = defineStore("notes", () => {
async function mutate(
id: string,
changes: Partial<Pick<Note, "body" | "pinned" | "archived" | "remind_at" | "recurrence">>,
): Promise<void> {
reconcile(await repo.notes.update(id, changes));
): Promise<Note> {
const note = await repo.notes.update(id, changes);
reconcile(note);
return note;
}
const setPinned = (id: string, pinned: boolean) => mutate(id, { pinned });
@@ -179,8 +181,10 @@ export const useNotesStore = defineStore("notes", () => {
reconcile(await repo.notes.snoozeReminder(id, minutes));
}
async function setLabels(id: string, labelIds: string[]): Promise<void> {
reconcile(await repo.notes.setLabels(id, labelIds));
async function setLabels(id: string, labelIds: string[]): Promise<Note> {
const note = await repo.notes.setLabels(id, labelIds);
reconcile(note);
return note;
}
async function updateItem(id: string, itemId: string, changes: { checked: boolean }): Promise<void> {