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