Claude commited on
Commit
b607027
·
1 Parent(s): 93e4afe

editor: clearer 'Include section' label; fix popup-blocked Preview

Browse files

Two small editor fixes:

* Rename "Whole section" → "Include section" in both the per-section
fieldset and the new bulk-toggle bar. The old label read fine in the
per-section context (the legend "Include in published guide" gave
context) but in the bulk bar it sat next to "Apply to all sections:"
and was confusing — "apply to all sections: whole section". The new
wording stands on its own.

* Preview button no longer trips the popup blocker. previewHTML was
async and awaited inlineAllAudio() BEFORE calling window.open(); once
you await inside a click handler the browser no longer treats the
subsequent window.open as user-initiated, so Safari and Chrome both
reject it. Open the tab synchronously at the top of the handler with
about:blank, then navigate it to the blob URL once the HTML is ready.
Errors close the pre-opened tab so we don't leave an orphan window.

https://claude.ai/code/session_01EM8jiYxdVFy1w3LeJ9GBJg

Files changed (1) hide show
  1. app/templates/review.html +23 -16
app/templates/review.html CHANGED
@@ -291,7 +291,7 @@
291
  box as indeterminate. Editor-only chrome, stripped from output. #}
292
  <div class="vgm-bulk" data-editor role="group" aria-label="Apply to every section">
293
  <strong class="vgm-bulk__label">Apply to all sections:</strong>
294
- <label><input type="checkbox" data-bulk-toggle="include"> <span>Whole section</span></label>
295
  <label><input type="checkbox" data-bulk-toggle="description"> <span>Scene description</span></label>
296
  <label><input type="checkbox" data-bulk-toggle="alt_text"> <span>Alt-text</span></label>
297
  <label><input type="checkbox" data-bulk-toggle="on_screen_text"> <span>On-screen text</span></label>
@@ -382,7 +382,7 @@
382
  <legend>Include in published guide</legend>
383
  <label class="vgm-include-set__row">
384
  <input type="checkbox" data-bind="include" id="include-{{ seg.index }}" checked>
385
- <span>Whole section</span>
386
  </label>
387
  <label class="vgm-include-set__row">
388
  <input type="checkbox" data-element-toggle="description" id="include-description-{{ seg.index }}" {% if seg.description %}checked{% endif %}>
@@ -1097,24 +1097,31 @@
1097
  }
1098
  });
1099
  async function previewHTML() {
1100
- setStatus('Preparing preview…');
1101
- await inlineAllAudio();
1102
- const html = buildFinalHTML();
1103
- // Use a Blob URL — opening an empty window and document.write'ing into
1104
- // it from inside an iframe lands as a blank tab in some browsers
1105
- // (cross-document write protection). A real URL the browser can load
1106
- // works reliably whether we're embedded or standalone.
1107
- if (previewURL) URL.revokeObjectURL(previewURL);
1108
- const blob = new Blob([html], { type: 'text/html;charset=utf-8' });
1109
- previewURL = URL.createObjectURL(blob);
1110
- // Named target reuses the same tab on subsequent previews.
1111
- const win = window.open(previewURL, 'vgm-preview');
1112
  if (!win) {
1113
  setStatus('Pop-up blocked — allow pop-ups for this site to preview.');
1114
  return;
1115
  }
1116
- win.focus();
1117
- setStatus('Preview opened in a new tab.');
 
 
 
 
 
 
 
 
 
 
 
 
1118
  }
1119
 
1120
  async function downloadZIP() {
 
291
  box as indeterminate. Editor-only chrome, stripped from output. #}
292
  <div class="vgm-bulk" data-editor role="group" aria-label="Apply to every section">
293
  <strong class="vgm-bulk__label">Apply to all sections:</strong>
294
+ <label><input type="checkbox" data-bulk-toggle="include"> <span>Include section</span></label>
295
  <label><input type="checkbox" data-bulk-toggle="description"> <span>Scene description</span></label>
296
  <label><input type="checkbox" data-bulk-toggle="alt_text"> <span>Alt-text</span></label>
297
  <label><input type="checkbox" data-bulk-toggle="on_screen_text"> <span>On-screen text</span></label>
 
382
  <legend>Include in published guide</legend>
383
  <label class="vgm-include-set__row">
384
  <input type="checkbox" data-bind="include" id="include-{{ seg.index }}" checked>
385
+ <span>Include section</span>
386
  </label>
387
  <label class="vgm-include-set__row">
388
  <input type="checkbox" data-element-toggle="description" id="include-description-{{ seg.index }}" {% if seg.description %}checked{% endif %}>
 
1097
  }
1098
  });
1099
  async function previewHTML() {
1100
+ // Open the new tab SYNCHRONOUSLY at the top of the click handler.
1101
+ // The async/await below would otherwise sever the user-gesture
1102
+ // chain that browsers require for window.open(), and modern
1103
+ // popup blockers reject the call even though the user clicked
1104
+ // a button to get here. We navigate the freshly-opened tab to
1105
+ // the blob URL once the HTML is ready.
1106
+ const win = window.open('about:blank', 'vgm-preview');
 
 
 
 
 
1107
  if (!win) {
1108
  setStatus('Pop-up blocked — allow pop-ups for this site to preview.');
1109
  return;
1110
  }
1111
+ setStatus('Preparing preview…');
1112
+ try {
1113
+ await inlineAllAudio();
1114
+ const html = buildFinalHTML();
1115
+ if (previewURL) URL.revokeObjectURL(previewURL);
1116
+ const blob = new Blob([html], { type: 'text/html;charset=utf-8' });
1117
+ previewURL = URL.createObjectURL(blob);
1118
+ win.location.replace(previewURL);
1119
+ win.focus();
1120
+ setStatus('Preview opened in a new tab.');
1121
+ } catch (err) {
1122
+ win.close();
1123
+ setStatus('Preview failed: ' + (err && err.message ? err.message : err));
1124
+ }
1125
  }
1126
 
1127
  async function downloadZIP() {