@blocknote/xl-pdf-exporter 0.30.0 → 0.31.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.
@@ -437,77 +437,167 @@
437
437
  rows: [
438
438
  {
439
439
  cells: [
440
- [
441
- {
442
- styles: {},
443
- text: 'Wide Cell',
444
- type: 'text'
445
- }
446
- ],
447
- [
448
- {
449
- styles: {},
450
- text: 'Table Cell',
451
- type: 'text'
452
- }
453
- ],
454
- [
455
- {
456
- styles: {},
457
- text: 'Table Cell',
458
- type: 'text'
459
- }
460
- ]
440
+ {
441
+ content: [
442
+ {
443
+ styles: {},
444
+ text: 'Wide Cell',
445
+ type: 'text'
446
+ }
447
+ ],
448
+ props: {
449
+ backgroundColor: 'default',
450
+ colspan: 1,
451
+ rowspan: 1,
452
+ textAlignment: 'left',
453
+ textColor: 'default'
454
+ },
455
+ type: 'tableCell'
456
+ },
457
+ {
458
+ content: [
459
+ {
460
+ styles: {},
461
+ text: 'Table Cell',
462
+ type: 'text'
463
+ }
464
+ ],
465
+ props: {
466
+ backgroundColor: 'default',
467
+ colspan: 1,
468
+ rowspan: 1,
469
+ textAlignment: 'left',
470
+ textColor: 'default'
471
+ },
472
+ type: 'tableCell'
473
+ },
474
+ {
475
+ content: [
476
+ {
477
+ styles: {},
478
+ text: 'Table Cell',
479
+ type: 'text'
480
+ }
481
+ ],
482
+ props: {
483
+ backgroundColor: 'default',
484
+ colspan: 1,
485
+ rowspan: 1,
486
+ textAlignment: 'left',
487
+ textColor: 'default'
488
+ },
489
+ type: 'tableCell'
490
+ }
461
491
  ]
462
492
  },
463
493
  {
464
494
  cells: [
465
- [
466
- {
467
- styles: {},
468
- text: 'Wide Cell',
469
- type: 'text'
470
- }
471
- ],
472
- [
473
- {
474
- styles: {},
475
- text: 'Table Cell',
476
- type: 'text'
477
- }
478
- ],
479
- [
480
- {
481
- styles: {},
482
- text: 'Table Cell',
483
- type: 'text'
484
- }
485
- ]
495
+ {
496
+ content: [
497
+ {
498
+ styles: {},
499
+ text: 'Wide Cell',
500
+ type: 'text'
501
+ }
502
+ ],
503
+ props: {
504
+ backgroundColor: 'default',
505
+ colspan: 1,
506
+ rowspan: 1,
507
+ textAlignment: 'left',
508
+ textColor: 'default'
509
+ },
510
+ type: 'tableCell'
511
+ },
512
+ {
513
+ content: [
514
+ {
515
+ styles: {},
516
+ text: 'Table Cell',
517
+ type: 'text'
518
+ }
519
+ ],
520
+ props: {
521
+ backgroundColor: 'default',
522
+ colspan: 1,
523
+ rowspan: 1,
524
+ textAlignment: 'left',
525
+ textColor: 'default'
526
+ },
527
+ type: 'tableCell'
528
+ },
529
+ {
530
+ content: [
531
+ {
532
+ styles: {},
533
+ text: 'Table Cell',
534
+ type: 'text'
535
+ }
536
+ ],
537
+ props: {
538
+ backgroundColor: 'default',
539
+ colspan: 1,
540
+ rowspan: 1,
541
+ textAlignment: 'left',
542
+ textColor: 'default'
543
+ },
544
+ type: 'tableCell'
545
+ }
486
546
  ]
487
547
  },
488
548
  {
489
549
  cells: [
490
- [
491
- {
492
- styles: {},
493
- text: 'Wide Cell',
494
- type: 'text'
495
- }
496
- ],
497
- [
498
- {
499
- styles: {},
500
- text: 'Table Cell',
501
- type: 'text'
502
- }
503
- ],
504
- [
505
- {
506
- styles: {},
507
- text: 'Table Cell',
508
- type: 'text'
509
- }
510
- ]
550
+ {
551
+ content: [
552
+ {
553
+ styles: {},
554
+ text: 'Wide Cell',
555
+ type: 'text'
556
+ }
557
+ ],
558
+ props: {
559
+ backgroundColor: 'default',
560
+ colspan: 1,
561
+ rowspan: 1,
562
+ textAlignment: 'left',
563
+ textColor: 'default'
564
+ },
565
+ type: 'tableCell'
566
+ },
567
+ {
568
+ content: [
569
+ {
570
+ styles: {},
571
+ text: 'Table Cell',
572
+ type: 'text'
573
+ }
574
+ ],
575
+ props: {
576
+ backgroundColor: 'default',
577
+ colspan: 1,
578
+ rowspan: 1,
579
+ textAlignment: 'left',
580
+ textColor: 'default'
581
+ },
582
+ type: 'tableCell'
583
+ },
584
+ {
585
+ content: [
586
+ {
587
+ styles: {},
588
+ text: 'Table Cell',
589
+ type: 'text'
590
+ }
591
+ ],
592
+ props: {
593
+ backgroundColor: 'default',
594
+ colspan: 1,
595
+ rowspan: 1,
596
+ textAlignment: 'left',
597
+ textColor: 'default'
598
+ },
599
+ type: 'tableCell'
600
+ }
511
601
  ]
512
602
  }
513
603
  ],
@@ -817,79 +907,169 @@
817
907
  rows: [
818
908
  {
819
909
  cells: [
820
- [
821
- {
822
- styles: {},
823
- text: 'Table Cell 1',
824
- type: 'text'
825
- }
826
- ],
827
- [
828
- {
829
- styles: {},
830
- text: 'Table Cell 2',
831
- type: 'text'
832
- }
833
- ],
834
- [
835
- {
836
- styles: {},
837
- text: 'Table Cell 3',
838
- type: 'text'
839
- }
840
- ]
910
+ {
911
+ content: [
912
+ {
913
+ styles: {},
914
+ text: 'Table Cell 1',
915
+ type: 'text'
916
+ }
917
+ ],
918
+ props: {
919
+ backgroundColor: 'default',
920
+ colspan: 1,
921
+ rowspan: 1,
922
+ textAlignment: 'left',
923
+ textColor: 'default'
924
+ },
925
+ type: 'tableCell'
926
+ },
927
+ {
928
+ content: [
929
+ {
930
+ styles: {},
931
+ text: 'Table Cell 2',
932
+ type: 'text'
933
+ }
934
+ ],
935
+ props: {
936
+ backgroundColor: 'default',
937
+ colspan: 1,
938
+ rowspan: 1,
939
+ textAlignment: 'left',
940
+ textColor: 'default'
941
+ },
942
+ type: 'tableCell'
943
+ },
944
+ {
945
+ content: [
946
+ {
947
+ styles: {},
948
+ text: 'Table Cell 3',
949
+ type: 'text'
950
+ }
951
+ ],
952
+ props: {
953
+ backgroundColor: 'default',
954
+ colspan: 1,
955
+ rowspan: 1,
956
+ textAlignment: 'left',
957
+ textColor: 'default'
958
+ },
959
+ type: 'tableCell'
960
+ }
841
961
  ]
842
962
  },
843
963
  {
844
964
  cells: [
845
- [
846
- {
847
- styles: {},
848
- text: 'Table Cell 4',
849
- type: 'text'
850
- }
851
- ],
852
- [
853
- {
854
- styles: {
855
- bold: true
856
- },
857
- text: 'Table Cell Bold 5',
858
- type: 'text'
859
- }
860
- ],
861
- [
862
- {
863
- styles: {},
864
- text: 'Table Cell 6',
865
- type: 'text'
866
- }
867
- ]
965
+ {
966
+ content: [
967
+ {
968
+ styles: {},
969
+ text: 'Table Cell 4',
970
+ type: 'text'
971
+ }
972
+ ],
973
+ props: {
974
+ backgroundColor: 'default',
975
+ colspan: 1,
976
+ rowspan: 1,
977
+ textAlignment: 'left',
978
+ textColor: 'default'
979
+ },
980
+ type: 'tableCell'
981
+ },
982
+ {
983
+ content: [
984
+ {
985
+ styles: {
986
+ bold: true
987
+ },
988
+ text: 'Table Cell Bold 5',
989
+ type: 'text'
990
+ }
991
+ ],
992
+ props: {
993
+ backgroundColor: 'default',
994
+ colspan: 1,
995
+ rowspan: 1,
996
+ textAlignment: 'left',
997
+ textColor: 'default'
998
+ },
999
+ type: 'tableCell'
1000
+ },
1001
+ {
1002
+ content: [
1003
+ {
1004
+ styles: {},
1005
+ text: 'Table Cell 6',
1006
+ type: 'text'
1007
+ }
1008
+ ],
1009
+ props: {
1010
+ backgroundColor: 'default',
1011
+ colspan: 1,
1012
+ rowspan: 1,
1013
+ textAlignment: 'left',
1014
+ textColor: 'default'
1015
+ },
1016
+ type: 'tableCell'
1017
+ }
868
1018
  ]
869
1019
  },
870
1020
  {
871
1021
  cells: [
872
- [
873
- {
874
- styles: {},
875
- text: 'Table Cell 7',
876
- type: 'text'
877
- }
878
- ],
879
- [
880
- {
881
- styles: {},
882
- text: 'Table Cell 8',
883
- type: 'text'
884
- }
885
- ],
886
- [
887
- {
888
- styles: {},
889
- text: 'Table Cell 9',
890
- type: 'text'
891
- }
892
- ]
1022
+ {
1023
+ content: [
1024
+ {
1025
+ styles: {},
1026
+ text: 'Table Cell 7',
1027
+ type: 'text'
1028
+ }
1029
+ ],
1030
+ props: {
1031
+ backgroundColor: 'default',
1032
+ colspan: 1,
1033
+ rowspan: 1,
1034
+ textAlignment: 'left',
1035
+ textColor: 'default'
1036
+ },
1037
+ type: 'tableCell'
1038
+ },
1039
+ {
1040
+ content: [
1041
+ {
1042
+ styles: {},
1043
+ text: 'Table Cell 8',
1044
+ type: 'text'
1045
+ }
1046
+ ],
1047
+ props: {
1048
+ backgroundColor: 'default',
1049
+ colspan: 1,
1050
+ rowspan: 1,
1051
+ textAlignment: 'left',
1052
+ textColor: 'default'
1053
+ },
1054
+ type: 'tableCell'
1055
+ },
1056
+ {
1057
+ content: [
1058
+ {
1059
+ styles: {},
1060
+ text: 'Table Cell 9',
1061
+ type: 'text'
1062
+ }
1063
+ ],
1064
+ props: {
1065
+ backgroundColor: 'default',
1066
+ colspan: 1,
1067
+ rowspan: 1,
1068
+ textAlignment: 'left',
1069
+ textColor: 'default'
1070
+ },
1071
+ type: 'tableCell'
1072
+ }
893
1073
  ]
894
1074
  }
895
1075
  ],
@@ -52,7 +52,8 @@ export const pdfBlockMappingForDefaultSchema: BlockMapping<
52
52
  <ListItem
53
53
  listMarker={
54
54
  block.props.checked ? CHECK_MARKER_CHECKED : CHECK_MARKER_UNCHECKED
55
- }>
55
+ }
56
+ >
56
57
  <Text>{exporter.transformInlineContent(block.content)}</Text>
57
58
  </ListItem>
58
59
  );
@@ -65,7 +66,8 @@ export const pdfBlockMappingForDefaultSchema: BlockMapping<
65
66
  style={{
66
67
  fontSize: fontSizeEM * FONT_SIZE * PIXELS_PER_POINT,
67
68
  fontWeight: 700,
68
- }}>
69
+ }}
70
+ >
69
71
  {exporter.transformInlineContent(block.content)}
70
72
  </Text>
71
73
  );
@@ -77,7 +79,8 @@ export const pdfBlockMappingForDefaultSchema: BlockMapping<
77
79
  borderLeft: "#7D797A",
78
80
  color: "#7D797A",
79
81
  paddingLeft: 9.5 * PIXELS_PER_POINT,
80
- }}>
82
+ }}
83
+ >
81
84
  {exporter.transformInlineContent(block.content)}
82
85
  </Text>
83
86
  );
@@ -92,7 +95,8 @@ export const pdfBlockMappingForDefaultSchema: BlockMapping<
92
95
  key={`line_${index}`}
93
96
  style={{
94
97
  marginLeft: indent * 9.5 * PIXELS_PER_POINT,
95
- }}>
98
+ }}
99
+ >
96
100
  {line.trimStart() || <>&nbsp;</>}
97
101
  </Text>
98
102
  );
@@ -108,7 +112,8 @@ export const pdfBlockMappingForDefaultSchema: BlockMapping<
108
112
  lineHeight: 1.25,
109
113
  fontSize: FONT_SIZE * PIXELS_PER_POINT,
110
114
  fontFamily: "GeistMono",
111
- }}>
115
+ }}
116
+ >
112
117
  {lines}
113
118
  </View>
114
119
  );
@@ -125,7 +130,7 @@ export const pdfBlockMappingForDefaultSchema: BlockMapping<
125
130
  <Svg height={14} width={14} viewBox="0 0 24 24" fill="currentColor">
126
131
  <Path d="M2 16.0001H5.88889L11.1834 20.3319C11.2727 20.405 11.3846 20.4449 11.5 20.4449C11.7761 20.4449 12 20.2211 12 19.9449V4.05519C12 3.93977 11.9601 3.8279 11.887 3.73857C11.7121 3.52485 11.3971 3.49335 11.1834 3.66821L5.88889 8.00007H2C1.44772 8.00007 1 8.44778 1 9.00007V15.0001C1 15.5524 1.44772 16.0001 2 16.0001ZM23 12C23 15.292 21.5539 18.2463 19.2622 20.2622L17.8445 18.8444C19.7758 17.1937 21 14.7398 21 12C21 9.26016 19.7758 6.80629 17.8445 5.15557L19.2622 3.73779C21.5539 5.75368 23 8.70795 23 12ZM18 12C18 10.0883 17.106 8.38548 15.7133 7.28673L14.2842 8.71584C15.3213 9.43855 16 10.64 16 12C16 13.36 15.3213 14.5614 14.2842 15.2841L15.7133 16.7132C17.106 15.6145 18 13.9116 18 12Z"></Path>
127
132
  </Svg>,
128
- exporter
133
+ exporter,
129
134
  )}
130
135
  {caption(block.props, exporter)}
131
136
  </View>
@@ -140,7 +145,7 @@ export const pdfBlockMappingForDefaultSchema: BlockMapping<
140
145
  <Svg height={14} width={14} viewBox="0 0 24 24" fill="currentColor">
141
146
  <Path d="M2 3.9934C2 3.44476 2.45531 3 2.9918 3H21.0082C21.556 3 22 3.44495 22 3.9934V20.0066C22 20.5552 21.5447 21 21.0082 21H2.9918C2.44405 21 2 20.5551 2 20.0066V3.9934ZM8 5V19H16V5H8ZM4 5V7H6V5H4ZM18 5V7H20V5H18ZM4 9V11H6V9H4ZM18 9V11H20V9H18ZM4 13V15H6V13H4ZM18 13V15H20V13H18ZM4 17V19H6V17H4ZM18 17V19H20V17H18Z" />
142
147
  </Svg>,
143
- exporter
148
+ exporter,
144
149
  )}
145
150
  {caption(block.props, exporter)}
146
151
  </View>
@@ -155,7 +160,7 @@ export const pdfBlockMappingForDefaultSchema: BlockMapping<
155
160
  <Svg height={16} width={16} viewBox="0 0 24 24" fill="currentColor">
156
161
  <Path d="M3 8L9.00319 2H19.9978C20.5513 2 21 2.45531 21 2.9918V21.0082C21 21.556 20.5551 22 20.0066 22H3.9934C3.44476 22 3 21.5501 3 20.9932V8ZM10 4V9H5V20H19V4H10Z" />
157
162
  </Svg>,
158
- exporter
163
+ exporter,
159
164
  )}
160
165
  {caption(block.props, exporter)}
161
166
  </View>
@@ -185,7 +190,7 @@ function file(
185
190
  props: Partial<DefaultProps & { name: string; url: string }>,
186
191
  defaultText: string,
187
192
  icon: React.ReactElement<Svg>,
188
- _exporter: any
193
+ _exporter: any,
189
194
  ) {
190
195
  const PIXELS_PER_POINT = 0.75;
191
196
  return (
@@ -195,7 +200,8 @@ function file(
195
200
  display: "flex",
196
201
  gap: 8 * PIXELS_PER_POINT,
197
202
  flexDirection: "row",
198
- }}>
203
+ }}
204
+ >
199
205
  {icon}
200
206
  <Text>{props.name || defaultText}</Text>
201
207
  </View>
@@ -205,7 +211,7 @@ function file(
205
211
 
206
212
  function caption(
207
213
  props: Partial<DefaultProps & { caption: string; previewWidth: number }>,
208
- _exporter: any
214
+ _exporter: any,
209
215
  ) {
210
216
  if (!props.caption) {
211
217
  return undefined;
@@ -217,7 +223,8 @@ function caption(
217
223
  ? props.previewWidth * PIXELS_PER_POINT
218
224
  : undefined,
219
225
  fontSize: FONT_SIZE * 0.8 * PIXELS_PER_POINT,
220
- }}>
226
+ }}
227
+ >
221
228
  {props.caption}
222
229
  </Text>
223
230
  );
@@ -34,7 +34,7 @@ describe("exporter", () => {
34
34
  type: "extraBlock",
35
35
  propSchema: {},
36
36
  },
37
- {} as any
37
+ {} as any,
38
38
  ),
39
39
  },
40
40
  });
@@ -42,7 +42,7 @@ describe("exporter", () => {
42
42
  new PDFExporter(
43
43
  schema,
44
44
  // @ts-expect-error
45
- pdfDefaultSchemaMappings
45
+ pdfDefaultSchemaMappings,
46
46
  );
47
47
 
48
48
  new PDFExporter(schema, {
@@ -74,7 +74,7 @@ describe("exporter", () => {
74
74
  content: "styled",
75
75
  propSchema: {},
76
76
  },
77
- {} as any
77
+ {} as any,
78
78
  ),
79
79
  },
80
80
  });
@@ -82,7 +82,7 @@ describe("exporter", () => {
82
82
  new PDFExporter(
83
83
  schema,
84
84
  // @ts-expect-error
85
- pdfDefaultSchemaMappings
85
+ pdfDefaultSchemaMappings,
86
86
  );
87
87
 
88
88
  new PDFExporter(schema, {
@@ -114,7 +114,7 @@ describe("exporter", () => {
114
114
  type: "extraStyle",
115
115
  propSchema: "boolean",
116
116
  },
117
- {} as any
117
+ {} as any,
118
118
  ),
119
119
  },
120
120
  });
@@ -122,7 +122,7 @@ describe("exporter", () => {
122
122
  new PDFExporter(
123
123
  schema,
124
124
  // @ts-expect-error
125
- pdfDefaultSchemaMappings
125
+ pdfDefaultSchemaMappings,
126
126
  );
127
127
 
128
128
  new PDFExporter(schema, {
@@ -160,7 +160,7 @@ describe("exporter", () => {
160
160
  BlockNoteSchema.create({
161
161
  blockSpecs: { ...defaultBlockSpecs, pageBreak: PageBreak },
162
162
  }),
163
- pdfDefaultSchemaMappings
163
+ pdfDefaultSchemaMappings,
164
164
  );
165
165
 
166
166
  const transformed = await exporter.toReactPDFDocument(testDocument);
@@ -193,7 +193,7 @@ describe("exporter", () => {
193
193
  BlockNoteSchema.create({
194
194
  blockSpecs: { ...defaultBlockSpecs, pageBreak: PageBreak },
195
195
  }),
196
- pdfDefaultSchemaMappings
196
+ pdfDefaultSchemaMappings,
197
197
  );
198
198
 
199
199
  const transformed = await exporter.toReactPDFDocument(testDocument, {
@@ -202,7 +202,7 @@ describe("exporter", () => {
202
202
  });
203
203
  const str = reactElementToJSXString(transformed);
204
204
  await expect(str).toMatchFileSnapshot(
205
- "__snapshots__/exampleWithHeaderAndFooter.jsx"
205
+ "__snapshots__/exampleWithHeaderAndFooter.jsx",
206
206
  );
207
207
 
208
208
  // await ReactPDF.render(