Checkpoint line-grid renderer state
This commit is contained in:
@@ -95,22 +95,30 @@ class LayoutRendererModule extends BaseModule {
|
||||
return null;
|
||||
}
|
||||
|
||||
const lineHeight = lineHeightPx || parseFloat(window.getComputedStyle(paragraph).lineHeight) || 24;
|
||||
if (!Number.isFinite(Number(lineHeightPx)) || Number(lineHeightPx) <= 0) {
|
||||
throw new Error('LayoutRenderer: Missing canonical lineHeightPx for story layout.');
|
||||
}
|
||||
const lineHeight = Number(lineHeightPx);
|
||||
let marginLines = 0;
|
||||
if (layoutData.role === 'chapter-heading') {
|
||||
paragraph.style.marginTop = `${lineHeight * 2}px`;
|
||||
paragraph.style.marginBottom = `${lineHeight}px`;
|
||||
marginLines = 3;
|
||||
} else if (layoutData.role === 'section-heading') {
|
||||
paragraph.style.marginTop = `${lineHeight}px`;
|
||||
paragraph.style.marginBottom = `${lineHeight}px`;
|
||||
marginLines = 2;
|
||||
} else if (layoutData.addTopSpace) {
|
||||
paragraph.style.marginTop = `${lineHeight}px`;
|
||||
marginLines = 1;
|
||||
}
|
||||
const maxLineWidth = Array.isArray(measures) && measures.length > 0
|
||||
? Math.max(...measures)
|
||||
: storyElement.clientWidth;
|
||||
// Height should include all lines (breaks.length represents number of lines)
|
||||
const numLines = breaks.length - 1;
|
||||
const numLines = Math.max(1, breaks.length - 1);
|
||||
paragraph.style.height = `${lineHeight * numLines}px`;
|
||||
paragraph.dataset.heightLines = String(numLines + marginLines);
|
||||
|
||||
console.log(`LayoutRenderer: Rendering paragraph ${id} - ${breaks.length} breaks (${numLines} lines), lineHeight: ${lineHeight}px, total height: ${lineHeight * numLines}px`);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user