Commit 34a68a8
authored
feat(template-builder): reactive mode changes and refresh method (SD-2406) (#2726)
* feat(template-builder): reactive mode changes and refresh method
- Remove document.mode from init effect deps so mode changes don't
destroy and recreate the editor (no more scroll jump / content flash)
- Add separate useEffect that calls setDocumentMode() imperatively,
following the same pattern as the React wrapper
- Add refresh() method to the imperative handle for re-discovering
fields after async data delivery
- Document refresh() in API reference
Closes SD-2406
* fix(template-builder): queue mode changes during init
If document.mode changes while SuperDoc is still loading, the change
is queued and applied once handleReady fires. Follows the same
pendingModeRef pattern as the React wrapper.
* fix(template-builder): address review findings for mode change logic
- Remove redundant prevModeRef — useEffect dep array handles this
- Clear pendingModeRef in init cleanup to prevent stale mode on re-init
- Clear pendingModeRef when applying mode directly
- Extract applyDocumentMode helper to centralize the as-any cast1 parent 2c27fd9 commit 34a68a8
File tree
3 files changed
+38
-1
lines changed- apps/docs/solutions/template-builder
- packages/template-builder/src
3 files changed
+38
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
361 | 361 | | |
362 | 362 | | |
363 | 363 | | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
364 | 372 | | |
365 | 373 | | |
366 | 374 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
18 | 22 | | |
19 | 23 | | |
20 | 24 | | |
| |||
443 | 447 | | |
444 | 448 | | |
445 | 449 | | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
446 | 456 | | |
447 | 457 | | |
448 | 458 | | |
| |||
475 | 485 | | |
476 | 486 | | |
477 | 487 | | |
| 488 | + | |
478 | 489 | | |
479 | 490 | | |
480 | 491 | | |
481 | | - | |
482 | 492 | | |
483 | 493 | | |
484 | 494 | | |
| |||
489 | 499 | | |
490 | 500 | | |
491 | 501 | | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
492 | 514 | | |
493 | 515 | | |
494 | 516 | | |
| |||
638 | 660 | | |
639 | 661 | | |
640 | 662 | | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
641 | 668 | | |
642 | 669 | | |
643 | 670 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
161 | 161 | | |
162 | 162 | | |
163 | 163 | | |
| 164 | + | |
| 165 | + | |
164 | 166 | | |
165 | 167 | | |
166 | 168 | | |
| |||
0 commit comments