@blocknote/xl-docx-exporter 0.47.2 → 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.
- package/dist/GeistMono-Regular-CHVKamKz.cjs +2 -0
- package/dist/GeistMono-Regular-CHVKamKz.cjs.map +1 -0
- package/dist/GeistMono-Regular-DC6WVheu.js +6 -0
- package/dist/GeistMono-Regular-DC6WVheu.js.map +1 -0
- package/dist/Inter_18pt-Regular-DVodnrPc.js +6 -0
- package/dist/Inter_18pt-Regular-DVodnrPc.js.map +1 -0
- package/dist/Inter_18pt-Regular-PkBfh_8C.cjs +2 -0
- package/dist/Inter_18pt-Regular-PkBfh_8C.cjs.map +1 -0
- package/dist/blocknote-xl-docx-exporter.cjs +3 -3
- package/dist/blocknote-xl-docx-exporter.cjs.map +1 -1
- package/dist/blocknote-xl-docx-exporter.js +354 -495
- package/dist/blocknote-xl-docx-exporter.js.map +1 -1
- package/dist/styles-C7Ws_DIi.js +6 -0
- package/dist/styles-C7Ws_DIi.js.map +1 -0
- package/dist/{styles-Bw_Yt1z6.js → styles-Cz94-HtD.cjs} +3 -6
- package/dist/styles-Cz94-HtD.cjs.map +1 -0
- package/dist/webpack-stats.json +1 -1
- package/package.json +6 -6
- package/dist/GeistMono-Regular--NrcstcO.cjs +0 -2
- package/dist/GeistMono-Regular--NrcstcO.cjs.map +0 -1
- package/dist/GeistMono-Regular-D4rKXxwr.js +0 -5
- package/dist/GeistMono-Regular-D4rKXxwr.js.map +0 -1
- package/dist/Inter_18pt-Regular-CCMUw8TC.cjs +0 -2
- package/dist/Inter_18pt-Regular-CCMUw8TC.cjs.map +0 -1
- package/dist/Inter_18pt-Regular-byxnNS-8.js +0 -5
- package/dist/Inter_18pt-Regular-byxnNS-8.js.map +0 -1
- package/dist/index-B-FmPo2r.cjs +0 -7
- package/dist/index-B-FmPo2r.cjs.map +0 -1
- package/dist/index-cA_PmnZy.js +0 -1040
- package/dist/index-cA_PmnZy.js.map +0 -1
- package/dist/styles-BRTtNJM0.cjs +0 -1016
- package/dist/styles-BRTtNJM0.cjs.map +0 -1
- package/dist/styles-Bw_Yt1z6.js.map +0 -1
|
@@ -1,505 +1,364 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
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
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
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
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
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
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
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
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
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
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
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
|
-
|
|
334
|
-
|
|
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
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
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
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
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
|
-
//#
|
|
361
|
+
//#endregion
|
|
362
|
+
export { k as DOCXExporter, T as docxDefaultSchemaMappings };
|
|
363
|
+
|
|
364
|
+
//# sourceMappingURL=blocknote-xl-docx-exporter.js.map
|