mirror of
https://github.com/narrrl/narl-workspace.git
synced 2026-11-03 16:41:27 +01:00
A note now leaves the scratchpad by becoming something else: `K` keeps it as a document, as before; `C` makes it a card where `:card` would put one, the first line its title; `A` opens `:append` with the document on screen filled in, Tab completing any other title, and puts the note at its end. `/api/capture` takes `to: "note"` and `to: "document"` (named as a link names it), and `note`, the scratch note the text came from, dropped once the text has landed. Appending keeps the revision before it and indexes links and media, as a save does. Migration 0028 adds `scratch_fts`; `GET /api/scratch?q=` searches it, and `/` lists note hits under "notes" after the cards, Enter lowering the drawer at the note. The `c` capture line cycles its target with Tab: a card, a note, or a timed line in today's entry, which `:today <text>` now writes.
19 lines
873 B
SQL
19 lines
873 B
SQL
-- The scratchpad is where things are written down before it is clear where
|
|
-- they belong, which makes it the first place to look for something half
|
|
-- remembered. Search finds a note the way it finds a document or a card.
|
|
CREATE VIRTUAL TABLE scratch_fts USING fts5 (body, tokenize = 'unicode61');
|
|
|
|
CREATE TRIGGER scratch_ai AFTER INSERT ON scratch_notes BEGIN
|
|
INSERT INTO scratch_fts (rowid, body) VALUES (new.id, new.body);
|
|
END;
|
|
CREATE TRIGGER scratch_ad AFTER DELETE ON scratch_notes BEGIN
|
|
DELETE FROM scratch_fts WHERE rowid = old.id;
|
|
END;
|
|
CREATE TRIGGER scratch_au AFTER UPDATE OF body ON scratch_notes BEGIN
|
|
DELETE FROM scratch_fts WHERE rowid = old.id;
|
|
INSERT INTO scratch_fts (rowid, body) VALUES (new.id, new.body);
|
|
END;
|
|
|
|
-- The notes written before the triggers existed.
|
|
INSERT INTO scratch_fts (rowid, body) SELECT id, body FROM scratch_notes;
|