Commit a4736c8
fix: handle null declaration in DocxExporter to prevent export crash (#2578)
* fix: handle null declaration in DocxExporter to prevent export crash
When exporting a SuperDoc to DOCX, if the converter's declaration is null
(e.g., for documents created/edited via Yjs collaboration without raw XML
import), the export crashes with: TypeError: Cannot read properties of null
(reading 'attributes').
Add optional chaining and a standard XML declaration fallback
(version="1.0" encoding="UTF-8" standalone="yes") so export succeeds when
converter.declaration is null or undefined.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* refactor(super-converter): extract DEFAULT_XML_DECLARATION to shared constant
Move the inline XML declaration fallback to constants.js so exporter.js
and citation-sources.js share one source of truth. Collapse duplicate
null/undefined test cases into it.each.
---------
Co-authored-by: aldrinjenson <aldrin@athenaintelligence.ai>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>1 parent b65488d commit a4736c8
4 files changed
Lines changed: 35 additions & 13 deletions
File tree
- packages/super-editor/src
- core/super-converter
- tests/export
Lines changed: 1 addition & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
| |||
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | 16 | | |
24 | 17 | | |
25 | 18 | | |
| |||
Lines changed: 9 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
14 | 23 | | |
15 | 24 | | |
16 | 25 | | |
| |||
Lines changed: 2 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| 42 | + | |
42 | 43 | | |
43 | 44 | | |
44 | 45 | | |
| |||
586 | 587 | | |
587 | 588 | | |
588 | 589 | | |
589 | | - | |
590 | | - | |
591 | | - | |
592 | | - | |
593 | | - | |
| 590 | + | |
594 | 591 | | |
595 | 592 | | |
596 | 593 | | |
| |||
Lines changed: 23 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
44 | 67 | | |
45 | 68 | | |
46 | 69 | | |
| |||
0 commit comments