@@ -6472,6 +6472,62 @@ describe('DomPainter', () => {
64726472 expect ( svgEl ?. style . transform ) . toBe ( '' ) ;
64736473 } ) ;
64746474
6475+ it ( 'rebuilds drawing text with PAGE fields when page context changes during patch rendering' , ( ) => {
6476+ const vectorShapeBlock : FlowBlock = {
6477+ kind : 'drawing' ,
6478+ id : 'drawing-page-field' ,
6479+ drawingKind : 'vectorShape' ,
6480+ geometry : { width : 100 , height : 50 , rotation : 0 , flipH : false , flipV : false } ,
6481+ shapeKind : 'rect' ,
6482+ textContent : {
6483+ parts : [
6484+ { text : 'Page ' , formatting : { fontFamily : 'Arial' , fontSize : 18 } } ,
6485+ { text : '' , fieldType : 'PAGE' , formatting : { fontFamily : 'Arial' , fontSize : 18 } } ,
6486+ ] ,
6487+ } ,
6488+ textAlign : 'center' ,
6489+ } ;
6490+
6491+ const vectorShapeMeasure : Measure = {
6492+ kind : 'drawing' ,
6493+ drawingKind : 'vectorShape' ,
6494+ width : 100 ,
6495+ height : 50 ,
6496+ scale : 1 ,
6497+ naturalWidth : 100 ,
6498+ naturalHeight : 50 ,
6499+ geometry : { width : 100 , height : 50 , rotation : 0 , flipH : false , flipV : false } ,
6500+ } ;
6501+
6502+ const drawingFragment = {
6503+ kind : 'drawing' as const ,
6504+ drawingKind : 'vectorShape' as const ,
6505+ blockId : 'drawing-page-field' ,
6506+ x : 30 ,
6507+ y : 40 ,
6508+ width : 100 ,
6509+ height : 50 ,
6510+ geometry : { width : 100 , height : 50 , rotation : 0 , flipH : false , flipV : false } ,
6511+ scale : 1 ,
6512+ } ;
6513+
6514+ const painter = createTestPainter ( { blocks : [ vectorShapeBlock ] , measures : [ vectorShapeMeasure ] } ) ;
6515+ const firstLayout : Layout = {
6516+ pageSize : layout . pageSize ,
6517+ pages : [ { number : 1 , numberText : '1' , fragments : [ drawingFragment ] } ] ,
6518+ } ;
6519+ const secondLayout : Layout = {
6520+ pageSize : layout . pageSize ,
6521+ pages : [ { number : 2 , numberText : '2' , fragments : [ drawingFragment ] } ] ,
6522+ } ;
6523+
6524+ painter . paint ( firstLayout , mount ) ;
6525+ expect ( mount . querySelector ( '.superdoc-vector-shape' ) ?. textContent ) . toContain ( 'Page 1' ) ;
6526+
6527+ painter . paint ( secondLayout , mount ) ;
6528+ expect ( mount . querySelector ( '.superdoc-vector-shape' ) ?. textContent ) . toContain ( 'Page 2' ) ;
6529+ } ) ;
6530+
64756531 describe ( 'resolved paragraph rendering' , ( ) => {
64766532 it ( 'renders resolved paragraph lines with precomputed indent styles' , ( ) => {
64776533 const paragraphBlock : FlowBlock = {
0 commit comments