@blocknote/xl-pdf-exporter 0.31.3 → 0.32.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.
@@ -19,7 +19,7 @@
19
19
  Header
20
20
  </TEXT>
21
21
  </VIEW>
22
- <React.Fragment key=".1:0">
22
+ <React.Fragment key=".1:$">
23
23
  <VIEW
24
24
  style={{
25
25
  alignItems: undefined,
@@ -52,7 +52,7 @@
52
52
  marginLeft: 18
53
53
  }}
54
54
  >
55
- <React.Fragment key=".0">
55
+ <React.Fragment key=".$">
56
56
  <VIEW
57
57
  style={{
58
58
  alignItems: undefined,
@@ -73,7 +73,7 @@
73
73
  marginLeft: 18
74
74
  }}
75
75
  >
76
- <React.Fragment key=".0">
76
+ <React.Fragment key=".$">
77
77
  <VIEW
78
78
  style={{
79
79
  alignItems: undefined,
@@ -94,7 +94,7 @@
94
94
  </React.Fragment>
95
95
  </VIEW>
96
96
  </React.Fragment>
97
- <React.Fragment key=".1:1">
97
+ <React.Fragment key=".1:$">
98
98
  <VIEW
99
99
  style={{
100
100
  alignItems: undefined,
@@ -115,7 +115,7 @@
115
115
  </TEXT>
116
116
  </VIEW>
117
117
  </React.Fragment>
118
- <React.Fragment key=".1:2">
118
+ <React.Fragment key=".1:$">
119
119
  <VIEW
120
120
  style={{
121
121
  alignItems: undefined,
@@ -132,7 +132,7 @@
132
132
  </TEXT>
133
133
  </VIEW>
134
134
  </React.Fragment>
135
- <React.Fragment key=".1:3">
135
+ <React.Fragment key=".1:$">
136
136
  <VIEW
137
137
  style={{
138
138
  alignItems: undefined,
@@ -154,7 +154,7 @@
154
154
  </TEXT>
155
155
  </VIEW>
156
156
  </React.Fragment>
157
- <React.Fragment key=".1:4">
157
+ <React.Fragment key=".1:$">
158
158
  <VIEW
159
159
  style={{
160
160
  alignItems: 'flex-end',
@@ -176,7 +176,7 @@
176
176
  </TEXT>
177
177
  </VIEW>
178
178
  </React.Fragment>
179
- <React.Fragment key=".1:5">
179
+ <React.Fragment key=".1:$">
180
180
  <VIEW
181
181
  style={{
182
182
  alignItems: undefined,
@@ -194,7 +194,7 @@
194
194
  </VIEW>
195
195
  </React.Fragment>
196
196
  <VIEW break />
197
- <React.Fragment key=".1:7">
197
+ <React.Fragment key=".1:$">
198
198
  <VIEW
199
199
  style={{
200
200
  alignItems: undefined,
@@ -217,7 +217,7 @@
217
217
  marginLeft: 18
218
218
  }}
219
219
  >
220
- <React.Fragment key=".0">
220
+ <React.Fragment key=".$">
221
221
  <VIEW
222
222
  style={{
223
223
  alignItems: undefined,
@@ -236,7 +236,7 @@
236
236
  </ListItem>
237
237
  </VIEW>
238
238
  </React.Fragment>
239
- <React.Fragment key=".1">
239
+ <React.Fragment key=".$">
240
240
  <VIEW
241
241
  style={{
242
242
  alignItems: 'flex-end',
@@ -255,7 +255,7 @@
255
255
  </ListItem>
256
256
  </VIEW>
257
257
  </React.Fragment>
258
- <React.Fragment key=".2">
258
+ <React.Fragment key=".$">
259
259
  <VIEW
260
260
  style={{
261
261
  alignItems: undefined,
@@ -274,7 +274,7 @@
274
274
  </ListItem>
275
275
  </VIEW>
276
276
  </React.Fragment>
277
- <React.Fragment key=".3">
277
+ <React.Fragment key=".$">
278
278
  <VIEW
279
279
  style={{
280
280
  alignItems: undefined,
@@ -297,7 +297,7 @@
297
297
  marginLeft: 18
298
298
  }}
299
299
  >
300
- <React.Fragment key=".0">
300
+ <React.Fragment key=".$">
301
301
  <VIEW
302
302
  style={{
303
303
  alignItems: undefined,
@@ -316,7 +316,7 @@
316
316
  </ListItem>
317
317
  </VIEW>
318
318
  </React.Fragment>
319
- <React.Fragment key=".1">
319
+ <React.Fragment key=".$">
320
320
  <VIEW
321
321
  style={{
322
322
  alignItems: undefined,
@@ -335,7 +335,7 @@
335
335
  </ListItem>
336
336
  </VIEW>
337
337
  </React.Fragment>
338
- <React.Fragment key=".2">
338
+ <React.Fragment key=".$">
339
339
  <VIEW
340
340
  style={{
341
341
  alignItems: 'flex-end',
@@ -354,7 +354,7 @@
354
354
  </ListItem>
355
355
  </VIEW>
356
356
  </React.Fragment>
357
- <React.Fragment key=".3">
357
+ <React.Fragment key=".$">
358
358
  <VIEW
359
359
  style={{
360
360
  alignItems: 'center',
@@ -377,7 +377,7 @@
377
377
  </React.Fragment>
378
378
  </VIEW>
379
379
  </React.Fragment>
380
- <React.Fragment key=".1:8">
380
+ <React.Fragment key=".1:$">
381
381
  <VIEW
382
382
  style={{
383
383
  alignItems: undefined,
@@ -396,7 +396,7 @@
396
396
  </ListItem>
397
397
  </VIEW>
398
398
  </React.Fragment>
399
- <React.Fragment key=".1:9">
399
+ <React.Fragment key=".1:$">
400
400
  <VIEW
401
401
  style={{
402
402
  alignItems: undefined,
@@ -415,7 +415,7 @@
415
415
  </ListItem>
416
416
  </VIEW>
417
417
  </React.Fragment>
418
- <React.Fragment key=".1:a">
418
+ <React.Fragment key=".1:$">
419
419
  <VIEW
420
420
  style={{
421
421
  alignItems: undefined,
@@ -607,7 +607,7 @@
607
607
  />
608
608
  </VIEW>
609
609
  </React.Fragment>
610
- <React.Fragment key=".1:b">
610
+ <React.Fragment key=".1:$">
611
611
  <VIEW
612
612
  style={{
613
613
  alignItems: undefined,
@@ -642,7 +642,7 @@
642
642
  </VIEW>
643
643
  </VIEW>
644
644
  </React.Fragment>
645
- <React.Fragment key=".1:c">
645
+ <React.Fragment key=".1:$">
646
646
  <VIEW
647
647
  style={{
648
648
  alignItems: undefined,
@@ -670,7 +670,7 @@
670
670
  </VIEW>
671
671
  </VIEW>
672
672
  </React.Fragment>
673
- <React.Fragment key=".1:d">
673
+ <React.Fragment key=".1:$">
674
674
  <VIEW
675
675
  style={{
676
676
  alignItems: 'flex-end',
@@ -690,7 +690,7 @@
690
690
  </VIEW>
691
691
  </VIEW>
692
692
  </React.Fragment>
693
- <React.Fragment key=".1:e">
693
+ <React.Fragment key=".1:$">
694
694
  <VIEW
695
695
  style={{
696
696
  alignItems: undefined,
@@ -733,7 +733,7 @@
733
733
  </VIEW>
734
734
  </VIEW>
735
735
  </React.Fragment>
736
- <React.Fragment key=".1:f">
736
+ <React.Fragment key=".1:$">
737
737
  <VIEW
738
738
  style={{
739
739
  alignItems: undefined,
@@ -776,7 +776,7 @@
776
776
  </VIEW>
777
777
  </VIEW>
778
778
  </React.Fragment>
779
- <React.Fragment key=".1:g">
779
+ <React.Fragment key=".1:$">
780
780
  <VIEW
781
781
  style={{
782
782
  alignItems: undefined,
@@ -789,7 +789,7 @@
789
789
  <TEXT />
790
790
  </VIEW>
791
791
  </React.Fragment>
792
- <React.Fragment key=".1:h">
792
+ <React.Fragment key=".1:$">
793
793
  <VIEW
794
794
  style={{
795
795
  alignItems: undefined,
@@ -832,7 +832,7 @@
832
832
  </VIEW>
833
833
  </VIEW>
834
834
  </React.Fragment>
835
- <React.Fragment key=".1:i">
835
+ <React.Fragment key=".1:$">
836
836
  <VIEW
837
837
  style={{
838
838
  alignItems: undefined,
@@ -853,7 +853,7 @@
853
853
  </TEXT>
854
854
  </VIEW>
855
855
  </React.Fragment>
856
- <React.Fragment key=".1:j">
856
+ <React.Fragment key=".1:$">
857
857
  <VIEW
858
858
  style={{
859
859
  alignItems: undefined,
@@ -885,7 +885,7 @@
885
885
  </TEXT>
886
886
  </VIEW>
887
887
  </React.Fragment>
888
- <React.Fragment key=".1:k">
888
+ <React.Fragment key=".1:$">
889
889
  <VIEW
890
890
  style={{
891
891
  alignItems: undefined,
@@ -1079,7 +1079,7 @@
1079
1079
  />
1080
1080
  </VIEW>
1081
1081
  </React.Fragment>
1082
- <React.Fragment key=".1:l">
1082
+ <React.Fragment key=".1:$">
1083
1083
  <VIEW
1084
1084
  style={{
1085
1085
  alignItems: undefined,
@@ -10,6 +10,7 @@ import {
10
10
  BULLET_MARKER,
11
11
  CHECK_MARKER_CHECKED,
12
12
  CHECK_MARKER_UNCHECKED,
13
+ CHEVRON_MARKER,
13
14
  ListItem,
14
15
  } from "../util/listItem.js";
15
16
  import { Table } from "../util/table/Table.js";
@@ -26,12 +27,23 @@ export const pdfBlockMappingForDefaultSchema: BlockMapping<
26
27
  > = {
27
28
  paragraph: (block, exporter) => {
28
29
  // const style = blocknoteDefaultPropsToReactPDFStyle(block.props);
29
- return <Text>{exporter.transformInlineContent(block.content)}</Text>;
30
+ return (
31
+ <Text key={"paragraph" + block.id}>
32
+ {exporter.transformInlineContent(block.content)}
33
+ </Text>
34
+ );
35
+ },
36
+ toggleListItem: (block, exporter) => {
37
+ return (
38
+ <ListItem listMarker={CHEVRON_MARKER}>
39
+ <Text>{exporter.transformInlineContent(block.content)}</Text>
40
+ </ListItem>
41
+ );
30
42
  },
31
43
  bulletListItem: (block, exporter) => {
32
44
  // const style = t(block.props);
33
45
  return (
34
- <ListItem listMarker={BULLET_MARKER}>
46
+ <ListItem listMarker={BULLET_MARKER} key={"bulletListItem" + block.id}>
35
47
  <Text>{exporter.transformInlineContent(block.content)}</Text>
36
48
  </ListItem>
37
49
  );
@@ -40,7 +52,10 @@ export const pdfBlockMappingForDefaultSchema: BlockMapping<
40
52
  // const style = blocknoteDefaultPropsToReactPDFStyle(block.props);
41
53
  // console.log("NUMBERED LIST ITEM", block.props.textAlignment, style);
42
54
  return (
43
- <ListItem listMarker={`${numberedListIndex}.`}>
55
+ <ListItem
56
+ listMarker={`${numberedListIndex}.`}
57
+ key={"numberedListItem" + block.id}
58
+ >
44
59
  <Text>{exporter.transformInlineContent(block.content)}</Text>
45
60
  </ListItem>
46
61
  );
@@ -53,18 +68,26 @@ export const pdfBlockMappingForDefaultSchema: BlockMapping<
53
68
  listMarker={
54
69
  block.props.checked ? CHECK_MARKER_CHECKED : CHECK_MARKER_UNCHECKED
55
70
  }
71
+ key={"checkListItem" + block.id}
56
72
  >
57
73
  <Text>{exporter.transformInlineContent(block.content)}</Text>
58
74
  </ListItem>
59
75
  );
60
76
  },
61
77
  heading: (block, exporter) => {
62
- const fontSizeEM =
63
- block.props.level === 1 ? 2 : block.props.level === 2 ? 1.5 : 1.17;
78
+ const levelFontSizeEM = {
79
+ 1: 2,
80
+ 2: 1.5,
81
+ 3: 1.17,
82
+ 4: 1,
83
+ 5: 0.83,
84
+ 6: 0.67,
85
+ }[block.props.level];
64
86
  return (
65
87
  <Text
88
+ key={"heading" + block.id}
66
89
  style={{
67
- fontSize: fontSizeEM * FONT_SIZE * PIXELS_PER_POINT,
90
+ fontSize: levelFontSizeEM * FONT_SIZE * PIXELS_PER_POINT,
68
91
  fontWeight: 700,
69
92
  }}
70
93
  >
@@ -75,6 +98,7 @@ export const pdfBlockMappingForDefaultSchema: BlockMapping<
75
98
  quote: (block, exporter) => {
76
99
  return (
77
100
  <Text
101
+ key={"quote" + block.id}
78
102
  style={{
79
103
  borderLeft: "#7D797A",
80
104
  color: "#7D797A",
@@ -92,7 +116,7 @@ export const pdfBlockMappingForDefaultSchema: BlockMapping<
92
116
 
93
117
  return (
94
118
  <Text
95
- key={`line_${index}`}
119
+ key={`line_${index}` + block.id}
96
120
  style={{
97
121
  marginLeft: indent * 9.5 * PIXELS_PER_POINT,
98
122
  }}
@@ -113,17 +137,18 @@ export const pdfBlockMappingForDefaultSchema: BlockMapping<
113
137
  fontSize: FONT_SIZE * PIXELS_PER_POINT,
114
138
  fontFamily: "GeistMono",
115
139
  }}
140
+ key={"codeBlock" + block.id}
116
141
  >
117
142
  {lines}
118
143
  </View>
119
144
  );
120
145
  },
121
146
  pageBreak: () => {
122
- return <View break />;
147
+ return <View break key={"pageBreak"} />;
123
148
  },
124
149
  audio: (block, exporter) => {
125
150
  return (
126
- <View wrap={false}>
151
+ <View wrap={false} key={"audio" + block.id}>
127
152
  {file(
128
153
  block.props,
129
154
  "Open audio file",
@@ -138,7 +163,7 @@ export const pdfBlockMappingForDefaultSchema: BlockMapping<
138
163
  },
139
164
  video: (block, exporter) => {
140
165
  return (
141
- <View wrap={false}>
166
+ <View wrap={false} key={"video" + block.id}>
142
167
  {file(
143
168
  block.props,
144
169
  "Open video file",
@@ -153,7 +178,7 @@ export const pdfBlockMappingForDefaultSchema: BlockMapping<
153
178
  },
154
179
  file: (block, exporter) => {
155
180
  return (
156
- <View wrap={false}>
181
+ <View wrap={false} key={"file" + block.id}>
157
182
  {file(
158
183
  block.props,
159
184
  "Open file",
@@ -168,7 +193,7 @@ export const pdfBlockMappingForDefaultSchema: BlockMapping<
168
193
  },
169
194
  image: async (block, t) => {
170
195
  return (
171
- <View wrap={false}>
196
+ <View wrap={false} key={"image" + block.id}>
172
197
  <Image
173
198
  src={await t.resolveFile(block.props.url)}
174
199
  style={{
@@ -182,7 +207,9 @@ export const pdfBlockMappingForDefaultSchema: BlockMapping<
182
207
  );
183
208
  },
184
209
  table: (block, t) => {
185
- return <Table data={block.content} transformer={t} />;
210
+ return (
211
+ <Table data={block.content} transformer={t} key={"table" + block.id} />
212
+ );
186
213
  },
187
214
  };
188
215
 
@@ -194,7 +221,7 @@ function file(
194
221
  ) {
195
222
  const PIXELS_PER_POINT = 0.75;
196
223
  return (
197
- <Link src={props.url}>
224
+ <Link src={props.url} key={"file" + props.url}>
198
225
  <View
199
226
  style={{
200
227
  display: "flex",
@@ -218,6 +245,7 @@ function caption(
218
245
  }
219
246
  return (
220
247
  <Text
248
+ key={"caption" + props.caption}
221
249
  style={{
222
250
  width: props.previewWidth
223
251
  ? props.previewWidth * PIXELS_PER_POINT
@@ -12,7 +12,7 @@ export const pdfInlineContentMappingForDefaultSchema: InlineContentMapping<
12
12
  > = {
13
13
  link: (ic, exporter) => {
14
14
  return (
15
- <Link href={ic.href}>
15
+ <Link href={ic.href} key={"link" + ic.href}>
16
16
  {ic.content.map((content) => exporter.transformStyledText(content))}
17
17
  </Link>
18
18
  );
@@ -10,6 +10,7 @@ import {
10
10
  StyleSchema,
11
11
  StyledText,
12
12
  } from "@blocknote/core";
13
+ import { Fragment } from "react";
13
14
  import {
14
15
  Document,
15
16
  Font,
@@ -117,7 +118,11 @@ export class PDFExporter<
117
118
  public transformStyledText(styledText: StyledText<S>) {
118
119
  const stylesArray = this.mapStyles(styledText.styles);
119
120
  const styles = Object.assign({}, ...stylesArray);
120
- return <Text style={styles}>{styledText.text}</Text>;
121
+ return (
122
+ <Text style={styles} key={styledText.text}>
123
+ {styledText.text}
124
+ </Text>
125
+ );
121
126
  }
122
127
 
123
128
  /**
@@ -150,7 +155,7 @@ export class PDFExporter<
150
155
 
151
156
  const style = this.blocknoteDefaultPropsToReactPDFStyle(b.props as any);
152
157
  ret.push(
153
- <>
158
+ <Fragment key={b.id}>
154
159
  <View
155
160
  style={{
156
161
  paddingVertical: 3 * PIXELS_PER_POINT,
@@ -166,11 +171,12 @@ export class PDFExporter<
166
171
  marginLeft: FONT_SIZE * 1.5 * PIXELS_PER_POINT,
167
172
  ...this.styles.blockChildren,
168
173
  }}
174
+ key={b.id + nestingLevel + "children"}
169
175
  >
170
176
  {children}
171
177
  </View>
172
178
  )}
173
- </>,
179
+ </Fragment>,
174
180
  );
175
181
  }
176
182
 
@@ -19,6 +19,19 @@ const styles = StyleSheet.create({
19
19
 
20
20
  export const BULLET_MARKER = "\u2022";
21
21
 
22
+ // https://fonts.google.com/icons?selected=Material+Symbols+Rounded:chevron_right:FILL@0;wght@700;GRAD@0;opsz@24&icon.query=chevron&icon.style=Rounded&icon.size=24&icon.color=%23e8eaed
23
+ export const CHEVRON_MARKER = (
24
+ <Svg
25
+ style={{ marginTop: 2 }}
26
+ height="12"
27
+ viewBox="0 -960 960 960"
28
+ width="12"
29
+ fill="undefined"
30
+ >
31
+ <Path d="M472-480 332-620q-18-18-18-44t18-44q18-18 44-18t44 18l183 183q9 9 14 21t5 24q0 12-5 24t-14 21L420-252q-18 18-44 18t-44-18q-18-18-18-44t18-44l140-140Z" />
32
+ </Svg>
33
+ );
34
+
22
35
  // https://fonts.google.com/icons?selected=Material+Symbols+Outlined:check_box_outline_blank:FILL@0;wght@400;GRAD@0;opsz@24&icon.size=24&icon.color=undefined
23
36
  export const CHECK_MARKER_UNCHECKED = (
24
37
  <Svg
@@ -1,5 +1,6 @@
1
1
  import { Style } from "../types.js";
2
2
  export declare const BULLET_MARKER = "\u2022";
3
+ export declare const CHEVRON_MARKER: import("react/jsx-runtime.js").JSX.Element;
3
4
  export declare const CHECK_MARKER_UNCHECKED: import("react/jsx-runtime.js").JSX.Element;
4
5
  export declare const CHECK_MARKER_CHECKED: import("react/jsx-runtime.js").JSX.Element;
5
6
  export declare const ListItem: ({ listMarker, children, style, }: {