privacy-redact 1.1.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,7 +2,7 @@
2
2
  * Review screen controller. Looks up its nodes inside the element root so a host
3
3
  * page can mount the same flow without owning the document.
4
4
  */
5
- import { CATEGORIES, TEXT_TYPES } from '../detect/patterns.js';
5
+ import { CATEGORIES, TEXT_TYPES, createDetector, defaultDetector } from '../detect/patterns.js';
6
6
  import { regionsFromLines, maskHint, documentTranscript } from '../detect/textRegions.js';
7
7
  import { renderRedactions } from '../render/effects.js';
8
8
  import { normalizeActions, downloadAction } from './actions.js';
@@ -10,6 +10,10 @@ import {
10
10
  SCAN_TYPES, PICTURE_SCAN_TYPES, loadScanPrefs, saveScanPrefs, defaultScanPrefs,
11
11
  normalizeScanPrefs, enabledTextTypes, enabledSteps, emailPhonePrefs, scanScopeText,
12
12
  } from '../prefs/scan.js';
13
+ import {
14
+ OPTIONAL_LANGUAGES, loadLanguagePrefs, saveLanguagePrefs,
15
+ languagesFromPrefs, prefsFromLanguages,
16
+ } from '../prefs/languages.js';
13
17
 
14
18
  const TAGS = {
15
19
  card: 'Credit card', ssn: 'SSN / ID', aadhaar: 'Aadhaar', pan: 'PAN', email: 'Email', phone: 'Phone', address: 'Address', account: 'Account no.',
@@ -23,7 +27,7 @@ const DROP_TITLE = 'Drop a screenshot, photo, or PDF here';
23
27
  * Bind the review flow to one element. Queries stay in its shadow tree. Page paste
24
28
  * is ignored while the person is typing in the host.
25
29
  * @param {HTMLElement} host
26
- * @param {{ style?: string, strength?: number, actions?: unknown }} [initial]
30
+ * @param {{ style?: string, strength?: number, actions?: unknown, languages?: unknown, regions?: unknown }} [initial]
27
31
  */
28
32
  export function attachController(host, initial = {}) {
29
33
  const root = host.shadowRoot;
@@ -48,9 +52,37 @@ export function attachController(host, initial = {}) {
48
52
  const state = {
49
53
  doc: null, page: 0, style: 'blur', strength: 0.65, catOn: {}, scan: loadScanPrefs(), scanning: false, run: 0, transcriptRedacted: true,
50
54
  actions: normalizeActions(undefined), sendAs: 'both',
55
+ detector: defaultDetector,
56
+ languages: loadLanguagePrefs(),
57
+ regions: ['US', 'CA', 'GB', 'IN'],
51
58
  };
52
59
  let nextId = 1;
53
60
 
61
+ /** Compile the detector from the current language prefs and regions. */
62
+ function applyDetectorScope() {
63
+ state.detector = createDetector({
64
+ languages: languagesFromPrefs(state.languages),
65
+ regions: state.regions,
66
+ });
67
+ import('../detect/ocr.js').then((m) => m.setOcrScope(state.detector)).catch(() => {});
68
+ }
69
+
70
+ /**
71
+ * Host override for languages/regions. A languages list also updates the
72
+ * Settings toggles and the local save so the screen matches the host.
73
+ */
74
+ function setScope({ languages, regions } = {}) {
75
+ if (regions != null) {
76
+ if (!Array.isArray(regions)) throw new TypeError('regions must be an array of region ids');
77
+ state.regions = regions;
78
+ }
79
+ if (languages != null) {
80
+ state.languages = saveLanguagePrefs(prefsFromLanguages(languages));
81
+ drawLangPrefs();
82
+ }
83
+ applyDetectorScope();
84
+ }
85
+
54
86
  const isActive = (r) => state.catOn[r.type] !== false && r.on;
55
87
  const cur = () => state.doc.pages[state.page];
56
88
  const activeRegions = (p) => p.regions.filter(isActive);
@@ -190,13 +222,6 @@ export function attachController(host, initial = {}) {
190
222
  $('pg-next').disabled = state.page === n - 1;
191
223
  }
192
224
 
193
- /** Fold or open the scanner reading without touching the text already filled in. */
194
- function setTranscriptOpen(open) {
195
- $('transcript-panel').hidden = !open;
196
- $('transcript-toggle').setAttribute('aria-expanded', String(open));
197
- $('transcript-card').classList.toggle('open', open);
198
- }
199
-
200
225
  /** Boxes still on, one list per page. The transcript mask follows these, so the text matches the image. */
201
226
  function activeBoxesByPage() {
202
227
  return state.doc.pages.map((p) => activeRegions(p));
@@ -345,7 +370,12 @@ export function attachController(host, initial = {}) {
345
370
  if (actionBlocked(action)) return;
346
371
  const outputs = outputsFor(action);
347
372
  const detail = {
348
- action: action.id, outputs, findings: state.doc ? activeFindings() : [], truncated: !!state.doc?.truncated,
373
+ action: action.id,
374
+ outputs,
375
+ findings: state.doc ? activeFindings() : [],
376
+ truncated: !!state.doc?.truncated,
377
+ scope: { ...state.detector.scope },
378
+ warnings: [],
349
379
  };
350
380
  // An action that releases nothing only reports the click. No document data leaves.
351
381
  if (!outputs.length) {
@@ -394,21 +424,35 @@ export function attachController(host, initial = {}) {
394
424
  }));
395
425
  }
396
426
 
397
- /** Fill the folded transcript. Stays closed until the user opens it. */
427
+ /** Word/character counts for the reading shown below the text. */
428
+ function transcriptStats(text) {
429
+ const chars = [...text].length;
430
+ const words = text.trim() ? text.trim().split(/\s+/).length : 0;
431
+ const bits = [
432
+ `${words} word${words === 1 ? '' : 's'}`,
433
+ `${chars} character${chars === 1 ? '' : 's'}`,
434
+ ];
435
+ if (state.doc?.pages.length > 1) bits.push(`${state.doc.pages.length} pages`);
436
+ return bits.join(' · ');
437
+ }
438
+
439
+ /** Fill the scrollable scanner reading and the stats under it. */
398
440
  function drawTranscript() {
399
441
  const pre = $('transcript-text');
400
442
  const empty = $('transcript-empty');
443
+ const stats = $('transcript-stats');
401
444
  const copy = $('btn-transcript-copy');
402
445
  if (!state.doc) {
403
446
  pre.textContent = '';
447
+ pre.hidden = true;
404
448
  empty.hidden = true;
449
+ stats.hidden = true;
450
+ stats.textContent = '';
405
451
  copy.disabled = true;
406
452
  copy.textContent = 'Copy text';
407
- $('transcript-count').textContent = '';
408
453
  return;
409
454
  }
410
455
  const n = state.doc.pages.length;
411
- $('transcript-label').textContent = 'What the scanner read';
412
456
  const view = transcriptView();
413
457
  pre.textContent = view.text;
414
458
  pre.hidden = !view.text;
@@ -416,11 +460,13 @@ export function attachController(host, initial = {}) {
416
460
  empty.hidden = !view.empty;
417
461
  copy.disabled = !view.text || view.pending;
418
462
  copy.textContent = n > 1 ? 'Copy all' : 'Copy text';
419
- const lines = view.text ? view.text.split('\n').length : 0;
420
- const bits = [];
421
- if (n > 1) bits.push(`${n} pages`);
422
- if (lines) bits.push(`${lines} line${lines === 1 ? '' : 's'}`);
423
- $('transcript-count').textContent = bits.join(' · ');
463
+ if (view.text) {
464
+ stats.textContent = transcriptStats(view.text);
465
+ stats.hidden = false;
466
+ } else {
467
+ stats.textContent = '';
468
+ stats.hidden = true;
469
+ }
424
470
  }
425
471
 
426
472
  function refreshAll() { drawOverlay(); drawCategories(); drawTranscript(); syncActionButtons(); schedule(); }
@@ -518,10 +564,12 @@ export function attachController(host, initial = {}) {
518
564
  let found = [];
519
565
  if (!{ ocr: ocrMod, barcode: barMod, face: faceMod }[id]) throw new Error('detector not loaded');
520
566
  if (id === 'ocr') {
567
+ if (ocrMod.setOcrScope) ocrMod.setOcrScope(state.detector);
521
568
  const lines = await ocrMod.recognizeLines(page.canvas, (f) => !stale() && progress(si, f));
522
569
  page.lines = lines;
523
570
  page.ocr = 'done';
524
- found = regionsFromLines(lines, textTypes).map((r) => ({ ...r, hint: maskHint(r.text) }));
571
+ found = regionsFromLines(lines, textTypes, state.detector.findSensitive)
572
+ .map((r) => ({ ...r, hint: maskHint(r.text) }));
525
573
  } else if (id === 'barcode') {
526
574
  found = (await barMod.detectBarcodes(page.canvas)).map((r) => ({ ...r, type: 'barcode' }));
527
575
  } else {
@@ -537,7 +585,10 @@ export function attachController(host, initial = {}) {
537
585
  fails.add(id);
538
586
  if (id === 'ocr') page.ocr = 'fail';
539
587
  setStep(id, 'fail', 'unavailable');
540
- toast(`Couldn’t run ${STEPS.find((s) => s[0] === id)[1].toLowerCase()} detection – you can still draw boxes by hand.`, 5000);
588
+ const msg = String(err?.message || '');
589
+ toast(msg.startsWith('Text reading failed:')
590
+ ? msg
591
+ : `Couldn’t run ${STEPS.find((s) => s[0] === id)[1].toLowerCase()} detection – you can still draw boxes by hand.`, 5000);
541
592
  }
542
593
  }
543
594
  }
@@ -576,7 +627,6 @@ export function attachController(host, initial = {}) {
576
627
  const doc = await loadFile(file, (m) => ($('dropzone').querySelector('.dz-title').textContent = m));
577
628
  if (runId !== state.run) return;
578
629
  doc.pages = doc.pages.map((canvas) => ({ canvas, regions: [], lines: [], ocr: null }));
579
- setTranscriptOpen(false);
580
630
  state.transcriptRedacted = true;
581
631
  syncTranscriptRedact();
582
632
  state.doc = doc;
@@ -621,7 +671,6 @@ export function attachController(host, initial = {}) {
621
671
  $('file').value = '';
622
672
  $('dropzone').querySelector('.dz-title').textContent = DROP_TITLE;
623
673
  $('scanfx').hidden = true;
624
- setTranscriptOpen(false);
625
674
  showError('');
626
675
  import('../detect/ocr.js').then((m) => m.disposeOcr()).catch(() => {});
627
676
  }
@@ -661,6 +710,52 @@ export function attachController(host, initial = {}) {
661
710
  for (const id of TEXT_TYPES) appendPrefSwitch(ul, id);
662
711
  appendPrefGroup(ul, 'Picture');
663
712
  for (const id of PICTURE_SCAN_TYPES) appendPrefSwitch(ul, id);
713
+ drawLangPrefs();
714
+ }
715
+
716
+ /** One language chip (English locked, optionals toggle). */
717
+ function appendLangChip(ul, { id, label, mark, detail, locked, on }) {
718
+ const li = document.createElement('li');
719
+ const btn = document.createElement('button');
720
+ btn.type = 'button';
721
+ btn.className = `lang-chip${on ? ' on' : ''}`;
722
+ btn.dataset.lang = id;
723
+ btn.setAttribute('role', 'switch');
724
+ btn.setAttribute('aria-checked', String(on));
725
+ if (locked) btn.setAttribute('aria-disabled', 'true');
726
+ if (detail) btn.title = detail;
727
+ btn.append(span('mark', mark), document.createTextNode(label));
728
+ li.append(btn);
729
+ ul.append(li);
730
+ }
731
+
732
+ /** Rebuild language chips on the drop screen and beside the field list. */
733
+ function drawLangPrefs() {
734
+ const lists = root.querySelectorAll('[data-lang-prefs]');
735
+ for (const ul of lists) {
736
+ ul.replaceChildren();
737
+ appendLangChip(ul, {
738
+ id: 'en', label: 'English', mark: 'A', locked: true, on: true,
739
+ });
740
+ for (const pack of OPTIONAL_LANGUAGES) {
741
+ appendLangChip(ul, {
742
+ id: pack.id,
743
+ label: pack.label,
744
+ mark: 'अ',
745
+ locked: false,
746
+ on: state.languages[pack.id] === true,
747
+ });
748
+ }
749
+ }
750
+ }
751
+
752
+ /** Toggle an optional language; rescan the open file so OCR matches. */
753
+ function toggleLanguage(id) {
754
+ if (!id || id === 'en') return;
755
+ state.languages = saveLanguagePrefs({ ...state.languages, [id]: state.languages[id] !== true });
756
+ drawLangPrefs();
757
+ applyDetectorScope();
758
+ if (state.doc) rescanCurrent();
664
759
  }
665
760
 
666
761
  /** Show rescan only while a file is open, and keep a single primary button. */
@@ -731,6 +826,11 @@ export function attachController(host, initial = {}) {
731
826
  $('prefs').addEventListener('keydown', (e) => {
732
827
  if ((e.key === 'Enter' || e.key === ' ') && e.target.classList.contains('cat')) { e.preventDefault(); e.target.click(); }
733
828
  });
829
+ root.addEventListener('click', (e) => {
830
+ const chip = e.target.closest?.('.lang-chip[data-lang]');
831
+ if (!chip || !root.contains(chip) || chip.getAttribute('aria-disabled') === 'true') return;
832
+ toggleLanguage(chip.dataset.lang);
833
+ });
734
834
 
735
835
  let dragDepth = 0;
736
836
  /** True when a file drag is aimed at this element, not at another control on the page. */
@@ -880,9 +980,17 @@ export function attachController(host, initial = {}) {
880
980
 
881
981
  // The built-in Save button runs the same release path as a host action.
882
982
  $('btn-save').addEventListener('click', () => runAction(state.actions.find((a) => a.builtin) || downloadAction(), $('btn-save')));
883
- $('transcript-toggle').addEventListener('click', () => {
884
- setTranscriptOpen($('transcript-panel').hidden);
885
- });
983
+
984
+ /** Show the thin transcript scrollbar only while the person is scrolling. */
985
+ {
986
+ const pre = $('transcript-text');
987
+ let hideTimer = 0;
988
+ pre.addEventListener('scroll', () => {
989
+ pre.classList.add('is-scrolling');
990
+ clearTimeout(hideTimer);
991
+ hideTimer = setTimeout(() => pre.classList.remove('is-scrolling'), 700);
992
+ }, { passive: true });
993
+ }
886
994
 
887
995
  /** Switch the reading between redacted (default) and the original words. */
888
996
  $('transcript-redact').addEventListener('click', () => {
@@ -891,7 +999,7 @@ export function attachController(host, initial = {}) {
891
999
  drawTranscript();
892
1000
  });
893
1001
 
894
- /** Copy every page. Works while the panel is still folded, in whichever mode is showing. */
1002
+ /** Copy every page from the preview, in whichever mode is showing. */
895
1003
  $('btn-transcript-copy').addEventListener('click', async () => {
896
1004
  if (!state.doc) return;
897
1005
  const view = transcriptView();
@@ -902,7 +1010,7 @@ export function attachController(host, initial = {}) {
902
1010
  toast(`${kind} transcript copied.`);
903
1011
  } catch (err) {
904
1012
  console.error(err);
905
- toast('Your browser blocked clipboard access. Expand the transcript and select the text.', 4500);
1013
+ toast('Your browser blocked clipboard access. Select the text in the reading instead.', 4500);
906
1014
  }
907
1015
  });
908
1016
 
@@ -927,6 +1035,12 @@ export function attachController(host, initial = {}) {
927
1035
 
928
1036
  if (initial.style) setStyle(initial.style);
929
1037
  if (initial.strength != null) setStrength(initial.strength);
1038
+ if (initial.regions != null) state.regions = initial.regions;
1039
+ if (initial.languages != null) {
1040
+ state.languages = saveLanguagePrefs(prefsFromLanguages(initial.languages));
1041
+ }
1042
+ applyDetectorScope();
1043
+ drawLangPrefs();
930
1044
  setActions(initial.actions);
931
1045
  setScreen('drop');
932
1046
 
@@ -938,9 +1052,14 @@ export function attachController(host, initial = {}) {
938
1052
  setStyle,
939
1053
  setStrength,
940
1054
  setActions,
1055
+ setScope,
941
1056
  getActions: () => state.actions,
942
1057
  getStyle: () => state.style,
943
1058
  getStrength: () => state.strength,
1059
+ getScope: () => ({
1060
+ languages: languagesFromPrefs(state.languages),
1061
+ regions: [...state.regions],
1062
+ }),
944
1063
  /** Release page listeners. The element calls this when it leaves the document. */
945
1064
  dispose() {
946
1065
  cancelAnimationFrame(rafId);
@@ -83,6 +83,26 @@ class PiiRedactReview extends HTMLElement {
83
83
  this.open(value);
84
84
  }
85
85
 
86
+ /** Language pack ids or pack objects for detection and OCR. */
87
+ get languages() {
88
+ return this._api?.getScope()?.languages ?? this._languages;
89
+ }
90
+
91
+ set languages(value) {
92
+ this._languages = value;
93
+ this._api?.setScope({ languages: value, regions: this._regions });
94
+ }
95
+
96
+ /** Region pack ids for detection (US, CA, GB, IN). */
97
+ get regions() {
98
+ return this._api?.getScope()?.regions ?? this._regions;
99
+ }
100
+
101
+ set regions(value) {
102
+ this._regions = value;
103
+ this._api?.setScope({ languages: this._languages, regions: value });
104
+ }
105
+
86
106
  connectedCallback() {
87
107
  if (this._api) return;
88
108
  if (!this.shadowRoot) this.attachShadow({ mode: 'open' });
@@ -92,10 +112,15 @@ class PiiRedactReview extends HTMLElement {
92
112
  markup.innerHTML = reviewTemplate;
93
113
  this.shadowRoot.replaceChildren(style, markup.content.cloneNode(true));
94
114
  const strengthAttr = this.getAttribute('strength');
115
+ const langAttr = this.getAttribute('languages');
116
+ const regionAttr = this.getAttribute('regions');
117
+ const parseIds = (raw) => (raw == null || raw === '' ? undefined : raw.trim().split(/\s+/).filter(Boolean));
95
118
  this._api = attachController(this, {
96
119
  style: this._redactStyle || this.getAttribute('redact-style') || undefined,
97
120
  strength: this._strength ?? (strengthAttr != null && strengthAttr !== '' ? Number(strengthAttr) : undefined),
98
121
  actions: this._actions,
122
+ languages: this._languages ?? parseIds(langAttr),
123
+ regions: this._regions ?? parseIds(regionAttr),
99
124
  });
100
125
  if (this._pendingFile) this._api.open(this._pendingFile);
101
126
  }
@@ -5,10 +5,12 @@ import { createElement, useEffect, useRef } from 'react';
5
5
  import './element.js';
6
6
 
7
7
  /** Drop-in review screen. `onResult` runs when the person saves, and only then. */
8
- export function PrivacyRedactReview({ file, style, strength, actions, onResult }) {
8
+ export function PrivacyRedactReview({ file, style, strength, actions, languages, regions, onResult }) {
9
9
  const ref = useRef(null);
10
10
  // Compare the action list by value, so an inline array does not reset the screen on every render.
11
11
  const actionsKey = actions ? JSON.stringify(actions) : '';
12
+ const languagesKey = languages ? JSON.stringify(languages) : '';
13
+ const regionsKey = regions ? JSON.stringify(regions) : '';
12
14
 
13
15
  useEffect(() => {
14
16
  const el = ref.current;
@@ -42,5 +44,17 @@ export function PrivacyRedactReview({ file, style, strength, actions, onResult }
42
44
  el.actions = actions;
43
45
  }, [actionsKey]);
44
46
 
47
+ useEffect(() => {
48
+ const el = ref.current;
49
+ if (!el || languages == null) return;
50
+ el.languages = languages;
51
+ }, [languagesKey]);
52
+
53
+ useEffect(() => {
54
+ const el = ref.current;
55
+ if (!el || regions == null) return;
56
+ el.regions = regions;
57
+ }, [regionsKey]);
58
+
45
59
  return createElement('privacy-redact-review', { ref });
46
60
  }
@@ -130,7 +130,6 @@
130
130
  .seg button:focus-visible,
131
131
  .fmt select:focus-visible,
132
132
  .slider input:focus-visible,
133
- .transcript-toggle:focus-visible,
134
133
  .transcript-redact:focus-visible,
135
134
  .cat:focus-visible {
136
135
  outline: none;
@@ -180,6 +179,49 @@
180
179
  }
181
180
  .dz-sub { color: var(--on-surface-muted); margin-top: 0.5rem; font-size: 14px; line-height: 1.6; }
182
181
  .dz-formats { color: var(--on-surface-muted); font-size: 13px; font-weight: 400; margin-top: 1rem; letter-spacing: 0.04em; }
182
+ .lang-chips {
183
+ list-style: none;
184
+ margin: 0;
185
+ padding: 0;
186
+ display: flex;
187
+ flex-wrap: wrap;
188
+ gap: 0.4rem;
189
+ }
190
+ .landing-langs {
191
+ justify-content: center;
192
+ margin: 0.85rem auto 0;
193
+ max-width: 38rem;
194
+ }
195
+ .lang-chips .lang-chip {
196
+ display: inline-flex;
197
+ align-items: center;
198
+ gap: 0.3rem;
199
+ margin: 0;
200
+ padding: 0.35rem 0.65rem;
201
+ border: 1px solid color-mix(in srgb, var(--on-surface) 14%, transparent);
202
+ border-radius: var(--radius-md);
203
+ background: var(--surface);
204
+ color: var(--on-surface);
205
+ font: inherit;
206
+ font-size: 13px;
207
+ line-height: 1.3;
208
+ cursor: pointer;
209
+ transition: background var(--ease), border-color var(--ease);
210
+ }
211
+ .lang-chips .lang-chip:hover {
212
+ border-color: color-mix(in srgb, var(--accent) 45%, transparent);
213
+ }
214
+ .lang-chips .lang-chip.on {
215
+ background: color-mix(in srgb, var(--accent) 14%, var(--surface));
216
+ border-color: color-mix(in srgb, var(--accent) 55%, transparent);
217
+ }
218
+ .lang-chips .lang-chip[aria-disabled="true"] {
219
+ cursor: default;
220
+ }
221
+ .lang-chips .lang-chip .mark {
222
+ font-size: 12px;
223
+ line-height: 1;
224
+ }
183
225
  .settings-cue { margin-top: 1rem; }
184
226
  .error {
185
227
  margin: 1rem auto 0;
@@ -351,17 +393,15 @@
351
393
  #scan-card.done .scan-steps { margin-bottom: 0; }
352
394
  #scan-card.done .scan-steps li:not(.done) { display: none; }
353
395
 
354
- .transcript-head { display: flex; align-items: center; flex-wrap: wrap; gap: 0.75rem; min-width: 0; max-width: 100%; }
396
+ .panel-langs { margin: 0; }
355
397
  .transcript-actions {
356
398
  display: flex;
357
399
  align-items: center;
358
400
  flex-wrap: wrap;
359
401
  gap: 0.5rem;
360
- margin-left: auto;
361
- min-width: 0;
362
- max-width: 100%;
402
+ justify-content: flex-start;
403
+ margin: -0.25rem 0 0;
363
404
  }
364
- .transcript-actions > * { flex: none; max-width: 100%; }
365
405
  .transcript-redact {
366
406
  font-family: var(--font-ui);
367
407
  font-size: 13px;
@@ -376,44 +416,9 @@
376
416
  box-shadow: var(--shadow-sm);
377
417
  }
378
418
  .transcript-redact.on { color: var(--on-surface); background: var(--surface-sunken); }
379
- #transcript-empty:not([hidden]) + #transcript-text:not([hidden]) { margin-top: 0.75rem; }
380
- .transcript-toggle {
381
- flex: 1 1 auto;
382
- display: flex;
383
- align-items: center;
384
- gap: 0.75rem;
385
- min-width: 0;
386
- max-width: 100%;
387
- margin: 0;
388
- padding: 0;
389
- border: 0;
390
- background: transparent;
391
- box-shadow: none;
392
- cursor: pointer;
393
- text-align: left;
394
- font-family: var(--font-display);
395
- font-size: 1.25rem;
396
- font-weight: 300;
397
- line-height: 1.4;
398
- letter-spacing: -0.02em;
399
- color: var(--on-surface);
400
- }
401
- .transcript-toggle:hover { background: transparent; transform: none; box-shadow: none; }
402
- .transcript-toggle #transcript-label { min-width: 0; overflow-wrap: anywhere; }
403
- .twist {
404
- width: 0.45rem;
405
- height: 0.45rem;
406
- border-right: 1.5px solid var(--on-surface-muted);
407
- border-bottom: 1.5px solid var(--on-surface-muted);
408
- transform: rotate(-45deg);
409
- transition: transform var(--ease);
410
- flex: none;
411
- }
412
- .transcript.open .twist { transform: rotate(45deg); }
413
- #transcript-panel { margin-top: 1rem; }
414
- #transcript-empty { text-align: left; }
419
+ #transcript-empty { text-align: left; margin: 0.75rem 0 0; }
415
420
  #transcript-text {
416
- margin: 0;
421
+ margin: 0.75rem 0 0;
417
422
  max-height: 16rem;
418
423
  overflow: auto;
419
424
  padding: 1rem;
@@ -427,7 +432,27 @@
427
432
  overflow-wrap: anywhere;
428
433
  user-select: text;
429
434
  color: var(--on-surface);
435
+ scrollbar-width: thin;
436
+ scrollbar-color: transparent transparent;
437
+ }
438
+ #transcript-text.is-scrolling {
439
+ scrollbar-color: color-mix(in srgb, var(--on-surface) 28%, transparent) transparent;
440
+ }
441
+ #transcript-text::-webkit-scrollbar {
442
+ width: 3px;
443
+ height: 3px;
444
+ }
445
+ #transcript-text::-webkit-scrollbar-track {
446
+ background: transparent;
447
+ }
448
+ #transcript-text::-webkit-scrollbar-thumb {
449
+ background: transparent;
450
+ border-radius: 99px;
451
+ }
452
+ #transcript-text.is-scrolling::-webkit-scrollbar-thumb {
453
+ background: color-mix(in srgb, var(--on-surface) 28%, transparent);
430
454
  }
455
+ .transcript-stats { margin: 0.5rem 0 0; text-align: left; }
431
456
 
432
457
  .cats { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.25rem; }
433
458
  .cat {
@@ -10,8 +10,9 @@ export const reviewTemplate = `
10
10
  <div class="dz-sub">or <u>browse</u> · or paste with <kbd>Ctrl</kbd>/<kbd>⌘</kbd>+<kbd>V</kbd></div>
11
11
  <div class="dz-formats">PNG · JPG · WebP · GIF · PDF</div>
12
12
  </label>
13
+ <ul id="landing-lang-prefs" class="lang-chips landing-langs" data-lang-prefs role="group" aria-label="Document languages"></ul>
13
14
  <div class="settings-cue">
14
- <button id="btn-settings-landing" class="btn ghost sm" type="button">Choose fields to scan</button>
15
+ <button id="btn-settings-landing" class="btn ghost sm" type="button">Choose what to scan</button>
15
16
  </div>
16
17
  <div id="landing-error" class="error" role="alert" hidden></div>
17
18
  </div>
@@ -59,6 +60,8 @@ export const reviewTemplate = `
59
60
  </div>
60
61
 
61
62
  <aside class="panel">
63
+ <ul id="panel-lang-prefs" class="lang-chips panel-langs" data-lang-prefs role="group" aria-label="Document languages"></ul>
64
+
62
65
  <div class="card" id="scan-card">
63
66
  <div class="card-head"><h2 id="scan-title">Scanning…</h2><span id="scan-count" class="count-badge"></span></div>
64
67
  <ul id="steps" class="scan-steps"></ul>
@@ -67,21 +70,16 @@ export const reviewTemplate = `
67
70
  </div>
68
71
 
69
72
  <div class="card transcript" id="transcript-card">
70
- <div class="transcript-head">
71
- <button type="button" id="transcript-toggle" class="transcript-toggle" aria-expanded="false" aria-controls="transcript-panel">
72
- <span class="twist" aria-hidden="true"></span>
73
- <span id="transcript-label">What the scanner read</span>
74
- </button>
75
- <span class="transcript-actions">
76
- <button type="button" id="transcript-redact" class="transcript-redact on" role="switch" aria-checked="true" title="Hide the words the scanner would cover">Redacted</button>
77
- <span id="transcript-count" class="count-badge"></span>
78
- <button id="btn-transcript-copy" class="btn ghost sm" type="button" disabled>Copy text</button>
79
- </span>
73
+ <div class="card-head">
74
+ <h2 id="transcript-label">What the scanner read</h2>
80
75
  </div>
81
- <div id="transcript-panel" hidden>
82
- <p id="transcript-empty" class="fine" hidden></p>
83
- <pre id="transcript-text"></pre>
76
+ <div class="transcript-actions">
77
+ <button type="button" id="transcript-redact" class="transcript-redact on" role="switch" aria-checked="true" title="Hide the words the scanner would cover">Redacted</button>
78
+ <button id="btn-transcript-copy" class="btn ghost sm" type="button" disabled>Copy text</button>
84
79
  </div>
80
+ <p id="transcript-empty" class="fine" hidden></p>
81
+ <pre id="transcript-text" hidden></pre>
82
+ <p id="transcript-stats" class="fine transcript-stats" hidden></p>
85
83
  </div>
86
84
 
87
85
  <div class="card">