@@ -1201,18 +1201,19 @@ export class DomPainter {
12011201 this . beginPaintSnapshot ( resolvedLayout ) ;
12021202
12031203 this . totalPages = resolvedLayout . pages . length ;
1204+ const previousLayout = this . currentLayout ;
1205+ this . currentLayout = resolvedLayout ;
12041206 if ( this . isSemanticFlow ) {
12051207 // Semantic mode always renders as a single continuous surface.
12061208 applyStyles ( mount , containerStyles ) ;
12071209 mount . style . gap = '0px' ;
12081210 mount . style . alignItems = 'stretch' ;
1209- if ( ! this . currentLayout || this . pageStates . length === 0 ) {
1211+ if ( ! previousLayout || this . pageStates . length === 0 ) {
12101212 this . fullRender ( resolvedLayout ) ;
12111213 } else {
12121214 this . patchLayout ( resolvedLayout ) ;
12131215 }
12141216 this . setMountedPageIndices ( this . createAllPageIndices ( resolvedLayout . pages . length ) ) ;
1215- this . currentLayout = resolvedLayout ;
12161217 this . changedBlocks . clear ( ) ;
12171218 this . currentMapping = null ;
12181219 return ;
@@ -1259,7 +1260,7 @@ export class DomPainter {
12591260 } else {
12601261 // Use configured page gap for normal vertical rendering
12611262 mount . style . gap = `${ this . pageGap } px` ;
1262- if ( ! this . currentLayout || this . pageStates . length === 0 ) {
1263+ if ( ! previousLayout || this . pageStates . length === 0 ) {
12631264 this . fullRender ( resolvedLayout ) ;
12641265 } else {
12651266 this . patchLayout ( resolvedLayout ) ;
@@ -2475,22 +2476,26 @@ export class DomPainter {
24752476 }
24762477
24772478 private getEffectivePageStyles ( ) : PageStyles | undefined {
2479+ const documentBackgroundColor = this . currentLayout ?. documentBackground ?. color ;
2480+ const base = this . options . pageStyles ?? { } ;
2481+ const baseWithDocumentBackground = documentBackgroundColor
2482+ ? { ...base , background : documentBackgroundColor }
2483+ : base ;
2484+
24782485 if ( this . isSemanticFlow ) {
2479- const base = this . options . pageStyles ?? { } ;
24802486 return {
2481- ...base ,
2482- background : base . background ?? 'var(--sd-layout-page-bg, #fff)' ,
2487+ ...baseWithDocumentBackground ,
2488+ background : baseWithDocumentBackground . background ?? 'var(--sd-layout-page-bg, #fff)' ,
24832489 boxShadow : 'none' ,
24842490 border : 'none' ,
24852491 margin : '0' ,
24862492 } ;
24872493 }
24882494 if ( this . virtualEnabled && this . layoutMode === 'vertical' ) {
24892495 // Remove top/bottom margins to avoid double-counting with container gap during virtualization
2490- const base = this . options . pageStyles ?? { } ;
2491- return { ...base , margin : '0 auto' } ;
2496+ return { ...baseWithDocumentBackground , margin : '0 auto' } ;
24922497 }
2493- return this . options . pageStyles ;
2498+ return documentBackgroundColor ? baseWithDocumentBackground : this . options . pageStyles ;
24942499 }
24952500
24962501 private renderFragment (
0 commit comments