@blocknote/xl-docx-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 (33) hide show
  1. package/dist/GeistMono-Regular-CHVKamKz.cjs +2 -0
  2. package/dist/GeistMono-Regular-CHVKamKz.cjs.map +1 -0
  3. package/dist/GeistMono-Regular-DC6WVheu.js +6 -0
  4. package/dist/GeistMono-Regular-DC6WVheu.js.map +1 -0
  5. package/dist/Inter_18pt-Regular-DVodnrPc.js +6 -0
  6. package/dist/Inter_18pt-Regular-DVodnrPc.js.map +1 -0
  7. package/dist/Inter_18pt-Regular-PkBfh_8C.cjs +2 -0
  8. package/dist/Inter_18pt-Regular-PkBfh_8C.cjs.map +1 -0
  9. package/dist/blocknote-xl-docx-exporter.cjs +3 -3
  10. package/dist/blocknote-xl-docx-exporter.cjs.map +1 -1
  11. package/dist/blocknote-xl-docx-exporter.js +354 -495
  12. package/dist/blocknote-xl-docx-exporter.js.map +1 -1
  13. package/dist/styles-C7Ws_DIi.js +6 -0
  14. package/dist/styles-C7Ws_DIi.js.map +1 -0
  15. package/dist/{styles-Bw_Yt1z6.js → styles-Cz94-HtD.cjs} +3 -6
  16. package/dist/styles-Cz94-HtD.cjs.map +1 -0
  17. package/dist/webpack-stats.json +1 -1
  18. package/package.json +6 -6
  19. package/dist/GeistMono-Regular--NrcstcO.cjs +0 -2
  20. package/dist/GeistMono-Regular--NrcstcO.cjs.map +0 -1
  21. package/dist/GeistMono-Regular-D4rKXxwr.js +0 -5
  22. package/dist/GeistMono-Regular-D4rKXxwr.js.map +0 -1
  23. package/dist/Inter_18pt-Regular-CCMUw8TC.cjs +0 -2
  24. package/dist/Inter_18pt-Regular-CCMUw8TC.cjs.map +0 -1
  25. package/dist/Inter_18pt-Regular-byxnNS-8.js +0 -5
  26. package/dist/Inter_18pt-Regular-byxnNS-8.js.map +0 -1
  27. package/dist/index-B-FmPo2r.cjs +0 -7
  28. package/dist/index-B-FmPo2r.cjs.map +0 -1
  29. package/dist/index-cA_PmnZy.js +0 -1040
  30. package/dist/index-cA_PmnZy.js.map +0 -1
  31. package/dist/styles-BRTtNJM0.cjs +0 -1016
  32. package/dist/styles-BRTtNJM0.cjs.map +0 -1
  33. package/dist/styles-Bw_Yt1z6.js.map +0 -1
@@ -1,505 +1,364 @@
1
- import { mapTableCell as O, UnreachableCaseError as L, Exporter as S, COLORS_DEFAULT as _ } from "@blocknote/core";
2
- import { Table as I, TableRow as D, TableCell as y, Paragraph as a, ShadingType as x, ImageRun as E, PageBreak as M, TextRun as p, CheckBox as U, ExternalHyperlink as k, Tab as R, AlignmentType as B, LevelFormat as T, Packer as H, Document as $ } from "docx";
3
- async function W(e) {
4
- if (typeof window < "u") {
5
- const t = await createImageBitmap(e), { width: n, height: r } = t;
6
- return t.close(), { width: n, height: r };
7
- } else {
8
- const t = (await import("image-meta")).imageMeta, n = new Uint8Array(await e.arrayBuffer()), r = t(n);
9
- if (!r.width || !r.height)
10
- throw new Error("Image dimensions not found");
11
- return { width: r.width, height: r.height };
12
- }
1
+ import { COLORS_DEFAULT as e, Exporter as t, UnreachableCaseError as n, mapTableCell as r } from "@blocknote/core";
2
+ import { AlignmentType as i, CheckBox as a, Document as o, ExternalHyperlink as s, ImageRun as c, LevelFormat as l, Packer as u, PageBreak as d, Paragraph as f, ShadingType as p, Tab as m, Table as h, TableCell as g, TableRow as _, TextRun as v } from "docx";
3
+ //#region ../../shared/util/imageUtil.ts
4
+ async function y(e) {
5
+ if (typeof window < "u") {
6
+ let t = await createImageBitmap(e), { width: n, height: r } = t;
7
+ return t.close(), {
8
+ width: n,
9
+ height: r
10
+ };
11
+ } else {
12
+ let t = (await import("image-meta")).imageMeta, n = t(new Uint8Array(await e.arrayBuffer()));
13
+ if (!n.width || !n.height) throw Error("Image dimensions not found");
14
+ return {
15
+ width: n.width,
16
+ height: n.height
17
+ };
18
+ }
13
19
  }
14
- const z = (e, t) => {
15
- const r = new Array(e.headerRows ?? 0).fill(!0), o = new Array(e.headerCols ?? 0).fill(!0);
16
- return new I({
17
- layout: "autofit",
18
- columnWidths: e.columnWidths.map(
19
- (i) => (i ?? 120) * /* to points */
20
- 0.75 * /* to twips */
21
- 20
22
- ),
23
- rows: e.rows.map((i, s) => {
24
- const u = r[s];
25
- return new D({
26
- tableHeader: u,
27
- children: i.cells.map((d, b) => {
28
- var A;
29
- const C = (A = e.columnWidths) == null ? void 0 : A[b], l = O(d), F = o[b];
30
- return new y({
31
- width: C ? {
32
- // The type is twentieths of a point (dxa)
33
- size: C * 0.75 * 20,
34
- type: "dxa"
35
- } : void 0,
36
- columnSpan: l.props.colspan,
37
- rowSpan: l.props.rowspan,
38
- shading: l.props.backgroundColor === "default" || !l.props.backgroundColor ? void 0 : {
39
- type: x.SOLID,
40
- color: (() => {
41
- var m;
42
- const f = (m = t.options.colors[l.props.backgroundColor]) == null ? void 0 : m.background;
43
- if (f)
44
- return f.slice(1);
45
- })()
46
- },
47
- children: [
48
- new a({
49
- children: t.transformInlineContent(l.content),
50
- alignment: !l.props.textAlignment || l.props.textAlignment === "left" ? void 0 : l.props.textAlignment === "center" ? "center" : l.props.textAlignment === "right" ? "right" : l.props.textAlignment === "justify" ? "distribute" : (() => {
51
- throw new L(
52
- l.props.textAlignment
53
- );
54
- })(),
55
- run: {
56
- // TODO add support for table headers exporting, bolding seems to not be working at the moment
57
- bold: u || F,
58
- // TODO table paragraph color seems to not be working at the moment
59
- // Probably because the runs are setting their own color
60
- color: l.props.textColor === "default" || !l.props.textColor ? void 0 : (() => {
61
- var m;
62
- const f = (m = t.options.colors[l.props.textColor]) == null ? void 0 : m.text;
63
- if (f)
64
- return f.slice(1);
65
- })()
66
- }
67
- })
68
- ]
69
- });
70
- })
71
- });
72
- })
73
- });
20
+ //#endregion
21
+ //#region src/docx/util/Table.tsx
22
+ var b = (e, t) => {
23
+ let i = Array(e.headerRows ?? 0).fill(!0), a = Array(e.headerCols ?? 0).fill(!0);
24
+ return new h({
25
+ layout: "autofit",
26
+ columnWidths: e.columnWidths.map((e) => (e ?? 120) * .75 * 20),
27
+ rows: e.rows.map((o, s) => {
28
+ let c = i[s];
29
+ return new _({
30
+ tableHeader: c,
31
+ children: o.cells.map((i, o) => {
32
+ let s = e.columnWidths?.[o], l = r(i), u = a[o];
33
+ return new g({
34
+ width: s ? {
35
+ size: s * .75 * 20,
36
+ type: "dxa"
37
+ } : void 0,
38
+ columnSpan: l.props.colspan,
39
+ rowSpan: l.props.rowspan,
40
+ shading: l.props.backgroundColor === "default" || !l.props.backgroundColor ? void 0 : {
41
+ type: p.SOLID,
42
+ color: (() => {
43
+ let e = t.options.colors[l.props.backgroundColor]?.background;
44
+ if (e) return e.slice(1);
45
+ })()
46
+ },
47
+ children: [new f({
48
+ children: t.transformInlineContent(l.content),
49
+ alignment: !l.props.textAlignment || l.props.textAlignment === "left" ? void 0 : l.props.textAlignment === "center" ? "center" : l.props.textAlignment === "right" ? "right" : l.props.textAlignment === "justify" ? "distribute" : (() => {
50
+ throw new n(l.props.textAlignment);
51
+ })(),
52
+ run: {
53
+ bold: c || u,
54
+ color: l.props.textColor === "default" || !l.props.textColor ? void 0 : (() => {
55
+ let e = t.options.colors[l.props.textColor]?.text;
56
+ if (e) return e.slice(1);
57
+ })()
58
+ }
59
+ })]
60
+ });
61
+ })
62
+ });
63
+ })
64
+ });
74
65
  };
75
- function c(e, t) {
76
- return {
77
- shading: e.backgroundColor === "default" || !e.backgroundColor ? void 0 : {
78
- type: x.CLEAR,
79
- fill: (() => {
80
- var r;
81
- const n = (r = t[e.backgroundColor]) == null ? void 0 : r.background;
82
- if (n)
83
- return n.slice(1);
84
- })()
85
- },
86
- run: e.textColor === "default" || !e.textColor ? void 0 : {
87
- color: (() => {
88
- var r;
89
- const n = (r = t[e.textColor]) == null ? void 0 : r.text;
90
- if (n)
91
- return n.slice(1);
92
- })()
93
- },
94
- alignment: !e.textAlignment || e.textAlignment === "left" ? void 0 : e.textAlignment === "center" ? "center" : e.textAlignment === "right" ? "right" : e.textAlignment === "justify" ? "distribute" : (() => {
95
- throw new L(e.textAlignment);
96
- })()
97
- };
66
+ //#endregion
67
+ //#region src/docx/defaultSchema/blocks.ts
68
+ function x(e, t) {
69
+ return {
70
+ shading: e.backgroundColor === "default" || !e.backgroundColor ? void 0 : {
71
+ type: p.CLEAR,
72
+ fill: (() => {
73
+ let n = t[e.backgroundColor]?.background;
74
+ if (n) return n.slice(1);
75
+ })()
76
+ },
77
+ run: e.textColor === "default" || !e.textColor ? void 0 : { color: (() => {
78
+ let n = t[e.textColor]?.text;
79
+ if (n) return n.slice(1);
80
+ })() },
81
+ alignment: !e.textAlignment || e.textAlignment === "left" ? void 0 : e.textAlignment === "center" ? "center" : e.textAlignment === "right" ? "right" : e.textAlignment === "justify" ? "distribute" : (() => {
82
+ throw new n(e.textAlignment);
83
+ })()
84
+ };
98
85
  }
99
- const P = {
100
- paragraph: (e, t) => new a({
101
- ...c(e.props, t.options.colors),
102
- children: t.transformInlineContent(e.content)
103
- }),
104
- toggleListItem: (e, t) => new a({
105
- ...c(e.props, t.options.colors),
106
- children: [
107
- new p({
108
- children: ["> "]
109
- }),
110
- ...t.transformInlineContent(e.content)
111
- ]
112
- }),
113
- numberedListItem: (e, t, n) => new a({
114
- ...c(e.props, t.options.colors),
115
- children: t.transformInlineContent(e.content),
116
- numbering: {
117
- reference: "blocknote-numbered-list",
118
- level: n
119
- }
120
- }),
121
- bulletListItem: (e, t, n) => new a({
122
- ...c(e.props, t.options.colors),
123
- children: t.transformInlineContent(e.content),
124
- numbering: {
125
- reference: "blocknote-bullet-list",
126
- level: n
127
- }
128
- }),
129
- checkListItem: (e, t) => new a({
130
- ...c(e.props, t.options.colors),
131
- children: [
132
- new U({ checked: e.props.checked }),
133
- new p({
134
- children: [" "]
135
- }),
136
- ...t.transformInlineContent(e.content)
137
- ]
138
- }),
139
- heading: (e, t) => new a({
140
- ...c(e.props, t.options.colors),
141
- children: t.transformInlineContent(e.content),
142
- heading: `Heading${e.props.level}`
143
- }),
144
- quote: (e, t) => new a({
145
- style: "BlockQuote",
146
- ...c(e.props, t.options.colors),
147
- children: t.transformInlineContent(e.content)
148
- }),
149
- audio: (e, t) => [
150
- w(e.props, "Open audio", t),
151
- ...h(e.props, t)
152
- ],
153
- video: (e, t) => [
154
- w(e.props, "Open video", t),
155
- ...h(e.props, t)
156
- ],
157
- file: (e, t) => [
158
- w(e.props, "Open file", t),
159
- ...h(e.props, t)
160
- ],
161
- codeBlock: (e) => {
162
- var n;
163
- const t = ((n = e.content[0]) == null ? void 0 : n.text) || "";
164
- return new a({
165
- style: "SourceCode",
166
- children: [
167
- ...t.split(`
168
- `).map((r, o) => new p({
169
- text: r,
170
- break: o > 0 ? 1 : 0
171
- }))
172
- ]
173
- });
174
- },
175
- pageBreak: () => new a({
176
- children: [new M()]
177
- }),
178
- divider: () => new a({
179
- border: {
180
- top: {
181
- color: "auto",
182
- space: 1,
183
- style: "single",
184
- size: 1
185
- }
186
- }
187
- }),
188
- column: (e, t, n, r, o) => new y({
189
- width: {
190
- size: `${e.props.width * 100}%`,
191
- type: "pct"
192
- },
193
- children: (o || []).flatMap((i) => Array.isArray(i) ? i : [i])
194
- }),
195
- columnList: (e, t, n, r, o) => new I({
196
- layout: "autofit",
197
- borders: {
198
- bottom: { style: "nil" },
199
- top: { style: "nil" },
200
- left: { style: "nil" },
201
- right: { style: "nil" },
202
- insideHorizontal: { style: "nil" },
203
- insideVertical: { style: "nil" }
204
- },
205
- rows: [
206
- new D({
207
- children: o.map(
208
- (i, s, u) => {
209
- var d;
210
- return new y({
211
- width: {
212
- size: `${parseFloat(`${((d = i.options.width) == null ? void 0 : d.size) || "100%"}`) / (u.length * 100) * 100}%`,
213
- type: "pct"
214
- },
215
- children: i.options.children
216
- });
217
- }
218
- )
219
- })
220
- ]
221
- }),
222
- image: async (e, t) => {
223
- const n = await t.resolveFile(e.props.url), { width: r, height: o } = await W(n);
224
- return [
225
- new a({
226
- ...c(e.props, t.options.colors),
227
- children: [
228
- new E({
229
- data: await n.arrayBuffer(),
230
- // it would be nicer to set the actual data type here, but then we'd need to use a mime type / image type
231
- // detector. atm passing gif does not seem to be causing issues as the "type" is mainly used by docxjs internally
232
- // (i.e.: to make sure it's not svg)
233
- type: "gif",
234
- altText: e.props.caption ? {
235
- description: e.props.caption,
236
- name: e.props.caption,
237
- title: e.props.caption
238
- } : void 0,
239
- transformation: {
240
- width: e.props.previewWidth || r,
241
- height: (e.props.previewWidth || r) / r * o
242
- }
243
- })
244
- ]
245
- }),
246
- ...h(e.props, t)
247
- ];
248
- },
249
- table: (e, t) => z(e.content, t)
86
+ var S = {
87
+ paragraph: (e, t) => new f({
88
+ ...x(e.props, t.options.colors),
89
+ children: t.transformInlineContent(e.content)
90
+ }),
91
+ toggleListItem: (e, t) => new f({
92
+ ...x(e.props, t.options.colors),
93
+ children: [new v({ children: ["> "] }), ...t.transformInlineContent(e.content)]
94
+ }),
95
+ numberedListItem: (e, t, n) => new f({
96
+ ...x(e.props, t.options.colors),
97
+ children: t.transformInlineContent(e.content),
98
+ numbering: {
99
+ reference: "blocknote-numbered-list",
100
+ level: n
101
+ }
102
+ }),
103
+ bulletListItem: (e, t, n) => new f({
104
+ ...x(e.props, t.options.colors),
105
+ children: t.transformInlineContent(e.content),
106
+ numbering: {
107
+ reference: "blocknote-bullet-list",
108
+ level: n
109
+ }
110
+ }),
111
+ checkListItem: (e, t) => new f({
112
+ ...x(e.props, t.options.colors),
113
+ children: [
114
+ new a({ checked: e.props.checked }),
115
+ new v({ children: [" "] }),
116
+ ...t.transformInlineContent(e.content)
117
+ ]
118
+ }),
119
+ heading: (e, t) => new f({
120
+ ...x(e.props, t.options.colors),
121
+ children: t.transformInlineContent(e.content),
122
+ heading: `Heading${e.props.level}`
123
+ }),
124
+ quote: (e, t) => new f({
125
+ style: "BlockQuote",
126
+ ...x(e.props, t.options.colors),
127
+ children: t.transformInlineContent(e.content)
128
+ }),
129
+ audio: (e, t) => [C(e.props, "Open audio", t), ...w(e.props, t)],
130
+ video: (e, t) => [C(e.props, "Open video", t), ...w(e.props, t)],
131
+ file: (e, t) => [C(e.props, "Open file", t), ...w(e.props, t)],
132
+ codeBlock: (e) => new f({
133
+ style: "SourceCode",
134
+ children: [...(e.content[0]?.text || "").split("\n").map((e, t) => new v({
135
+ text: e,
136
+ break: t > 0 ? 1 : 0
137
+ }))]
138
+ }),
139
+ pageBreak: () => new f({ children: [new d()] }),
140
+ divider: () => new f({ border: { top: {
141
+ color: "auto",
142
+ space: 1,
143
+ style: "single",
144
+ size: 1
145
+ } } }),
146
+ column: (e, t, n, r, i) => new g({
147
+ width: {
148
+ size: `${e.props.width * 100}%`,
149
+ type: "pct"
150
+ },
151
+ children: (i || []).flatMap((e) => Array.isArray(e) ? e : [e])
152
+ }),
153
+ columnList: (e, t, n, r, i) => new h({
154
+ layout: "autofit",
155
+ borders: {
156
+ bottom: { style: "nil" },
157
+ top: { style: "nil" },
158
+ left: { style: "nil" },
159
+ right: { style: "nil" },
160
+ insideHorizontal: { style: "nil" },
161
+ insideVertical: { style: "nil" }
162
+ },
163
+ rows: [new _({ children: i.map((e, t, n) => new g({
164
+ width: {
165
+ size: `${parseFloat(`${e.options.width?.size || "100%"}`) / (n.length * 100) * 100}%`,
166
+ type: "pct"
167
+ },
168
+ children: e.options.children
169
+ })) })]
170
+ }),
171
+ image: async (e, t) => {
172
+ let n = await t.resolveFile(e.props.url), { width: r, height: i } = await y(n);
173
+ return [new f({
174
+ ...x(e.props, t.options.colors),
175
+ children: [new c({
176
+ data: await n.arrayBuffer(),
177
+ type: "gif",
178
+ altText: e.props.caption ? {
179
+ description: e.props.caption,
180
+ name: e.props.caption,
181
+ title: e.props.caption
182
+ } : void 0,
183
+ transformation: {
184
+ width: e.props.previewWidth || r,
185
+ height: (e.props.previewWidth || r) / r * i
186
+ }
187
+ })]
188
+ }), ...w(e.props, t)];
189
+ },
190
+ table: (e, t) => b(e.content, t)
250
191
  };
251
- function w(e, t, n) {
252
- return new a({
253
- ...c(e, n.options.colors),
254
- children: [
255
- new k({
256
- children: [
257
- new p({
258
- text: e.name || t,
259
- style: "Hyperlink"
260
- })
261
- ],
262
- link: e.url
263
- })
264
- ]
265
- });
192
+ function C(e, t, n) {
193
+ return new f({
194
+ ...x(e, n.options.colors),
195
+ children: [new s({
196
+ children: [new v({
197
+ text: e.name || t,
198
+ style: "Hyperlink"
199
+ })],
200
+ link: e.url
201
+ })]
202
+ });
266
203
  }
267
- function h(e, t) {
268
- return e.caption ? [
269
- new a({
270
- ...c(e, t.options.colors),
271
- children: [
272
- new p({
273
- text: e.caption
274
- })
275
- ],
276
- style: "Caption"
277
- })
278
- ] : [];
204
+ function w(e, t) {
205
+ return e.caption ? [new f({
206
+ ...x(e, t.options.colors),
207
+ children: [new v({ text: e.caption })],
208
+ style: "Caption"
209
+ })] : [];
279
210
  }
280
- const j = {
281
- link: (e, t) => new k({
282
- children: e.content.map((n) => t.transformStyledText(
283
- n,
284
- !0
285
- )),
286
- link: e.href
287
- }),
288
- text: (e, t) => t.transformStyledText(e)
289
- }, J = {
290
- bold: (e) => e ? {
291
- bold: e
292
- } : {},
293
- italic: (e) => e ? {
294
- italics: e
295
- } : {},
296
- underline: (e) => e ? {
297
- underline: {
298
- type: "single"
299
- }
300
- } : {},
301
- strike: (e) => e ? {
302
- strike: e
303
- } : {},
304
- backgroundColor: (e, t) => {
305
- var r;
306
- if (!e)
307
- return {};
308
- const n = (r = t.options.colors[e]) == null ? void 0 : r.background;
309
- return n ? {
310
- shading: {
311
- type: x.CLEAR,
312
- fill: n.slice(1)
313
- }
314
- } : {};
315
- },
316
- textColor: (e, t) => {
317
- var r;
318
- if (!e)
319
- return {};
320
- const n = (r = t.options.colors[e]) == null ? void 0 : r.text;
321
- return n ? {
322
- color: n.slice(1)
323
- } : {};
324
- },
325
- code: (e) => e ? {
326
- style: "VerbatimChar"
327
- } : {}
328
- }, G = {
329
- blockMapping: P,
330
- inlineContentMapping: j,
331
- styleMapping: J
211
+ //#endregion
212
+ //#region src/docx/defaultSchema/index.ts
213
+ var T = {
214
+ blockMapping: S,
215
+ inlineContentMapping: {
216
+ link: (e, t) => new s({
217
+ children: e.content.map((e) => t.transformStyledText(e, !0)),
218
+ link: e.href
219
+ }),
220
+ text: (e, t) => t.transformStyledText(e)
221
+ },
222
+ styleMapping: {
223
+ bold: (e) => e ? { bold: e } : {},
224
+ italic: (e) => e ? { italics: e } : {},
225
+ underline: (e) => e ? { underline: { type: "single" } } : {},
226
+ strike: (e) => e ? { strike: e } : {},
227
+ backgroundColor: (e, t) => {
228
+ if (!e) return {};
229
+ let n = t.options.colors[e]?.background;
230
+ return n ? { shading: {
231
+ type: p.CLEAR,
232
+ fill: n.slice(1)
233
+ } } : {};
234
+ },
235
+ textColor: (e, t) => {
236
+ if (!e) return {};
237
+ let n = t.options.colors[e]?.text;
238
+ return n ? { color: n.slice(1) } : {};
239
+ },
240
+ code: (e) => e ? { style: "VerbatimChar" } : {}
241
+ }
332
242
  };
333
- async function N(e) {
334
- return "https://corsproxy.api.blocknotejs.org/corsproxy/?url=" + encodeURIComponent(e);
243
+ //#endregion
244
+ //#region ../../shared/api/corsProxy.ts
245
+ async function E(e) {
246
+ return "https://corsproxy.api.blocknotejs.org/corsproxy/?url=" + encodeURIComponent(e);
335
247
  }
336
- async function v(e) {
337
- {
338
- const t = e.default;
339
- return await (await fetch(t)).arrayBuffer();
340
- }
248
+ //#endregion
249
+ //#region ../../shared/util/fileUtil.ts
250
+ async function D(e) {
251
+ {
252
+ let t = e.default;
253
+ return await (await fetch(t)).arrayBuffer();
254
+ }
341
255
  }
342
- const g = (
343
- /* default font size */
344
- 16 * /* 1 pixel is 0.75 points */
345
- 0.75 * /* 1.5em*/
346
- 1.5 * /* 1 point is 20 twips */
347
- 20
348
- );
349
- class Q extends S {
350
- constructor(t, n, r) {
351
- const i = {
352
- ...{
353
- colors: _,
354
- resolveFileUrl: N
355
- },
356
- ...r
357
- };
358
- super(t, n, i), this.schema = t, this.mappings = n;
359
- }
360
- /**
361
- * Mostly for internal use, you probably want to use `toBlob` or `toDocxJsDocument` instead.
362
- */
363
- transformStyledText(t, n) {
364
- const r = this.mapStyles(t.styles), o = Object.assign(
365
- {},
366
- ...r
367
- );
368
- return new p({
369
- ...o,
370
- style: n ? "Hyperlink" : o.style,
371
- text: t.text
372
- });
373
- }
374
- /**
375
- * Mostly for internal use, you probably want to use `toBlob` or `toDocxJsDocument` instead.
376
- */
377
- async transformBlocks(t, n = 0) {
378
- const r = [];
379
- for (const o of t) {
380
- let i = await this.transformBlocks(o.children, n + 1);
381
- ["columnList", "column"].includes(o.type) || (i = i.map((u, d) => (u instanceof a && !u.properties.numberingReferences.length && u.addRunToFront(
382
- new p({
383
- children: [new R()]
384
- })
385
- ), u)));
386
- const s = await this.mapBlock(
387
- o,
388
- n,
389
- 0,
390
- i
391
- );
392
- ["columnList", "column"].includes(o.type) ? r.push(s) : Array.isArray(s) ? r.push(...s, ...i) : r.push(s, ...i);
393
- }
394
- return r;
395
- }
396
- async getFonts() {
397
- let t = await v(
398
- await import("./Inter_18pt-Regular-byxnNS-8.js")
399
- ), n = await v(
400
- await import("./GeistMono-Regular-D4rKXxwr.js")
401
- );
402
- if (t instanceof ArrayBuffer || n instanceof ArrayBuffer) {
403
- const r = (await import("./index-cA_PmnZy.js").then((o) => o.i)).Buffer;
404
- t instanceof ArrayBuffer && (t = r.from(t)), n instanceof ArrayBuffer && (n = r.from(n));
405
- }
406
- return [
407
- { name: "Inter", data: t },
408
- {
409
- name: "GeistMono",
410
- data: n
411
- }
412
- ];
413
- }
414
- async createDefaultDocumentOptions(t) {
415
- let n = (await import("./styles-Bw_Yt1z6.js")).default;
416
- const r = t && t.trim() || "en-US";
417
- n = n.replace(
418
- /(<w:lang\b[^>]*\bw:val=")([^"]+)("[^>]*\/>)/g,
419
- `$1${r}$3`
420
- );
421
- const o = ["•"];
422
- return {
423
- numbering: {
424
- config: [
425
- {
426
- reference: "blocknote-numbered-list",
427
- levels: Array.from({ length: 9 }, (i, s) => ({
428
- start: 1,
429
- level: s,
430
- format: T.DECIMAL,
431
- text: `%${s + 1}.`,
432
- alignment: B.LEFT,
433
- style: {
434
- paragraph: {
435
- indent: {
436
- left: g * (s + 1),
437
- hanging: g
438
- }
439
- }
440
- }
441
- }))
442
- },
443
- {
444
- reference: "blocknote-bullet-list",
445
- levels: Array.from({ length: 9 }, (i, s) => ({
446
- start: 1,
447
- level: s,
448
- format: T.BULLET,
449
- text: o[s % o.length],
450
- alignment: B.LEFT,
451
- style: {
452
- paragraph: {
453
- indent: {
454
- left: g * (s + 1),
455
- hanging: g
456
- }
457
- }
458
- }
459
- }))
460
- }
461
- ]
462
- },
463
- fonts: await this.getFonts(),
464
- defaultTabStop: 200,
465
- externalStyles: n
466
- };
467
- }
468
- /**
469
- * Convert a document (array of Blocks to a Blob representing a .docx file)
470
- */
471
- async toBlob(t, n = {
472
- sectionOptions: {},
473
- documentOptions: {}
474
- }) {
475
- const r = await this.toDocxJsDocument(t, n), o = globalThis.Buffer;
476
- try {
477
- return globalThis.Buffer || (globalThis.Buffer = (await import("buffer")).default.Buffer), H.toBlob(r);
478
- } finally {
479
- globalThis.Buffer = o;
480
- }
481
- }
482
- /**
483
- * Convert a document (array of Blocks to a docxjs Document)
484
- */
485
- async toDocxJsDocument(t, n = {
486
- sectionOptions: {},
487
- documentOptions: {}
488
- }) {
489
- return new $({
490
- ...await this.createDefaultDocumentOptions(n.locale),
491
- ...n.documentOptions,
492
- sections: [
493
- {
494
- children: await this.transformBlocks(t),
495
- ...n.sectionOptions
496
- }
497
- ]
498
- });
499
- }
500
- }
501
- export {
502
- Q as DOCXExporter,
503
- G as docxDefaultSchemaMappings
256
+ //#endregion
257
+ //#region src/docx/docxExporter.ts
258
+ var O = 16 * .75 * 1.5 * 20, k = class extends t {
259
+ constructor(t, n, r) {
260
+ let i = {
261
+ colors: e,
262
+ resolveFileUrl: E,
263
+ ...r
264
+ };
265
+ super(t, n, i), this.schema = t, this.mappings = n;
266
+ }
267
+ transformStyledText(e, t) {
268
+ let n = this.mapStyles(e.styles), r = Object.assign({}, ...n);
269
+ return new v({
270
+ ...r,
271
+ style: t ? "Hyperlink" : r.style,
272
+ text: e.text
273
+ });
274
+ }
275
+ async transformBlocks(e, t = 0) {
276
+ let n = [];
277
+ for (let r of e) {
278
+ let e = await this.transformBlocks(r.children, t + 1);
279
+ ["columnList", "column"].includes(r.type) || (e = e.map((e, t) => (e instanceof f && !e.properties.numberingReferences.length && e.addRunToFront(new v({ children: [new m()] })), e)));
280
+ let i = await this.mapBlock(r, t, 0, e);
281
+ ["columnList", "column"].includes(r.type) ? n.push(i) : Array.isArray(i) ? n.push(...i, ...e) : n.push(i, ...e);
282
+ }
283
+ return n;
284
+ }
285
+ async getFonts() {
286
+ let e = await D(await import("./Inter_18pt-Regular-DVodnrPc.js")), t = await D(await import("./GeistMono-Regular-DC6WVheu.js"));
287
+ if (e instanceof ArrayBuffer || t instanceof ArrayBuffer) {
288
+ let n = (await import("buffer/")).Buffer;
289
+ e instanceof ArrayBuffer && (e = n.from(e)), t instanceof ArrayBuffer && (t = n.from(t));
290
+ }
291
+ return [{
292
+ name: "Inter",
293
+ data: e
294
+ }, {
295
+ name: "GeistMono",
296
+ data: t
297
+ }];
298
+ }
299
+ async createDefaultDocumentOptions(e) {
300
+ let t = (await import("./styles-C7Ws_DIi.js")).default, n = e && e.trim() || "en-US";
301
+ t = t.replace(/(<w:lang\b[^>]*\bw:val=")([^"]+)("[^>]*\/>)/g, `$1${n}$3`);
302
+ let r = ["•"];
303
+ return {
304
+ numbering: { config: [{
305
+ reference: "blocknote-numbered-list",
306
+ levels: Array.from({ length: 9 }, (e, t) => ({
307
+ start: 1,
308
+ level: t,
309
+ format: l.DECIMAL,
310
+ text: `%${t + 1}.`,
311
+ alignment: i.LEFT,
312
+ style: { paragraph: { indent: {
313
+ left: O * (t + 1),
314
+ hanging: O
315
+ } } }
316
+ }))
317
+ }, {
318
+ reference: "blocknote-bullet-list",
319
+ levels: Array.from({ length: 9 }, (e, t) => ({
320
+ start: 1,
321
+ level: t,
322
+ format: l.BULLET,
323
+ text: r[t % r.length],
324
+ alignment: i.LEFT,
325
+ style: { paragraph: { indent: {
326
+ left: O * (t + 1),
327
+ hanging: O
328
+ } } }
329
+ }))
330
+ }] },
331
+ fonts: await this.getFonts(),
332
+ defaultTabStop: 200,
333
+ externalStyles: t
334
+ };
335
+ }
336
+ async toBlob(e, t = {
337
+ sectionOptions: {},
338
+ documentOptions: {}
339
+ }) {
340
+ let n = await this.toDocxJsDocument(e, t), r = globalThis.Buffer;
341
+ try {
342
+ return globalThis.Buffer || (globalThis.Buffer = (await import("buffer")).default.Buffer), u.toBlob(n);
343
+ } finally {
344
+ globalThis.Buffer = r;
345
+ }
346
+ }
347
+ async toDocxJsDocument(e, t = {
348
+ sectionOptions: {},
349
+ documentOptions: {}
350
+ }) {
351
+ return new o({
352
+ ...await this.createDefaultDocumentOptions(t.locale),
353
+ ...t.documentOptions,
354
+ sections: [{
355
+ children: await this.transformBlocks(e),
356
+ ...t.sectionOptions
357
+ }]
358
+ });
359
+ }
504
360
  };
505
- //# sourceMappingURL=blocknote-xl-docx-exporter.js.map
361
+ //#endregion
362
+ export { k as DOCXExporter, T as docxDefaultSchemaMappings };
363
+
364
+ //# sourceMappingURL=blocknote-xl-docx-exporter.js.map