jspdf-md-renderer 3.3.2 → 3.3.3
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.
- package/README.md +5 -2
- package/dist/index.js +2 -2
- package/dist/index.mjs +943 -1336
- package/dist/index.umd.js +2 -2
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -1,1339 +1,946 @@
|
|
|
1
|
-
import { marked as
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
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
|
-
|
|
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
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
}
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
},
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
n.options.font.regular.name,
|
|
937
|
-
c
|
|
938
|
-
);
|
|
939
|
-
const p = n.options.page.maxContentWidth - i - n.X, f = t.splitTextToSize(s, p), d = l === "codespan", h = 1, m = "#EEEEEE";
|
|
940
|
-
if (n.isInlineLockActive)
|
|
941
|
-
for (let x = 0; x < f.length; x++) {
|
|
942
|
-
if (d) {
|
|
943
|
-
const b = t.getTextWidth(f[x]) + H(t), C = F(t);
|
|
944
|
-
t.setFillColor(m), t.roundedRect(
|
|
945
|
-
n.X + i - h,
|
|
946
|
-
n.Y - h,
|
|
947
|
-
b + h * 2,
|
|
948
|
-
C + h * 2,
|
|
949
|
-
2,
|
|
950
|
-
2,
|
|
951
|
-
"F"
|
|
952
|
-
), t.setFillColor("#000000");
|
|
953
|
-
}
|
|
954
|
-
t.text(f[x], n.X + i, n.Y, {
|
|
955
|
-
baseline: "top",
|
|
956
|
-
maxWidth: p
|
|
957
|
-
}), n.updateX(
|
|
958
|
-
t.getTextDimensions(f[x]).w + (d ? h * 2 : 1),
|
|
959
|
-
"add"
|
|
960
|
-
), x < f.length - 1 && (n.updateY(F(t), "add"), n.updateX(
|
|
961
|
-
n.options.page.xpading,
|
|
962
|
-
"set"
|
|
963
|
-
));
|
|
964
|
-
}
|
|
965
|
-
else if (f.length > 1) {
|
|
966
|
-
const x = f[0], b = f?.slice(1)?.join(" ");
|
|
967
|
-
if (d) {
|
|
968
|
-
const W = t.getTextWidth(x) + H(t), S = F(t);
|
|
969
|
-
t.setFillColor(m), t.roundedRect(
|
|
970
|
-
n.X + (i >= 2 ? i + 2 : 0) - h,
|
|
971
|
-
n.Y - h,
|
|
972
|
-
W + h * 2,
|
|
973
|
-
S + h * 2,
|
|
974
|
-
2,
|
|
975
|
-
2,
|
|
976
|
-
"F"
|
|
977
|
-
), t.setFillColor("#000000");
|
|
978
|
-
}
|
|
979
|
-
t.text(
|
|
980
|
-
x,
|
|
981
|
-
n.X + (i >= 2 ? i + 2 * g(l) : 0),
|
|
982
|
-
n.Y,
|
|
983
|
-
{
|
|
984
|
-
baseline: "top",
|
|
985
|
-
maxWidth: p
|
|
986
|
-
}
|
|
987
|
-
), n.updateX(n.options.page.xpading + i), n.updateY(F(t), "add");
|
|
988
|
-
const C = n.options.page.maxContentWidth - i - n.options.page.xpading;
|
|
989
|
-
t.splitTextToSize(
|
|
990
|
-
b,
|
|
991
|
-
C
|
|
992
|
-
).forEach((W) => {
|
|
993
|
-
if (d) {
|
|
994
|
-
const S = t.getTextWidth(W) + H(t), T = F(t);
|
|
995
|
-
t.setFillColor(m), t.roundedRect(
|
|
996
|
-
n.X + H(t) - h,
|
|
997
|
-
n.Y - h,
|
|
998
|
-
S + h * 2,
|
|
999
|
-
T + h * 2,
|
|
1000
|
-
2,
|
|
1001
|
-
2,
|
|
1002
|
-
"F"
|
|
1003
|
-
), t.setFillColor("#000000");
|
|
1004
|
-
}
|
|
1005
|
-
t.text(
|
|
1006
|
-
W,
|
|
1007
|
-
n.X + H(t),
|
|
1008
|
-
n.Y,
|
|
1009
|
-
{
|
|
1010
|
-
baseline: "top",
|
|
1011
|
-
maxWidth: C
|
|
1012
|
-
}
|
|
1013
|
-
);
|
|
1014
|
-
});
|
|
1015
|
-
} else {
|
|
1016
|
-
if (d) {
|
|
1017
|
-
const x = t.getTextWidth(s) + H(t), b = F(t);
|
|
1018
|
-
t.setFillColor(m), t.roundedRect(
|
|
1019
|
-
n.X + i - h,
|
|
1020
|
-
n.Y - h,
|
|
1021
|
-
x + h * 2,
|
|
1022
|
-
b + h * 2,
|
|
1023
|
-
2,
|
|
1024
|
-
2,
|
|
1025
|
-
"F"
|
|
1026
|
-
), t.setFillColor("#000000");
|
|
1027
|
-
}
|
|
1028
|
-
t.text(s, n.X + i, n.Y, {
|
|
1029
|
-
baseline: "top",
|
|
1030
|
-
maxWidth: p
|
|
1031
|
-
}), n.updateX(
|
|
1032
|
-
t.getTextDimensions(s).w + (i >= 2 ? s.split(" ").length + 2 : 2) * g(l) * 0.5 + (d ? h * 2 : 0),
|
|
1033
|
-
"add"
|
|
1034
|
-
);
|
|
1035
|
-
}
|
|
1036
|
-
};
|
|
1037
|
-
if (e.type === "text" && e.items && e.items.length > 0)
|
|
1038
|
-
for (const s of e.items)
|
|
1039
|
-
if (s.type === "codespan")
|
|
1040
|
-
a(s.content || "", "codespan");
|
|
1041
|
-
else if (s.type === "em" || s.type === "strong") {
|
|
1042
|
-
const l = s.type === "em" ? "italic" : "bold";
|
|
1043
|
-
if (s.items && s.items.length > 0)
|
|
1044
|
-
for (const p of s.items)
|
|
1045
|
-
p.type === "strong" && l === "italic" || p.type === "em" && l === "bold" ? a(
|
|
1046
|
-
p.content || "",
|
|
1047
|
-
"bolditalic"
|
|
1048
|
-
) : a(
|
|
1049
|
-
p.content || "",
|
|
1050
|
-
l
|
|
1051
|
-
);
|
|
1052
|
-
else
|
|
1053
|
-
a(s.content || "", l);
|
|
1054
|
-
} else
|
|
1055
|
-
a(s.content || "", "normal");
|
|
1056
|
-
else e.type === "em" ? a(e.content || "", "italic") : e.type === "strong" ? a(e.content || "", "bold") : e.type === "codespan" ? a(e.content || "", "codespan") : a(e.content || "", "normal");
|
|
1057
|
-
t.setFont(r, c), t.setFontSize(o);
|
|
1058
|
-
}, lt = (t, e, i) => {
|
|
1059
|
-
const r = t.getFont().fontName, c = t.getFont().fontStyle, o = t.getFontSize(), g = t.getTextColor(), a = n.options.link?.linkColor || [0, 0, 255];
|
|
1060
|
-
t.setTextColor(...a);
|
|
1061
|
-
const s = n.options.page.maxContentWidth - i - n.X, l = e.text || e.content || "", p = e.href || "", f = t.splitTextToSize(l, s);
|
|
1062
|
-
if (n.isInlineLockActive)
|
|
1063
|
-
for (let d = 0; d < f.length; d++) {
|
|
1064
|
-
const h = t.getTextDimensions(f[d]).w, m = F(t) / 2;
|
|
1065
|
-
t.link(
|
|
1066
|
-
n.X + i,
|
|
1067
|
-
n.Y,
|
|
1068
|
-
h,
|
|
1069
|
-
m,
|
|
1070
|
-
{ url: p }
|
|
1071
|
-
), t.text(f[d], n.X + i, n.Y, {
|
|
1072
|
-
baseline: "top",
|
|
1073
|
-
maxWidth: s
|
|
1074
|
-
}), n.updateX(h + 1, "add"), n.X + h > n.options.page.maxContentWidth - i && (n.updateY(m, "add"), n.updateX(
|
|
1075
|
-
n.options.page.xpading + i,
|
|
1076
|
-
"set"
|
|
1077
|
-
)), d < f.length - 1 && (n.updateY(m, "add"), n.updateX(
|
|
1078
|
-
n.options.page.xpading + i,
|
|
1079
|
-
"set"
|
|
1080
|
-
));
|
|
1081
|
-
}
|
|
1082
|
-
else if (f.length > 1) {
|
|
1083
|
-
const d = f[0], h = f?.slice(1)?.join(" "), m = t.getTextDimensions(d).w, x = F(t) / 2;
|
|
1084
|
-
t.link(
|
|
1085
|
-
n.X + i,
|
|
1086
|
-
n.Y,
|
|
1087
|
-
m,
|
|
1088
|
-
x,
|
|
1089
|
-
{ url: p }
|
|
1090
|
-
), t.text(d, n.X + i, n.Y, {
|
|
1091
|
-
baseline: "top",
|
|
1092
|
-
maxWidth: s
|
|
1093
|
-
}), n.updateX(n.options.page.xpading + i), n.updateY(x, "add");
|
|
1094
|
-
const b = n.options.page.maxContentWidth - i - n.options.page.xpading;
|
|
1095
|
-
t.splitTextToSize(h, b).forEach((y) => {
|
|
1096
|
-
const W = t.getTextDimensions(y).w;
|
|
1097
|
-
t.link(
|
|
1098
|
-
n.X + H(t),
|
|
1099
|
-
n.Y,
|
|
1100
|
-
W,
|
|
1101
|
-
x,
|
|
1102
|
-
{ url: p }
|
|
1103
|
-
), t.text(
|
|
1104
|
-
y,
|
|
1105
|
-
n.X + H(t),
|
|
1106
|
-
n.Y,
|
|
1107
|
-
{
|
|
1108
|
-
baseline: "top",
|
|
1109
|
-
maxWidth: b
|
|
1110
|
-
}
|
|
1111
|
-
);
|
|
1112
|
-
});
|
|
1113
|
-
} else {
|
|
1114
|
-
const d = t.getTextDimensions(l).w, h = F(t) / 2;
|
|
1115
|
-
t.link(
|
|
1116
|
-
n.X + i,
|
|
1117
|
-
n.Y,
|
|
1118
|
-
d,
|
|
1119
|
-
h,
|
|
1120
|
-
{ url: p }
|
|
1121
|
-
), t.text(l, n.X + i, n.Y, {
|
|
1122
|
-
baseline: "top",
|
|
1123
|
-
maxWidth: s
|
|
1124
|
-
}), n.updateX(d + 2, "add");
|
|
1125
|
-
}
|
|
1126
|
-
t.setFont(r, c), t.setFontSize(o), t.setTextColor(g);
|
|
1127
|
-
}, gt = (t, e, i, r) => {
|
|
1128
|
-
const c = n.options, o = i + 1, g = n.X + i * c.page.indent, a = n.Y, s = g + c.page.indent / 2, l = a, p = t.internal.getCurrentPageInfo().pageNumber;
|
|
1129
|
-
e.items && e.items.length > 0 && e.items.forEach((h) => {
|
|
1130
|
-
r(h, o);
|
|
1131
|
-
});
|
|
1132
|
-
const f = n.Y, d = t.internal.getCurrentPageInfo().pageNumber;
|
|
1133
|
-
t.setDrawColor(100), t.setLineWidth(1);
|
|
1134
|
-
for (let h = p; h <= d; h++) {
|
|
1135
|
-
t.setPage(h);
|
|
1136
|
-
const m = h === p, x = h === d, b = m ? l : c.page.topmargin, C = x ? f : c.page.maxContentHeight;
|
|
1137
|
-
t.line(s, b, s, C);
|
|
1138
|
-
}
|
|
1139
|
-
n.recordContentY(), t.setPage(d);
|
|
1140
|
-
}, ct = (t) => {
|
|
1141
|
-
if (t.data) {
|
|
1142
|
-
if (t.data.startsWith("data:image/png")) return "PNG";
|
|
1143
|
-
if (t.data.startsWith("data:image/jpeg") || t.data.startsWith("data:image/jpg"))
|
|
1144
|
-
return "JPEG";
|
|
1145
|
-
if (t.data.startsWith("data:image/webp") || t.data.startsWith("data:image/webp")) return "WEBP";
|
|
1146
|
-
if (t.data.startsWith("data:image/gif")) return "GIF";
|
|
1147
|
-
}
|
|
1148
|
-
if (t.src) {
|
|
1149
|
-
const i = t.src.split("?")[0].split("#")[0].split(".").pop()?.toUpperCase();
|
|
1150
|
-
if (i && ["PNG", "JPEG", "JPG", "WEBP", "GIF"].includes(i))
|
|
1151
|
-
return i === "JPG" ? "JPEG" : i;
|
|
1152
|
-
}
|
|
1153
|
-
return "JPEG";
|
|
1154
|
-
}, pt = (t, e, i) => {
|
|
1155
|
-
if (!e.data)
|
|
1156
|
-
return;
|
|
1157
|
-
const r = n.options, c = r.page.unit || "mm", o = i * r.page.indent, g = r.page.maxContentWidth - o, a = n.X + o;
|
|
1158
|
-
let s = n.Y;
|
|
1159
|
-
try {
|
|
1160
|
-
const l = r.page.maxContentHeight - r.page.topmargin, { finalWidth: p, finalHeight: f } = $(
|
|
1161
|
-
t,
|
|
1162
|
-
e,
|
|
1163
|
-
g,
|
|
1164
|
-
l,
|
|
1165
|
-
c
|
|
1166
|
-
);
|
|
1167
|
-
s + f > r.page.maxContentHeight && (Y(t), s = n.Y);
|
|
1168
|
-
const d = e.align || r.image?.defaultAlign || "left";
|
|
1169
|
-
let h;
|
|
1170
|
-
switch (d) {
|
|
1171
|
-
case "right":
|
|
1172
|
-
h = a + g - p;
|
|
1173
|
-
break;
|
|
1174
|
-
case "center":
|
|
1175
|
-
h = a + (g - p) / 2;
|
|
1176
|
-
break;
|
|
1177
|
-
default:
|
|
1178
|
-
h = a;
|
|
1179
|
-
break;
|
|
1180
|
-
}
|
|
1181
|
-
const m = ct(e);
|
|
1182
|
-
p > 0 && f > 0 && t.addImage(
|
|
1183
|
-
e.data,
|
|
1184
|
-
m,
|
|
1185
|
-
h,
|
|
1186
|
-
s,
|
|
1187
|
-
p,
|
|
1188
|
-
f
|
|
1189
|
-
), n.updateY(f, "add"), n.recordContentY();
|
|
1190
|
-
} catch (l) {
|
|
1191
|
-
console.warn("Failed to render image", l);
|
|
1192
|
-
}
|
|
1193
|
-
}, ht = () => {
|
|
1194
|
-
const t = z;
|
|
1195
|
-
if (typeof z == "function")
|
|
1196
|
-
return z;
|
|
1197
|
-
if (typeof t.default == "function")
|
|
1198
|
-
return t.default;
|
|
1199
|
-
if (typeof t.autoTable == "function")
|
|
1200
|
-
return t.autoTable;
|
|
1201
|
-
throw new Error(
|
|
1202
|
-
"Could not resolve jspdf-autotable export. Expected a callable export."
|
|
1203
|
-
);
|
|
1204
|
-
}, ft = (t, e, i) => {
|
|
1205
|
-
if (!e.header || !e.rows)
|
|
1206
|
-
return;
|
|
1207
|
-
const r = n.options, c = r.page.xmargin + i * r.page.indent, o = [e.header.map((s) => s.content || "")], g = e.rows.map(
|
|
1208
|
-
(s) => s.map((l) => l.content || "")
|
|
1209
|
-
), a = r.table || {};
|
|
1210
|
-
ht()(t, {
|
|
1211
|
-
head: o,
|
|
1212
|
-
body: g,
|
|
1213
|
-
startY: n.Y,
|
|
1214
|
-
margin: { left: c, right: r.page.xmargin },
|
|
1215
|
-
...a,
|
|
1216
|
-
didDrawPage: (s) => {
|
|
1217
|
-
a.didDrawPage && a.didDrawPage(s);
|
|
1218
|
-
},
|
|
1219
|
-
didDrawCell: (s) => {
|
|
1220
|
-
a.didDrawCell && a.didDrawCell(s), n.setCursor({
|
|
1221
|
-
x: n.X,
|
|
1222
|
-
y: s.cell.y + s.cell.height + 2 * r.page.lineSpace
|
|
1223
|
-
});
|
|
1224
|
-
}
|
|
1225
|
-
});
|
|
1226
|
-
}, D = {
|
|
1227
|
-
page: {
|
|
1228
|
-
indent: 10,
|
|
1229
|
-
maxContentWidth: 190,
|
|
1230
|
-
maxContentHeight: 277,
|
|
1231
|
-
lineSpace: 1.5,
|
|
1232
|
-
defaultLineHeightFactor: 1.2,
|
|
1233
|
-
defaultFontSize: 12,
|
|
1234
|
-
defaultTitleFontSize: 14,
|
|
1235
|
-
topmargin: 10,
|
|
1236
|
-
xpading: 10,
|
|
1237
|
-
xmargin: 10,
|
|
1238
|
-
format: "a4",
|
|
1239
|
-
orientation: "p"
|
|
1240
|
-
},
|
|
1241
|
-
font: {
|
|
1242
|
-
bold: { name: "helvetica", style: "bold" },
|
|
1243
|
-
regular: { name: "helvetica", style: "normal" },
|
|
1244
|
-
light: { name: "helvetica", style: "light" }
|
|
1245
|
-
},
|
|
1246
|
-
image: {
|
|
1247
|
-
defaultAlign: "left"
|
|
1248
|
-
}
|
|
1249
|
-
}, dt = (t) => {
|
|
1250
|
-
if (!t)
|
|
1251
|
-
throw new Error("RenderOption is required");
|
|
1252
|
-
const e = { ...D.page, ...t.page }, i = { ...D.font, ...t.font }, r = { ...D.image, ...t.image };
|
|
1253
|
-
return e.maxContentWidth || (e.maxContentWidth = 190), e.maxContentHeight || (e.maxContentHeight = 277), {
|
|
1254
|
-
...t,
|
|
1255
|
-
page: e,
|
|
1256
|
-
font: i,
|
|
1257
|
-
image: r
|
|
1258
|
-
};
|
|
1259
|
-
}, xt = async (t, e, i) => {
|
|
1260
|
-
const r = dt(i);
|
|
1261
|
-
n.initialize(r);
|
|
1262
|
-
const c = await K(e);
|
|
1263
|
-
await J(c);
|
|
1264
|
-
const o = (g, a = 0, s = !1, l = 0, p = !1) => {
|
|
1265
|
-
const f = a * r.page.indent;
|
|
1266
|
-
switch (g.type) {
|
|
1267
|
-
case u.Heading:
|
|
1268
|
-
tt(t, g, f, o);
|
|
1269
|
-
break;
|
|
1270
|
-
case u.Paragraph:
|
|
1271
|
-
et(t, g, f, o);
|
|
1272
|
-
break;
|
|
1273
|
-
case u.List:
|
|
1274
|
-
nt(t, g, a, o);
|
|
1275
|
-
break;
|
|
1276
|
-
case u.ListItem:
|
|
1277
|
-
it(
|
|
1278
|
-
t,
|
|
1279
|
-
g,
|
|
1280
|
-
a,
|
|
1281
|
-
o,
|
|
1282
|
-
l,
|
|
1283
|
-
p
|
|
1284
|
-
);
|
|
1285
|
-
break;
|
|
1286
|
-
case u.Hr:
|
|
1287
|
-
at(t);
|
|
1288
|
-
break;
|
|
1289
|
-
case u.Code:
|
|
1290
|
-
ot(t, g, a);
|
|
1291
|
-
break;
|
|
1292
|
-
case u.Strong:
|
|
1293
|
-
case u.Em:
|
|
1294
|
-
case u.CodeSpan:
|
|
1295
|
-
rt(t, g, f);
|
|
1296
|
-
break;
|
|
1297
|
-
case u.Link:
|
|
1298
|
-
lt(t, g, f);
|
|
1299
|
-
break;
|
|
1300
|
-
case u.Blockquote:
|
|
1301
|
-
gt(t, g, a, o);
|
|
1302
|
-
break;
|
|
1303
|
-
case u.Image:
|
|
1304
|
-
pt(t, g, a);
|
|
1305
|
-
break;
|
|
1306
|
-
case u.Table:
|
|
1307
|
-
ft(t, g, a);
|
|
1308
|
-
break;
|
|
1309
|
-
case u.Raw:
|
|
1310
|
-
case u.Text:
|
|
1311
|
-
st(
|
|
1312
|
-
t,
|
|
1313
|
-
g,
|
|
1314
|
-
a,
|
|
1315
|
-
s,
|
|
1316
|
-
o,
|
|
1317
|
-
l,
|
|
1318
|
-
p,
|
|
1319
|
-
r.content?.textAlignment === "justify"
|
|
1320
|
-
);
|
|
1321
|
-
break;
|
|
1322
|
-
default:
|
|
1323
|
-
console.warn(
|
|
1324
|
-
`Warning: Unsupported element type encountered: ${g.type}.
|
|
1
|
+
import { marked as e } from "marked";
|
|
2
|
+
import t from "jspdf-autotable";
|
|
3
|
+
//#region src/enums/mdTokenType.ts
|
|
4
|
+
var n = /* @__PURE__ */ function(e) {
|
|
5
|
+
return e.Heading = "heading", e.Paragraph = "paragraph", e.List = "list", e.ListItem = "list_item", e.Blockquote = "blockquote", e.Code = "code", e.CodeSpan = "codespan", e.Table = "table", e.Html = "html", e.Hr = "hr", e.Image = "image", e.Link = "link", e.Strong = "strong", e.Em = "em", e.TableHeader = "table_header", e.TableCell = "table_cell", e.Raw = "raw", e.Text = "text", e;
|
|
6
|
+
}({}), r = "__jmr_", i = /(!\[[^\]]*\]\()([^)]+)(\))\s*\{([^}]+)\}/g, a = /(\w+)\s*=\s*(\w+)/g, o = [
|
|
7
|
+
"left",
|
|
8
|
+
"center",
|
|
9
|
+
"right"
|
|
10
|
+
], s = (e) => {
|
|
11
|
+
let t = [];
|
|
12
|
+
return e.width !== void 0 && t.push(`w=${e.width}`), e.height !== void 0 && t.push(`h=${e.height}`), e.align && t.push(`a=${e.align}`), t.length > 0 ? `#${r}${t.join("&")}` : "";
|
|
13
|
+
}, c = (e) => {
|
|
14
|
+
let t = {}, n;
|
|
15
|
+
for (; (n = a.exec(e)) !== null;) {
|
|
16
|
+
let e = n[1].toLowerCase(), r = n[2];
|
|
17
|
+
switch (e) {
|
|
18
|
+
case "width":
|
|
19
|
+
case "w": {
|
|
20
|
+
let e = parseInt(r, 10);
|
|
21
|
+
!isNaN(e) && e > 0 && (t.width = e);
|
|
22
|
+
break;
|
|
23
|
+
}
|
|
24
|
+
case "height":
|
|
25
|
+
case "h": {
|
|
26
|
+
let e = parseInt(r, 10);
|
|
27
|
+
!isNaN(e) && e > 0 && (t.height = e);
|
|
28
|
+
break;
|
|
29
|
+
}
|
|
30
|
+
case "align": {
|
|
31
|
+
let e = r.toLowerCase();
|
|
32
|
+
o.includes(e) && (t.align = e);
|
|
33
|
+
break;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return t;
|
|
38
|
+
}, l = (e) => e.replace(i, (e, t, n, r, i) => `${t}${n}${s(c(i))}${r}`), u = (e) => {
|
|
39
|
+
let t = e.indexOf(`#${r}`);
|
|
40
|
+
if (t === -1) return {
|
|
41
|
+
cleanHref: e,
|
|
42
|
+
attrs: {}
|
|
43
|
+
};
|
|
44
|
+
let n = e.substring(0, t), i = e.substring(t + 1 + 6), a = {}, s = i.split("&");
|
|
45
|
+
for (let e of s) {
|
|
46
|
+
let [t, n] = e.split("=");
|
|
47
|
+
switch (t) {
|
|
48
|
+
case "w": {
|
|
49
|
+
let e = parseInt(n, 10);
|
|
50
|
+
!isNaN(e) && e > 0 && (a.width = e);
|
|
51
|
+
break;
|
|
52
|
+
}
|
|
53
|
+
case "h": {
|
|
54
|
+
let e = parseInt(n, 10);
|
|
55
|
+
!isNaN(e) && e > 0 && (a.height = e);
|
|
56
|
+
break;
|
|
57
|
+
}
|
|
58
|
+
case "a":
|
|
59
|
+
o.includes(n) && (a.align = n);
|
|
60
|
+
break;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return {
|
|
64
|
+
cleanHref: n,
|
|
65
|
+
attrs: a
|
|
66
|
+
};
|
|
67
|
+
}, d = async (t) => {
|
|
68
|
+
let n = l(t);
|
|
69
|
+
return f(await e.lexer(n, {
|
|
70
|
+
async: !0,
|
|
71
|
+
gfm: !0
|
|
72
|
+
}));
|
|
73
|
+
}, f = (e) => {
|
|
74
|
+
let t = [];
|
|
75
|
+
return e.forEach((e) => {
|
|
76
|
+
try {
|
|
77
|
+
let r = p[e.type];
|
|
78
|
+
r ? t.push(r(e)) : t.push({
|
|
79
|
+
type: n.Raw,
|
|
80
|
+
content: e.raw
|
|
81
|
+
});
|
|
82
|
+
} catch (t) {
|
|
83
|
+
console.error("Failed to handle token ==>", e, t);
|
|
84
|
+
}
|
|
85
|
+
}), t;
|
|
86
|
+
}, p = {
|
|
87
|
+
[n.Heading]: (e) => ({
|
|
88
|
+
type: n.Heading,
|
|
89
|
+
depth: e.depth,
|
|
90
|
+
content: e.text,
|
|
91
|
+
items: e.tokens ? f(e.tokens) : []
|
|
92
|
+
}),
|
|
93
|
+
[n.Paragraph]: (e) => ({
|
|
94
|
+
type: n.Paragraph,
|
|
95
|
+
content: e.text,
|
|
96
|
+
items: e.tokens ? f(e.tokens) : []
|
|
97
|
+
}),
|
|
98
|
+
[n.List]: (e) => ({
|
|
99
|
+
type: n.List,
|
|
100
|
+
ordered: e.ordered,
|
|
101
|
+
start: e.start,
|
|
102
|
+
items: e.items ? f(e.items) : []
|
|
103
|
+
}),
|
|
104
|
+
[n.ListItem]: (e) => ({
|
|
105
|
+
type: n.ListItem,
|
|
106
|
+
content: e.text,
|
|
107
|
+
items: e.tokens ? f(e.tokens) : []
|
|
108
|
+
}),
|
|
109
|
+
[n.Code]: (e) => ({
|
|
110
|
+
type: n.Code,
|
|
111
|
+
lang: e.lang,
|
|
112
|
+
code: e.text
|
|
113
|
+
}),
|
|
114
|
+
[n.Table]: (e) => ({
|
|
115
|
+
type: n.Table,
|
|
116
|
+
header: e.header.map((e) => ({
|
|
117
|
+
type: n.TableHeader,
|
|
118
|
+
content: e.text
|
|
119
|
+
})),
|
|
120
|
+
rows: e.rows.map((e) => e.map((e) => ({
|
|
121
|
+
type: n.TableCell,
|
|
122
|
+
content: e.text
|
|
123
|
+
})))
|
|
124
|
+
}),
|
|
125
|
+
[n.Image]: (e) => {
|
|
126
|
+
let { cleanHref: t, attrs: r } = u(e.href);
|
|
127
|
+
return {
|
|
128
|
+
type: n.Image,
|
|
129
|
+
src: t,
|
|
130
|
+
alt: e.text,
|
|
131
|
+
width: r.width,
|
|
132
|
+
height: r.height,
|
|
133
|
+
align: r.align
|
|
134
|
+
};
|
|
135
|
+
},
|
|
136
|
+
[n.Link]: (e) => ({
|
|
137
|
+
type: n.Link,
|
|
138
|
+
href: e.href,
|
|
139
|
+
text: e.text,
|
|
140
|
+
items: e.tokens ? f(e.tokens) : []
|
|
141
|
+
}),
|
|
142
|
+
[n.Strong]: (e) => ({
|
|
143
|
+
type: n.Strong,
|
|
144
|
+
content: e.text,
|
|
145
|
+
items: e.tokens ? f(e.tokens) : []
|
|
146
|
+
}),
|
|
147
|
+
[n.Em]: (e) => ({
|
|
148
|
+
type: n.Em,
|
|
149
|
+
content: e.text,
|
|
150
|
+
items: e.tokens ? f(e.tokens) : []
|
|
151
|
+
}),
|
|
152
|
+
[n.Text]: (e) => ({
|
|
153
|
+
type: n.Text,
|
|
154
|
+
content: e.text,
|
|
155
|
+
items: e.tokens ? f(e.tokens) : []
|
|
156
|
+
}),
|
|
157
|
+
[n.Hr]: (e) => ({
|
|
158
|
+
type: n.Hr,
|
|
159
|
+
content: e.raw,
|
|
160
|
+
items: e.tokens ? f(e.tokens) : []
|
|
161
|
+
}),
|
|
162
|
+
[n.CodeSpan]: (e) => ({
|
|
163
|
+
type: n.CodeSpan,
|
|
164
|
+
content: e.text,
|
|
165
|
+
items: e.tokens ? f(e.tokens) : []
|
|
166
|
+
}),
|
|
167
|
+
[n.Blockquote]: (e) => ({
|
|
168
|
+
type: n.Blockquote,
|
|
169
|
+
content: e.text,
|
|
170
|
+
items: e.tokens ? f(e.tokens) : []
|
|
171
|
+
})
|
|
172
|
+
}, m = class {
|
|
173
|
+
static {
|
|
174
|
+
this.cursor = {
|
|
175
|
+
x: 0,
|
|
176
|
+
y: 0
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
static {
|
|
180
|
+
this.lastContentY_ = 0;
|
|
181
|
+
}
|
|
182
|
+
static {
|
|
183
|
+
this.inlineLock = !1;
|
|
184
|
+
}
|
|
185
|
+
static initialize(e) {
|
|
186
|
+
this.options_ = e, this.cursor = {
|
|
187
|
+
x: e.cursor.x,
|
|
188
|
+
y: e.cursor.y
|
|
189
|
+
}, this.lastContentY_ = e.cursor.y;
|
|
190
|
+
}
|
|
191
|
+
static getCursor() {
|
|
192
|
+
return this.cursor;
|
|
193
|
+
}
|
|
194
|
+
static setCursor(e) {
|
|
195
|
+
this.cursor = e;
|
|
196
|
+
}
|
|
197
|
+
static get options() {
|
|
198
|
+
return this.options_;
|
|
199
|
+
}
|
|
200
|
+
static get isInlineLockActive() {
|
|
201
|
+
return this.inlineLock;
|
|
202
|
+
}
|
|
203
|
+
static activateInlineLock() {
|
|
204
|
+
this.inlineLock = !0;
|
|
205
|
+
}
|
|
206
|
+
static deactivateInlineLock() {
|
|
207
|
+
this.inlineLock = !1;
|
|
208
|
+
}
|
|
209
|
+
static updateX(e, t = "set") {
|
|
210
|
+
t === "set" ? this.cursor.x = e : t === "add" && (this.cursor.x += e);
|
|
211
|
+
}
|
|
212
|
+
static updateY(e, t = "set") {
|
|
213
|
+
t === "set" ? this.cursor.y = e : t === "add" && (this.cursor.y += e);
|
|
214
|
+
}
|
|
215
|
+
static recordContentY(e) {
|
|
216
|
+
this.lastContentY_ = e === void 0 ? this.cursor.y : e;
|
|
217
|
+
}
|
|
218
|
+
static get lastContentY() {
|
|
219
|
+
return this.lastContentY_;
|
|
220
|
+
}
|
|
221
|
+
static get X() {
|
|
222
|
+
return this.cursor.x;
|
|
223
|
+
}
|
|
224
|
+
static get Y() {
|
|
225
|
+
return this.cursor.y;
|
|
226
|
+
}
|
|
227
|
+
}, h = (e) => e.getTextDimensions("H").h * m.options.page.defaultLineHeightFactor, g = (e) => e.getTextDimensions("H").w * m.options.page.defaultLineHeightFactor, _ = (e, t, n, r) => {
|
|
228
|
+
let i = 6 - (t?.depth ?? 0) > 0 ? 6 - (t?.depth ?? 0) : 1;
|
|
229
|
+
if (e.setFontSize(m.options.page.defaultFontSize + i), t?.items && t?.items.length > 0) for (let e of t?.items ?? []) r(e, n, !1);
|
|
230
|
+
else {
|
|
231
|
+
let r = h(e);
|
|
232
|
+
e.text(t?.content ?? "", m.X + n, m.Y, {
|
|
233
|
+
align: "left",
|
|
234
|
+
maxWidth: m.options.page.maxContentWidth - n,
|
|
235
|
+
baseline: "top"
|
|
236
|
+
}), m.recordContentY(m.Y + r), m.updateY(r, "add");
|
|
237
|
+
}
|
|
238
|
+
e.setFontSize(m.options.page.defaultFontSize), m.updateX(m.options.page.xpading, "set");
|
|
239
|
+
}, v = (e) => {
|
|
240
|
+
typeof m.options.pageBreakHandler == "function" ? m.options.pageBreakHandler(e) : e.addPage(m.options.page?.format, m.options.page?.orientation), m.updateY(m.options.page.topmargin), m.updateX(m.options.page.xpading);
|
|
241
|
+
}, y = 96, b = (e, t = "mm") => {
|
|
242
|
+
switch (t) {
|
|
243
|
+
case "pt": return e * 72 / y;
|
|
244
|
+
case "in": return e / y;
|
|
245
|
+
case "px": return e;
|
|
246
|
+
default: return e * 25.4 / y;
|
|
247
|
+
}
|
|
248
|
+
}, x = (e) => {
|
|
249
|
+
try {
|
|
250
|
+
let t = "";
|
|
251
|
+
if (e.includes("base64,")) {
|
|
252
|
+
let n = e.split("base64,")[1];
|
|
253
|
+
t = typeof window < "u" && typeof window.atob == "function" ? decodeURIComponent(escape(window.atob(n))) : typeof Buffer < "u" ? Buffer.from(n, "base64").toString("utf-8") : decodeURIComponent(escape(atob(n)));
|
|
254
|
+
} else t = decodeURIComponent(e.split(",")[1] || "");
|
|
255
|
+
let n = t.match(/<svg[^>]*\swidth=(?:'|")([0-9.]+)[a-zA-Z]*(?:'|")/i), r = t.match(/<svg[^>]*\sheight=(?:'|")([0-9.]+)[a-zA-Z]*(?:'|")/i), i = t.match(/<svg[^>]*\sviewBox=(?:'|")[^'"]*(?:'|")/i), a = n ? parseFloat(n[1]) : 0, o = r ? parseFloat(r[1]) : 0;
|
|
256
|
+
if ((!a || !o) && i) {
|
|
257
|
+
let e = i[0].match(/viewBox=(?:'|")([^'"]+)(?:'|")/i);
|
|
258
|
+
if (e) {
|
|
259
|
+
let t = e[1].split(/[ ,]+/).filter(Boolean).map(parseFloat);
|
|
260
|
+
t.length >= 4 && (a ||= t[2], o ||= t[3]);
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
if (a > 0 && o > 0) return {
|
|
264
|
+
width: a,
|
|
265
|
+
height: o
|
|
266
|
+
};
|
|
267
|
+
} catch (e) {
|
|
268
|
+
console.warn("Failed to extract SVG dimensions:", e);
|
|
269
|
+
}
|
|
270
|
+
return null;
|
|
271
|
+
}, S = (e, t, n, r, i = "mm") => {
|
|
272
|
+
if (!t.data) return {
|
|
273
|
+
finalWidth: 0,
|
|
274
|
+
finalHeight: 0
|
|
275
|
+
};
|
|
276
|
+
let a = t.naturalWidth || 0, o = t.naturalHeight || 0;
|
|
277
|
+
if (!a || !o) if (t.data.startsWith("data:image/svg")) {
|
|
278
|
+
let e = x(t.data);
|
|
279
|
+
e && (a = e.width, o = e.height);
|
|
280
|
+
} else try {
|
|
281
|
+
let n = e.getImageProperties(t.data);
|
|
282
|
+
a = n.width, o = n.height;
|
|
283
|
+
} catch (e) {
|
|
284
|
+
console.warn("Failed to get image properties for intrinsic sizing:", e);
|
|
285
|
+
}
|
|
286
|
+
let s = o > 0 ? a / o : 1, c, l;
|
|
287
|
+
if (t.width && t.height ? (c = b(t.width, i), l = b(t.height, i)) : t.width ? (c = b(t.width, i), l = c / s) : t.height ? (l = b(t.height, i), c = l * s) : (c = b(a, i), l = b(o, i)), c > n) {
|
|
288
|
+
let e = n / c;
|
|
289
|
+
c = n, l *= e;
|
|
290
|
+
}
|
|
291
|
+
if (l > r) {
|
|
292
|
+
let e = r / l;
|
|
293
|
+
l = r, c *= e;
|
|
294
|
+
}
|
|
295
|
+
return {
|
|
296
|
+
finalWidth: c,
|
|
297
|
+
finalHeight: l
|
|
298
|
+
};
|
|
299
|
+
}, C = async (e) => {
|
|
300
|
+
for (let t of e) {
|
|
301
|
+
if (t.type === n.Image && t.src) try {
|
|
302
|
+
if (t.src.startsWith("data:")) t.data = t.src;
|
|
303
|
+
else {
|
|
304
|
+
let e = await fetch(t.src);
|
|
305
|
+
if (!e.ok) throw Error(`Failed to fetch image: ${e.statusText}`);
|
|
306
|
+
let n = await e.blob();
|
|
307
|
+
t.data = await new Promise((e, t) => {
|
|
308
|
+
let r = new FileReader();
|
|
309
|
+
r.onloadend = () => {
|
|
310
|
+
typeof r.result == "string" ? e(r.result) : t(/* @__PURE__ */ Error("Failed to convert image to base64 string"));
|
|
311
|
+
}, r.onerror = t, r.readAsDataURL(n);
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
t.data && t.data.startsWith("data:image/svg") && typeof window < "u" && typeof document < "u" && (t.data = await new Promise((e) => {
|
|
315
|
+
let n = new Image();
|
|
316
|
+
n.onload = () => {
|
|
317
|
+
let r = document.createElement("canvas"), i = x(t.data), a = i ? i.width : n.width || 300, o = i ? i.height : n.height || 150;
|
|
318
|
+
t.naturalWidth = a, t.naturalHeight = o, r.width = a * 4, r.height = o * 4;
|
|
319
|
+
let s = r.getContext("2d");
|
|
320
|
+
s ? (s.scale(4, 4), s.drawImage(n, 0, 0, a, o), e(r.toDataURL("image/png"))) : e(t.data);
|
|
321
|
+
}, n.onerror = () => e(t.data), n.src = t.data;
|
|
322
|
+
}));
|
|
323
|
+
} catch (e) {
|
|
324
|
+
console.warn(`[jspdf-md-renderer] Warning: Failed to load image at ${t.src}. It will be skipped.`, e);
|
|
325
|
+
}
|
|
326
|
+
t.items && t.items.length > 0 && await C(t.items);
|
|
327
|
+
}
|
|
328
|
+
}, w = class {
|
|
329
|
+
static getCodespanOptions() {
|
|
330
|
+
let e = m.options.codespan ?? {};
|
|
331
|
+
return {
|
|
332
|
+
backgroundColor: e.backgroundColor ?? "#EEEEEE",
|
|
333
|
+
padding: e.padding ?? .5,
|
|
334
|
+
showBackground: e.showBackground !== !1,
|
|
335
|
+
fontSizeScale: e.fontSizeScale ?? .9
|
|
336
|
+
};
|
|
337
|
+
}
|
|
338
|
+
static applyStyle(e, t) {
|
|
339
|
+
let n = e.getFont().fontName, r = e.getFontSize(), i = () => {
|
|
340
|
+
let e = m.options.font.bold?.name;
|
|
341
|
+
return e && e !== "" ? e : n;
|
|
342
|
+
}, a = () => {
|
|
343
|
+
let e = m.options.font.regular?.name;
|
|
344
|
+
return e && e !== "" ? e : n;
|
|
345
|
+
};
|
|
346
|
+
switch (t) {
|
|
347
|
+
case "bold":
|
|
348
|
+
e.setFont(i(), m.options.font.bold?.style || "bold");
|
|
349
|
+
break;
|
|
350
|
+
case "italic":
|
|
351
|
+
e.setFont(a(), "italic");
|
|
352
|
+
break;
|
|
353
|
+
case "bolditalic":
|
|
354
|
+
e.setFont(i(), "bolditalic");
|
|
355
|
+
break;
|
|
356
|
+
case "codespan":
|
|
357
|
+
e.setFont("courier", "normal"), e.setFontSize(r * this.getCodespanOptions().fontSizeScale);
|
|
358
|
+
break;
|
|
359
|
+
default:
|
|
360
|
+
e.setFont(a(), e.getFont().fontStyle);
|
|
361
|
+
break;
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
static measureWordWidth(e, t, n) {
|
|
365
|
+
let r = e.getFont(), i = e.getFontSize();
|
|
366
|
+
this.applyStyle(e, n);
|
|
367
|
+
let a = e.getTextWidth(t), o = e.getCharSpace?.() ?? 0, s = a + t.length * o;
|
|
368
|
+
return e.setFont(r.fontName, r.fontStyle), e.setFontSize(i), s;
|
|
369
|
+
}
|
|
370
|
+
static getStyleFromType(e, t) {
|
|
371
|
+
switch (e) {
|
|
372
|
+
case "strong": return t === "italic" ? "bolditalic" : "bold";
|
|
373
|
+
case "em": return t === "bold" ? "bolditalic" : "italic";
|
|
374
|
+
case "codespan": return "codespan";
|
|
375
|
+
default: return t || "normal";
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
static flattenToWords(e, t, n = "normal", r = !1, i) {
|
|
379
|
+
let a = [];
|
|
380
|
+
for (let o of t) {
|
|
381
|
+
let t = this.getStyleFromType(o.type, n), s = o.type === "link" || r, c = o.href || i;
|
|
382
|
+
if (o.items && o.items.length > 0) {
|
|
383
|
+
let n = this.flattenToWords(e, o.items, t, s, c);
|
|
384
|
+
a.push(...n);
|
|
385
|
+
} else if (o.type === "image") {
|
|
386
|
+
let n = m.options.page.maxContentHeight - m.options.page.topmargin, { finalWidth: r, finalHeight: i } = S(e, o, m.options.page.maxContentWidth - m.options.page.indent * 0, n, m.options.page.unit || "mm");
|
|
387
|
+
a.push({
|
|
388
|
+
text: "",
|
|
389
|
+
width: r,
|
|
390
|
+
style: t,
|
|
391
|
+
isLink: s,
|
|
392
|
+
href: c,
|
|
393
|
+
linkColor: s ? m.options.link?.linkColor || [
|
|
394
|
+
0,
|
|
395
|
+
0,
|
|
396
|
+
255
|
|
397
|
+
] : void 0,
|
|
398
|
+
isImage: !0,
|
|
399
|
+
imageElement: o,
|
|
400
|
+
imageHeight: i
|
|
401
|
+
});
|
|
402
|
+
} else {
|
|
403
|
+
let n = o.content || o.text || "";
|
|
404
|
+
if (!n) continue;
|
|
405
|
+
if (t === "codespan") {
|
|
406
|
+
let r = n.trim();
|
|
407
|
+
r && a.push({
|
|
408
|
+
text: r,
|
|
409
|
+
width: this.measureWordWidth(e, r, t),
|
|
410
|
+
style: t,
|
|
411
|
+
isLink: s,
|
|
412
|
+
href: c,
|
|
413
|
+
linkColor: s ? m.options.link?.linkColor || [
|
|
414
|
+
0,
|
|
415
|
+
0,
|
|
416
|
+
255
|
|
417
|
+
] : void 0
|
|
418
|
+
});
|
|
419
|
+
continue;
|
|
420
|
+
}
|
|
421
|
+
let r = n.split(/\s+/).filter((e) => e.length > 0);
|
|
422
|
+
if (r.length === 0) continue;
|
|
423
|
+
for (let n = 0; n < r.length; n++) {
|
|
424
|
+
let i = r[n];
|
|
425
|
+
a.push({
|
|
426
|
+
text: i,
|
|
427
|
+
width: this.measureWordWidth(e, i, t),
|
|
428
|
+
style: t,
|
|
429
|
+
isLink: s,
|
|
430
|
+
href: c,
|
|
431
|
+
linkColor: s ? m.options.link?.linkColor || [
|
|
432
|
+
0,
|
|
433
|
+
0,
|
|
434
|
+
255
|
|
435
|
+
] : void 0
|
|
436
|
+
});
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
return a;
|
|
441
|
+
}
|
|
442
|
+
static breakIntoLines(e, t, n) {
|
|
443
|
+
let r = [], i = [], a = 0, o = 0, s = h(e) * m.options.page.defaultLineHeightFactor, c = e.getTextWidth(" ");
|
|
444
|
+
for (let l = 0; l < t.length; l++) {
|
|
445
|
+
let u = t[l], d = i.length > 0 ? c + u.width : u.width, f = u.isImage && u.imageHeight ? u.imageHeight : h(e) * m.options.page.defaultLineHeightFactor;
|
|
446
|
+
o + d > n && i.length > 0 ? (r.push({
|
|
447
|
+
words: i,
|
|
448
|
+
totalTextWidth: a,
|
|
449
|
+
isLastLine: !1,
|
|
450
|
+
lineHeight: s
|
|
451
|
+
}), i = [u], a = u.width, o = u.width, s = f) : (i.push(u), a += u.width, o += d, s = Math.max(s, f));
|
|
452
|
+
}
|
|
453
|
+
return i.length > 0 && r.push({
|
|
454
|
+
words: i,
|
|
455
|
+
totalTextWidth: a,
|
|
456
|
+
isLastLine: !0,
|
|
457
|
+
lineHeight: s
|
|
458
|
+
}), r;
|
|
459
|
+
}
|
|
460
|
+
static renderWord(e, t, n, r) {
|
|
461
|
+
let i = e.getFont(), a = e.getFontSize(), o = e.getTextColor();
|
|
462
|
+
if (this.applyStyle(e, t.style), t.isLink && t.linkColor && e.setTextColor(...t.linkColor), t.isImage && t.imageElement && t.imageElement.data) try {
|
|
463
|
+
let i = "JPEG";
|
|
464
|
+
if (t.imageElement.data.startsWith("data:image/png")) i = "PNG";
|
|
465
|
+
else if (t.imageElement.data.startsWith("data:image/webp")) i = "WEBP";
|
|
466
|
+
else if (t.imageElement.data.startsWith("data:image/gif")) i = "GIF";
|
|
467
|
+
else if (t.imageElement.src) {
|
|
468
|
+
let e = t.imageElement.src.split("?")[0].split("#")[0].split(".").pop()?.toUpperCase();
|
|
469
|
+
e && [
|
|
470
|
+
"PNG",
|
|
471
|
+
"JPEG",
|
|
472
|
+
"JPG",
|
|
473
|
+
"WEBP",
|
|
474
|
+
"GIF"
|
|
475
|
+
].includes(e) && (i = e === "JPG" ? "JPEG" : e);
|
|
476
|
+
}
|
|
477
|
+
if (t.width > 0 && (t.imageHeight || 0) > 0) {
|
|
478
|
+
let a = t.imageHeight || 0, o = r;
|
|
479
|
+
e.addImage(t.imageElement.data, i, n, o, t.width, a);
|
|
480
|
+
}
|
|
481
|
+
} catch (e) {
|
|
482
|
+
console.warn("Failed to render inline image", e);
|
|
483
|
+
}
|
|
484
|
+
else {
|
|
485
|
+
if (t.style === "codespan") {
|
|
486
|
+
let i = this.getCodespanOptions();
|
|
487
|
+
if (i.showBackground) {
|
|
488
|
+
let a = h(e), o = i.padding;
|
|
489
|
+
e.setFillColor(i.backgroundColor), e.rect(n - o, r - o, t.width + o * 2, a + o * 2, "F"), e.setFillColor("#000000");
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
e.text(t.text, n, r, { baseline: "top" });
|
|
493
|
+
}
|
|
494
|
+
if (t.isLink && t.href) {
|
|
495
|
+
let i = t.isImage && t.imageHeight ? t.imageHeight : h(e);
|
|
496
|
+
e.link(n, r, t.width, i, { url: t.href });
|
|
497
|
+
}
|
|
498
|
+
e.setFont(i.fontName, i.fontStyle), e.setFontSize(a), e.setTextColor(o);
|
|
499
|
+
}
|
|
500
|
+
static renderAlignedLine(e, t, n, r, i, a = "left") {
|
|
501
|
+
let { words: o, totalTextWidth: s, isLastLine: c } = t;
|
|
502
|
+
if (o.length === 0) return;
|
|
503
|
+
let l = e.getTextWidth(" "), u = n, d = l, f = s + (o.length - 1) * l;
|
|
504
|
+
switch (a) {
|
|
505
|
+
case "right":
|
|
506
|
+
u = n + i - f;
|
|
507
|
+
break;
|
|
508
|
+
case "center":
|
|
509
|
+
u = n + (i - f) / 2;
|
|
510
|
+
break;
|
|
511
|
+
case "justify":
|
|
512
|
+
!c && o.length > 1 && (d = (i - s) / (o.length - 1));
|
|
513
|
+
break;
|
|
514
|
+
default: break;
|
|
515
|
+
}
|
|
516
|
+
let p = u, g = h(e) * m.options.page.defaultLineHeightFactor;
|
|
517
|
+
for (let n = 0; n < o.length; n++) {
|
|
518
|
+
let i = o[n], a = r, s = i.isImage && i.imageHeight ? i.imageHeight : g;
|
|
519
|
+
i.isImage ? a = r : s < t.lineHeight && (a = r + (t.lineHeight - s)), this.renderWord(e, i, p, a), p += i.width, n < o.length - 1 && (p += d);
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
static renderStyledParagraph(e, t, n, r, i, a) {
|
|
523
|
+
let o = a ?? m.options.content?.textAlignment ?? "left", s = this.flattenToWords(e, t);
|
|
524
|
+
if (s.length === 0) return;
|
|
525
|
+
let c = this.breakIntoLines(e, s, i), l = r;
|
|
526
|
+
for (let t of c) l + t.lineHeight > m.options.page.maxContentHeight && (v(e), l = m.Y), this.renderAlignedLine(e, t, n, l, i, o), m.recordContentY(l + t.lineHeight), l += t.lineHeight, m.updateY(t.lineHeight, "add");
|
|
527
|
+
let u = c[c.length - 1];
|
|
528
|
+
if (u) {
|
|
529
|
+
let t = u.totalTextWidth + (u.words.length - 1) * e.getTextWidth(" ");
|
|
530
|
+
m.updateX(n + t, "set");
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
static renderJustifiedParagraph(e, t, n, r, i) {
|
|
534
|
+
this.renderStyledParagraph(e, t, n, r, i);
|
|
535
|
+
}
|
|
536
|
+
}, T = class {
|
|
537
|
+
static renderText(e, t, n = m.X, r = m.Y, i, a = !1) {
|
|
538
|
+
let o = e.splitTextToSize(t, i), s = h(e), c = s * m.options.page.defaultLineHeightFactor, l = r;
|
|
539
|
+
for (let t = 0; t < o.length; t++) {
|
|
540
|
+
let r = o[t];
|
|
541
|
+
l + c > m.options.page.maxContentHeight && (v(e), l = m.Y), a ? t === o.length - 1 ? e.text(r, n, l, { baseline: "top" }) : e.text(r, n, l, {
|
|
542
|
+
maxWidth: i,
|
|
543
|
+
align: "justify",
|
|
544
|
+
baseline: "top"
|
|
545
|
+
}) : e.text(r, n, l, { baseline: "top" }), m.recordContentY(l + s), l += c, m.updateY(c, "add");
|
|
546
|
+
}
|
|
547
|
+
return l;
|
|
548
|
+
}
|
|
549
|
+
}, E = (e, t, n, r) => {
|
|
550
|
+
m.activateInlineLock(), e.setFontSize(m.options.page.defaultFontSize);
|
|
551
|
+
let i = m.options.page.maxContentWidth - n;
|
|
552
|
+
if (t?.items && t?.items.length > 0) {
|
|
553
|
+
if (t.items.length === 1 && t.items[0].type === "image") {
|
|
554
|
+
r(t.items[0], n, !1), m.updateX(m.options.page.xpading), m.deactivateInlineLock();
|
|
555
|
+
return;
|
|
556
|
+
}
|
|
557
|
+
let a = [
|
|
558
|
+
"strong",
|
|
559
|
+
"em",
|
|
560
|
+
"text",
|
|
561
|
+
"codespan",
|
|
562
|
+
"link",
|
|
563
|
+
"image"
|
|
564
|
+
];
|
|
565
|
+
if (t.items.some((e) => !a.includes(e.type))) {
|
|
566
|
+
let o = [], s = () => {
|
|
567
|
+
o.length > 0 && (w.renderStyledParagraph(e, o, m.X + n, m.Y, i), o.length = 0);
|
|
568
|
+
};
|
|
569
|
+
for (let e of t.items) a.includes(e.type) ? o.push(e) : (s(), r(e, n, !1));
|
|
570
|
+
s();
|
|
571
|
+
} else w.renderStyledParagraph(e, t.items, m.X + n, m.Y, i);
|
|
572
|
+
} else {
|
|
573
|
+
let r = t.content ?? "", a = m.options.content?.textAlignment ?? "left";
|
|
574
|
+
r.trim() && T.renderText(e, r, m.X + n, m.Y, i, a === "justify");
|
|
575
|
+
}
|
|
576
|
+
m.updateX(m.options.page.xpading), m.deactivateInlineLock();
|
|
577
|
+
}, D = (e, t, n, r) => {
|
|
578
|
+
e.setFontSize(m.options.page.defaultFontSize);
|
|
579
|
+
for (let [e, i] of t?.items?.entries() ?? []) {
|
|
580
|
+
let a = t.ordered ? (t.start ?? 0) + e : t.start;
|
|
581
|
+
r(i, n + 1, !0, a, t.ordered);
|
|
582
|
+
}
|
|
583
|
+
}, O = (e, t, r, i, a, o) => {
|
|
584
|
+
m.Y + h(e) >= m.options.page.maxContentHeight && v(e);
|
|
585
|
+
let s = m.options, c = r * s.page.indent, l = o ? `${a}. ` : "• ", u = s.page.xpading;
|
|
586
|
+
m.updateX(u, "set"), e.setFont(s.font.regular.name, s.font.regular.style), e.text(l, u + c, m.Y, { baseline: "top" });
|
|
587
|
+
let d = e.getTextWidth(l), f = u + c + d, p = s.page.maxContentWidth - c - d;
|
|
588
|
+
if (t.items && t.items.length > 0) {
|
|
589
|
+
let s = [], c = () => {
|
|
590
|
+
s.length > 0 && (w.renderStyledParagraph(e, s, f, m.Y, p), s.length = 0, m.updateX(u, "set"));
|
|
591
|
+
};
|
|
592
|
+
for (let e of t.items) e.type === n.List ? (c(), i(e, r, !0, a, e.ordered ?? !1)) : e.type === n.ListItem ? (c(), i(e, r, !0, a, o)) : s.push(e);
|
|
593
|
+
c();
|
|
594
|
+
} else if (t.content) {
|
|
595
|
+
let n = s.content?.textAlignment ?? "left";
|
|
596
|
+
T.renderText(e, t.content, f, m.Y, p, n === "justify");
|
|
597
|
+
}
|
|
598
|
+
}, k = (e, t, n, r, i, a, o, s = !0) => {
|
|
599
|
+
if (t?.items && t?.items.length > 0) for (let e of t?.items ?? []) i(e, n, r, a, o, s);
|
|
600
|
+
else {
|
|
601
|
+
let i = m.options, c = n * i.page.indent, l = r ? o ? `${a}. ` : "• " : "", u = t.content || "", d = i.page.xpading;
|
|
602
|
+
if (!u && !l) return;
|
|
603
|
+
if (!u.trim() && !l) {
|
|
604
|
+
let t = (u.match(/\n/g) || []).length;
|
|
605
|
+
if (t > 1) {
|
|
606
|
+
let n = (t - 1) * (e.getTextDimensions("A").h * i.page.defaultLineHeightFactor);
|
|
607
|
+
m.Y + n > i.page.maxContentHeight ? v(e) : (m.updateY(n, "add"), m.recordContentY(m.Y));
|
|
608
|
+
}
|
|
609
|
+
return;
|
|
610
|
+
}
|
|
611
|
+
if (m.updateX(d, "set"), r && l) {
|
|
612
|
+
let t = e.getTextWidth(l), n = i.page.maxContentWidth - c - t;
|
|
613
|
+
e.setFont(i.font.regular.name, i.font.regular.style), e.text(l, d + c, m.Y, { baseline: "top" }), T.renderText(e, u, d + c + t, m.Y, n, s);
|
|
614
|
+
} else {
|
|
615
|
+
let t = i.page.maxContentWidth - c;
|
|
616
|
+
T.renderText(e, u, d + c, m.Y, t, s);
|
|
617
|
+
}
|
|
618
|
+
m.updateX(d, "set");
|
|
619
|
+
}
|
|
620
|
+
}, A = (e) => {
|
|
621
|
+
let t = e.internal.pageSize.getWidth();
|
|
622
|
+
e.setLineDashPattern([1, 1], 0), e.setLineWidth(.1), e.line(m.options.page.xpading, m.Y, t - m.options.page.xpading, m.Y), e.setLineWidth(.1), e.setLineDashPattern([], 0), m.updateY(h(e), "add");
|
|
623
|
+
}, j = (e, t, n) => {
|
|
624
|
+
let r = e.getFont(), i = e.getFontSize();
|
|
625
|
+
e.setFont("courier", "normal");
|
|
626
|
+
let a = m.options.page.defaultFontSize * .9;
|
|
627
|
+
e.setFontSize(a);
|
|
628
|
+
let o = n * m.options.page.indent, s = m.options.page.maxContentWidth - o - 8, c = e.getLineHeightFactor(), l = a / e.internal.scaleFactor * c, u = (t.code ?? "").replace(/[\r\n\s]+$/, "");
|
|
629
|
+
if (!u) {
|
|
630
|
+
e.setFont(r.fontName, r.fontStyle), e.setFontSize(i);
|
|
631
|
+
return;
|
|
632
|
+
}
|
|
633
|
+
let d = e.splitTextToSize(u, s);
|
|
634
|
+
for (; d.length > 0 && d[d.length - 1].trim() === "";) d.pop();
|
|
635
|
+
if (d.length === 0) {
|
|
636
|
+
e.setFont(r.fontName, r.fontStyle), e.setFontSize(i);
|
|
637
|
+
return;
|
|
638
|
+
}
|
|
639
|
+
let f = 0;
|
|
640
|
+
for (; f < d.length;) {
|
|
641
|
+
let n = m.options.page.maxContentHeight - m.Y, r = d.length - f, i = n - 8, a = Math.floor(i / l);
|
|
642
|
+
if (a <= 0) {
|
|
643
|
+
v(e);
|
|
644
|
+
continue;
|
|
645
|
+
}
|
|
646
|
+
a > r && (a = r);
|
|
647
|
+
let o = d.slice(f, f + a), s = f === 0, c = f + a >= d.length, u = a * l;
|
|
648
|
+
if (s && m.updateY(4, "add"), e.setFillColor("#EEEEEE"), e.setDrawColor("#DDDDDD"), e.roundedRect(m.X, m.Y - 4, m.options.page.maxContentWidth, u + (s ? 4 : 0) + (c ? 4 : 0), 2, 2, "FD"), s && t.lang) {
|
|
649
|
+
let n = e.getFontSize();
|
|
650
|
+
e.setFontSize(10), e.setTextColor("#666666"), e.text(t.lang, m.X + m.options.page.maxContentWidth - e.getTextWidth(t.lang) - 4, m.Y, { baseline: "top" }), e.setFontSize(n), e.setTextColor("#000000");
|
|
651
|
+
}
|
|
652
|
+
let p = m.Y;
|
|
653
|
+
for (let t of o) e.text(t, m.X + 4, p, { baseline: "top" }), p += l;
|
|
654
|
+
m.updateY(u, "add"), m.recordContentY(m.Y + (c ? 4 : 0)), c && m.updateY(4, "add"), f += a, f < d.length && v(e);
|
|
655
|
+
}
|
|
656
|
+
e.setFont(r.fontName, r.fontStyle), e.setFontSize(i);
|
|
657
|
+
}, M = (e, t, n) => {
|
|
658
|
+
let r = e.getFont().fontName, i = e.getFont().fontStyle, a = e.getFontSize(), o = (e) => {
|
|
659
|
+
switch (e) {
|
|
660
|
+
case "normal": return 0;
|
|
661
|
+
case "bold": return 1;
|
|
662
|
+
case "italic": return 1.5;
|
|
663
|
+
case "bolditalic": return 1.5;
|
|
664
|
+
case "codespan": return .5;
|
|
665
|
+
default: return 0;
|
|
666
|
+
}
|
|
667
|
+
}, s = (t, s) => {
|
|
668
|
+
s === "bold" ? e.setFont(m.options.font.bold.name && m.options.font.bold.name !== "" ? m.options.font.bold.name : r, m.options.font.bold.style || "bold") : s === "italic" ? e.setFont(m.options.font.regular.name, "italic") : s === "bolditalic" ? e.setFont(m.options.font.bold.name && m.options.font.bold.name !== "" ? m.options.font.bold.name : r, "bolditalic") : s === "codespan" ? (e.setFont("courier", "normal"), e.setFontSize(a * .9)) : e.setFont(m.options.font.regular.name, i);
|
|
669
|
+
let c = m.options.page.maxContentWidth - n - m.X, l = e.splitTextToSize(t, c), u = s === "codespan", d = "#EEEEEE";
|
|
670
|
+
if (m.isInlineLockActive) for (let t = 0; t < l.length; t++) {
|
|
671
|
+
if (u) {
|
|
672
|
+
let r = e.getTextWidth(l[t]) + g(e), i = h(e);
|
|
673
|
+
e.setFillColor(d), e.roundedRect(m.X + n - 1, m.Y - 1, r + 2, i + 2, 2, 2, "F"), e.setFillColor("#000000");
|
|
674
|
+
}
|
|
675
|
+
e.text(l[t], m.X + n, m.Y, {
|
|
676
|
+
baseline: "top",
|
|
677
|
+
maxWidth: c
|
|
678
|
+
}), m.updateX(e.getTextDimensions(l[t]).w + (u ? 2 : 1), "add"), t < l.length - 1 && (m.updateY(h(e), "add"), m.updateX(m.options.page.xpading, "set"));
|
|
679
|
+
}
|
|
680
|
+
else if (l.length > 1) {
|
|
681
|
+
let t = l[0], r = l?.slice(1)?.join(" ");
|
|
682
|
+
if (u) {
|
|
683
|
+
let r = e.getTextWidth(t) + g(e), i = h(e);
|
|
684
|
+
e.setFillColor(d), e.roundedRect(m.X + (n >= 2 ? n + 2 : 0) - 1, m.Y - 1, r + 2, i + 2, 2, 2, "F"), e.setFillColor("#000000");
|
|
685
|
+
}
|
|
686
|
+
e.text(t, m.X + (n >= 2 ? n + 2 * o(s) : 0), m.Y, {
|
|
687
|
+
baseline: "top",
|
|
688
|
+
maxWidth: c
|
|
689
|
+
}), m.updateX(m.options.page.xpading + n), m.updateY(h(e), "add");
|
|
690
|
+
let i = m.options.page.maxContentWidth - n - m.options.page.xpading;
|
|
691
|
+
e.splitTextToSize(r, i).forEach((t) => {
|
|
692
|
+
if (u) {
|
|
693
|
+
let n = e.getTextWidth(t) + g(e), r = h(e);
|
|
694
|
+
e.setFillColor(d), e.roundedRect(m.X + g(e) - 1, m.Y - 1, n + 2, r + 2, 2, 2, "F"), e.setFillColor("#000000");
|
|
695
|
+
}
|
|
696
|
+
e.text(t, m.X + g(e), m.Y, {
|
|
697
|
+
baseline: "top",
|
|
698
|
+
maxWidth: i
|
|
699
|
+
});
|
|
700
|
+
});
|
|
701
|
+
} else {
|
|
702
|
+
if (u) {
|
|
703
|
+
let r = e.getTextWidth(t) + g(e), i = h(e);
|
|
704
|
+
e.setFillColor(d), e.roundedRect(m.X + n - 1, m.Y - 1, r + 2, i + 2, 2, 2, "F"), e.setFillColor("#000000");
|
|
705
|
+
}
|
|
706
|
+
e.text(t, m.X + n, m.Y, {
|
|
707
|
+
baseline: "top",
|
|
708
|
+
maxWidth: c
|
|
709
|
+
}), m.updateX(e.getTextDimensions(t).w + (n >= 2 ? t.split(" ").length + 2 : 2) * o(s) * .5 + (u ? 2 : 0), "add");
|
|
710
|
+
}
|
|
711
|
+
};
|
|
712
|
+
if (t.type === "text" && t.items && t.items.length > 0) for (let e of t.items) if (e.type === "codespan") s(e.content || "", "codespan");
|
|
713
|
+
else if (e.type === "em" || e.type === "strong") {
|
|
714
|
+
let t = e.type === "em" ? "italic" : "bold";
|
|
715
|
+
if (e.items && e.items.length > 0) for (let n of e.items) n.type === "strong" && t === "italic" || n.type === "em" && t === "bold" ? s(n.content || "", "bolditalic") : s(n.content || "", t);
|
|
716
|
+
else s(e.content || "", t);
|
|
717
|
+
} else s(e.content || "", "normal");
|
|
718
|
+
else t.type === "em" ? s(t.content || "", "italic") : t.type === "strong" ? s(t.content || "", "bold") : t.type === "codespan" ? s(t.content || "", "codespan") : s(t.content || "", "normal");
|
|
719
|
+
e.setFont(r, i), e.setFontSize(a);
|
|
720
|
+
}, N = (e, t, n) => {
|
|
721
|
+
let r = e.getFont().fontName, i = e.getFont().fontStyle, a = e.getFontSize(), o = e.getTextColor(), s = m.options.link?.linkColor || [
|
|
722
|
+
0,
|
|
723
|
+
0,
|
|
724
|
+
255
|
|
725
|
+
];
|
|
726
|
+
e.setTextColor(...s);
|
|
727
|
+
let c = m.options.page.maxContentWidth - n - m.X, l = t.text || t.content || "", u = t.href || "", d = e.splitTextToSize(l, c);
|
|
728
|
+
if (m.isInlineLockActive) for (let t = 0; t < d.length; t++) {
|
|
729
|
+
let r = e.getTextDimensions(d[t]).w, i = h(e) / 2;
|
|
730
|
+
e.link(m.X + n, m.Y, r, i, { url: u }), e.text(d[t], m.X + n, m.Y, {
|
|
731
|
+
baseline: "top",
|
|
732
|
+
maxWidth: c
|
|
733
|
+
}), m.updateX(r + 1, "add"), m.X + r > m.options.page.maxContentWidth - n && (m.updateY(i, "add"), m.updateX(m.options.page.xpading + n, "set")), t < d.length - 1 && (m.updateY(i, "add"), m.updateX(m.options.page.xpading + n, "set"));
|
|
734
|
+
}
|
|
735
|
+
else if (d.length > 1) {
|
|
736
|
+
let t = d[0], r = d?.slice(1)?.join(" "), i = e.getTextDimensions(t).w, a = h(e) / 2;
|
|
737
|
+
e.link(m.X + n, m.Y, i, a, { url: u }), e.text(t, m.X + n, m.Y, {
|
|
738
|
+
baseline: "top",
|
|
739
|
+
maxWidth: c
|
|
740
|
+
}), m.updateX(m.options.page.xpading + n), m.updateY(a, "add");
|
|
741
|
+
let o = m.options.page.maxContentWidth - n - m.options.page.xpading;
|
|
742
|
+
e.splitTextToSize(r, o).forEach((t) => {
|
|
743
|
+
let n = e.getTextDimensions(t).w;
|
|
744
|
+
e.link(m.X + g(e), m.Y, n, a, { url: u }), e.text(t, m.X + g(e), m.Y, {
|
|
745
|
+
baseline: "top",
|
|
746
|
+
maxWidth: o
|
|
747
|
+
});
|
|
748
|
+
});
|
|
749
|
+
} else {
|
|
750
|
+
let t = e.getTextDimensions(l).w, r = h(e) / 2;
|
|
751
|
+
e.link(m.X + n, m.Y, t, r, { url: u }), e.text(l, m.X + n, m.Y, {
|
|
752
|
+
baseline: "top",
|
|
753
|
+
maxWidth: c
|
|
754
|
+
}), m.updateX(t + 2, "add");
|
|
755
|
+
}
|
|
756
|
+
e.setFont(r, i), e.setFontSize(a), e.setTextColor(o);
|
|
757
|
+
}, P = (e, t, n, r) => {
|
|
758
|
+
let i = m.options, a = n + 1, o = m.X + n * i.page.indent, s = m.Y, c = o + i.page.indent / 2, l = s, u = e.internal.getCurrentPageInfo().pageNumber;
|
|
759
|
+
t.items && t.items.length > 0 && t.items.forEach((e) => {
|
|
760
|
+
r(e, a);
|
|
761
|
+
});
|
|
762
|
+
let d = m.Y, f = e.internal.getCurrentPageInfo().pageNumber;
|
|
763
|
+
e.setDrawColor(100), e.setLineWidth(1);
|
|
764
|
+
for (let t = u; t <= f; t++) {
|
|
765
|
+
e.setPage(t);
|
|
766
|
+
let n = t === u, r = t === f, a = n ? l : i.page.topmargin, o = r ? d : i.page.maxContentHeight;
|
|
767
|
+
e.line(c, a, c, o);
|
|
768
|
+
}
|
|
769
|
+
m.recordContentY(), e.setPage(f);
|
|
770
|
+
}, F = (e) => {
|
|
771
|
+
if (e.data) {
|
|
772
|
+
if (e.data.startsWith("data:image/png")) return "PNG";
|
|
773
|
+
if (e.data.startsWith("data:image/jpeg") || e.data.startsWith("data:image/jpg")) return "JPEG";
|
|
774
|
+
if (e.data.startsWith("data:image/webp") || e.data.startsWith("data:image/webp")) return "WEBP";
|
|
775
|
+
if (e.data.startsWith("data:image/gif")) return "GIF";
|
|
776
|
+
}
|
|
777
|
+
if (e.src) {
|
|
778
|
+
let t = e.src.split("?")[0].split("#")[0].split(".").pop()?.toUpperCase();
|
|
779
|
+
if (t && [
|
|
780
|
+
"PNG",
|
|
781
|
+
"JPEG",
|
|
782
|
+
"JPG",
|
|
783
|
+
"WEBP",
|
|
784
|
+
"GIF"
|
|
785
|
+
].includes(t)) return t === "JPG" ? "JPEG" : t;
|
|
786
|
+
}
|
|
787
|
+
return "JPEG";
|
|
788
|
+
}, I = (e, t, n) => {
|
|
789
|
+
if (!t.data) return;
|
|
790
|
+
let r = m.options, i = r.page.unit || "mm", a = n * r.page.indent, o = r.page.maxContentWidth - a, s = m.X + a, c = m.Y;
|
|
791
|
+
try {
|
|
792
|
+
let { finalWidth: n, finalHeight: a } = S(e, t, o, r.page.maxContentHeight - r.page.topmargin, i);
|
|
793
|
+
c + a > r.page.maxContentHeight && (v(e), c = m.Y);
|
|
794
|
+
let l = t.align || r.image?.defaultAlign || "left", u;
|
|
795
|
+
switch (l) {
|
|
796
|
+
case "right":
|
|
797
|
+
u = s + o - n;
|
|
798
|
+
break;
|
|
799
|
+
case "center":
|
|
800
|
+
u = s + (o - n) / 2;
|
|
801
|
+
break;
|
|
802
|
+
default:
|
|
803
|
+
u = s;
|
|
804
|
+
break;
|
|
805
|
+
}
|
|
806
|
+
let d = F(t);
|
|
807
|
+
n > 0 && a > 0 && e.addImage(t.data, d, u, c, n, a), m.updateY(a, "add"), m.recordContentY();
|
|
808
|
+
} catch (e) {
|
|
809
|
+
console.warn("Failed to render image", e);
|
|
810
|
+
}
|
|
811
|
+
}, L = () => {
|
|
812
|
+
let e = t;
|
|
813
|
+
if (typeof t == "function") return t;
|
|
814
|
+
if (typeof e.default == "function") return e.default;
|
|
815
|
+
if (typeof e.autoTable == "function") return e.autoTable;
|
|
816
|
+
throw Error("Could not resolve jspdf-autotable export. Expected a callable export.");
|
|
817
|
+
}, R = (e, t, n) => {
|
|
818
|
+
if (!t.header || !t.rows) return;
|
|
819
|
+
let r = m.options, i = r.page.xmargin + n * r.page.indent, a = [t.header.map((e) => e.content || "")], o = t.rows.map((e) => e.map((e) => e.content || "")), s = r.table || {};
|
|
820
|
+
L()(e, {
|
|
821
|
+
head: a,
|
|
822
|
+
body: o,
|
|
823
|
+
startY: m.Y,
|
|
824
|
+
margin: {
|
|
825
|
+
left: i,
|
|
826
|
+
right: r.page.xmargin
|
|
827
|
+
},
|
|
828
|
+
...s,
|
|
829
|
+
didDrawPage: (e) => {
|
|
830
|
+
s.didDrawPage && s.didDrawPage(e);
|
|
831
|
+
},
|
|
832
|
+
didDrawCell: (e) => {
|
|
833
|
+
s.didDrawCell && s.didDrawCell(e), m.setCursor({
|
|
834
|
+
x: m.X,
|
|
835
|
+
y: e.cell.y + e.cell.height + 2 * r.page.lineSpace
|
|
836
|
+
});
|
|
837
|
+
}
|
|
838
|
+
});
|
|
839
|
+
}, z = {
|
|
840
|
+
page: {
|
|
841
|
+
indent: 10,
|
|
842
|
+
maxContentWidth: 190,
|
|
843
|
+
maxContentHeight: 277,
|
|
844
|
+
lineSpace: 1.5,
|
|
845
|
+
defaultLineHeightFactor: 1.2,
|
|
846
|
+
defaultFontSize: 12,
|
|
847
|
+
defaultTitleFontSize: 14,
|
|
848
|
+
topmargin: 10,
|
|
849
|
+
xpading: 10,
|
|
850
|
+
xmargin: 10,
|
|
851
|
+
format: "a4",
|
|
852
|
+
orientation: "p"
|
|
853
|
+
},
|
|
854
|
+
font: {
|
|
855
|
+
bold: {
|
|
856
|
+
name: "helvetica",
|
|
857
|
+
style: "bold"
|
|
858
|
+
},
|
|
859
|
+
regular: {
|
|
860
|
+
name: "helvetica",
|
|
861
|
+
style: "normal"
|
|
862
|
+
},
|
|
863
|
+
light: {
|
|
864
|
+
name: "helvetica",
|
|
865
|
+
style: "light"
|
|
866
|
+
}
|
|
867
|
+
},
|
|
868
|
+
image: { defaultAlign: "left" }
|
|
869
|
+
}, B = (e) => {
|
|
870
|
+
if (!e) throw Error("RenderOption is required");
|
|
871
|
+
let t = {
|
|
872
|
+
...z.page,
|
|
873
|
+
...e.page
|
|
874
|
+
}, n = {
|
|
875
|
+
...z.font,
|
|
876
|
+
...e.font
|
|
877
|
+
}, r = {
|
|
878
|
+
...z.image,
|
|
879
|
+
...e.image
|
|
880
|
+
};
|
|
881
|
+
return t.maxContentWidth ||= 190, t.maxContentHeight ||= 277, {
|
|
882
|
+
...e,
|
|
883
|
+
page: t,
|
|
884
|
+
font: n,
|
|
885
|
+
image: r
|
|
886
|
+
};
|
|
887
|
+
}, V = async (e, t, r) => {
|
|
888
|
+
let i = B(r);
|
|
889
|
+
m.initialize(i);
|
|
890
|
+
let a = await d(t);
|
|
891
|
+
await C(a);
|
|
892
|
+
let o = (t, r = 0, a = !1, s = 0, c = !1) => {
|
|
893
|
+
let l = r * i.page.indent;
|
|
894
|
+
switch (t.type) {
|
|
895
|
+
case n.Heading:
|
|
896
|
+
_(e, t, l, o);
|
|
897
|
+
break;
|
|
898
|
+
case n.Paragraph:
|
|
899
|
+
E(e, t, l, o);
|
|
900
|
+
break;
|
|
901
|
+
case n.List:
|
|
902
|
+
D(e, t, r, o);
|
|
903
|
+
break;
|
|
904
|
+
case n.ListItem:
|
|
905
|
+
O(e, t, r, o, s, c);
|
|
906
|
+
break;
|
|
907
|
+
case n.Hr:
|
|
908
|
+
A(e);
|
|
909
|
+
break;
|
|
910
|
+
case n.Code:
|
|
911
|
+
j(e, t, r);
|
|
912
|
+
break;
|
|
913
|
+
case n.Strong:
|
|
914
|
+
case n.Em:
|
|
915
|
+
case n.CodeSpan:
|
|
916
|
+
M(e, t, l);
|
|
917
|
+
break;
|
|
918
|
+
case n.Link:
|
|
919
|
+
N(e, t, l);
|
|
920
|
+
break;
|
|
921
|
+
case n.Blockquote:
|
|
922
|
+
P(e, t, r, o);
|
|
923
|
+
break;
|
|
924
|
+
case n.Image:
|
|
925
|
+
I(e, t, r);
|
|
926
|
+
break;
|
|
927
|
+
case n.Table:
|
|
928
|
+
R(e, t, r);
|
|
929
|
+
break;
|
|
930
|
+
case n.Raw:
|
|
931
|
+
case n.Text:
|
|
932
|
+
k(e, t, r, a, o, s, c, i.content?.textAlignment === "justify");
|
|
933
|
+
break;
|
|
934
|
+
default:
|
|
935
|
+
console.warn(`Warning: Unsupported element type encountered: ${t.type}.
|
|
1325
936
|
If you believe this element type should be supported, please create an issue at:
|
|
1326
937
|
https://github.com/JeelGajera/jspdf-md-renderer/issues
|
|
1327
|
-
with details of the element and expected behavior. Thanks for helping to improve this library!`
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
o(g);
|
|
1334
|
-
r.endCursorYHandler(n.Y);
|
|
1335
|
-
};
|
|
1336
|
-
export {
|
|
1337
|
-
K as MdTextParser,
|
|
1338
|
-
xt as MdTextRender
|
|
938
|
+
with details of the element and expected behavior. Thanks for helping to improve this library!`);
|
|
939
|
+
break;
|
|
940
|
+
}
|
|
941
|
+
};
|
|
942
|
+
for (let e of a) o(e);
|
|
943
|
+
i.endCursorYHandler(m.Y);
|
|
1339
944
|
};
|
|
945
|
+
//#endregion
|
|
946
|
+
export { d as MdTextParser, V as MdTextRender };
|