diff --git a/OVERVIEW.md b/OVERVIEW.md index 5cafea0..d910812 100644 --- a/OVERVIEW.md +++ b/OVERVIEW.md @@ -68,7 +68,7 @@ A **visual sequence** (`kind: 'sequence'`, numbered `frames` of image + text wit - **Walkthroughs (issue #23):** a sequence frame may carry `ifStuck` text and a `stop` flag, and a sequence a `captured` date. In Edit, "Capture from screen…" uses `getDisplayMedia` (`startScreenCapture`, `grabScreenFrame`, `stopScreenCapture` in `images.js`; the stream lives in a closure variable in `app.js`, ended when leaving edit mode) and adds frames via `addCapture()` in `ops.js`. In view mode `state.walk` (`{id, k}`, not saved) shows a sequence one step at a time (`walkSequence`). - **Credential references (issue #24):** a frame's `uses: [{record, field}]` points at record fields by id. A field gets an `id` the first time it is referenced (`ensureFieldId`, `addUse`, `findFieldRef`, `allRecordsIn` in `ops.js`). A dangling reference is shown as removed, never a validation error. `viewUses` and `copyValue` (30 s clipboard wipe) are in `app.js`; `usesView` in `print.js` does the masked/included print text. - **Annotation (issue #25):** a frame's `marks` are `{type:'marker',x,y}` or `{type:'box',x,y,w,h}` as fractions of the picture (`isMark`, `normRect` in `images.js`). `markedImage()` in `app.js` wraps a step's `` in a `.marked` box and lays CSS overlays over it, so the same marks work in the list, player, lightbox and print. `openAnnotator()` is a canvas dialog; Blur out runs `pixelateRegion()` (pure, in `images.js`) on the pixels and `Apply` re-encodes the picture, so no unblurred copy is stored. Marks are dropped when the picture is replaced, removed or erased by `clearSecrets`. -- **Search (issue #27):** `src/search.js` has the pure `searchRanges()` (case-insensitive, plain text) and `stepSearchIndex()`. In `app.js` the bar is a persistent element re-attached on every `render()` (so the typed text and focus survive). `findAllHits()` builds a hidden copy of every section with `state.searchAll` set (all sub-tabs, nothing folded) using the normal view functions, then counts matches per entry (`data-eid` on record/item/sequence elements). `stepSearch()` navigates (section, sub-tab, unfold, `state.walk = null`); `highlightSearch()` runs at the end of `render()` and wraps the matches in ``. Text under `SEARCH_SKIP` (buttons, inputs, `.secret`, `.nosearch`) is never searched, so secrets stay out. New view-mode furniture such as dates and badges needs the `nosearch` class or it will be counted. +- **Search (issue #27):** `src/search.js` has the pure `searchRanges()` (case-insensitive, plain text) and `stepSearchIndex()`. In `app.js` a toolbar **Search** button sets `state.searchOpen`, which swaps the toolbar's buttons for the search controls (same row); Cancel swaps them back. The controls are a persistent element re-attached on every `render()` (so the typed text and focus survive). `findAllHits()` builds a hidden copy of every section with `state.searchAll` set (all sub-tabs, nothing folded) using the normal view functions, then counts matches per entry (`data-eid` on record/item/sequence elements). `stepSearch()` navigates (section, sub-tab, unfold, `state.walk = null`); `highlightSearch()` runs at the end of `render()` and wraps the matches in ``. Text under `SEARCH_SKIP` (buttons, inputs, `.secret`, `.nosearch`) is never searched, so secrets stay out. New view-mode furniture such as dates and badges needs the `nosearch` class or it will be counted. - **Reset (`?reset=1`):** opening the file with `?reset=1` or `#reset=1` shows a banner after unlock offering to erase every secret-flagged field value and secret frame (`clearSecrets()` in `ops.js`, count from `countSecrets`). Labels, structure and flags stay. It is read live (`resetRequested()`), with a `hashchange` listener to re-offer, and `state.resetOffered` dismisses it. Nothing is written until Save, so make a Backup copy first. It's meant for working on layout on a less safe machine. **Save.** Uses the File System Access API (`showSaveFilePicker`, handle reused) where available, otherwise a Blob download. `assemble()` rebuilds the full HTML from the page's own CSS and JS plus a fresh encrypted payload. "Backup copy" downloads `final-wishes-YYYYMMDD.html`. diff --git a/README.md b/README.md index 6f74f2a..1039b88 100644 --- a/README.md +++ b/README.md @@ -85,7 +85,8 @@ After sealing, `data/seed.json` is still plaintext. Delete it (and see one until you save and replace it. ## Searching -Below the toolbar (in view mode) is a search box with **Search**, **← Previous**, +Click **Search** in the toolbar (view mode only). The toolbar buttons are +replaced, in the same row, by a search box with **Search**, **← Previous**, **Next →** and **Cancel** buttons. Type a word, press **Search** or Enter. It ignores capitals and looks through the whole document: section titles, text, record titles, field labels and values, notes, items and visual-sequence step @@ -98,12 +99,14 @@ the count shows as "2 of 6". collapsed record if the match is inside it. - **Not found:** nothing is highlighted, the box says "Not found", the arrows are greyed and Tab behaves normally (it moves on to the next control). -- **Cancel** (or Esc) clears the box and the highlights. Typing a new word - also clears the old results until you search again. +- **Cancel** (or Esc) clears the box and the highlights and puts the usual + toolbar buttons back. Typing a new word also clears the old results until you + search again. - **Secrets are never searched or shown.** A word that only appears inside a value marked secret is "Not found". Field labels are searched, values marked secret are not. Image text is not searchable. -- Search is for reading: **Edit** hides the bar and clears the results. +- Search is for reading: there is no Search button in Edit mode, and + starting to edit clears any results. - The Print header page and dates such as "Updated" are not searched. ## Sub-tabs diff --git a/src/app.js b/src/app.js index b2fb8fe..4ffe243 100644 --- a/src/app.js +++ b/src/app.js @@ -13,6 +13,7 @@ pwChanged: false, // passphrase changed since the last save tabs: {}, // section id -> id of the sub-tab being shown ('' = General); not saved collapsed: new Set(), // ids of records folded to just their title (view mode only) + searchOpen: false, // the search controls are showing in place of the toolbar buttons search: null, // { q, hits: [{sid, eid, n}], i, scroll }: the active search (not saved) searchAll: false, // true only while building the hidden copy the search counts matches in walk: null, // { id, k }: the visual sequence shown as a one-step-at-a-time walkthrough (not saved) @@ -1016,7 +1017,7 @@ function render() { if (capture && !state.editing) endCapture(); // sharing only lasts while editing - if (state.editing) state.search = null; // search is for reading; Edit clears it + if (state.editing) { state.search = null; state.searchOpen = false; } // search is for reading; Edit clears it const keepFocus = searchEl && searchEl.contains(document.activeElement) ? document.activeElement : null; root.replaceChildren(); if (!state.doc) return root.append(renderStart()); @@ -1031,20 +1032,21 @@ h('span', { class: 'muted', id: 'version', title: 'Version of this app' }, 'Ver ' + APP_VERSION), h('span', { id: 'dirty', class: 'badge tbd', hidden: !state.dirty }, 'Unsaved changes'), h('span', { id: 'status', class: 'muted', role: 'status' }, state.status)), - h('div', { class: 'toolbar' }, + // While searching, the search controls take the toolbar's place; Cancel brings the buttons back. + h('div', { class: 'toolbar' }, state.searchOpen ? searchBarEl() : [ btn('Save', () => save(), state.dirty ? 'primary' : ''), state.editing ? btn('Cancel', cancelEdit, '', { title: 'Discard unsaved changes to this section and stop editing' }) : null, btn('Backup copy', () => save({ backup: true })), btn('Change passphrase', changePassphrase), btn('Print…', openPrintDialog), - btn(state.editing ? 'Done editing' : 'Edit', () => { state.editing = !state.editing; render(); }, state.editing ? 'primary' : ''))), - ...(state.editing ? [] : [searchBarEl()]), + state.editing ? null : btn('Search', openSearch, '', { id: 'searchopen', title: 'Find a word in the document' }), + btn(state.editing ? 'Done editing' : 'Edit', () => { state.editing = !state.editing; render(); }, state.editing ? 'primary' : '')])), ...(resetRequested() && !state.resetOffered ? [resetBanner()] : []), // never pass null: append() would print "null" h('div', { class: 'layout' }, renderNav(), h('main', {}, onHeader ? [h('h2', {}, 'Print header'), headerPanel()] : sec ? [h('h2', {}, sec.title), state.editing ? editSection(sec) : viewSection(sec)] : h('p', { class: 'muted' }, 'No sections yet. Choose Edit to add one.')))); - if (!state.editing) updateSearchUi(); + if (state.searchOpen) updateSearchUi(); if (keepFocus) keepFocus.focus(); highlightSearch(); } @@ -1081,6 +1083,12 @@ return searchEl; } + function openSearch() { + state.searchOpen = true; + render(); + searchInput.focus(); + } + function updateSearchUi() { if (!searchEl) return; const s = state.search; @@ -1130,15 +1138,19 @@ function runSearch() { const q = searchInput.value.trim(); - if (!q) return cancelSearch(); + if (!q) { state.search = null; return render(); } state.search = { q, hits: findAllHits(q), i: -1 }; if (state.search.hits.length) stepSearch(1); else render(); } + // Cancel: forget the search and put the toolbar buttons back. function cancelSearch() { searchInput.value = ''; state.search = null; + state.searchOpen = false; render(); + const again = document.getElementById('searchopen'); + if (again) again.focus(); } // Go to match i: its section, its sub-tab, unfolded, then highlight and scroll to it. diff --git a/src/style.css b/src/style.css index 440c8aa..0c4c324 100644 --- a/src/style.css +++ b/src/style.css @@ -63,8 +63,8 @@ li.seqitem { display: block; list-style: none; margin-left: -1.4rem; } .frameedi .mbox { position: absolute; box-sizing: border-box; border: 3px solid #e11; box-shadow: 0 0 0 1px #fff; border-radius: 3px; pointer-events: none; } .mpin { position: absolute; box-sizing: border-box; transform: translate(-50%, -50%); width: 1.6rem; height: 1.6rem; border-radius: 50%; background: #e11; color: #fff; border: 2px solid #fff; font: 700 .85rem/1.2rem system-ui, sans-serif; text-align: center; pointer-events: none; } .annotator { max-width: min(95vw, 70rem); } .annot { display: block; max-width: 100%; max-height: 65vh; margin: .5rem auto; cursor: crosshair; touch-action: none; border: 1px solid var(--line); } -.searchbar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin: .75rem 0 1rem; } -.searchbox { flex: 1 1 14rem; min-width: 8rem; font: inherit; padding: .45rem .6rem; border: 1px solid var(--line); border-radius: .4rem; background: var(--card); color: var(--fg); } +.searchbar { display: flex; flex: 1 1 100%; flex-wrap: wrap; gap: .5rem; align-items: center; } +.searchbox { flex: 1 1 14rem; min-width: 8rem; font: inherit; padding: .4rem .6rem; line-height: 1.2; border: 1px solid var(--line); border-radius: .4rem; background: var(--card); color: var(--fg); } .searchnote { min-width: 4.5rem; text-align: right; } mark.hit { background: var(--warn-bg); color: var(--warn-fg); border-radius: .2rem; padding: 0 .1em; } mark.hit.cur { background: var(--accent); color: var(--bg); outline: 2px solid var(--accent); } diff --git a/src/version.js b/src/version.js index 27125d3..4e98e1f 100644 --- a/src/version.js +++ b/src/version.js @@ -2,7 +2,7 @@ // YYMMDD is the date, X the iteration that day (A first, B second, ...). // Bump with `npm run bump` (see bump-version.js). build.js strips `export`. -export const APP_VERSION = '261124H'; +export const APP_VERSION = '261124I'; const VERSION_RE = /^(\d{6})([A-Z])$/; export const isVersion = (v) => typeof v === 'string' && VERSION_RE.test(v);