Commit a1ced0b
authored
feat(page-number): per-field PAGE value-format switches & case-insensitive field dispatch (SD-3006) (#3599)
* feat(super-converter): match field dispatch keywords case-insensitively
OOXML field type names are case-insensitive, but the field-reference
preprocessors dispatched on the raw first token (e.g. only "PAGE",
not "page"). A lowercase PAGE/NUMPAGES field in a repeated footer fell
through to the cached static text and showed the same number on every
page.
Add a shared extractFieldKeyword helper that normalizes the dispatch
token to upper case while leaving the original instruction text intact
for downstream processors, and route fldSimple/fldChar dispatch and the
header/footer page-field scan through it. Make the HYPERLINK target
regex case-insensitive and anchored. Cover the new behavior with unit
tests and a behavior spec asserting a lowercase PAGE footer resolves
per page.
* test(super-converter): cover field keyword dispatch
* fix(super-converter): trust header footer field keyword
* feat(page-number): support PAGE field value-format switches
Parse the `\*` value-format switches on PAGE field instructions (Arabic,
Roman/roman, ALPHABETIC/alphabetic, ArabicDash) into a run-local
pageNumberFormat override, and apply it independently of section numbering
when resolving page-number tokens.
- add parsePageInstruction / pageNumberFormatToInstructionSwitch in a new
page-instruction.js; page-preprocessor stores the original instruction and
parsed format on sd:autoPageNumber
- round-trip instruction + pageNumberFormat through the autoPageNumber
translator and the page-number extension node (preserve imported
instruction text, synthesize a switch for new formatted nodes)
- add pageNumberFormat to TextRun and thread it through layout-bridge,
layout-resolved, painters (resolveRunText), and stamp section-aware
displayNumber on pages so formatting uses the pre-format numeric value
- move formatPageNumber + PageNumberFormat into @superdoc/contracts as the
single source of truth; re-export from pageNumbering
- include pageNumberFormat in block-version, merge, and hash signatures so
format changes invalidate cached layouts
upperLetter/lowerLetter now render as repeated letters (AA, BB, CC) to match
Word instead of the previous Excel-style sequence (AA, AB).
* fix(page-number): render ArabicDash spacing
* fix(layout-bridge): hash page number formats
* fix(page-number): fall back for unknown formats
* test(behavior): cover formatted footer page fields
* fix(page-number): address PAGE field review feedback
* fix(sequence-field): preserve cached numbering for lowercase seq fields
Only dispatch the SEQ pre-processor for uppercase SEQ instructions so
lowercase `seq` fields keep their cached visible result runs instead of
being re-resolved. Also recurse into run-wrapped content when extracting
resolved text so cached numbers nested inside runs are captured.
* fix(painter): rebuild drawing page fields on context changes
* fix: footnote formatter parity test
* fix(layout): remove duplicate displayNumber fields and fix page signature ref
Drop the redundant displayNumber declarations from HeaderFooterPage,
ResolvedHeaderFooterPage, and the layout-bridge page builder, keeping the
section-aware variant. Correct the renderer page context signature to read
displayPageNumber instead of the nonexistent pageNumberDisplayNumber.
* test(layout): update page-number field expectations
Adjust header/footer token and footer rendering expectations to the
spaced "- N -" format, and migrate the renderer page-context test to the
pageNumberFieldFormat shape.1 parent bade825 commit a1ced0b
41 files changed
Lines changed: 1037 additions & 76 deletions
File tree
- packages
- layout-engine
- contracts/src
- layout-bridge
- src
- test
- layout-engine/src
- layout-resolved/src
- painters/dom/src
- paragraph
- runs
- tests/src
- super-editor/src/editors/v1
- core
- layout-adapter
- converters/inline-converters
- super-converter
- field-references
- fld-preprocessors
- v3/handlers/sd
- autoPageNumber
- sequenceField
- extensions/types
- tests/behavior
- helpers
- tests/field-annotations
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2260 | 2260 | | |
2261 | 2261 | | |
2262 | 2262 | | |
2263 | | - | |
2264 | 2263 | | |
| 2264 | + | |
| 2265 | + | |
2265 | 2266 | | |
2266 | 2267 | | |
2267 | 2268 | | |
| |||
Lines changed: 7 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
11 | | - | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
| |||
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
20 | 25 | | |
21 | 26 | | |
22 | 27 | | |
| |||
Lines changed: 5 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
37 | 31 | | |
38 | 32 | | |
39 | 33 | | |
| |||
49 | 43 | | |
50 | 44 | | |
51 | 45 | | |
52 | | - | |
| 46 | + | |
53 | 47 | | |
54 | 48 | | |
55 | 49 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
452 | 452 | | |
453 | 453 | | |
454 | 454 | | |
455 | | - | |
456 | | - | |
457 | 455 | | |
| 456 | + | |
| 457 | + | |
458 | 458 | | |
459 | 459 | | |
460 | 460 | | |
| |||
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
| 54 | + | |
54 | 55 | | |
55 | 56 | | |
56 | 57 | | |
| |||
Lines changed: 21 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
2 | 9 | | |
3 | 10 | | |
4 | 11 | | |
| |||
143 | 150 | | |
144 | 151 | | |
145 | 152 | | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
146 | 158 | | |
147 | 159 | | |
148 | 160 | | |
| |||
168 | 180 | | |
169 | 181 | | |
170 | 182 | | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
171 | 188 | | |
172 | 189 | | |
173 | 190 | | |
| |||
332 | 349 | | |
333 | 350 | | |
334 | 351 | | |
| 352 | + | |
335 | 353 | | |
336 | 354 | | |
337 | 355 | | |
| |||
372 | 390 | | |
373 | 391 | | |
374 | 392 | | |
| 393 | + | |
375 | 394 | | |
376 | 395 | | |
377 | 396 | | |
| |||
390 | 409 | | |
391 | 410 | | |
392 | 411 | | |
| 412 | + | |
393 | 413 | | |
394 | 414 | | |
395 | 415 | | |
| |||
Lines changed: 19 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
55 | 74 | | |
56 | 75 | | |
57 | 76 | | |
| |||
Lines changed: 45 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
89 | 89 | | |
90 | 90 | | |
91 | 91 | | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
92 | 109 | | |
93 | 110 | | |
94 | 111 | | |
| |||
440 | 457 | | |
441 | 458 | | |
442 | 459 | | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
443 | 488 | | |
444 | 489 | | |
445 | 490 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
81 | 81 | | |
82 | 82 | | |
83 | 83 | | |
84 | | - | |
| 84 | + | |
85 | 85 | | |
86 | 86 | | |
87 | 87 | | |
| |||
Lines changed: 23 additions & 19 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
34 | 38 | | |
35 | 39 | | |
36 | 40 | | |
37 | 41 | | |
38 | | - | |
39 | | - | |
| 42 | + | |
| 43 | + | |
40 | 44 | | |
41 | 45 | | |
42 | 46 | | |
43 | | - | |
| 47 | + | |
44 | 48 | | |
45 | 49 | | |
46 | 50 | | |
| |||
128 | 132 | | |
129 | 133 | | |
130 | 134 | | |
131 | | - | |
| 135 | + | |
132 | 136 | | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
138 | 142 | | |
139 | 143 | | |
140 | 144 | | |
141 | | - | |
142 | | - | |
143 | | - | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
144 | 148 | | |
145 | 149 | | |
146 | 150 | | |
| |||
158 | 162 | | |
159 | 163 | | |
160 | 164 | | |
161 | | - | |
| 165 | + | |
162 | 166 | | |
163 | | - | |
164 | | - | |
165 | | - | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
166 | 170 | | |
167 | 171 | | |
168 | 172 | | |
169 | | - | |
170 | | - | |
| 173 | + | |
| 174 | + | |
171 | 175 | | |
172 | 176 | | |
173 | 177 | | |
| |||
434 | 438 | | |
435 | 439 | | |
436 | 440 | | |
437 | | - | |
| 441 | + | |
438 | 442 | | |
439 | 443 | | |
440 | 444 | | |
| |||
0 commit comments