@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.
- package/dist/blocknote-xl-pdf-exporter.cjs +2 -2
- package/dist/blocknote-xl-pdf-exporter.cjs.map +1 -1
- package/dist/blocknote-xl-pdf-exporter.js +156 -124
- package/dist/blocknote-xl-pdf-exporter.js.map +1 -1
- package/dist/webpack-stats.json +1 -1
- package/package.json +3 -3
- package/src/pdf/__snapshots__/example.jsx +31 -31
- package/src/pdf/__snapshots__/exampleWithHeaderAndFooter.jsx +31 -31
- package/src/pdf/defaultSchema/blocks.tsx +42 -14
- package/src/pdf/defaultSchema/inlinecontent.tsx +1 -1
- package/src/pdf/pdfExporter.tsx +9 -3
- package/src/pdf/util/listItem.tsx +13 -0
- package/types/src/pdf/util/listItem.d.ts +1 -0
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { jsx as n, jsxs as f, Fragment as
|
|
5
|
-
import { View as l, StyleSheet as
|
|
6
|
-
import { mapTableCell as
|
|
7
|
-
|
|
1
|
+
var R = Object.defineProperty;
|
|
2
|
+
var P = (t, r, e) => r in t ? R(t, r, { enumerable: !0, configurable: !0, writable: !0, value: e }) : t[r] = e;
|
|
3
|
+
var w = (t, r, e) => P(t, typeof r != "symbol" ? r + "" : r, e);
|
|
4
|
+
import { jsx as n, jsxs as f, Fragment as F } from "react/jsx-runtime";
|
|
5
|
+
import { View as l, StyleSheet as v, Text as d, Svg as m, Path as g, Image as _, Link as V, Font as p, Document as D, Page as Z } from "@react-pdf/renderer";
|
|
6
|
+
import { mapTableCell as k, Exporter as B, COLORS_DEFAULT as A } from "@blocknote/core";
|
|
7
|
+
import { Fragment as q } from "react";
|
|
8
|
+
const O = 0.75, L = v.create({
|
|
8
9
|
listItem: {
|
|
9
10
|
display: "flex",
|
|
10
11
|
flexDirection: "row",
|
|
@@ -23,7 +24,7 @@ const O = 0.75, T = M.create({
|
|
|
23
24
|
viewBox: "0 -960 960 960",
|
|
24
25
|
width: "12",
|
|
25
26
|
fill: "undefined",
|
|
26
|
-
children: /* @__PURE__ */ n(
|
|
27
|
+
children: /* @__PURE__ */ n(g, { 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" })
|
|
27
28
|
}
|
|
28
29
|
), z = /* @__PURE__ */ n(
|
|
29
30
|
m,
|
|
@@ -33,16 +34,26 @@ const O = 0.75, T = M.create({
|
|
|
33
34
|
viewBox: "0 -960 960 960",
|
|
34
35
|
width: "12",
|
|
35
36
|
fill: "undefined",
|
|
36
|
-
children: /* @__PURE__ */ n(
|
|
37
|
+
children: /* @__PURE__ */ n(g, { d: "M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Zm0-80h560v-560H200v560Z" })
|
|
37
38
|
}
|
|
38
|
-
),
|
|
39
|
+
), N = /* @__PURE__ */ n(
|
|
40
|
+
m,
|
|
41
|
+
{
|
|
42
|
+
style: { marginTop: 2 },
|
|
43
|
+
height: "12",
|
|
44
|
+
viewBox: "0 -960 960 960",
|
|
45
|
+
width: "12",
|
|
46
|
+
fill: "undefined",
|
|
47
|
+
children: /* @__PURE__ */ n(g, { d: "m424-312 282-282-56-56-226 226-114-114-56 56 170 170ZM200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Zm0-80h560v-560H200v560Zm0-560v560-560Z" })
|
|
48
|
+
}
|
|
49
|
+
), x = ({
|
|
39
50
|
listMarker: t,
|
|
40
51
|
children: r,
|
|
41
52
|
style: e
|
|
42
|
-
}) => /* @__PURE__ */ f(l, { style: [
|
|
43
|
-
/* @__PURE__ */ n(l, { style:
|
|
53
|
+
}) => /* @__PURE__ */ f(l, { style: [L.listItem, e || {}], children: [
|
|
54
|
+
/* @__PURE__ */ n(l, { style: L.bullet, children: typeof t == "string" ? /* @__PURE__ */ n(d, { children: t }) : t }),
|
|
44
55
|
r
|
|
45
|
-
] }), E = 0.75, u =
|
|
56
|
+
] }), E = 0.75, u = v.create({
|
|
46
57
|
tableContainer: {
|
|
47
58
|
// width: "100%",
|
|
48
59
|
},
|
|
@@ -71,63 +82,80 @@ const O = 0.75, T = M.create({
|
|
|
71
82
|
rightCell: {
|
|
72
83
|
borderRight: "1px solid #ddd"
|
|
73
84
|
}
|
|
74
|
-
}),
|
|
85
|
+
}), K = (t) => {
|
|
75
86
|
const r = new Array(t.data.headerRows ?? 0).fill(!0), e = new Array(t.data.headerCols ?? 0).fill(!0);
|
|
76
|
-
return /* @__PURE__ */ n(l, { style: u.tableContainer, wrap: !1, children: t.data.rows.map((
|
|
87
|
+
return /* @__PURE__ */ n(l, { style: u.tableContainer, wrap: !1, children: t.data.rows.map((i, a) => /* @__PURE__ */ n(
|
|
77
88
|
l,
|
|
78
89
|
{
|
|
79
90
|
style: [
|
|
80
91
|
u.row,
|
|
81
|
-
|
|
92
|
+
a === t.data.rows.length - 1 ? u.bottomCell : {}
|
|
82
93
|
],
|
|
83
|
-
children:
|
|
84
|
-
const
|
|
94
|
+
children: i.cells.map((c, o) => {
|
|
95
|
+
const s = k(c), y = r[a], I = e[o];
|
|
85
96
|
return /* @__PURE__ */ n(
|
|
86
97
|
l,
|
|
87
98
|
{
|
|
88
99
|
style: [
|
|
89
100
|
u.cell,
|
|
90
|
-
y ||
|
|
91
|
-
|
|
92
|
-
t.data.columnWidths[
|
|
101
|
+
y || I ? u.headerCell : {},
|
|
102
|
+
o === i.cells.length - 1 ? u.rightCell : {},
|
|
103
|
+
t.data.columnWidths[o] ? { width: t.data.columnWidths[o] } : { flex: 1 },
|
|
93
104
|
{
|
|
94
|
-
color:
|
|
95
|
-
backgroundColor:
|
|
96
|
-
textAlign:
|
|
105
|
+
color: s.props.textColor === "default" ? void 0 : t.transformer.options.colors[s.props.textColor].text,
|
|
106
|
+
backgroundColor: s.props.backgroundColor === "default" ? void 0 : t.transformer.options.colors[s.props.backgroundColor].background,
|
|
107
|
+
textAlign: s.props.textAlignment
|
|
97
108
|
}
|
|
98
109
|
],
|
|
99
|
-
children: t.transformer.transformInlineContent(
|
|
110
|
+
children: t.transformer.transformInlineContent(s.content)
|
|
100
111
|
},
|
|
101
|
-
|
|
112
|
+
o
|
|
102
113
|
);
|
|
103
114
|
})
|
|
104
115
|
},
|
|
105
|
-
|
|
116
|
+
a
|
|
106
117
|
)) });
|
|
107
|
-
}, h = 0.75,
|
|
108
|
-
paragraph: (t, r) => /* @__PURE__ */ n(d, { children: r.transformInlineContent(t.content) }),
|
|
109
|
-
|
|
110
|
-
|
|
118
|
+
}, h = 0.75, b = 16, U = {
|
|
119
|
+
paragraph: (t, r) => /* @__PURE__ */ n(d, { children: r.transformInlineContent(t.content) }, "paragraph" + t.id),
|
|
120
|
+
toggleListItem: (t, r) => /* @__PURE__ */ n(x, { listMarker: j, children: /* @__PURE__ */ n(d, { children: r.transformInlineContent(t.content) }) }),
|
|
121
|
+
bulletListItem: (t, r) => /* @__PURE__ */ n(x, { listMarker: W, children: /* @__PURE__ */ n(d, { children: r.transformInlineContent(t.content) }) }, "bulletListItem" + t.id),
|
|
122
|
+
numberedListItem: (t, r, e, i) => /* @__PURE__ */ n(
|
|
123
|
+
x,
|
|
124
|
+
{
|
|
125
|
+
listMarker: `${i}.`,
|
|
126
|
+
children: /* @__PURE__ */ n(d, { children: r.transformInlineContent(t.content) })
|
|
127
|
+
},
|
|
128
|
+
"numberedListItem" + t.id
|
|
129
|
+
),
|
|
111
130
|
// would be nice to have pdf checkboxes:
|
|
112
131
|
// https://github.com/diegomura/react-pdf/issues/2103
|
|
113
132
|
checkListItem: (t, r) => /* @__PURE__ */ n(
|
|
114
|
-
|
|
133
|
+
x,
|
|
115
134
|
{
|
|
116
|
-
listMarker: t.props.checked ?
|
|
135
|
+
listMarker: t.props.checked ? N : z,
|
|
117
136
|
children: /* @__PURE__ */ n(d, { children: r.transformInlineContent(t.content) })
|
|
118
|
-
}
|
|
137
|
+
},
|
|
138
|
+
"checkListItem" + t.id
|
|
119
139
|
),
|
|
120
140
|
heading: (t, r) => {
|
|
121
|
-
const e =
|
|
141
|
+
const e = {
|
|
142
|
+
1: 2,
|
|
143
|
+
2: 1.5,
|
|
144
|
+
3: 1.17,
|
|
145
|
+
4: 1,
|
|
146
|
+
5: 0.83,
|
|
147
|
+
6: 0.67
|
|
148
|
+
}[t.props.level];
|
|
122
149
|
return /* @__PURE__ */ n(
|
|
123
150
|
d,
|
|
124
151
|
{
|
|
125
152
|
style: {
|
|
126
|
-
fontSize: e *
|
|
153
|
+
fontSize: e * b * h,
|
|
127
154
|
fontWeight: 700
|
|
128
155
|
},
|
|
129
156
|
children: r.transformInlineContent(t.content)
|
|
130
|
-
}
|
|
157
|
+
},
|
|
158
|
+
"heading" + t.id
|
|
131
159
|
);
|
|
132
160
|
},
|
|
133
161
|
quote: (t, r) => /* @__PURE__ */ n(
|
|
@@ -139,23 +167,24 @@ const O = 0.75, T = M.create({
|
|
|
139
167
|
paddingLeft: 9.5 * h
|
|
140
168
|
},
|
|
141
169
|
children: r.transformInlineContent(t.content)
|
|
142
|
-
}
|
|
170
|
+
},
|
|
171
|
+
"quote" + t.id
|
|
143
172
|
),
|
|
144
173
|
codeBlock: (t) => {
|
|
145
|
-
var
|
|
146
|
-
const e = (((
|
|
147
|
-
`).map((
|
|
148
|
-
var
|
|
149
|
-
const
|
|
174
|
+
var i;
|
|
175
|
+
const e = (((i = t.content[0]) == null ? void 0 : i.text) || "").split(`
|
|
176
|
+
`).map((a, c) => {
|
|
177
|
+
var s;
|
|
178
|
+
const o = ((s = a.match(/^\s*/)) == null ? void 0 : s[0].length) || 0;
|
|
150
179
|
return /* @__PURE__ */ n(
|
|
151
180
|
d,
|
|
152
181
|
{
|
|
153
182
|
style: {
|
|
154
|
-
marginLeft:
|
|
183
|
+
marginLeft: o * 9.5 * h
|
|
155
184
|
},
|
|
156
|
-
children:
|
|
185
|
+
children: a.trimStart() || /* @__PURE__ */ n(F, { children: " " })
|
|
157
186
|
},
|
|
158
|
-
`line_${c}`
|
|
187
|
+
`line_${c}` + t.id
|
|
159
188
|
);
|
|
160
189
|
});
|
|
161
190
|
return /* @__PURE__ */ n(
|
|
@@ -167,41 +196,42 @@ const O = 0.75, T = M.create({
|
|
|
167
196
|
backgroundColor: "#161616",
|
|
168
197
|
color: "#ffffff",
|
|
169
198
|
lineHeight: 1.25,
|
|
170
|
-
fontSize:
|
|
199
|
+
fontSize: b * h,
|
|
171
200
|
fontFamily: "GeistMono"
|
|
172
201
|
},
|
|
173
202
|
children: e
|
|
174
|
-
}
|
|
203
|
+
},
|
|
204
|
+
"codeBlock" + t.id
|
|
175
205
|
);
|
|
176
206
|
},
|
|
177
|
-
pageBreak: () => /* @__PURE__ */ n(l, { break: !0 }),
|
|
207
|
+
pageBreak: () => /* @__PURE__ */ n(l, { break: !0 }, "pageBreak"),
|
|
178
208
|
audio: (t, r) => /* @__PURE__ */ f(l, { wrap: !1, children: [
|
|
179
209
|
S(
|
|
180
210
|
t.props,
|
|
181
211
|
"Open audio file",
|
|
182
|
-
/* @__PURE__ */ n(m, { height: 14, width: 14, viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ n(
|
|
212
|
+
/* @__PURE__ */ n(m, { height: 14, width: 14, viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ n(g, { 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" }) })
|
|
183
213
|
),
|
|
184
|
-
|
|
185
|
-
] }),
|
|
214
|
+
H(t.props)
|
|
215
|
+
] }, "audio" + t.id),
|
|
186
216
|
video: (t, r) => /* @__PURE__ */ f(l, { wrap: !1, children: [
|
|
187
217
|
S(
|
|
188
218
|
t.props,
|
|
189
219
|
"Open video file",
|
|
190
|
-
/* @__PURE__ */ n(m, { height: 14, width: 14, viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ n(
|
|
220
|
+
/* @__PURE__ */ n(m, { height: 14, width: 14, viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ n(g, { 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" }) })
|
|
191
221
|
),
|
|
192
|
-
|
|
193
|
-
] }),
|
|
222
|
+
H(t.props)
|
|
223
|
+
] }, "video" + t.id),
|
|
194
224
|
file: (t, r) => /* @__PURE__ */ f(l, { wrap: !1, children: [
|
|
195
225
|
S(
|
|
196
226
|
t.props,
|
|
197
227
|
"Open file",
|
|
198
|
-
/* @__PURE__ */ n(m, { height: 16, width: 16, viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ n(
|
|
228
|
+
/* @__PURE__ */ n(m, { height: 16, width: 16, viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ n(g, { 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" }) })
|
|
199
229
|
),
|
|
200
|
-
|
|
201
|
-
] }),
|
|
230
|
+
H(t.props)
|
|
231
|
+
] }, "file" + t.id),
|
|
202
232
|
image: async (t, r) => /* @__PURE__ */ f(l, { wrap: !1, children: [
|
|
203
233
|
/* @__PURE__ */ n(
|
|
204
|
-
|
|
234
|
+
_,
|
|
205
235
|
{
|
|
206
236
|
src: await r.resolveFile(t.props.url),
|
|
207
237
|
style: {
|
|
@@ -209,12 +239,12 @@ const O = 0.75, T = M.create({
|
|
|
209
239
|
}
|
|
210
240
|
}
|
|
211
241
|
),
|
|
212
|
-
|
|
213
|
-
] }),
|
|
214
|
-
table: (t, r) => /* @__PURE__ */ n(
|
|
242
|
+
H(t.props)
|
|
243
|
+
] }, "image" + t.id),
|
|
244
|
+
table: (t, r) => /* @__PURE__ */ n(K, { data: t.content, transformer: r }, "table" + t.id)
|
|
215
245
|
};
|
|
216
|
-
function S(t, r, e,
|
|
217
|
-
return /* @__PURE__ */ n(
|
|
246
|
+
function S(t, r, e, i) {
|
|
247
|
+
return /* @__PURE__ */ n(V, { src: t.url, children: /* @__PURE__ */ f(
|
|
218
248
|
l,
|
|
219
249
|
{
|
|
220
250
|
style: {
|
|
@@ -227,25 +257,26 @@ function S(t, r, e, o) {
|
|
|
227
257
|
/* @__PURE__ */ n(d, { children: t.name || r })
|
|
228
258
|
]
|
|
229
259
|
}
|
|
230
|
-
) });
|
|
260
|
+
) }, "file" + t.url);
|
|
231
261
|
}
|
|
232
|
-
function
|
|
262
|
+
function H(t, r) {
|
|
233
263
|
if (t.caption)
|
|
234
264
|
return /* @__PURE__ */ n(
|
|
235
265
|
d,
|
|
236
266
|
{
|
|
237
267
|
style: {
|
|
238
268
|
width: t.previewWidth ? t.previewWidth * h : void 0,
|
|
239
|
-
fontSize:
|
|
269
|
+
fontSize: b * 0.8 * h
|
|
240
270
|
},
|
|
241
271
|
children: t.caption
|
|
242
|
-
}
|
|
272
|
+
},
|
|
273
|
+
"caption" + t.caption
|
|
243
274
|
);
|
|
244
275
|
}
|
|
245
|
-
const
|
|
246
|
-
link: (t, r) => /* @__PURE__ */ n(
|
|
276
|
+
const $ = {
|
|
277
|
+
link: (t, r) => /* @__PURE__ */ n(V, { href: t.href, children: t.content.map((e) => r.transformStyledText(e)) }, "link" + t.href),
|
|
247
278
|
text: (t, r) => r.transformStyledText(t)
|
|
248
|
-
},
|
|
279
|
+
}, X = {
|
|
249
280
|
bold: (t) => t ? {
|
|
250
281
|
fontWeight: "bold"
|
|
251
282
|
} : {},
|
|
@@ -268,43 +299,43 @@ const U = {
|
|
|
268
299
|
code: (t) => t ? {
|
|
269
300
|
fontFamily: "GeistMono"
|
|
270
301
|
} : {}
|
|
271
|
-
},
|
|
272
|
-
blockMapping:
|
|
273
|
-
inlineContentMapping:
|
|
274
|
-
styleMapping:
|
|
302
|
+
}, nt = {
|
|
303
|
+
blockMapping: U,
|
|
304
|
+
inlineContentMapping: $,
|
|
305
|
+
styleMapping: X
|
|
275
306
|
};
|
|
276
|
-
async function
|
|
307
|
+
async function G(t) {
|
|
277
308
|
return "https://corsproxy.api.blocknotejs.org/corsproxy/?url=" + encodeURIComponent(t);
|
|
278
309
|
}
|
|
279
|
-
async function
|
|
310
|
+
async function J(t, r) {
|
|
280
311
|
return t.default;
|
|
281
312
|
}
|
|
282
|
-
async function
|
|
283
|
-
return
|
|
313
|
+
async function C(t) {
|
|
314
|
+
return J(t);
|
|
284
315
|
}
|
|
285
|
-
const
|
|
286
|
-
class
|
|
287
|
-
constructor(e,
|
|
288
|
-
const
|
|
316
|
+
const T = 16, M = 0.75;
|
|
317
|
+
class it extends B {
|
|
318
|
+
constructor(e, i, a) {
|
|
319
|
+
const o = {
|
|
289
320
|
...{
|
|
290
321
|
emojiSource: {
|
|
291
322
|
format: "png",
|
|
292
323
|
url: "https://cdnjs.cloudflare.com/ajax/libs/twemoji/14.0.2/72x72/"
|
|
293
324
|
},
|
|
294
|
-
resolveFileUrl:
|
|
325
|
+
resolveFileUrl: G,
|
|
295
326
|
colors: A
|
|
296
327
|
},
|
|
297
|
-
...
|
|
328
|
+
...a
|
|
298
329
|
};
|
|
299
|
-
super(e,
|
|
300
|
-
|
|
301
|
-
|
|
330
|
+
super(e, i, o);
|
|
331
|
+
w(this, "fontsRegistered", !1);
|
|
332
|
+
w(this, "styles", v.create({
|
|
302
333
|
page: {
|
|
303
334
|
paddingTop: 35,
|
|
304
335
|
paddingBottom: 65,
|
|
305
336
|
paddingHorizontal: 35,
|
|
306
337
|
fontFamily: "Inter",
|
|
307
|
-
fontSize:
|
|
338
|
+
fontSize: T * M,
|
|
308
339
|
// pixels
|
|
309
340
|
lineHeight: 1.5
|
|
310
341
|
},
|
|
@@ -315,92 +346,93 @@ class et extends B {
|
|
|
315
346
|
position: "absolute"
|
|
316
347
|
}
|
|
317
348
|
}));
|
|
318
|
-
|
|
319
|
-
this.schema = e, this.options =
|
|
349
|
+
w(this, "options");
|
|
350
|
+
this.schema = e, this.options = o;
|
|
320
351
|
}
|
|
321
352
|
/**
|
|
322
353
|
* Mostly for internal use, you probably want to use `toBlob` or `toReactPDFDocument` instead.
|
|
323
354
|
*/
|
|
324
355
|
transformStyledText(e) {
|
|
325
|
-
const
|
|
326
|
-
return /* @__PURE__ */ n(d, { style:
|
|
356
|
+
const i = this.mapStyles(e.styles), a = Object.assign({}, ...i);
|
|
357
|
+
return /* @__PURE__ */ n(d, { style: a, children: e.text }, e.text);
|
|
327
358
|
}
|
|
328
359
|
/**
|
|
329
360
|
* Mostly for internal use, you probably want to use `toBlob` or `toReactPDFDocument` instead.
|
|
330
361
|
*/
|
|
331
|
-
async transformBlocks(e,
|
|
332
|
-
const
|
|
362
|
+
async transformBlocks(e, i = 0) {
|
|
363
|
+
const a = [];
|
|
333
364
|
let c = 0;
|
|
334
|
-
for (const
|
|
335
|
-
|
|
336
|
-
const
|
|
337
|
-
i,
|
|
365
|
+
for (const o of e) {
|
|
366
|
+
o.type === "numberedListItem" ? c++ : c = 0;
|
|
367
|
+
const s = await this.transformBlocks(o.children, i + 1), y = await this.mapBlock(
|
|
338
368
|
o,
|
|
369
|
+
i,
|
|
339
370
|
c
|
|
340
371
|
);
|
|
341
|
-
if (
|
|
342
|
-
|
|
372
|
+
if (o.type === "pageBreak") {
|
|
373
|
+
a.push(y);
|
|
343
374
|
continue;
|
|
344
375
|
}
|
|
345
|
-
const
|
|
346
|
-
|
|
347
|
-
/* @__PURE__ */ f(
|
|
376
|
+
const I = this.blocknoteDefaultPropsToReactPDFStyle(o.props);
|
|
377
|
+
a.push(
|
|
378
|
+
/* @__PURE__ */ f(q, { children: [
|
|
348
379
|
/* @__PURE__ */ n(
|
|
349
380
|
l,
|
|
350
381
|
{
|
|
351
382
|
style: {
|
|
352
|
-
paddingVertical: 3 *
|
|
383
|
+
paddingVertical: 3 * M,
|
|
353
384
|
...this.styles.block,
|
|
354
|
-
...
|
|
385
|
+
...I
|
|
355
386
|
},
|
|
356
387
|
children: y
|
|
357
388
|
}
|
|
358
389
|
),
|
|
359
|
-
|
|
390
|
+
s.length > 0 && /* @__PURE__ */ n(
|
|
360
391
|
l,
|
|
361
392
|
{
|
|
362
393
|
style: {
|
|
363
|
-
marginLeft:
|
|
394
|
+
marginLeft: T * 1.5 * M,
|
|
364
395
|
...this.styles.blockChildren
|
|
365
396
|
},
|
|
366
|
-
children:
|
|
367
|
-
}
|
|
397
|
+
children: s
|
|
398
|
+
},
|
|
399
|
+
o.id + i + "children"
|
|
368
400
|
)
|
|
369
|
-
] })
|
|
401
|
+
] }, o.id)
|
|
370
402
|
);
|
|
371
403
|
}
|
|
372
|
-
return
|
|
404
|
+
return a;
|
|
373
405
|
}
|
|
374
406
|
async registerFonts() {
|
|
375
407
|
if (this.fontsRegistered)
|
|
376
408
|
return;
|
|
377
409
|
this.options.emojiSource && p.registerEmojiSource(this.options.emojiSource);
|
|
378
|
-
let e = await
|
|
410
|
+
let e = await C(
|
|
379
411
|
await import("./Inter_18pt-Regular-byxnNS-8.js")
|
|
380
412
|
);
|
|
381
413
|
p.register({
|
|
382
414
|
family: "Inter",
|
|
383
415
|
src: e
|
|
384
|
-
}), e = await
|
|
416
|
+
}), e = await C(
|
|
385
417
|
await import("./Inter_18pt-Italic-BVnfHlUD.js")
|
|
386
418
|
), p.register({
|
|
387
419
|
family: "Inter",
|
|
388
420
|
fontStyle: "italic",
|
|
389
421
|
src: e
|
|
390
|
-
}), e = await
|
|
422
|
+
}), e = await C(
|
|
391
423
|
await import("./Inter_18pt-Bold-BOnnSImi.js")
|
|
392
424
|
), p.register({
|
|
393
425
|
family: "Inter",
|
|
394
426
|
src: e,
|
|
395
427
|
fontWeight: "bold"
|
|
396
|
-
}), e = await
|
|
428
|
+
}), e = await C(
|
|
397
429
|
await import("./Inter_18pt-BoldItalic-DPKIpVzB.js")
|
|
398
430
|
), p.register({
|
|
399
431
|
family: "Inter",
|
|
400
432
|
fontStyle: "italic",
|
|
401
433
|
src: e,
|
|
402
434
|
fontWeight: "bold"
|
|
403
|
-
}), e = await
|
|
435
|
+
}), e = await C(
|
|
404
436
|
await import("./GeistMono-Regular-D4rKXxwr.js")
|
|
405
437
|
), p.register({
|
|
406
438
|
family: "GeistMono",
|
|
@@ -410,11 +442,11 @@ class et extends B {
|
|
|
410
442
|
/**
|
|
411
443
|
* Convert a document (array of Blocks) to a react-pdf Document.
|
|
412
444
|
*/
|
|
413
|
-
async toReactPDFDocument(e,
|
|
414
|
-
return await this.registerFonts(), /* @__PURE__ */ n(
|
|
415
|
-
|
|
445
|
+
async toReactPDFDocument(e, i = {}) {
|
|
446
|
+
return await this.registerFonts(), /* @__PURE__ */ n(D, { children: /* @__PURE__ */ f(Z, { dpi: 100, size: "A4", style: this.styles.page, children: [
|
|
447
|
+
i.header && /* @__PURE__ */ n(l, { fixed: !0, style: this.styles.header, children: i.header }),
|
|
416
448
|
await this.transformBlocks(e),
|
|
417
|
-
|
|
449
|
+
i.footer && /* @__PURE__ */ n(
|
|
418
450
|
l,
|
|
419
451
|
{
|
|
420
452
|
fixed: !0,
|
|
@@ -426,7 +458,7 @@ class et extends B {
|
|
|
426
458
|
},
|
|
427
459
|
this.styles.footer
|
|
428
460
|
],
|
|
429
|
-
children:
|
|
461
|
+
children: i.footer
|
|
430
462
|
}
|
|
431
463
|
)
|
|
432
464
|
] }) });
|
|
@@ -441,7 +473,7 @@ class et extends B {
|
|
|
441
473
|
}
|
|
442
474
|
}
|
|
443
475
|
export {
|
|
444
|
-
|
|
445
|
-
|
|
476
|
+
it as PDFExporter,
|
|
477
|
+
nt as pdfDefaultSchemaMappings
|
|
446
478
|
};
|
|
447
479
|
//# sourceMappingURL=blocknote-xl-pdf-exporter.js.map
|