fix(book): backfill cover spec flags so older books don't drop back/spine layers

ensureBookState() now fills in any defaultBookSpec() fields missing
from state.book.spec. Older saved books that pre-date the
coverHasBack / coverHasSpine flags would otherwise restore with those
fields undefined, and the eleven '!!s.coverHasBack' / '!!s.coverHasSpine'
truthiness checks scattered across the cover-preview filter, sheet
sizing, renderDimensions, the cover edit slot layout, and the PDF
export pipeline would all read those as 'false' — silently filtering
back-cover and spine layers out of the spread.

User symptom: a cover with text + linked designs + a background shape
that spans the spread would render only the front panel's content,
because the back / spine layers were being dropped by the filter.
The spread width also collapsed to front + bleed, throwing off the
bleed visualization.

renderBookCoverPreview() now calls ensureBookState() before reading
the spec so the backfill runs even if no prior code path touched the
book this render cycle.

Co-Authored-By: Claude Opus 4.7 <[email protected]>
This commit is contained in:
thePR0M3TH3ANandClaude Opus 4.7 committed 2026-06-04 15:10:19 -04:00
1 parent 842e672fc0
commit ef7e85a418
1 file changed
+14 -1
+14 -1
View File
@@ -8852,6 +8852,16 @@
}
function ensureBookState() {
if (!state.book) state.book = defaultBookState();
// Backfill any spec fields that pre-date later additions, so
// older saved books don't end up with undefined coverHasBack /
// coverHasSpine (which would make `!!s.coverHasBack` evaluate
// false and drop back-panel layers from the preview, sheet
// sizing, and PDF export).
if (!state.book.spec) state.book.spec = defaultBookSpec();
const defaults = defaultBookSpec();
for (const k of Object.keys(defaults)) {
if (state.book.spec[k] === undefined) state.book.spec[k] = defaults[k];
}
return state.book;
}
// Physical page count — manifest entries except reflow segments,
@@ -12718,7 +12728,10 @@
function renderBookCoverPreview() {
const wrap = document.getElementById('bookCoverPreview');
const summary = document.getElementById('bookCoverSummary');
const book = state.book;
// Backfill any missing spec flags (older saved books) before we
// read coverHasBack / coverHasSpine — `!!undefined === false`
// would otherwise drop the back and spine layers entirely.
const book = state.book ? ensureBookState() : null;
if (!wrap || !summary || !book) return;
const s = book.spec;
const spineW = bookSpineWidthInches();