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