@@ -6416,6 +6416,62 @@ describe('DomPainter', () => {
64166416 expect ( svgEl ?. style . transform ) . toBe ( '' ) ;
64176417 } ) ;
64186418
6419+ it ( 'rebuilds drawing text with PAGE fields when page context changes during patch rendering' , ( ) => {
6420+ const vectorShapeBlock : FlowBlock = {
6421+ kind : 'drawing' ,
6422+ id : 'drawing-page-field' ,
6423+ drawingKind : 'vectorShape' ,
6424+ geometry : { width : 100 , height : 50 , rotation : 0 , flipH : false , flipV : false } ,
6425+ shapeKind : 'rect' ,
6426+ textContent : {
6427+ parts : [
6428+ { text : 'Page ' , formatting : { fontFamily : 'Arial' , fontSize : 18 } } ,
6429+ { text : '' , fieldType : 'PAGE' , formatting : { fontFamily : 'Arial' , fontSize : 18 } } ,
6430+ ] ,
6431+ } ,
6432+ textAlign : 'center' ,
6433+ } ;
6434+
6435+ const vectorShapeMeasure : Measure = {
6436+ kind : 'drawing' ,
6437+ drawingKind : 'vectorShape' ,
6438+ width : 100 ,
6439+ height : 50 ,
6440+ scale : 1 ,
6441+ naturalWidth : 100 ,
6442+ naturalHeight : 50 ,
6443+ geometry : { width : 100 , height : 50 , rotation : 0 , flipH : false , flipV : false } ,
6444+ } ;
6445+
6446+ const drawingFragment = {
6447+ kind : 'drawing' as const ,
6448+ drawingKind : 'vectorShape' as const ,
6449+ blockId : 'drawing-page-field' ,
6450+ x : 30 ,
6451+ y : 40 ,
6452+ width : 100 ,
6453+ height : 50 ,
6454+ geometry : { width : 100 , height : 50 , rotation : 0 , flipH : false , flipV : false } ,
6455+ scale : 1 ,
6456+ } ;
6457+
6458+ const painter = createTestPainter ( { blocks : [ vectorShapeBlock ] , measures : [ vectorShapeMeasure ] } ) ;
6459+ const firstLayout : Layout = {
6460+ pageSize : layout . pageSize ,
6461+ pages : [ { number : 1 , numberText : '1' , fragments : [ drawingFragment ] } ] ,
6462+ } ;
6463+ const secondLayout : Layout = {
6464+ pageSize : layout . pageSize ,
6465+ pages : [ { number : 2 , numberText : '2' , fragments : [ drawingFragment ] } ] ,
6466+ } ;
6467+
6468+ painter . paint ( firstLayout , mount ) ;
6469+ expect ( mount . querySelector ( '.superdoc-vector-shape' ) ?. textContent ) . toContain ( 'Page 1' ) ;
6470+
6471+ painter . paint ( secondLayout , mount ) ;
6472+ expect ( mount . querySelector ( '.superdoc-vector-shape' ) ?. textContent ) . toContain ( 'Page 2' ) ;
6473+ } ) ;
6474+
64196475 describe ( 'resolved paragraph rendering' , ( ) => {
64206476 it ( 'renders resolved paragraph lines with precomputed indent styles' , ( ) => {
64216477 const paragraphBlock : FlowBlock = {
0 commit comments