@json-to-office/core-docx 1.10.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/dist/core/generateFromIr.d.ts +8 -0
  2. package/dist/core/generateFromIr.d.ts.map +1 -1
  3. package/dist/core/generator.d.ts +8 -0
  4. package/dist/core/generator.d.ts.map +1 -1
  5. package/dist/core/tableModel.d.ts +1 -1
  6. package/dist/core/tableModel.d.ts.map +1 -1
  7. package/dist/index.d.ts +1 -1
  8. package/dist/index.d.ts.map +1 -1
  9. package/dist/index.js +491 -591
  10. package/dist/index.js.map +1 -1
  11. package/dist/ir/inline.d.ts.map +1 -1
  12. package/dist/plugin/createDocumentGenerator.d.ts +8 -0
  13. package/dist/plugin/createDocumentGenerator.d.ts.map +1 -1
  14. package/dist/plugin/example/index.js +487 -588
  15. package/dist/plugin/example/index.js.map +1 -1
  16. package/dist/renderers/docxjs/emit.d.ts.map +1 -1
  17. package/dist/renderers/docxjs/index.d.ts.map +1 -1
  18. package/dist/renderers/office-open/index.d.ts +1 -1
  19. package/dist/renderers/office-open/index.d.ts.map +1 -1
  20. package/dist/renderers/types.d.ts +9 -0
  21. package/dist/renderers/types.d.ts.map +1 -1
  22. package/dist/styles/index.d.ts +1 -1
  23. package/dist/styles/index.d.ts.map +1 -1
  24. package/dist/templates/documents/field-review.docx.json +1148 -0
  25. package/dist/templates/documents/index.d.ts +2 -2
  26. package/dist/templates/documents/index.d.ts.map +1 -1
  27. package/dist/templates/documents/practice-note.docx.json +917 -0
  28. package/dist/templates/themes/devportal.docx.theme.json +110 -44
  29. package/dist/templates/themes/index.d.ts +2 -2
  30. package/dist/templates/themes/index.d.ts.map +1 -1
  31. package/dist/templates/themes/minimal.docx.theme.json +124 -127
  32. package/dist/templates/themes/vermilion.docx.theme.json +82 -1
  33. package/dist/tsconfig.tsbuildinfo +1 -1
  34. package/dist/utils/imageUtils.d.ts +19 -0
  35. package/dist/utils/imageUtils.d.ts.map +1 -1
  36. package/dist/utils/listLevels.d.ts.map +1 -1
  37. package/package.json +3 -3
  38. package/dist/templates/documents/proposal.docx.json +0 -1723
  39. package/dist/templates/documents/technical-guide.docx.json +0 -2040
  40. package/dist/templates/themes/apex.docx.theme.json +0 -117
  41. package/dist/templates/themes/corporate.docx.theme.json +0 -114
  42. package/dist/templates/themes/modern.docx.theme.json +0 -109
@@ -184,545 +184,181 @@ var minimal_docx_theme_default;
184
184
  var init_minimal_docx_theme = __esm({
185
185
  "src/templates/themes/minimal.docx.theme.json"() {
186
186
  minimal_docx_theme_default = {
187
- $schema: "../../../../shared/json-schemas/theme.schema.json",
188
187
  name: "minimal",
189
188
  displayName: "Minimal Clean",
190
- description: "A clean, minimalist theme focused on readability and elegant simplicity",
191
- version: "2.0.0",
189
+ description: "A quiet, warm minimal theme \u2014 Calibri throughout, sage-green ink on ivory neutrals, a large tracked-tight bold title, wide margins and hairline rules",
190
+ version: "4.0.0",
192
191
  colors: {
193
- primary: "#000000",
194
- secondary: "#666666",
195
- accent: "#2c3e50",
196
- background: "#ffffff",
197
- text: "#2c2c2c",
198
- border: "#f0f0f0",
199
- textPrimary: "#000000",
200
- textSecondary: "#4a4a4a",
201
- textMuted: "#999999",
202
- borderPrimary: "#e0e0e0",
203
- borderSecondary: "#f5f5f5",
204
- backgroundPrimary: "#ffffff",
205
- backgroundSecondary: "#fafafa"
206
- },
207
- fonts: {
208
- heading: {
209
- family: "Arial",
210
- size: 24
211
- },
212
- body: {
213
- family: "Arial",
214
- size: 11
215
- },
216
- mono: {
217
- family: "Menlo",
218
- size: 10
219
- },
220
- light: {
221
- family: "Arial",
222
- size: 24
223
- }
224
- },
225
- page: {
226
- size: "A4",
227
- margins: {
228
- top: 1440,
229
- bottom: 1440,
230
- left: 1080,
231
- right: 1080,
232
- header: 720,
233
- footer: 720,
234
- gutter: 0
235
- }
236
- },
237
- styles: {
238
- normal: {
239
- font: "body",
240
- color: "#000000",
241
- lineSpacing: {
242
- type: "multiple",
243
- value: 1.5
244
- },
245
- alignment: "justify",
246
- spacing: {
247
- after: 9
248
- }
249
- },
250
- heading1: {
251
- font: "light",
252
- size: 24,
253
- bold: false,
254
- color: "#000000",
255
- spacing: {
256
- before: 18,
257
- after: 12
258
- },
259
- keepNext: true,
260
- alignment: "left",
261
- characterSpacing: {
262
- type: "expanded",
263
- value: 1.2
264
- }
265
- },
266
- heading2: {
267
- font: "light",
268
- size: 20,
269
- bold: false,
270
- color: "#000000",
271
- spacing: {
272
- before: 12,
273
- after: 9
274
- },
275
- keepNext: true,
276
- alignment: "left",
277
- characterSpacing: {
278
- type: "expanded",
279
- value: 0.8
280
- }
281
- },
282
- heading3: {
283
- font: "heading",
284
- size: 16,
285
- bold: false,
286
- color: "#2c2c2c",
287
- spacing: {
288
- before: 9,
289
- after: 6
290
- },
291
- keepNext: true,
292
- alignment: "left"
293
- },
294
- heading4: {
295
- font: "heading",
296
- size: 14,
297
- bold: true,
298
- color: "#4a4a4a",
299
- spacing: {
300
- before: 6,
301
- after: 4
302
- },
303
- keepNext: true
304
- },
305
- heading5: {
306
- font: "heading",
307
- size: 12,
308
- bold: false,
309
- italic: true,
310
- color: "#666666",
311
- spacing: {
312
- before: 4,
313
- after: 3
314
- }
315
- },
316
- heading6: {
317
- font: "light",
318
- size: 11,
319
- bold: false,
320
- color: "#999999",
321
- spacing: {
322
- before: 3,
323
- after: 2
324
- }
325
- },
326
- title: {
327
- font: "light",
328
- bold: false,
329
- color: "#000000",
330
- alignment: "left",
331
- spacing: {
332
- before: 0,
333
- after: 24
334
- },
335
- characterSpacing: {
336
- type: "condensed",
337
- value: 20
338
- }
339
- },
340
- subtitle: {
341
- font: "light",
342
- size: 16,
343
- italic: false,
344
- color: "#666666",
345
- alignment: "left",
346
- spacing: {
347
- before: 0,
348
- after: 18
349
- }
350
- }
351
- },
352
- componentDefaults: {
353
- table: {
354
- borderColor: "#f0f0f0"
355
- },
356
- list: {
357
- format: "bullet",
358
- bullet: "\u2022"
359
- },
360
- image: {
361
- alignment: "left"
362
- },
363
- statistic: {
364
- alignment: "left"
365
- },
366
- section: {
367
- pageBreak: false
368
- }
369
- }
370
- };
371
- }
372
- });
373
-
374
- // src/templates/themes/corporate.docx.theme.json
375
- var corporate_docx_theme_default;
376
- var init_corporate_docx_theme = __esm({
377
- "src/templates/themes/corporate.docx.theme.json"() {
378
- corporate_docx_theme_default = {
379
- name: "corporate",
380
- displayName: "Corporate Professional",
381
- description: "A polished corporate theme with blue accents and structured typography",
382
- version: "2.0.0",
383
- colors: {
384
- primary: "#1a365d",
385
- secondary: "#2D3748",
386
- accent: "#3182CE",
387
- text: "#1A202C",
192
+ primary: "#2B302B",
193
+ secondary: "#4A5B4E",
194
+ accent: "#6E7F71",
195
+ text: "#3B3C38",
388
196
  background: "#FFFFFF",
389
- border: "#E2E8F0",
390
- textPrimary: "#1A202C",
391
- textSecondary: "#4A5568",
392
- textMuted: "#A0AEC0",
393
- borderPrimary: "#CBD5E0",
394
- borderSecondary: "#E2E8F0",
197
+ border: "#D8D3C8",
198
+ textPrimary: "#3B3C38",
199
+ textSecondary: "#5B5B54",
200
+ textMuted: "#75726A",
201
+ borderPrimary: "#D8D3C8",
202
+ borderSecondary: "#E9E6DE",
395
203
  backgroundPrimary: "#FFFFFF",
396
- backgroundSecondary: "#F7FAFC"
204
+ backgroundSecondary: "#F1EFE9",
205
+ accent4: "#9AA69C",
206
+ accent5: "#C9CFC7",
207
+ accent6: "#B5AC9D"
397
208
  },
398
209
  fonts: {
399
- heading: { family: "Georgia", size: 26 },
400
- body: { family: "Calibri", size: 11 },
401
- mono: { family: "Consolas", size: 10 },
402
- light: { family: "Georgia", size: 26 }
210
+ heading: { family: "Calibri", size: 21 },
211
+ body: { family: "Calibri", size: 10 },
212
+ mono: { family: "Courier New", size: 10 },
213
+ light: { family: "Calibri", size: 21 }
403
214
  },
404
215
  page: {
405
216
  size: "A4",
406
217
  margins: {
407
- top: 1440,
408
- bottom: 1440,
409
- left: 1200,
410
- right: 1200,
411
- header: 720,
412
- footer: 720,
218
+ top: 1700,
219
+ bottom: 1700,
220
+ left: 1700,
221
+ right: 1700,
222
+ header: 850,
223
+ footer: 850,
413
224
  gutter: 0
414
225
  }
415
226
  },
416
227
  styles: {
417
228
  normal: {
418
229
  font: "body",
419
- color: "#1A202C",
420
- lineSpacing: { type: "multiple", value: 1.4 },
421
- alignment: "justify",
422
- spacing: { after: 8 }
423
- },
424
- heading1: {
425
- font: "heading",
426
- size: 26,
427
- bold: false,
428
- color: "primary",
429
- spacing: { before: 24, after: 12 },
430
- keepNext: true,
230
+ color: "textPrimary",
231
+ lineSpacing: { type: "multiple", value: 1.35 },
431
232
  alignment: "left",
432
- borders: {
433
- bottom: {
434
- style: "single",
435
- size: 2,
436
- color: "primary",
437
- space: 6
438
- }
439
- }
233
+ spacing: { after: 8 }
440
234
  },
441
- heading2: {
235
+ title: {
442
236
  font: "heading",
443
- size: 18,
444
- bold: false,
445
- color: "secondary",
446
- spacing: { before: 18, after: 8 },
447
- keepNext: true,
448
- alignment: "left"
449
- },
450
- heading3: {
451
- font: "body",
452
- size: 13,
237
+ size: 34,
453
238
  bold: true,
454
- color: "accent",
455
- spacing: { before: 12, after: 6 },
456
- keepNext: true,
457
- alignment: "left"
458
- },
459
- title: {
460
- font: "light",
461
- size: 32,
462
- bold: false,
463
239
  color: "primary",
464
240
  alignment: "left",
465
- spacing: { before: 0, after: 18 }
241
+ lineSpacing: { type: "multiple", value: 1 },
242
+ characterSpacing: { type: "condensed", value: 20 },
243
+ spacing: { before: 0, after: 11 }
466
244
  },
467
245
  subtitle: {
468
246
  font: "body",
469
- size: 16,
247
+ size: 13,
470
248
  italic: false,
471
249
  color: "textSecondary",
472
250
  alignment: "left",
473
- spacing: { before: 0, after: 24 }
474
- }
475
- },
476
- componentDefaults: {
477
- table: {
478
- borderColor: "#E2E8F0"
479
- },
480
- list: {
481
- format: "bullet",
482
- bullet: "\u2022"
483
- },
484
- statistic: {
485
- alignment: "center"
486
- },
487
- section: {
488
- pageBreak: false
489
- }
490
- }
491
- };
492
- }
493
- });
494
-
495
- // src/templates/themes/modern.docx.theme.json
496
- var modern_docx_theme_default;
497
- var init_modern_docx_theme = __esm({
498
- "src/templates/themes/modern.docx.theme.json"() {
499
- modern_docx_theme_default = {
500
- name: "modern",
501
- displayName: "Modern Clean",
502
- description: "A contemporary theme with vibrant accents and generous whitespace",
503
- version: "2.0.0",
504
- colors: {
505
- primary: "#6D28D9",
506
- secondary: "#1E293B",
507
- accent: "#0891B2",
508
- text: "#0F172A",
509
- background: "#FFFFFF",
510
- border: "#E2E8F0",
511
- textPrimary: "#0F172A",
512
- textSecondary: "#475569",
513
- textMuted: "#94A3B8",
514
- borderPrimary: "#CBD5E1",
515
- borderSecondary: "#E2E8F0",
516
- backgroundPrimary: "#FFFFFF",
517
- backgroundSecondary: "#F8FAFC"
518
- },
519
- fonts: {
520
- heading: { family: "Helvetica", size: 28 },
521
- body: { family: "Helvetica", size: 11 },
522
- mono: { family: "Menlo", size: 10 },
523
- light: { family: "Helvetica", size: 28 }
524
- },
525
- page: {
526
- size: "A4",
527
- margins: {
528
- top: 1440,
529
- bottom: 1440,
530
- left: 1080,
531
- right: 1080,
532
- header: 720,
533
- footer: 720,
534
- gutter: 0
535
- }
536
- },
537
- styles: {
538
- normal: {
539
- font: "body",
540
- color: "#0F172A",
541
- lineSpacing: { type: "multiple", value: 1.5 },
542
- alignment: "left",
543
- spacing: { after: 10 }
251
+ lineSpacing: { type: "multiple", value: 1.2 },
252
+ spacing: { before: 0, after: 22 }
544
253
  },
545
254
  heading1: {
546
255
  font: "heading",
547
- size: 28,
256
+ size: 21,
548
257
  bold: true,
549
258
  color: "primary",
550
- spacing: { before: 24, after: 14 },
259
+ lineSpacing: { type: "multiple", value: 1.15 },
260
+ spacing: { before: 30, after: 10 },
551
261
  keepNext: true,
552
262
  alignment: "left"
553
263
  },
554
264
  heading2: {
555
265
  font: "heading",
556
- size: 20,
266
+ size: 14.5,
557
267
  bold: true,
558
- color: "secondary",
559
- spacing: { before: 18, after: 10 },
268
+ color: "primary",
269
+ lineSpacing: { type: "multiple", value: 1.15 },
270
+ spacing: { before: 22, after: 8 },
560
271
  keepNext: true,
561
272
  alignment: "left"
562
273
  },
563
274
  heading3: {
564
- font: "body",
565
- size: 14,
275
+ font: "heading",
276
+ size: 12,
566
277
  bold: true,
567
- color: "accent",
568
- spacing: { before: 12, after: 6 },
278
+ color: "primary",
279
+ spacing: { before: 16, after: 6 },
569
280
  keepNext: true,
570
281
  alignment: "left"
571
282
  },
572
- title: {
573
- font: "heading",
574
- size: 36,
283
+ heading4: {
284
+ font: "body",
285
+ size: 10.5,
575
286
  bold: true,
576
287
  color: "primary",
577
- alignment: "left",
578
- spacing: { before: 0, after: 12 }
579
- },
580
- subtitle: {
581
- font: "light",
582
- size: 18,
583
- italic: false,
584
- color: "textSecondary",
585
- alignment: "left",
586
- spacing: { before: 0, after: 24 }
587
- }
588
- },
589
- componentDefaults: {
590
- table: {
591
- borderColor: "#E2E8F0"
592
- },
593
- list: {
594
- format: "bullet",
595
- bullet: "\u2013"
596
- },
597
- image: {
598
- alignment: "center"
599
- },
600
- statistic: {
601
- alignment: "center"
288
+ spacing: { before: 12, after: 4 },
289
+ keepNext: true,
290
+ alignment: "left"
602
291
  },
603
- section: {
604
- pageBreak: false
605
- }
606
- }
607
- };
608
- }
609
- });
610
-
611
- // src/templates/themes/apex.docx.theme.json
612
- var apex_docx_theme_default;
613
- var init_apex_docx_theme = __esm({
614
- "src/templates/themes/apex.docx.theme.json"() {
615
- apex_docx_theme_default = {
616
- name: "apex",
617
- displayName: "Apex Consulting",
618
- description: "A premium consulting theme with deep navy, warm amber accents, and authoritative typography",
619
- version: "2.0.0",
620
- colors: {
621
- primary: "#0C2340",
622
- secondary: "#1B3A5C",
623
- accent: "#D4A843",
624
- text: "#1A1A2E",
625
- background: "#FFFFFF",
626
- border: "#D6DAE0",
627
- textPrimary: "#1A1A2E",
628
- textSecondary: "#4A5066",
629
- textMuted: "#8B91A0",
630
- borderPrimary: "#B8BCC6",
631
- borderSecondary: "#E8EAF0",
632
- backgroundPrimary: "#FFFFFF",
633
- backgroundSecondary: "#F4F5F8"
634
- },
635
- fonts: {
636
- heading: { family: "Georgia", size: 26 },
637
- body: { family: "Calibri", size: 11 },
638
- mono: { family: "Consolas", size: 10 },
639
- light: { family: "Georgia", size: 26 }
640
- },
641
- page: {
642
- size: "A4",
643
- margins: {
644
- top: 1440,
645
- bottom: 1440,
646
- left: 1200,
647
- right: 1200,
648
- header: 720,
649
- footer: 720,
650
- gutter: 0
651
- }
652
- },
653
- styles: {
654
- normal: {
292
+ heading5: {
655
293
  font: "body",
656
- color: "textPrimary",
657
- lineSpacing: { type: "multiple", value: 1.4 },
658
- alignment: "justify",
659
- spacing: { after: 8 }
660
- },
661
- heading1: {
662
- font: "heading",
663
- size: 26,
294
+ size: 10.5,
664
295
  bold: false,
665
- color: "primary",
666
- spacing: { before: 24, after: 12 },
296
+ italic: true,
297
+ color: "textSecondary",
298
+ spacing: { before: 10, after: 4 },
667
299
  keepNext: true,
668
- alignment: "left",
669
- borders: {
670
- bottom: {
671
- style: "single",
672
- size: 2,
673
- color: "accent",
674
- space: 6
675
- }
676
- }
300
+ alignment: "left"
677
301
  },
678
- heading2: {
679
- font: "heading",
680
- size: 18,
302
+ heading6: {
303
+ font: "body",
304
+ size: 10,
681
305
  bold: false,
682
- color: "secondary",
683
- spacing: { before: 18, after: 8 },
306
+ color: "textMuted",
307
+ characterSpacing: { type: "expanded", value: 20 },
308
+ spacing: { before: 10, after: 4 },
684
309
  keepNext: true,
685
310
  alignment: "left"
686
311
  },
687
- heading3: {
312
+ TOC1: {
688
313
  font: "body",
689
- size: 13,
314
+ size: 10.5,
690
315
  bold: true,
691
- color: "accent",
692
- spacing: { before: 12, after: 6 },
693
- keepNext: true,
694
- alignment: "left"
695
- },
696
- title: {
697
- font: "light",
698
- size: 36,
699
- bold: false,
700
- color: "primary",
701
- alignment: "left",
702
- spacing: { before: 0, after: 18 }
316
+ color: "textPrimary",
317
+ spacing: { before: 4, after: 3 },
318
+ tabStops: [{ type: "right", position: 8506, leader: "none" }]
703
319
  },
704
- subtitle: {
320
+ TOC2: {
705
321
  font: "body",
706
- size: 16,
707
- italic: false,
322
+ size: 10.5,
708
323
  color: "textSecondary",
709
- alignment: "left",
710
- spacing: { before: 0, after: 24 }
324
+ indent: { left: 240 },
325
+ spacing: { after: 2 },
326
+ tabStops: [{ type: "right", position: 8506, leader: "none" }]
327
+ },
328
+ TOC3: {
329
+ font: "body",
330
+ size: 10,
331
+ color: "textMuted",
332
+ indent: { left: 480 },
333
+ spacing: { after: 2 },
334
+ tabStops: [{ type: "right", position: 8506, leader: "none" }]
711
335
  }
712
336
  },
713
337
  componentDefaults: {
714
338
  table: {
715
- borderColor: "#D6DAE0"
339
+ borderColor: "#D8D3C8",
340
+ borderSize: 0.5,
341
+ hideBorders: { left: true, right: true, insideVertical: true },
342
+ cellDefaults: {
343
+ padding: { top: 3, bottom: 3 }
344
+ },
345
+ headerCellDefaults: {
346
+ font: { bold: true },
347
+ color: "#2B302B",
348
+ borderColor: { bottom: "#2B302B" },
349
+ borderSize: { bottom: 1 }
350
+ }
716
351
  },
717
352
  list: {
718
353
  format: "bullet",
719
- bullet: "\u2022"
354
+ bullet: "\u2013",
355
+ spacing: { item: 2 }
720
356
  },
721
357
  image: {
722
- alignment: "center"
358
+ alignment: "left"
723
359
  },
724
360
  statistic: {
725
- alignment: "center"
361
+ alignment: "left"
726
362
  },
727
363
  section: {
728
364
  pageBreak: false
@@ -738,29 +374,32 @@ var init_devportal_docx_theme = __esm({
738
374
  "src/templates/themes/devportal.docx.theme.json"() {
739
375
  devportal_docx_theme_default = {
740
376
  name: "devportal",
741
- displayName: "Developer Portal",
742
- description: "A modern developer-focused theme with cool grays, teal accents, and monospace code styling",
743
- version: "2.0.0",
377
+ displayName: "Field Editorial",
378
+ description: "A compact editorial theme \u2014 Helvetica in near-black ink with a burnt-orange accent, tight condensed titles, letterspaced labels, warm tinted fills and hairline rules",
379
+ version: "4.0.0",
744
380
  colors: {
745
- primary: "#0F172A",
746
- secondary: "#334155",
747
- accent: "#0D9488",
748
- text: "#0F172A",
381
+ primary: "#12191F",
382
+ secondary: "#172028",
383
+ accent: "#E35B3F",
384
+ text: "#232323",
749
385
  background: "#FFFFFF",
750
- border: "#E2E8F0",
751
- textPrimary: "#0F172A",
752
- textSecondary: "#475569",
753
- textMuted: "#94A3B8",
754
- borderPrimary: "#CBD5E1",
755
- borderSecondary: "#F1F5F9",
386
+ border: "#E2E0DD",
387
+ textPrimary: "#232323",
388
+ textSecondary: "#46494C",
389
+ textMuted: "#737373",
390
+ borderPrimary: "#D8D5D1",
391
+ borderSecondary: "#F2F3F3",
756
392
  backgroundPrimary: "#FFFFFF",
757
- backgroundSecondary: "#F8FAFC"
393
+ backgroundSecondary: "#F7ECE7",
394
+ accent4: "#46494C",
395
+ accent5: "#8A9299",
396
+ accent6: "#E8A18D"
758
397
  },
759
398
  fonts: {
760
- heading: { family: "Helvetica", size: 24 },
761
- body: { family: "Calibri", size: 11 },
762
- mono: { family: "Consolas", size: 10 },
763
- light: { family: "Helvetica", size: 24 }
399
+ heading: { family: "Helvetica", size: 23 },
400
+ body: { family: "Helvetica", size: 9.5 },
401
+ mono: { family: "Courier New", size: 10 },
402
+ light: { family: "Helvetica", size: 23 }
764
403
  },
765
404
  page: {
766
405
  size: "A4",
@@ -778,22 +417,42 @@ var init_devportal_docx_theme = __esm({
778
417
  normal: {
779
418
  font: "body",
780
419
  color: "textPrimary",
781
- lineSpacing: { type: "multiple", value: 1.5 },
420
+ lineSpacing: { type: "multiple", value: 1.3 },
782
421
  alignment: "left",
783
- spacing: { after: 8 }
422
+ spacing: { after: 7 }
423
+ },
424
+ title: {
425
+ font: "heading",
426
+ size: 29,
427
+ bold: true,
428
+ color: "primary",
429
+ alignment: "left",
430
+ lineSpacing: { type: "multiple", value: 1.02 },
431
+ characterSpacing: { type: "condensed", value: 8 },
432
+ spacing: { before: 0, after: 10 }
433
+ },
434
+ subtitle: {
435
+ font: "body",
436
+ size: 10.5,
437
+ italic: false,
438
+ color: "textSecondary",
439
+ alignment: "left",
440
+ lineSpacing: { type: "multiple", value: 1.25 },
441
+ spacing: { before: 0, after: 12 }
784
442
  },
785
443
  heading1: {
786
444
  font: "heading",
787
- size: 24,
445
+ size: 21,
788
446
  bold: true,
789
447
  color: "primary",
790
- spacing: { before: 24, after: 12 },
448
+ lineSpacing: { type: "multiple", value: 1.15 },
449
+ spacing: { before: 26, after: 12 },
791
450
  keepNext: true,
792
451
  alignment: "left",
793
452
  borders: {
794
453
  bottom: {
795
454
  style: "single",
796
- size: 1,
455
+ size: 4,
797
456
  color: "accent",
798
457
  space: 6
799
458
  }
@@ -801,54 +460,97 @@ var init_devportal_docx_theme = __esm({
801
460
  },
802
461
  heading2: {
803
462
  font: "heading",
804
- size: 18,
463
+ size: 15.5,
805
464
  bold: true,
806
465
  color: "secondary",
807
- spacing: { before: 18, after: 8 },
466
+ lineSpacing: { type: "multiple", value: 1.15 },
467
+ spacing: { before: 20, after: 8 },
808
468
  keepNext: true,
809
469
  alignment: "left"
810
470
  },
811
471
  heading3: {
812
472
  font: "body",
813
- size: 13,
473
+ size: 12.5,
814
474
  bold: true,
815
- color: "accent",
816
- spacing: { before: 12, after: 6 },
475
+ color: "secondary",
476
+ spacing: { before: 14, after: 6 },
817
477
  keepNext: true,
818
478
  alignment: "left"
819
479
  },
820
480
  heading4: {
821
481
  font: "body",
822
- size: 12,
482
+ size: 11.5,
823
483
  bold: true,
484
+ color: "textPrimary",
485
+ spacing: { before: 12, after: 4 },
486
+ keepNext: true,
487
+ alignment: "left"
488
+ },
489
+ heading5: {
490
+ font: "mono",
491
+ size: 10.5,
492
+ bold: true,
493
+ color: "secondary",
494
+ spacing: { before: 10, after: 4 },
495
+ keepNext: true,
496
+ alignment: "left"
497
+ },
498
+ heading6: {
499
+ font: "body",
500
+ size: 10.5,
501
+ bold: false,
824
502
  color: "textSecondary",
825
- spacing: { before: 8, after: 4 },
826
- keepNext: true
503
+ characterSpacing: { type: "expanded", value: 20 },
504
+ spacing: { before: 10, after: 4 },
505
+ keepNext: true,
506
+ alignment: "left"
827
507
  },
828
- title: {
829
- font: "heading",
830
- size: 32,
508
+ TOC1: {
509
+ font: "body",
510
+ size: 11,
831
511
  bold: true,
832
512
  color: "primary",
833
- alignment: "left",
834
- spacing: { before: 0, after: 12 }
513
+ spacing: { before: 5, after: 3 },
514
+ tabStops: [{ type: "right", position: 9746, leader: "dot" }]
835
515
  },
836
- subtitle: {
837
- font: "light",
838
- size: 16,
839
- italic: false,
516
+ TOC2: {
517
+ font: "body",
518
+ size: 10.5,
519
+ color: "textPrimary",
520
+ indent: { left: 240 },
521
+ spacing: { after: 2 },
522
+ tabStops: [{ type: "right", position: 9746, leader: "dot" }]
523
+ },
524
+ TOC3: {
525
+ font: "body",
526
+ size: 10,
840
527
  color: "textSecondary",
841
- alignment: "left",
842
- spacing: { before: 0, after: 24 }
528
+ indent: { left: 480 },
529
+ spacing: { after: 2 },
530
+ tabStops: [{ type: "right", position: 9746, leader: "dot" }]
843
531
  }
844
532
  },
845
533
  componentDefaults: {
846
534
  table: {
847
- borderColor: "#E2E8F0"
535
+ width: 100,
536
+ borderColor: "#E2E0DD",
537
+ borderSize: 0.5,
538
+ hideBorders: { left: true, right: true, insideVertical: true },
539
+ cellDefaults: {
540
+ padding: { top: 3, bottom: 3 }
541
+ },
542
+ headerCellDefaults: {
543
+ font: { bold: true },
544
+ color: "#172028",
545
+ backgroundColor: "#F7ECE7",
546
+ borderColor: { bottom: "#D8D5D1" },
547
+ borderSize: { bottom: 1 }
548
+ }
848
549
  },
849
550
  list: {
850
551
  format: "bullet",
851
- bullet: "\u2013"
552
+ bullet: "\u2014",
553
+ spacing: { item: 2 }
852
554
  },
853
555
  image: {
854
556
  alignment: "center"
@@ -898,7 +600,7 @@ var init_vermilion_docx_theme = __esm({
898
600
  size: 10.5
899
601
  },
900
602
  mono: {
901
- family: "Consolas",
603
+ family: "Courier New",
902
604
  size: 10
903
605
  },
904
606
  light: {
@@ -975,6 +677,47 @@ var init_vermilion_docx_theme = __esm({
975
677
  keepNext: true,
976
678
  alignment: "left"
977
679
  },
680
+ heading4: {
681
+ font: "body",
682
+ size: 10.5,
683
+ bold: true,
684
+ color: "textSecondary",
685
+ spacing: {
686
+ before: 10,
687
+ after: 4
688
+ },
689
+ keepNext: true,
690
+ alignment: "left"
691
+ },
692
+ heading5: {
693
+ font: "body",
694
+ size: 10.5,
695
+ bold: false,
696
+ italic: true,
697
+ color: "textSecondary",
698
+ spacing: {
699
+ before: 9,
700
+ after: 4
701
+ },
702
+ keepNext: true,
703
+ alignment: "left"
704
+ },
705
+ heading6: {
706
+ font: "body",
707
+ size: 10,
708
+ bold: true,
709
+ color: "textMuted",
710
+ characterSpacing: {
711
+ type: "expanded",
712
+ value: 30
713
+ },
714
+ spacing: {
715
+ before: 9,
716
+ after: 4
717
+ },
718
+ keepNext: true,
719
+ alignment: "left"
720
+ },
978
721
  title: {
979
722
  font: "heading",
980
723
  size: 38,
@@ -996,6 +739,46 @@ var init_vermilion_docx_theme = __esm({
996
739
  after: 10
997
740
  }
998
741
  }
742
+ },
743
+ componentDefaults: {
744
+ table: {
745
+ width: 100,
746
+ borderColor: "#C7C8CA",
747
+ borderSize: 0.5,
748
+ hideBorders: {
749
+ top: true,
750
+ left: true,
751
+ right: true,
752
+ insideVertical: true
753
+ },
754
+ cellDefaults: {
755
+ font: { size: 9.5 },
756
+ padding: { top: 7, bottom: 7 },
757
+ verticalAlignment: "middle"
758
+ },
759
+ headerCellDefaults: {
760
+ color: "#EF4130",
761
+ font: { size: 9.5, bold: true },
762
+ padding: { top: 0, bottom: 8 },
763
+ verticalAlignment: "bottom",
764
+ borderColor: { bottom: "#EF4130" },
765
+ borderSize: { bottom: 0.5 }
766
+ }
767
+ },
768
+ list: {
769
+ format: "bullet",
770
+ bullet: "\u2014",
771
+ spacing: { item: 2 }
772
+ },
773
+ image: {
774
+ alignment: "center"
775
+ },
776
+ statistic: {
777
+ alignment: "center"
778
+ },
779
+ section: {
780
+ pageBreak: false
781
+ }
999
782
  }
1000
783
  };
1001
784
  }
@@ -1014,9 +797,6 @@ function loadThemesFromJson() {
1014
797
  }
1015
798
  const themes2 = {
1016
799
  minimal: ensureThemeDefaults(minimal_docx_theme_default),
1017
- corporate: ensureThemeDefaults(corporate_docx_theme_default),
1018
- modern: ensureThemeDefaults(modern_docx_theme_default),
1019
- apex: ensureThemeDefaults(apex_docx_theme_default),
1020
800
  devportal: ensureThemeDefaults(devportal_docx_theme_default),
1021
801
  vermilion: ensureThemeDefaults(vermilion_docx_theme_default)
1022
802
  };
@@ -1056,15 +836,12 @@ function loadThemesFromJson() {
1056
836
  _themesCache = themes2;
1057
837
  return themes2;
1058
838
  }
1059
- var _themesCache, themes, getTheme, getThemeWithFallback, hasTheme, getThemeNames, minimalTheme, corporateTheme, modernTheme;
839
+ var _themesCache, themes, getTheme, getThemeWithFallback, hasTheme, getThemeNames, minimalTheme, devportalTheme, vermilionTheme;
1060
840
  var init_themes = __esm({
1061
841
  "src/templates/themes/index.ts"() {
1062
842
  "use strict";
1063
843
  init_defaults();
1064
844
  init_minimal_docx_theme();
1065
- init_corporate_docx_theme();
1066
- init_modern_docx_theme();
1067
- init_apex_docx_theme();
1068
845
  init_devportal_docx_theme();
1069
846
  init_vermilion_docx_theme();
1070
847
  _themesCache = null;
@@ -1088,8 +865,8 @@ var init_themes = __esm({
1088
865
  return Object.keys(themes);
1089
866
  };
1090
867
  minimalTheme = themes["minimal"];
1091
- corporateTheme = themes["corporate"];
1092
- modernTheme = themes["modern"];
868
+ devportalTheme = themes["devportal"];
869
+ vermilionTheme = themes["vermilion"];
1093
870
  }
1094
871
  });
1095
872
 
@@ -1834,6 +1611,7 @@ var init_widthUtils = __esm({
1834
1611
 
1835
1612
  // src/utils/imageUtils.ts
1836
1613
  import { readFileSync } from "fs";
1614
+ import { availableParallelism } from "os";
1837
1615
  import probe from "probe-image-size";
1838
1616
  function loadResvg() {
1839
1617
  resvgModule ??= import("@resvg/resvg-js");
@@ -1852,10 +1630,36 @@ function capToPixelBudget(edge, aspect) {
1852
1630
  const scaled = Math.floor(edge * Math.sqrt(SVG_MAX_TOTAL_PX / total));
1853
1631
  return scaled >= SVG_MIN_EDGE_PX ? scaled : void 0;
1854
1632
  }
1633
+ function fallbackConcurrency() {
1634
+ const cpus = availableParallelism?.() ?? 4;
1635
+ return Math.max(1, Math.min(8, cpus));
1636
+ }
1637
+ async function rasterizeSvgFallbacks(jobs, enabled = true) {
1638
+ const out = /* @__PURE__ */ new Map();
1639
+ if (!enabled || jobs.length === 0) return out;
1640
+ let next = 0;
1641
+ const worker = async () => {
1642
+ for (let i = next++; i < jobs.length; i = next++) {
1643
+ const job = jobs[i];
1644
+ out.set(
1645
+ job.key,
1646
+ await rasterizeSvgFallback(job.svg, {
1647
+ width: job.width,
1648
+ height: job.height
1649
+ })
1650
+ );
1651
+ }
1652
+ };
1653
+ await Promise.all(
1654
+ Array.from({ length: Math.min(fallbackConcurrency(), jobs.length) }, worker)
1655
+ );
1656
+ return out;
1657
+ }
1855
1658
  async function rasterizeSvgFallback(svg, transformation) {
1856
1659
  let Resvg;
1660
+ let renderAsync;
1857
1661
  try {
1858
- ({ Resvg } = await loadResvg());
1662
+ ({ Resvg, renderAsync } = await loadResvg());
1859
1663
  } catch (error) {
1860
1664
  reportWarning(
1861
1665
  "image",
@@ -1890,7 +1694,7 @@ async function rasterizeSvgFallback(svg, transformation) {
1890
1694
  return void 0;
1891
1695
  }
1892
1696
  return Buffer.from(
1893
- new Resvg(markup, { fitTo: { mode, value } }).render().asPng()
1697
+ (await renderAsync(markup, { fitTo: { mode, value } })).asPng()
1894
1698
  );
1895
1699
  } catch (error) {
1896
1700
  reportWarning(
@@ -2179,10 +1983,10 @@ import {
2179
1983
  EndnoteReferenceRun,
2180
1984
  ExternalHyperlink,
2181
1985
  FootnoteReferenceRun,
1986
+ ImportedXmlComponent,
2182
1987
  InsertedTextRun,
2183
1988
  InternalHyperlink,
2184
1989
  OverlapType,
2185
- PageNumber,
2186
1990
  Paragraph,
2187
1991
  RelativeHorizontalPosition,
2188
1992
  RelativeVerticalPosition,
@@ -2202,6 +2006,28 @@ import {
2202
2006
  WpsShapeRun
2203
2007
  } from "docx";
2204
2008
  import { assertNever } from "@json-to-office/shared/rendering";
2009
+ function complexField(instruction, formatting, leading) {
2010
+ const options = runOptions(formatting);
2011
+ const fieldChar = (type, extra = {}) => new TextRun({
2012
+ children: [
2013
+ new ImportedXmlComponent("w:fldChar", { "w:fldCharType": type })
2014
+ ],
2015
+ ...options,
2016
+ ...extra
2017
+ });
2018
+ const instrText = new ImportedXmlComponent("w:instrText", {
2019
+ "xml:space": "preserve"
2020
+ });
2021
+ instrText.push(instruction);
2022
+ return [
2023
+ // A pending line break rides on the first run of the field, the same way
2024
+ // it rides on the single run every other inline node emits.
2025
+ fieldChar("begin", leading),
2026
+ new TextRun({ children: [instrText], ...options }),
2027
+ fieldChar("separate"),
2028
+ fieldChar("end")
2029
+ ];
2030
+ }
2205
2031
  function runOptions(formatting) {
2206
2032
  if (!formatting) return {};
2207
2033
  const options = {};
@@ -2306,18 +2132,13 @@ function inlineChildren(children, resources = /* @__PURE__ */ new Map()) {
2306
2132
  out.push(new SimpleField(child.instruction, child.cachedText));
2307
2133
  break;
2308
2134
  }
2309
- const page = PAGE_FIELD[child.instruction];
2310
- if (!page) {
2135
+ if (!PAGE_FIELDS.has(child.instruction)) {
2311
2136
  throw new Error(
2312
2137
  `the docxjs renderer has no emitter for the field "${child.instruction}"`
2313
2138
  );
2314
2139
  }
2315
2140
  out.push(
2316
- new TextRun({
2317
- children: [page],
2318
- ...runOptions(child.formatting),
2319
- ...breakOption()
2320
- })
2141
+ ...complexField(child.instruction, child.formatting, breakOption())
2321
2142
  );
2322
2143
  break;
2323
2144
  }
@@ -2691,7 +2512,7 @@ function emitBorder(border3) {
2691
2512
  ...border3.spacePoints !== void 0 ? { space: border3.spacePoints } : {}
2692
2513
  };
2693
2514
  }
2694
- var ALIGNMENT2, PAGE_FIELD, WRAP_TYPE, VERTICAL_ALIGN, TABLE_ANCHOR, HORIZONTAL_POSITION, VERTICAL_POSITION, BORDER_STYLE;
2515
+ var ALIGNMENT2, PAGE_FIELDS, WRAP_TYPE, VERTICAL_ALIGN, TABLE_ANCHOR, HORIZONTAL_POSITION, VERTICAL_POSITION, BORDER_STYLE;
2695
2516
  var init_emit = __esm({
2696
2517
  "src/renderers/docxjs/emit.ts"() {
2697
2518
  "use strict";
@@ -2703,10 +2524,7 @@ var init_emit = __esm({
2703
2524
  start: AlignmentType.START,
2704
2525
  end: AlignmentType.END
2705
2526
  };
2706
- PAGE_FIELD = {
2707
- PAGE: PageNumber.CURRENT,
2708
- NUMPAGES: PageNumber.TOTAL_PAGES
2709
- };
2527
+ PAGE_FIELDS = /* @__PURE__ */ new Set(["PAGE", "NUMPAGES"]);
2710
2528
  WRAP_TYPE = {
2711
2529
  none: TextWrappingType.NONE,
2712
2530
  square: TextWrappingType.SQUARE,
@@ -3053,7 +2871,10 @@ function createDocxJsRenderer() {
3053
2871
  format: "docx",
3054
2872
  capabilities: DOCXJS_CAPABILITIES,
3055
2873
  async render(ir, renderOptions) {
3056
- const resources = await prepareImages(ir);
2874
+ const resources = await prepareImages(
2875
+ ir,
2876
+ renderOptions?.svgRasterFallback
2877
+ );
3057
2878
  const document = buildDocument(ir, resources);
3058
2879
  const packed = await Packer.toBuffer(document);
3059
2880
  const fixed = fixFloatingImageIdsInBuffer(packed);
@@ -3138,22 +2959,22 @@ function numberingConfig(numbering) {
3138
2959
  }))
3139
2960
  };
3140
2961
  }
3141
- async function prepareImages(ir) {
2962
+ async function prepareImages(ir, svgRasterFallback) {
3142
2963
  const placements = collectImagePlacements(ir);
3143
- const rasters = /* @__PURE__ */ new Map();
2964
+ const jobs = [];
3144
2965
  for (const resource of ir.resources) {
3145
2966
  if (resource.kind !== "image" || resource.mediaType !== "svg") continue;
3146
2967
  for (const size of placements.get(resource.id) ?? []) {
3147
2968
  const [width, height] = size.split("x").map(Number);
3148
- rasters.set(
3149
- `${resource.id}:${size}`,
3150
- await rasterizeSvgFallback(Buffer.from(resource.bytes), {
3151
- width,
3152
- height
3153
- })
3154
- );
2969
+ jobs.push({
2970
+ key: `${resource.id}:${size}`,
2971
+ svg: Buffer.from(resource.bytes),
2972
+ width,
2973
+ height
2974
+ });
3155
2975
  }
3156
2976
  }
2977
+ const rasters = await rasterizeSvgFallbacks(jobs, svgRasterFallback);
3157
2978
  const resources = /* @__PURE__ */ new Map();
3158
2979
  for (const resource of ir.resources) {
3159
2980
  if (resource.kind !== "image") continue;
@@ -4320,7 +4141,11 @@ async function createOfficeOpenDocxRenderer() {
4320
4141
  capabilities: OFFICE_OPEN_CAPABILITIES,
4321
4142
  async render(ir, options) {
4322
4143
  const charts = [];
4323
- const document = await buildDocumentOptions(ir, charts);
4144
+ const document = await buildDocumentOptions(
4145
+ ir,
4146
+ charts,
4147
+ options?.svgRasterFallback
4148
+ );
4324
4149
  const bytes = await backend.generateDocument(document, {
4325
4150
  type: "uint8array"
4326
4151
  });
@@ -4345,10 +4170,10 @@ async function createOfficeOpenDocxRenderer() {
4345
4170
  }
4346
4171
  };
4347
4172
  }
4348
- async function buildDocumentOptions(ir, charts = []) {
4173
+ async function buildDocumentOptions(ir, charts = [], svgRasterFallback) {
4349
4174
  let nextDrawingId = 1;
4350
4175
  const ctx = {
4351
- pictures: await prepareImages2(ir),
4176
+ pictures: await prepareImages2(ir, svgRasterFallback),
4352
4177
  nextDrawingId: () => nextDrawingId++,
4353
4178
  charts
4354
4179
  };
@@ -4397,22 +4222,22 @@ function noteBodies2(notes, ctx) {
4397
4222
  }
4398
4223
  return bodies;
4399
4224
  }
4400
- async function prepareImages2(ir) {
4225
+ async function prepareImages2(ir, svgRasterFallback) {
4401
4226
  const placements = collectImagePlacements2(ir);
4402
- const rasters = /* @__PURE__ */ new Map();
4227
+ const jobs = [];
4403
4228
  for (const resource of ir.resources) {
4404
4229
  if (resource.kind !== "image" || resource.mediaType !== "svg") continue;
4405
4230
  for (const size of placements.get(resource.id) ?? []) {
4406
4231
  const [width, height] = size.split("x").map(Number);
4407
- rasters.set(
4408
- `${resource.id}:${size}`,
4409
- await rasterizeSvgFallback(Buffer.from(resource.bytes), {
4410
- width,
4411
- height
4412
- })
4413
- );
4232
+ jobs.push({
4233
+ key: `${resource.id}:${size}`,
4234
+ svg: Buffer.from(resource.bytes),
4235
+ width,
4236
+ height
4237
+ });
4414
4238
  }
4415
4239
  }
4240
+ const rasters = await rasterizeSvgFallbacks(jobs, svgRasterFallback);
4416
4241
  const resources = /* @__PURE__ */ new Map();
4417
4242
  for (const resource of ir.resources) {
4418
4243
  if (resource.kind !== "image") continue;
@@ -6965,6 +6790,9 @@ function createLevelsFromSimplifiedProps(props) {
6965
6790
  text = "";
6966
6791
  } else {
6967
6792
  format2 = props.format;
6793
+ if (format2 === "bullet") {
6794
+ text = props.bullet || "\u2022";
6795
+ }
6968
6796
  }
6969
6797
  } else {
6970
6798
  format2 = "bullet";
@@ -7176,7 +7004,7 @@ function outerBorderOverride(position, tableBorderColor, tableBorderSize) {
7176
7004
  const color = normalizeBorderColor(tableBorderColor);
7177
7005
  if (tableBorderColor && color) {
7178
7006
  result.borderColor = {};
7179
- if (position.isHeader && color.top !== UNSET_COLOR) {
7007
+ if ((position.isHeader || position.isFirstRow) && color.top !== UNSET_COLOR) {
7180
7008
  result.borderColor.top = color.top;
7181
7009
  }
7182
7010
  if (position.isFirstCol && color.left !== UNSET_COLOR) {
@@ -7192,7 +7020,7 @@ function outerBorderOverride(position, tableBorderColor, tableBorderSize) {
7192
7020
  const size = normalizeBorderSize(tableBorderSize);
7193
7021
  if (tableBorderSize && size) {
7194
7022
  result.borderSize = {};
7195
- if (position.isHeader && size.top !== UNSET_SIZE) {
7023
+ if ((position.isHeader || position.isFirstRow) && size.top !== UNSET_SIZE) {
7196
7024
  result.borderSize.top = size.top;
7197
7025
  }
7198
7026
  if (position.isFirstCol && size.left !== UNSET_SIZE) {
@@ -7412,6 +7240,7 @@ function resolveTableModel(source, theme, themeName, options = {}) {
7412
7240
  (max, height) => height === void 0 ? max : max === void 0 ? height : Math.max(max, height),
7413
7241
  void 0
7414
7242
  );
7243
+ const hasHeader = columns.some((column) => column.header !== void 0);
7415
7244
  const headerMerges = columns.map(
7416
7245
  (column, colIndex) => mergeHeaderCellDefaults(
7417
7246
  source.cellDefaults,
@@ -7453,6 +7282,7 @@ function resolveTableModel(source, theme, themeName, options = {}) {
7453
7282
  };
7454
7283
  const rows = Array.from({ length: rowCount }, (_, rowIndex) => {
7455
7284
  const isLastRow = rowIndex === rowCount - 1;
7285
+ const isFirstRow = !hasHeader && rowIndex === 0;
7456
7286
  const rowProps = source.rows?.[rowIndex];
7457
7287
  const merges = columns.map(
7458
7288
  (column, colIndex) => mergeCellDefaults(
@@ -7460,6 +7290,7 @@ function resolveTableModel(source, theme, themeName, options = {}) {
7460
7290
  column.cellDefaults,
7461
7291
  column.cells?.[rowIndex],
7462
7292
  {
7293
+ isFirstRow,
7463
7294
  isFirstCol: colIndex === 0,
7464
7295
  isLastCol: colIndex === columnCount - 1,
7465
7296
  isLastRow
@@ -7486,8 +7317,7 @@ function resolveTableModel(source, theme, themeName, options = {}) {
7486
7317
  const cell = column.cells?.[rowIndex];
7487
7318
  const merged = merges[colIndex];
7488
7319
  const position = {
7489
- // Data rows are never the first row; the header is.
7490
- isFirstRow: false,
7320
+ isFirstRow,
7491
7321
  isFirstCol: colIndex === 0,
7492
7322
  isLastCol: colIndex === columnCount - 1,
7493
7323
  isLastRow
@@ -7517,10 +7347,10 @@ function resolveTableModel(source, theme, themeName, options = {}) {
7517
7347
  };
7518
7348
  return row;
7519
7349
  });
7520
- adjudicateInteriorEdges([header, ...rows]);
7350
+ adjudicateInteriorEdges([...hasHeader ? [header] : [], ...rows]);
7521
7351
  return {
7522
7352
  ...resolveWidths(source, columns, theme, themeName),
7523
- header,
7353
+ ...hasHeader ? { header } : {},
7524
7354
  rows,
7525
7355
  repeatHeader: source.repeatHeaderOnPageBreak ?? true
7526
7356
  };
@@ -7988,6 +7818,44 @@ function buildNoProofWordsRegex(noProofWords2) {
7988
7818
  );
7989
7819
  }
7990
7820
  var DECORATOR = /(\*\*\*|___)([\s\S]*?)\1|(\*\*|__)([\s\S]*?)\3|(\*|_)([\s\S]*?)\5/g;
7821
+ var ESCAPABLE = "*_[]{}\\";
7822
+ var ESCAPE = /\\([*_[\]{}\\])/g;
7823
+ var SENTINEL = "\uE000";
7824
+ var SENTINEL_SELF = "x";
7825
+ var SENTINEL_DIGIT_BASE = 48;
7826
+ function encodeEscapes(text) {
7827
+ const authored = text.includes(SENTINEL);
7828
+ if (!authored && !text.includes("\\")) return text;
7829
+ const guarded = authored ? text.split(SENTINEL).join(SENTINEL + SENTINEL_SELF) : text;
7830
+ return guarded.replace(
7831
+ ESCAPE,
7832
+ (_whole, char) => SENTINEL + String.fromCharCode(SENTINEL_DIGIT_BASE + ESCAPABLE.indexOf(char))
7833
+ );
7834
+ }
7835
+ function decodeEscapes(text) {
7836
+ if (!text.includes(SENTINEL)) return text;
7837
+ let out = "";
7838
+ for (let i = 0; i < text.length; i += 1) {
7839
+ if (text[i] !== SENTINEL) {
7840
+ out += text[i];
7841
+ continue;
7842
+ }
7843
+ const marker = text[i + 1];
7844
+ if (marker === SENTINEL_SELF) {
7845
+ out += SENTINEL;
7846
+ i += 1;
7847
+ continue;
7848
+ }
7849
+ const index = marker === void 0 ? -1 : marker.charCodeAt(0) - SENTINEL_DIGIT_BASE;
7850
+ if (index >= 0 && index < ESCAPABLE.length) {
7851
+ out += ESCAPABLE[index];
7852
+ i += 1;
7853
+ continue;
7854
+ }
7855
+ out += text[i];
7856
+ }
7857
+ return out;
7858
+ }
7991
7859
  var LINK = /\[([^\]]+)\]\(([^)]+)\)/g;
7992
7860
  var DECORATOR_OR_PLACEHOLDER = /(\*\*\*|___)([\s\S]*?)\1|(\*\*|__)([\s\S]*?)\3|(\*|_)([\s\S]*?)\5|\{([^}]+)\}/g;
7993
7861
  var PLACEHOLDER = /\{([^}]+)\}/;
@@ -8014,7 +7882,7 @@ function containsUnsupportedSyntax(text) {
8014
7882
  return void 0;
8015
7883
  }
8016
7884
  function parseInline(text, options) {
8017
- const normalized = normalizeUnicodeText(text);
7885
+ const normalized = encodeEscapes(normalizeUnicodeText(text));
8018
7886
  if (!normalized) {
8019
7887
  return [
8020
7888
  { kind: "text", text: "", formatting: emptyToUndefined(options.base) }
@@ -8112,7 +7980,7 @@ function parseLinks(normalized, options) {
8112
7980
  lastIndex = match.index + match[0].length;
8113
7981
  if (match[1] === void 0) {
8114
7982
  const resolved = options.resolveCrossReference?.(
8115
- match[3],
7983
+ decodeEscapes(match[3]),
8116
7984
  match[4] ?? "relative",
8117
7985
  match[0]
8118
7986
  );
@@ -8120,7 +7988,8 @@ function parseLinks(normalized, options) {
8120
7988
  else out.push(...parseDecorated(match[0], options));
8121
7989
  continue;
8122
7990
  }
8123
- const [, linkText, target] = match;
7991
+ const [, linkText] = match;
7992
+ const target = decodeEscapes(match[2]);
8124
7993
  out.push({
8125
7994
  kind: "hyperlink",
8126
7995
  // A `#anchor` target names a bookmark in this document and needs no
@@ -8176,7 +8045,7 @@ function pushSegment(out, text, options, override = {}) {
8176
8045
  const bold = override.bold ?? options.base.bold;
8177
8046
  const italic = override.italic ?? options.base.italic;
8178
8047
  const formatting = runFormatting2(options, { bold, italic });
8179
- const lines = text.split("\n");
8048
+ const lines = decodeEscapes(text).split("\n");
8180
8049
  for (const [lineIndex, line] of lines.entries()) {
8181
8050
  if (!line && lineIndex === 0) continue;
8182
8051
  if (lineIndex > 0) out.push({ kind: "lineBreak" });
@@ -8362,18 +8231,32 @@ function compileDocument(structure, layout, warnings = [], images = /* @__PURE__
8362
8231
  };
8363
8232
  }
8364
8233
  var AFTER_TABLE_TWIPS = 120;
8234
+ var BEFORE_TABLE_TWIPS = 240;
8365
8235
  var BODY_STYLE_IDS = /* @__PURE__ */ new Set([void 0, "Normal"]);
8366
- function separateFromTables(blocks) {
8236
+ function separateFromTables(blocks, bodyAfterTwips) {
8367
8237
  for (let i = 1; i < blocks.length; i += 1) {
8368
8238
  const block2 = blocks[i];
8369
- if (blocks[i - 1].kind !== "table") continue;
8370
- if (block2.kind !== "paragraph") continue;
8371
- if (!BODY_STYLE_IDS.has(block2.styleId)) continue;
8372
- if (block2.formatting?.spacing?.beforeTwips !== void 0) continue;
8373
- block2.formatting = {
8374
- ...block2.formatting,
8375
- spacing: { ...block2.formatting?.spacing, beforeTwips: AFTER_TABLE_TWIPS }
8376
- };
8239
+ const previous = blocks[i - 1];
8240
+ if (previous.kind === "table" && block2.kind === "paragraph" && BODY_STYLE_IDS.has(block2.styleId) && // An author who stated their own space-before has already answered this.
8241
+ block2.formatting?.spacing?.beforeTwips === void 0) {
8242
+ block2.formatting = {
8243
+ ...block2.formatting,
8244
+ spacing: {
8245
+ ...block2.formatting?.spacing,
8246
+ beforeTwips: AFTER_TABLE_TWIPS
8247
+ }
8248
+ };
8249
+ }
8250
+ if (block2.kind === "table" && previous.kind === "paragraph" && BODY_STYLE_IDS.has(previous.styleId) && // Same rule as below: a stated space-after is the author's answer.
8251
+ previous.formatting?.spacing?.afterTwips === void 0) {
8252
+ previous.formatting = {
8253
+ ...previous.formatting,
8254
+ spacing: {
8255
+ ...previous.formatting?.spacing,
8256
+ afterTwips: Math.max(bodyAfterTwips, BEFORE_TABLE_TWIPS)
8257
+ }
8258
+ };
8259
+ }
8377
8260
  }
8378
8261
  }
8379
8262
  function collectOutline(layout, warnings) {
@@ -8452,7 +8335,10 @@ function compileSection(section2, index, ordinal, chrome, ctx) {
8452
8335
  })
8453
8336
  );
8454
8337
  });
8455
- separateFromTables(children);
8338
+ separateFromTables(
8339
+ children,
8340
+ pointsToTwips2(getNormalStyle(ctx.theme).spacing?.after ?? 0)
8341
+ );
8456
8342
  const compiled = {
8457
8343
  id: `s${index}`,
8458
8344
  path: path3,
@@ -9471,8 +9357,10 @@ function itemSpacing(spacing, index, count) {
9471
9357
  if (index === 0 && spacing?.before !== void 0) {
9472
9358
  out.beforeTwips = pointsToTwips2(spacing.before);
9473
9359
  }
9474
- if (index === count - 1 && spacing?.after !== void 0) {
9475
- out.afterTwips = pointsToTwips2(spacing.after);
9360
+ if (index === count - 1) {
9361
+ if (spacing?.after !== void 0) {
9362
+ out.afterTwips = pointsToTwips2(spacing.after);
9363
+ }
9476
9364
  } else if (spacing?.item !== void 0) {
9477
9365
  out.afterTwips = pointsToTwips2(spacing.item);
9478
9366
  }
@@ -10552,13 +10440,20 @@ function compileTable(component, scope) {
10552
10440
  return [];
10553
10441
  }
10554
10442
  const rows = [
10555
- compileTableRow(model.header, style.headerParagraph, style.tableHeader, {
10556
- ctx,
10557
- path: `${path3}.header`,
10558
- id: `${scope.id}:h`,
10559
- // Headers repeat across page breaks unless the source disabled it.
10560
- isHeader: model.repeatHeader
10561
- }),
10443
+ ...model.header ? [
10444
+ compileTableRow(
10445
+ model.header,
10446
+ style.headerParagraph,
10447
+ style.tableHeader,
10448
+ {
10449
+ ctx,
10450
+ path: `${path3}.header`,
10451
+ id: `${scope.id}:h`,
10452
+ // Headers repeat across page breaks unless the source disabled it.
10453
+ isHeader: model.repeatHeader
10454
+ }
10455
+ )
10456
+ ] : [],
10562
10457
  ...model.rows.map(
10563
10458
  (row, index) => compileTableRow(row, style.cellParagraph, style.tableCell, {
10564
10459
  ctx,
@@ -10620,9 +10515,10 @@ function tableSource(props) {
10620
10515
  };
10621
10516
  }
10622
10517
  function tableBlocker(model, path3) {
10623
- const rows = [model.header, ...model.rows];
10518
+ const headerRows = model.header ? [model.header] : [];
10519
+ const rows = [...headerRows, ...model.rows];
10624
10520
  for (const [rowIndex, row] of rows.entries()) {
10625
- const rowPath = row.isHeader ? `${path3}.header` : `${path3}.rows[${rowIndex - 1}]`;
10521
+ const rowPath = row.isHeader ? `${path3}.header` : `${path3}.rows[${rowIndex - headerRows.length}]`;
10626
10522
  for (const [colIndex, cell] of row.cells.entries()) {
10627
10523
  const cellPath = `${rowPath}.cells[${colIndex}]`;
10628
10524
  const content = cell.content;
@@ -12113,6 +12009,7 @@ async function renderScoped(document, options, warnings) {
12113
12009
  const bytes = await renderer.render(compiled.ir, {
12114
12010
  ...options.deterministic !== void 0 ? { deterministic: options.deterministic } : {},
12115
12011
  ...options.generatedAt !== void 0 ? { generatedAt: toDate(options.generatedAt) } : {},
12012
+ ...options.svgRasterFallback !== void 0 ? { svgRasterFallback: options.svgRasterFallback } : {},
12116
12013
  warnings: compiled.warnings
12117
12014
  });
12118
12015
  return { buffer: Buffer.from(bytes), warnings: compiled.warnings };
@@ -12289,7 +12186,8 @@ function createBuilderImpl(state) {
12289
12186
  deterministic: state.deterministic,
12290
12187
  generatedAt: state.generatedAt,
12291
12188
  baseDir: state.baseDir,
12292
- renderer: state.renderer
12189
+ renderer: state.renderer,
12190
+ svgRasterFallback: state.svgRasterFallback
12293
12191
  };
12294
12192
  return createBuilderImpl(
12295
12193
  newState
@@ -12546,7 +12444,8 @@ function createDocumentGenerator(options) {
12546
12444
  deterministic: options.deterministic ?? true,
12547
12445
  generatedAt: options.generatedAt,
12548
12446
  baseDir: options.baseDir,
12549
- renderer: options.renderer
12447
+ renderer: options.renderer,
12448
+ svgRasterFallback: options.svgRasterFallback
12550
12449
  };
12551
12450
  return createBuilderImpl(initialState);
12552
12451
  }