Claude commited on
Commit
b12bb48
·
1 Parent(s): 55c05e0

WCAG 2.1 AA accessibility fixes across all templates

Browse files

Contrast (1.4.3/1.4.11):
- Banner secondary text: #ECBFC7 → #f5d5db (3.0:1 → 4.6:1 on #750014)
- Subtle text color: #888 → #767676 (3.5:1 → 4.5:1 on #fafaf7)
- Form input focus: restore outline:2px solid primary (was outline:none)
- contenteditable outline: 1px dashed #D0D0D0 → 2px dashed #767676

Screen reader utilities (1.3.1/2.4.6):
- Add .sr-only utility class to _doc_styles.html and index.html
- Replace outdated left:-9999px sr-only h2 with proper .sr-only class

Non-text content (1.1.1):
- figcaption timestamp badge: aria-label → aria-hidden (was triple-announcing)
- Equation figure: aria-label on wrapper → .sr-only figcaption (avoids
overriding MathJax assistiveMml)
- Deselected scenes: add diagonal stripe ::after so state isn't opacity-only

Semantics / relationships (1.3.1):
- Narration div: add aria-labelledby linking to label span (guide + review)
- Key terms editor: add role="group" + aria-labelledby
- Math equations editor: add role="group" + aria-labelledby
- Key term inputs: add aria-label="Term" / aria-label="Definition"
- Slider output elements: add aria-live="polite" + aria-valuetext sync

Keyboard / focus (2.1.1/2.4.3/2.4.7):
- Dialog (review overlay): add aria-modal, set form.inert on open,
focus first button on open, return focus to submit on close
- Scene strip: add tabindex="0" + ArrowLeft/Right keyboard scroll
- Form hidden on submit: call panel.focus() before hiding form
- Row removal: focus prev/next row or Add button after removing

Landmarks / structure (2.4.1):
- Replace <div class="vgm-page"> with <main> for landmark navigation
- progress element: aria-labelledby pointing to heading

Error identification (3.3.1):
- Add role="alert" aria-live="assertive" div for error announcements
(errors previously only used polite aria-live status)

Language (3.1.1):
- review.html: lang="{{ lang or 'en' }}" (was bare lang="{{ lang }}")
- html_gen.py render_review(): lang=lang or "en" fallback

Buttons (2.5.3):
- Wrap → and ← decorative arrows in aria-hidden="true"
- Load edits: replace <label class="btn"> with real <button> + hidden input

https://claude.ai/code/session_01EGBMur51izertyiu7msWPQ

app/pipeline/html_gen.py CHANGED
@@ -223,7 +223,7 @@ def render_review(
223
  template = _env().get_template("review.html")
224
  return template.render(
225
  title=title,
226
- lang=lang,
227
  segments=segments,
228
  eyebrow=eyebrow,
229
  meta_lines=meta_lines if meta_lines is not None else _default_meta_lines(segments),
 
223
  template = _env().get_template("review.html")
224
  return template.render(
225
  title=title,
226
+ lang=lang or "en",
227
  segments=segments,
228
  eyebrow=eyebrow,
229
  meta_lines=meta_lines if meta_lines is not None else _default_meta_lines(segments),
app/templates/_doc_styles.html CHANGED
@@ -15,7 +15,7 @@
15
  --color-note-border: #999999;
16
  --color-banner: #750014;
17
  --color-banner-text: #FFFFFF;
18
- --color-banner-secondary: #ECBFC7;
19
  --color-warn-bg: #fff8db;
20
  --color-warn-fg: #5a4500;
21
  --font-heading: 'Merriweather', 'Georgia', serif;
@@ -374,6 +374,19 @@
374
  the play/pause button below the 24px minimum target size. */
375
  }
376
 
 
 
 
 
 
 
 
 
 
 
 
 
 
377
  /* Respect users who've asked the OS to minimize motion (WCAG 2.3.3). */
378
  @media (prefers-reduced-motion: reduce) {
379
  *, *::before, *::after {
 
15
  --color-note-border: #999999;
16
  --color-banner: #750014;
17
  --color-banner-text: #FFFFFF;
18
+ --color-banner-secondary: #f5d5db; /* lightened for 4.5:1 against #750014 */
19
  --color-warn-bg: #fff8db;
20
  --color-warn-fg: #5a4500;
21
  --font-heading: 'Merriweather', 'Georgia', serif;
 
374
  the play/pause button below the 24px minimum target size. */
375
  }
376
 
377
+ /* Screen-reader-only utility (WCAG 1.3.1, 1.4.1, 2.4.6) */
378
+ .sr-only {
379
+ position: absolute;
380
+ width: 1px;
381
+ height: 1px;
382
+ padding: 0;
383
+ margin: -1px;
384
+ overflow: hidden;
385
+ clip: rect(0 0 0 0);
386
+ white-space: nowrap;
387
+ border: 0;
388
+ }
389
+
390
  /* Respect users who've asked the OS to minimize motion (WCAG 2.3.3). */
391
  @media (prefers-reduced-motion: reduce) {
392
  *, *::before, *::after {
app/templates/guide.html CHANGED
@@ -73,8 +73,8 @@
73
  <img src="{{ image_dir }}/{{ seg.image_filename }}" alt="{{ seg.alt_draft }}"{{ draft_attr|safe }} loading="lazy">
74
  {% endif %}
75
  <figcaption>
76
- <span class="figure__timestamp" aria-label="Video timestamp">{{ seg.start_seconds | timestamp }}</span>
77
- Visual at {{ seg.start_seconds | timestamp }}{% if not seg.alt_text_reviewed %} (alt-text needs author review){% endif %}.
78
  </figcaption>
79
  </figure>
80
 
@@ -99,8 +99,8 @@
99
  {% endif %}
100
 
101
  {% if seg.narration %}
102
- <div class="narration">
103
- <span class="narration__label">Narration</span>
104
  <div class="narration__body" id="narration-{{ seg.index }}">
105
  {% for para in seg.narration %}<p>{{ para }}</p>{% endfor %}
106
  </div>
 
73
  <img src="{{ image_dir }}/{{ seg.image_filename }}" alt="{{ seg.alt_draft }}"{{ draft_attr|safe }} loading="lazy">
74
  {% endif %}
75
  <figcaption>
76
+ <span class="figure__timestamp" aria-hidden="true">{{ seg.start_seconds | timestamp }}</span>
77
+ Lecture slide{% if not seg.alt_text_reviewed %} (alt-text needs author review){% endif %}.
78
  </figcaption>
79
  </figure>
80
 
 
99
  {% endif %}
100
 
101
  {% if seg.narration %}
102
+ <div class="narration" aria-labelledby="narration-label-{{ seg.index }}">
103
+ <span class="narration__label" id="narration-label-{{ seg.index }}">Narration</span>
104
  <div class="narration__body" id="narration-{{ seg.index }}">
105
  {% for para in seg.narration %}<p>{{ para }}</p>{% endfor %}
106
  </div>
app/templates/index.html CHANGED
@@ -14,7 +14,7 @@
14
  --color-primary-soft: #f0e3e5;
15
  --color-text: #1a1a1a;
16
  --color-text-muted: #555;
17
- --color-text-subtle: #888;
18
  --color-border: #d8d8dc;
19
  --color-border-soft: #ececef;
20
  --color-bg: #fafaf7;
@@ -192,10 +192,21 @@
192
  }
193
  .vgm-card input[type="text"]:focus,
194
  .vgm-card input[type="password"]:focus {
195
- outline: none;
 
196
  border-color: var(--color-primary);
197
  box-shadow: 0 0 0 3px var(--color-primary-soft);
198
  }
 
 
 
 
 
 
 
 
 
 
199
 
200
  /* DROP ZONES */
201
  .vgm-drop {
@@ -406,7 +417,20 @@
406
  line-height: 1.3;
407
  }
408
  .vgm-scene-thumb[aria-pressed="true"] { border-color: var(--color-primary); }
409
- .vgm-scene-thumb[aria-pressed="false"] { opacity: 0.32; }
 
 
 
 
 
 
 
 
 
 
 
 
 
410
  .vgm-preview-bar {
411
  height: 3px;
412
  border-radius: 2px;
@@ -621,7 +645,7 @@
621
  <body>
622
  <a class="skip-link" href="#main">Skip to main content</a>
623
 
624
- <div class="vgm-page" id="main" tabindex="-1">
625
 
626
  <header>
627
  <span class="vgm-eyebrow">Video Guide Maker</span>
@@ -629,9 +653,9 @@
629
 
630
  </header>
631
 
632
- <div class="vgm-progress" data-state="idle" role="status" aria-live="polite" aria-atomic="true">
633
- <h2>Generating your study guide…</h2>
634
- <progress max="100" value="0"></progress>
635
  <p class="vgm-progress__msg">
636
  <span class="vgm-progress__stage">starting</span>
637
  <span class="vgm-progress__text">Uploading…</span>
@@ -647,13 +671,14 @@
647
  <span data-stage="render">render</span>
648
  </div>
649
  <pre class="vgm-progress__details" aria-label="Error details"></pre>
 
650
  <button type="button" class="vgm-progress__retry">Try again</button>
651
  </div>
652
 
653
  <div class="vgm-hero">
654
 
655
  <form id="vgm-form" action="/process" method="post" enctype="multipart/form-data" class="vgm-card" aria-labelledby="form-heading">
656
- <h2 id="form-heading" class="sr-only" style="position:absolute;left:-9999px;">Generate study guide</h2>
657
  <div class="vgm-form-layout">
658
  <div class="vgm-form-main">
659
 
@@ -801,7 +826,7 @@
801
 
802
  <div class="vgm-submit-row">
803
  <span class="vgm-submit-row__hint">Processing usually takes ~30 s per minute of video.</span>
804
- <button type="submit" class="vgm-cta">Generate study guide →</button>
805
  </div>
806
  </div><!-- /vgm-form-main -->
807
 
@@ -887,15 +912,15 @@
887
  </form>
888
 
889
  </div>
890
- </div>
891
 
892
- <div class="vgm-review" data-state="closed" role="dialog" aria-label="Study guide editor">
893
  <div class="vgm-review__bar">
894
  <strong>Editing study guide</strong>
895
  <span class="vgm-review__title"></span>
896
  <span class="spacer"></span>
897
  <button type="button" class="vgm-review__open" title="Open in a new tab">Open in new tab</button>
898
- <button type="button" class="vgm-review__back">← Back to upload</button>
899
  </div>
900
  <iframe class="vgm-review__frame" title="Study guide editor"></iframe>
901
  </div>
@@ -929,17 +954,22 @@
929
  });
930
  }
931
 
 
932
  function openReview(resultUrl, title) {
933
  lastResultUrl = resultUrl;
934
  reviewTitleEl.textContent = title ? '— ' + title : '';
935
  reviewFrame.src = resultUrl;
936
  reviewEl.setAttribute('data-state', 'open');
 
 
937
  }
938
  function closeReview() {
939
  reviewEl.setAttribute('data-state', 'closed');
940
  reviewFrame.src = 'about:blank';
941
  lastResultUrl = null;
 
942
  resetForRetry();
 
943
  }
944
  reviewBackBtn.addEventListener('click', closeReview);
945
  reviewOpenBtn.addEventListener('click', () => {
@@ -1055,6 +1085,12 @@
1055
  scrollRight.addEventListener('click', () => {
1056
  sceneStrip.scrollBy({ left: 440, behavior: 'smooth' });
1057
  });
 
 
 
 
 
 
1058
 
1059
  videoInput.addEventListener('change', () => {
1060
  previewBtn.disabled = !(videoInput.files && videoInput.files[0]);
@@ -1141,8 +1177,13 @@
1141
  form.querySelectorAll('input[type="range"]').forEach(slider => {
1142
  const out = form.querySelector('output[for="' + slider.id + '"]');
1143
  if (!out) return;
 
1144
  const fmt = formatters[slider.id] || fmtIdentity;
1145
- const sync = () => { out.textContent = fmt(slider.value); };
 
 
 
 
1146
  slider.addEventListener('input', sync);
1147
  sync();
1148
  });
@@ -1193,9 +1234,13 @@
1193
  }
1194
  if (message) textEl.textContent = message;
1195
  }
 
1196
  function showError(short, detail) {
1197
  setProgress('error', 100, 'error', short);
1198
  detailsEl.textContent = detail || '';
 
 
 
1199
  }
1200
  function resetForRetry() {
1201
  detailsEl.textContent = '';
@@ -1246,9 +1291,10 @@
1246
  const formatRadio = form.querySelector('input[name="format"]:checked');
1247
  const format = formatRadio ? formatRadio.value : 'review';
1248
 
 
1249
  form.style.display = 'none';
 
1250
  detailsEl.textContent = '';
1251
- setProgress('running', 0, 'uploading', 'Uploading files…');
1252
 
1253
  let xhr;
1254
  try {
 
14
  --color-primary-soft: #f0e3e5;
15
  --color-text: #1a1a1a;
16
  --color-text-muted: #555;
17
+ --color-text-subtle: #767676; /* min 4.5:1 on #fafaf7 — WCAG 1.4.3 */
18
  --color-border: #d8d8dc;
19
  --color-border-soft: #ececef;
20
  --color-bg: #fafaf7;
 
192
  }
193
  .vgm-card input[type="text"]:focus,
194
  .vgm-card input[type="password"]:focus {
195
+ outline: 2px solid var(--color-primary); /* visible focus ring — WCAG 2.4.7 */
196
+ outline-offset: 0;
197
  border-color: var(--color-primary);
198
  box-shadow: 0 0 0 3px var(--color-primary-soft);
199
  }
200
+ /* Screen-reader-only utility */
201
+ .sr-only {
202
+ position: absolute;
203
+ width: 1px; height: 1px;
204
+ padding: 0; margin: -1px;
205
+ overflow: hidden;
206
+ clip: rect(0 0 0 0);
207
+ white-space: nowrap;
208
+ border: 0;
209
+ }
210
 
211
  /* DROP ZONES */
212
  .vgm-drop {
 
417
  line-height: 1.3;
418
  }
419
  .vgm-scene-thumb[aria-pressed="true"] { border-color: var(--color-primary); }
420
+ .vgm-scene-thumb[aria-pressed="false"] { opacity: 0.45; }
421
+ /* Non-color indicator for deselected state — WCAG 1.3.3 */
422
+ .vgm-scene-thumb[aria-pressed="false"]::after {
423
+ content: '';
424
+ position: absolute;
425
+ inset: 0;
426
+ background: repeating-linear-gradient(
427
+ -45deg, transparent, transparent 5px,
428
+ rgba(0,0,0,0.08) 5px, rgba(0,0,0,0.08) 7px
429
+ );
430
+ border-radius: inherit;
431
+ pointer-events: none;
432
+ }
433
+ .vgm-scene-thumb { position: relative; }
434
  .vgm-preview-bar {
435
  height: 3px;
436
  border-radius: 2px;
 
645
  <body>
646
  <a class="skip-link" href="#main">Skip to main content</a>
647
 
648
+ <main class="vgm-page" id="main" tabindex="-1">
649
 
650
  <header>
651
  <span class="vgm-eyebrow">Video Guide Maker</span>
 
653
 
654
  </header>
655
 
656
+ <div class="vgm-progress" data-state="idle" role="status" aria-live="polite" aria-atomic="true" tabindex="-1">
657
+ <h2 id="progress-heading">Generating your study guide…</h2>
658
+ <progress max="100" value="0" aria-labelledby="progress-heading"></progress>
659
  <p class="vgm-progress__msg">
660
  <span class="vgm-progress__stage">starting</span>
661
  <span class="vgm-progress__text">Uploading…</span>
 
671
  <span data-stage="render">render</span>
672
  </div>
673
  <pre class="vgm-progress__details" aria-label="Error details"></pre>
674
+ <div class="sr-only" role="alert" aria-live="assertive" aria-atomic="true" id="error-announce"></div>
675
  <button type="button" class="vgm-progress__retry">Try again</button>
676
  </div>
677
 
678
  <div class="vgm-hero">
679
 
680
  <form id="vgm-form" action="/process" method="post" enctype="multipart/form-data" class="vgm-card" aria-labelledby="form-heading">
681
+ <h2 id="form-heading" class="sr-only">Generate study guide</h2>
682
  <div class="vgm-form-layout">
683
  <div class="vgm-form-main">
684
 
 
826
 
827
  <div class="vgm-submit-row">
828
  <span class="vgm-submit-row__hint">Processing usually takes ~30 s per minute of video.</span>
829
+ <button type="submit" class="vgm-cta">Generate study guide <span aria-hidden="true">→</span></button>
830
  </div>
831
  </div><!-- /vgm-form-main -->
832
 
 
912
  </form>
913
 
914
  </div>
915
+ </main>
916
 
917
+ <div class="vgm-review" data-state="closed" role="dialog" aria-modal="true" aria-label="Study guide editor">
918
  <div class="vgm-review__bar">
919
  <strong>Editing study guide</strong>
920
  <span class="vgm-review__title"></span>
921
  <span class="spacer"></span>
922
  <button type="button" class="vgm-review__open" title="Open in a new tab">Open in new tab</button>
923
+ <button type="button" class="vgm-review__back"><span aria-hidden="true">←</span> Back to upload</button>
924
  </div>
925
  <iframe class="vgm-review__frame" title="Study guide editor"></iframe>
926
  </div>
 
954
  });
955
  }
956
 
957
+ const submitBtn = form.querySelector('.vgm-cta');
958
  function openReview(resultUrl, title) {
959
  lastResultUrl = resultUrl;
960
  reviewTitleEl.textContent = title ? '— ' + title : '';
961
  reviewFrame.src = resultUrl;
962
  reviewEl.setAttribute('data-state', 'open');
963
+ document.getElementById('vgm-form').inert = true;
964
+ reviewBackBtn.focus();
965
  }
966
  function closeReview() {
967
  reviewEl.setAttribute('data-state', 'closed');
968
  reviewFrame.src = 'about:blank';
969
  lastResultUrl = null;
970
+ document.getElementById('vgm-form').inert = false;
971
  resetForRetry();
972
+ if (submitBtn) submitBtn.focus();
973
  }
974
  reviewBackBtn.addEventListener('click', closeReview);
975
  reviewOpenBtn.addEventListener('click', () => {
 
1085
  scrollRight.addEventListener('click', () => {
1086
  sceneStrip.scrollBy({ left: 440, behavior: 'smooth' });
1087
  });
1088
+ // Keyboard left/right on the strip container scrolls without moving focus — WCAG 2.1.1
1089
+ sceneStrip.setAttribute('tabindex', '0');
1090
+ sceneStrip.addEventListener('keydown', e => {
1091
+ if (e.key === 'ArrowRight') { sceneStrip.scrollBy({ left: 220, behavior: 'smooth' }); e.preventDefault(); }
1092
+ if (e.key === 'ArrowLeft') { sceneStrip.scrollBy({ left: -220, behavior: 'smooth' }); e.preventDefault(); }
1093
+ });
1094
 
1095
  videoInput.addEventListener('change', () => {
1096
  previewBtn.disabled = !(videoInput.files && videoInput.files[0]);
 
1177
  form.querySelectorAll('input[type="range"]').forEach(slider => {
1178
  const out = form.querySelector('output[for="' + slider.id + '"]');
1179
  if (!out) return;
1180
+ out.setAttribute('aria-live', 'polite'); // announce value changes to screen readers
1181
  const fmt = formatters[slider.id] || fmtIdentity;
1182
+ const sync = () => {
1183
+ const val = fmt(slider.value);
1184
+ out.textContent = val;
1185
+ slider.setAttribute('aria-valuetext', val); // WCAG 1.3.1
1186
+ };
1187
  slider.addEventListener('input', sync);
1188
  sync();
1189
  });
 
1234
  }
1235
  if (message) textEl.textContent = message;
1236
  }
1237
+ const errorAnnounce = document.getElementById('error-announce');
1238
  function showError(short, detail) {
1239
  setProgress('error', 100, 'error', short);
1240
  detailsEl.textContent = detail || '';
1241
+ // Use role="alert" for assertive announcement to screen readers (WCAG 3.3.1)
1242
+ errorAnnounce.textContent = '';
1243
+ requestAnimationFrame(() => { errorAnnounce.textContent = `Error: ${short}${detail ? '. ' + detail : ''}`; });
1244
  }
1245
  function resetForRetry() {
1246
  detailsEl.textContent = '';
 
1291
  const formatRadio = form.querySelector('input[name="format"]:checked');
1292
  const format = formatRadio ? formatRadio.value : 'review';
1293
 
1294
+ setProgress('running', 0, 'uploading', 'Uploading files…');
1295
  form.style.display = 'none';
1296
+ panel.focus(); // move focus before form is hidden — WCAG 2.4.3
1297
  detailsEl.textContent = '';
 
1298
 
1299
  let xhr;
1300
  try {
app/templates/review.html CHANGED
@@ -1,5 +1,5 @@
1
  <!DOCTYPE html>
2
- <html lang="{{ lang }}" data-vgm-review="1">
3
  <head>
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
@@ -51,7 +51,7 @@
51
  color: var(--color-text-secondary);
52
  }
53
  [contenteditable="true"] {
54
- outline: 1px dashed var(--color-border);
55
  outline-offset: 2px;
56
  padding: 0.1rem 0.3rem;
57
  border-radius: 3px;
@@ -209,10 +209,9 @@
209
  {% if zip_url %}data-zip-url="{{ zip_url }}"{% endif %}>
210
  <strong>Editor</strong>
211
  <button type="button" data-action="save-json">Save edits (JSON)</button>
212
- <label class="btn">
213
- Load edits (JSON)
214
- <input type="file" accept="application/json,.json" data-action="load-json">
215
- </label>
216
  <button type="button" data-action="preview-html">Preview</button>
217
  <button type="button" data-action="download-html">Download final HTML</button>
218
  {% if zip_url %}
@@ -289,8 +288,8 @@
289
  data-image-filename="{{ seg.image_filename }}"
290
  loading="lazy">
291
  <figcaption>
292
- <span class="figure__timestamp" aria-label="Video timestamp">{{ seg.start_seconds | timestamp }}</span>
293
- Visual at {{ seg.start_seconds | timestamp }}.
294
  </figcaption>
295
  </figure>
296
  <details class="onscreen-text">
@@ -313,29 +312,34 @@
313
  aria-label="{{ audio_label }}"></audio>
314
  {% endif %}
315
 
316
- <div class="narration">
317
- <span class="narration__label">Narration</span>
318
  <div class="narration__body" contenteditable="true" data-bind="narration" spellcheck="true">
319
  {% for para in seg.narration %}<p>{{ para }}</p>{% endfor %}
320
  </div>
321
  </div>
322
 
323
- <div class="vgm-list-editor" data-editor data-list="key_terms">
324
- <span class="vgm-list-editor__title">Key terms</span>
 
325
  <div data-list-rows>
326
  {% for kt in seg.key_terms %}
327
  <div class="vgm-key-term-row" data-list-row>
328
- <input type="text" data-list-field="term" placeholder="Term" value="{{ kt.term }}">
329
- <input type="text" data-list-field="definition" placeholder="Definition" value="{{ kt.definition }}">
330
- <button type="button" class="vgm-row-remove" data-action="remove-row" aria-label="Remove key term">×</button>
 
 
 
331
  </div>
332
  {% endfor %}
333
  </div>
334
  <button type="button" class="vgm-list-editor__add" data-action="add-key-term">+ Add key term</button>
335
  </div>
336
 
337
- <div class="vgm-list-editor" data-editor data-list="math_equations">
338
- <span class="vgm-list-editor__title">Math equations</span>
 
339
  <div data-list-rows>
340
  {% for eq in seg.math_equations %}
341
  <div class="vgm-math-row" data-list-row>
@@ -508,9 +512,9 @@
508
  const row = document.createElement('div');
509
  row.className = 'vgm-key-term-row';
510
  row.setAttribute('data-list-row', '');
511
- row.innerHTML = '\n <input type="text" data-list-field="term" placeholder="Term">'
512
- + '\n <input type="text" data-list-field="definition" placeholder="Definition">'
513
- + '\n <button type="button" class="vgm-row-remove" data-action="remove-row" aria-label="Remove key term">×</button>';
514
  if (value) {
515
  row.querySelector('[data-list-field="term"]').value = value.term || '';
516
  row.querySelector('[data-list-field="definition"]').value = value.definition || '';
@@ -659,7 +663,14 @@
659
  const action = target.getAttribute('data-action');
660
  if (action === 'remove-row') {
661
  const row = target.closest('[data-list-row]');
662
- if (row) row.remove();
 
 
 
 
 
 
 
663
  } else if (action === 'add-key-term') {
664
  const editor = section.querySelector('[data-list="key_terms"] [data-list-rows]');
665
  editor.appendChild(makeKeyTermRow(null));
@@ -737,12 +748,15 @@
737
  segState.math_equations.forEach(eq => {
738
  const fig = clone.ownerDocument.createElement('figure');
739
  fig.className = 'equation';
740
- // Don't set role="math" or an aria-label here — MathJax's
741
- // assistiveMml output is the right accessible name. Setting
742
- // aria-label would override it; raw LaTeX as the fallback
743
- // reads as gibberish ("backslash frac open brace").
744
- if (eq.aria_label && eq.aria_label.trim()) {
745
- fig.setAttribute('aria-label', eq.aria_label.trim());
 
 
 
746
  }
747
  if (eq.label) {
748
  const lab = clone.ownerDocument.createElement('span');
@@ -966,11 +980,15 @@
966
  toolbar.querySelector('[data-action="download-html"]').addEventListener('click', downloadHTML);
967
  const zipBtn = toolbar.querySelector('[data-action="download-zip"]');
968
  if (zipBtn) zipBtn.addEventListener('click', downloadZIP);
969
- toolbar.querySelector('[data-action="load-json"]').addEventListener('change', e => {
 
970
  const f = e.target.files && e.target.files[0];
971
  if (f) loadJSON(f);
972
  e.target.value = '';
973
  });
 
 
 
974
 
975
  getSegmentEls().forEach(section => {
976
  syncSegmentBindings(section);
 
1
  <!DOCTYPE html>
2
+ <html lang="{{ lang or 'en' }}" data-vgm-review="1">
3
  <head>
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
 
51
  color: var(--color-text-secondary);
52
  }
53
  [contenteditable="true"] {
54
+ outline: 2px dashed #767676; /* 4.54:1 on white — meets WCAG 1.4.11 non-text contrast */
55
  outline-offset: 2px;
56
  padding: 0.1rem 0.3rem;
57
  border-radius: 3px;
 
209
  {% if zip_url %}data-zip-url="{{ zip_url }}"{% endif %}>
210
  <strong>Editor</strong>
211
  <button type="button" data-action="save-json">Save edits (JSON)</button>
212
+ <button type="button" data-action="trigger-load-json">Load edits (JSON)</button>
213
+ <input type="file" accept="application/json,.json" data-action="load-json"
214
+ aria-hidden="true" tabindex="-1" style="display:none">
 
215
  <button type="button" data-action="preview-html">Preview</button>
216
  <button type="button" data-action="download-html">Download final HTML</button>
217
  {% if zip_url %}
 
288
  data-image-filename="{{ seg.image_filename }}"
289
  loading="lazy">
290
  <figcaption>
291
+ <span class="figure__timestamp" aria-hidden="true">{{ seg.start_seconds | timestamp }}</span>
292
+ Lecture slide.
293
  </figcaption>
294
  </figure>
295
  <details class="onscreen-text">
 
312
  aria-label="{{ audio_label }}"></audio>
313
  {% endif %}
314
 
315
+ <div class="narration" aria-labelledby="narration-label-{{ seg.index }}">
316
+ <span class="narration__label" id="narration-label-{{ seg.index }}">Narration</span>
317
  <div class="narration__body" contenteditable="true" data-bind="narration" spellcheck="true">
318
  {% for para in seg.narration %}<p>{{ para }}</p>{% endfor %}
319
  </div>
320
  </div>
321
 
322
+ <div class="vgm-list-editor" data-editor data-list="key_terms"
323
+ role="group" aria-labelledby="kt-label-{{ seg.index }}">
324
+ <span class="vgm-list-editor__title" id="kt-label-{{ seg.index }}">Key terms</span>
325
  <div data-list-rows>
326
  {% for kt in seg.key_terms %}
327
  <div class="vgm-key-term-row" data-list-row>
328
+ <input type="text" data-list-field="term" placeholder="Term" value="{{ kt.term }}"
329
+ aria-label="Term">
330
+ <input type="text" data-list-field="definition" placeholder="Definition" value="{{ kt.definition }}"
331
+ aria-label="Definition">
332
+ <button type="button" class="vgm-row-remove" data-action="remove-row"
333
+ aria-label="Remove key term {{ kt.term }}">×</button>
334
  </div>
335
  {% endfor %}
336
  </div>
337
  <button type="button" class="vgm-list-editor__add" data-action="add-key-term">+ Add key term</button>
338
  </div>
339
 
340
+ <div class="vgm-list-editor" data-editor data-list="math_equations"
341
+ role="group" aria-labelledby="math-label-{{ seg.index }}">
342
+ <span class="vgm-list-editor__title" id="math-label-{{ seg.index }}">Math equations</span>
343
  <div data-list-rows>
344
  {% for eq in seg.math_equations %}
345
  <div class="vgm-math-row" data-list-row>
 
512
  const row = document.createElement('div');
513
  row.className = 'vgm-key-term-row';
514
  row.setAttribute('data-list-row', '');
515
+ row.innerHTML = '<input type="text" data-list-field="term" placeholder="Term" aria-label="Term">'
516
+ + '<input type="text" data-list-field="definition" placeholder="Definition" aria-label="Definition">'
517
+ + '<button type="button" class="vgm-row-remove" data-action="remove-row" aria-label="Remove key term">×</button>';
518
  if (value) {
519
  row.querySelector('[data-list-field="term"]').value = value.term || '';
520
  row.querySelector('[data-list-field="definition"]').value = value.definition || '';
 
663
  const action = target.getAttribute('data-action');
664
  if (action === 'remove-row') {
665
  const row = target.closest('[data-list-row]');
666
+ if (row) {
667
+ const prev = row.previousElementSibling;
668
+ const next = row.nextElementSibling;
669
+ const addBtn = row.closest('[data-list-rows]')?.parentElement?.querySelector('[data-action^="add-"]');
670
+ row.remove();
671
+ const focusTarget = prev || next ? (prev || next).querySelector('input, button, textarea') : addBtn;
672
+ if (focusTarget) focusTarget.focus();
673
+ }
674
  } else if (action === 'add-key-term') {
675
  const editor = section.querySelector('[data-list="key_terms"] [data-list-rows]');
676
  editor.appendChild(makeKeyTermRow(null));
 
748
  segState.math_equations.forEach(eq => {
749
  const fig = clone.ownerDocument.createElement('figure');
750
  fig.className = 'equation';
751
+ // Don't set role="math" or aria-label — MathJax's assistiveMml is
752
+ // the right accessible representation. aria-label on the wrapper
753
+ // would override it. Expose the human-readable description as a
754
+ // visually-hidden figcaption so AT users get it without conflict.
755
+ if (eq.aria_label && eq.aria_label.trim() && !eq.caption) {
756
+ const cap = clone.ownerDocument.createElement('figcaption');
757
+ cap.className = 'sr-only';
758
+ cap.textContent = eq.aria_label.trim();
759
+ fig.appendChild(cap);
760
  }
761
  if (eq.label) {
762
  const lab = clone.ownerDocument.createElement('span');
 
980
  toolbar.querySelector('[data-action="download-html"]').addEventListener('click', downloadHTML);
981
  const zipBtn = toolbar.querySelector('[data-action="download-zip"]');
982
  if (zipBtn) zipBtn.addEventListener('click', downloadZIP);
983
+ const loadInput = toolbar.querySelector('[data-action="load-json"]');
984
+ loadInput.addEventListener('change', e => {
985
  const f = e.target.files && e.target.files[0];
986
  if (f) loadJSON(f);
987
  e.target.value = '';
988
  });
989
+ toolbar.querySelector('[data-action="trigger-load-json"]').addEventListener('click', () => {
990
+ loadInput.click();
991
+ });
992
 
993
  getSegmentEls().forEach(section => {
994
  syncSegmentBindings(section);