Commit 0bbe546
fix(superdoc): scrollToElement matches any of nodeId/sdBlockId/id/paraId per node
Block nodes in imported docx files can carry more than one ID-shaped
attr at once — paragraphs from `.docx` carry both `paraId` (from
`w14:paraId` in OOXML) and `sdBlockId` (minted by SuperDoc on import).
The previous walk did `const candidate = a.nodeId ?? a.sdBlockId ?? a.id ?? a.paraId`
and compared the single first-non-null pick to the caller's elementId.
That meant a paragraph carrying both `sdBlockId: "3496bf7f-..."` and
`paraId: "00000001"` would always return `sdBlockId` as the candidate
and never match a caller looking for `"00000001"`.
Compare each attr independently so the walk matches when ANY of the
candidate fields equals elementId. Consumers can now pass whichever
ID handle they have without knowing which ID types a given block
happens to carry.
Adds one regression test asserting that scrollToElement('00000001')
resolves to `true` even when the matching paragraph also has a
non-matching sdBlockId.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>1 parent 1fcf864 commit 0bbe546
2 files changed
Lines changed: 53 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1438 | 1438 | | |
1439 | 1439 | | |
1440 | 1440 | | |
1441 | | - | |
| 1441 | + | |
| 1442 | + | |
| 1443 | + | |
| 1444 | + | |
| 1445 | + | |
| 1446 | + | |
| 1447 | + | |
1442 | 1448 | | |
1443 | 1449 | | |
1444 | 1450 | | |
1445 | 1451 | | |
1446 | | - | |
1447 | | - | |
| 1452 | + | |
1448 | 1453 | | |
1449 | 1454 | | |
1450 | 1455 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
475 | 475 | | |
476 | 476 | | |
477 | 477 | | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
478 | 523 | | |
479 | 524 | | |
480 | 525 | | |
| |||
0 commit comments