@blocknote/xl-odt-exporter 0.26.0 → 0.27.2
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-odt-exporter.js +138 -123
- package/dist/blocknote-xl-odt-exporter.js.map +1 -1
- package/dist/blocknote-xl-odt-exporter.umd.cjs +3 -3
- package/dist/blocknote-xl-odt-exporter.umd.cjs.map +1 -1
- package/dist/webpack-stats.json +1 -1
- package/package.json +22 -17
- package/src/odt/defaultSchema/blocks.tsx +31 -3
- package/src/odt/defaultSchema/inlineContent.tsx +2 -2
- package/src/odt/util/jsx.d.ts +55 -53
- package/types/src/odt/defaultSchema/blocks.d.ts +1 -2
- package/types/src/odt/defaultSchema/index.d.ts +35 -4
- package/types/src/odt/defaultSchema/inlineContent.d.ts +1 -2
- package/types/src/odt/odtExporter.d.ts +0 -1
|
@@ -1,43 +1,45 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { jsxs as
|
|
1
|
+
var I = Object.defineProperty;
|
|
2
|
+
var N = (e, t, l) => t in e ? I(e, t, { enumerable: !0, configurable: !0, writable: !0, value: l }) : e[t] = l;
|
|
3
|
+
var u = (e, t, l) => N(e, typeof t != "symbol" ? t + "" : t, l);
|
|
4
|
+
import { jsxs as f, Fragment as h, jsx as n } from "react/jsx-runtime";
|
|
5
5
|
import { mapTableCell as T, Exporter as M, COLORS_DEFAULT as B } from "@blocknote/core";
|
|
6
|
-
import { ZipWriter as
|
|
7
|
-
import { renderToString as
|
|
8
|
-
const
|
|
9
|
-
const
|
|
6
|
+
import { ZipWriter as $, BlobWriter as A, TextReader as v, BlobReader as k } from "@zip.js/zip.js";
|
|
7
|
+
import { renderToString as C } from "react-dom/server";
|
|
8
|
+
const L = (e) => Array.from({ length: e }, () => /* @__PURE__ */ n("text:tab", {})), d = (e, t, l = "Standard", s = {}, a = {}, o = {}) => {
|
|
9
|
+
const m = {
|
|
10
|
+
...a
|
|
11
|
+
}, i = { ...o };
|
|
10
12
|
if (t.textAlignment && t.textAlignment !== "left") {
|
|
11
|
-
const
|
|
13
|
+
const y = {
|
|
12
14
|
left: "start",
|
|
13
15
|
center: "center",
|
|
14
16
|
right: "end",
|
|
15
17
|
justify: "justify"
|
|
16
18
|
};
|
|
17
|
-
|
|
19
|
+
m["fo:text-align"] = y[t.textAlignment];
|
|
18
20
|
}
|
|
19
|
-
const
|
|
20
|
-
if (
|
|
21
|
-
const
|
|
22
|
-
|
|
21
|
+
const r = t.backgroundColor && t.backgroundColor !== "default" ? e.options.colors[t.backgroundColor].background : void 0;
|
|
22
|
+
if (r && (m["fo:background-color"] = r), t.textColor && t.textColor !== "default") {
|
|
23
|
+
const y = e.options.colors[t.textColor].text;
|
|
24
|
+
i["fo:color"] = y;
|
|
23
25
|
}
|
|
24
|
-
return !
|
|
26
|
+
return !r && !Object.keys(s).length && !Object.keys(m).length && !Object.keys(i).length ? l || "Standard" : e.registerStyle((y) => /* @__PURE__ */ f(
|
|
25
27
|
"style:style",
|
|
26
28
|
{
|
|
27
29
|
"style:family": "paragraph",
|
|
28
|
-
"style:name":
|
|
30
|
+
"style:name": y,
|
|
29
31
|
"style:parent-style-name": l,
|
|
30
32
|
...s,
|
|
31
33
|
children: [
|
|
32
|
-
|
|
34
|
+
r && /* @__PURE__ */ n(
|
|
33
35
|
"loext:graphic-properties",
|
|
34
36
|
{
|
|
35
37
|
"draw:fill": "solid",
|
|
36
|
-
"draw:fill-color":
|
|
38
|
+
"draw:fill-color": r
|
|
37
39
|
}
|
|
38
40
|
),
|
|
39
|
-
Object.keys(
|
|
40
|
-
Object.keys(
|
|
41
|
+
Object.keys(m).length > 0 && /* @__PURE__ */ n("style:paragraph-properties", { ...m }),
|
|
42
|
+
Object.keys(i).length > 0 && /* @__PURE__ */ n("style:text-properties", { ...i })
|
|
41
43
|
]
|
|
42
44
|
}
|
|
43
45
|
));
|
|
@@ -62,42 +64,61 @@ const C = (e) => Array.from({ length: e }, () => /* @__PURE__ */ n("text:tab", {
|
|
|
62
64
|
) }));
|
|
63
65
|
return t.set(s, a), a;
|
|
64
66
|
};
|
|
65
|
-
},
|
|
67
|
+
}, W = (e, t) => e.registerStyle((s) => /* @__PURE__ */ n("style:style", { "style:family": "table", "style:name": s, children: /* @__PURE__ */ n(
|
|
66
68
|
"style:table-properties",
|
|
67
69
|
{
|
|
68
70
|
"table:align": "left",
|
|
69
71
|
"style:writing-mode": "lr-tb",
|
|
70
72
|
"style:width": `${t.width}pt`
|
|
71
73
|
}
|
|
72
|
-
) })),
|
|
74
|
+
) })), S = (e, t) => t <= 0 ? e : /* @__PURE__ */ n("text:list", { children: /* @__PURE__ */ n("text:list-item", { children: S(e, t - 1) }) }), O = {
|
|
73
75
|
paragraph: (e, t, l) => {
|
|
74
|
-
const s =
|
|
76
|
+
const s = d(
|
|
75
77
|
t,
|
|
76
78
|
e.props
|
|
77
79
|
);
|
|
78
|
-
return /* @__PURE__ */
|
|
79
|
-
|
|
80
|
+
return /* @__PURE__ */ f("text:p", { "text:style-name": s, children: [
|
|
81
|
+
L(l),
|
|
80
82
|
t.transformInlineContent(e.content)
|
|
81
83
|
] });
|
|
82
84
|
},
|
|
83
85
|
heading: (e, t, l) => {
|
|
84
|
-
const a =
|
|
86
|
+
const a = d(
|
|
85
87
|
t,
|
|
86
88
|
e.props,
|
|
87
89
|
"Heading_20_" + e.props.level
|
|
88
90
|
);
|
|
89
|
-
return /* @__PURE__ */
|
|
91
|
+
return /* @__PURE__ */ f(
|
|
90
92
|
"text:h",
|
|
91
93
|
{
|
|
92
94
|
"text:outline-level": `${e.props.level}`,
|
|
93
95
|
"text:style-name": a,
|
|
94
96
|
children: [
|
|
95
|
-
|
|
97
|
+
L(l),
|
|
96
98
|
t.transformInlineContent(e.content)
|
|
97
99
|
]
|
|
98
100
|
}
|
|
99
101
|
);
|
|
100
102
|
},
|
|
103
|
+
quote: (e, t, l) => {
|
|
104
|
+
const a = d(
|
|
105
|
+
t,
|
|
106
|
+
e.props,
|
|
107
|
+
"Standard",
|
|
108
|
+
{},
|
|
109
|
+
{
|
|
110
|
+
"fo:border-left": "2pt solid #7D797A",
|
|
111
|
+
"fo:padding-left": "0.25in"
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
"fo:color": "#7D797A"
|
|
115
|
+
}
|
|
116
|
+
);
|
|
117
|
+
return /* @__PURE__ */ f("text:p", { "text:style-name": a, children: [
|
|
118
|
+
L(l),
|
|
119
|
+
t.transformInlineContent(e.content)
|
|
120
|
+
] });
|
|
121
|
+
},
|
|
101
122
|
/**
|
|
102
123
|
* Note: we wrap each list item in it's own list element.
|
|
103
124
|
* This is not the cleanest solution, it would be nicer to recognize subsequent
|
|
@@ -109,19 +130,19 @@ const C = (e) => Array.from({ length: e }, () => /* @__PURE__ */ n("text:tab", {
|
|
|
109
130
|
* (LibreOffice does nicely wrap the list items in the same list element)
|
|
110
131
|
*/
|
|
111
132
|
bulletListItem: (e, t, l) => {
|
|
112
|
-
const s =
|
|
133
|
+
const s = d(
|
|
113
134
|
t,
|
|
114
135
|
e.props,
|
|
115
136
|
"Standard",
|
|
116
137
|
{ "style:list-style-name": "WWNum1" }
|
|
117
138
|
);
|
|
118
|
-
return /* @__PURE__ */ n("text:list", { "text:style-name": "WWNum1", children: /* @__PURE__ */ n("text:list-item", { children:
|
|
139
|
+
return /* @__PURE__ */ n("text:list", { "text:style-name": "WWNum1", children: /* @__PURE__ */ n("text:list-item", { children: S(
|
|
119
140
|
/* @__PURE__ */ n("text:p", { "text:style-name": s, children: t.transformInlineContent(e.content) }),
|
|
120
141
|
l
|
|
121
142
|
) }) });
|
|
122
143
|
},
|
|
123
144
|
numberedListItem: (e, t, l, s) => {
|
|
124
|
-
const a =
|
|
145
|
+
const a = d(
|
|
125
146
|
t,
|
|
126
147
|
e.props
|
|
127
148
|
), o = (s || 0) > 1 ? "true" : "false";
|
|
@@ -136,7 +157,7 @@ const C = (e) => Array.from({ length: e }, () => /* @__PURE__ */ n("text:tab", {
|
|
|
136
157
|
...o === "false" && {
|
|
137
158
|
"text:start-value": e.props.start
|
|
138
159
|
},
|
|
139
|
-
children:
|
|
160
|
+
children: S(
|
|
140
161
|
/* @__PURE__ */ n("text:p", { "text:style-name": a, children: t.transformInlineContent(e.content) }),
|
|
141
162
|
l
|
|
142
163
|
)
|
|
@@ -145,23 +166,23 @@ const C = (e) => Array.from({ length: e }, () => /* @__PURE__ */ n("text:tab", {
|
|
|
145
166
|
}
|
|
146
167
|
);
|
|
147
168
|
},
|
|
148
|
-
checkListItem: (e, t) => /* @__PURE__ */
|
|
169
|
+
checkListItem: (e, t) => /* @__PURE__ */ f("text:p", { "text:style-name": "Standard", children: [
|
|
149
170
|
e.props.checked ? "☒ " : "☐ ",
|
|
150
171
|
t.transformInlineContent(e.content)
|
|
151
172
|
] }),
|
|
152
173
|
pageBreak: async () => /* @__PURE__ */ n("text:p", { "text:style-name": "PageBreak" }),
|
|
153
174
|
image: async (e, t) => {
|
|
154
|
-
const l = t, { path: s, mimeType: a, ...o } = await l.registerPicture(e.props.url),
|
|
175
|
+
const l = t, { path: s, mimeType: a, ...o } = await l.registerPicture(e.props.url), m = d(
|
|
155
176
|
t,
|
|
156
177
|
e.props
|
|
157
|
-
), i = e.props.previewWidth,
|
|
178
|
+
), i = e.props.previewWidth, r = o.height / o.width * i, y = 20, x = /* @__PURE__ */ f("text:p", { "text:style-name": e.props.caption ? "Caption" : m, children: [
|
|
158
179
|
/* @__PURE__ */ n(
|
|
159
180
|
"draw:frame",
|
|
160
181
|
{
|
|
161
182
|
"draw:style-name": "Frame",
|
|
162
183
|
"style:rel-height": "scale",
|
|
163
184
|
"svg:width": `${i}px`,
|
|
164
|
-
"svg:height": `${
|
|
185
|
+
"svg:height": `${r}px`,
|
|
165
186
|
"style:rel-width": e.props.caption ? "100%" : `${i}px`,
|
|
166
187
|
...!e.props.caption && {
|
|
167
188
|
"text:anchor-type": "as-char"
|
|
@@ -181,63 +202,63 @@ const C = (e) => Array.from({ length: e }, () => /* @__PURE__ */ n("text:tab", {
|
|
|
181
202
|
/* @__PURE__ */ n("text:line-break", {}),
|
|
182
203
|
/* @__PURE__ */ n("text:span", { "text:style-name": "Caption", children: e.props.caption })
|
|
183
204
|
] });
|
|
184
|
-
return e.props.caption ? /* @__PURE__ */ n("text:p", { "text:style-name":
|
|
205
|
+
return e.props.caption ? /* @__PURE__ */ n("text:p", { "text:style-name": m, children: /* @__PURE__ */ n(
|
|
185
206
|
"draw:frame",
|
|
186
207
|
{
|
|
187
208
|
"draw:style-name": "Frame",
|
|
188
209
|
"style:rel-height": "scale",
|
|
189
210
|
"style:rel-width": `${i}px`,
|
|
190
211
|
"svg:width": `${i}px`,
|
|
191
|
-
"svg:height": `${
|
|
212
|
+
"svg:height": `${r + y}px`,
|
|
192
213
|
"text:anchor-type": "as-char",
|
|
193
|
-
children: /* @__PURE__ */ n("draw:text-box", { children:
|
|
214
|
+
children: /* @__PURE__ */ n("draw:text-box", { children: x })
|
|
194
215
|
}
|
|
195
|
-
) }) :
|
|
216
|
+
) }) : x;
|
|
196
217
|
},
|
|
197
218
|
table: (e, t) => {
|
|
198
|
-
var
|
|
219
|
+
var r;
|
|
199
220
|
const a = (e.content.columnWidths.reduce(
|
|
200
|
-
(
|
|
221
|
+
(y, x) => (y || 0) + (x || 120),
|
|
201
222
|
0
|
|
202
|
-
) || 0) * 0.75, o = t,
|
|
203
|
-
return /* @__PURE__ */
|
|
204
|
-
(
|
|
205
|
-
const
|
|
223
|
+
) || 0) * 0.75, o = t, m = P(o), i = W(o, { width: a });
|
|
224
|
+
return /* @__PURE__ */ f("table:table", { "table:name": e.id, "table:style-name": i, children: [
|
|
225
|
+
(r = e.content.rows[0]) == null ? void 0 : r.cells.map((y, x) => {
|
|
226
|
+
const g = (e.content.columnWidths[x] || 120) * 0.75, c = o.registerStyle((_) => /* @__PURE__ */ n("style:style", { "style:name": _, "style:family": "table-column", children: /* @__PURE__ */ n(
|
|
206
227
|
"style:table-column-properties",
|
|
207
228
|
{
|
|
208
|
-
"style:column-width": `${
|
|
229
|
+
"style:column-width": `${g}pt`
|
|
209
230
|
}
|
|
210
231
|
) }));
|
|
211
|
-
return /* @__PURE__ */ n("table:table-column", { "table:style-name": c },
|
|
232
|
+
return /* @__PURE__ */ n("table:table-column", { "table:style-name": c }, x);
|
|
212
233
|
}),
|
|
213
|
-
e.content.rows.map((
|
|
234
|
+
e.content.rows.map((y, x) => /* @__PURE__ */ n("table:table-row", { children: y.cells.map((b, g) => {
|
|
214
235
|
const c = T(b);
|
|
215
236
|
return /* @__PURE__ */ n(
|
|
216
237
|
"table:table-cell",
|
|
217
238
|
{
|
|
218
|
-
"table:style-name":
|
|
239
|
+
"table:style-name": m(c),
|
|
219
240
|
"office:value-type": "string",
|
|
220
241
|
"style:text-align-source": "fix",
|
|
221
242
|
"style:paragraph-properties-text-align": c.props.textAlignment,
|
|
222
243
|
children: /* @__PURE__ */ n("text:p", { "text:style-name": "Standard", children: t.transformInlineContent(c.content) })
|
|
223
244
|
},
|
|
224
|
-
`${
|
|
245
|
+
`${x}-${g}`
|
|
225
246
|
);
|
|
226
|
-
}) },
|
|
247
|
+
}) }, x))
|
|
227
248
|
] });
|
|
228
249
|
},
|
|
229
250
|
codeBlock: (e) => {
|
|
230
251
|
var l;
|
|
231
252
|
const t = ((l = e.content[0]) == null ? void 0 : l.text) || "";
|
|
232
|
-
return /* @__PURE__ */
|
|
253
|
+
return /* @__PURE__ */ f("text:p", { "text:style-name": "Codeblock", children: [
|
|
233
254
|
...t.split(`
|
|
234
|
-
`).map((s, a) => /* @__PURE__ */
|
|
255
|
+
`).map((s, a) => /* @__PURE__ */ f(h, { children: [
|
|
235
256
|
a !== 0 && /* @__PURE__ */ n("text:line-break", {}),
|
|
236
257
|
s
|
|
237
258
|
] }))
|
|
238
259
|
] });
|
|
239
260
|
},
|
|
240
|
-
file: async (e) => /* @__PURE__ */
|
|
261
|
+
file: async (e) => /* @__PURE__ */ f(h, { children: [
|
|
241
262
|
/* @__PURE__ */ n("text:p", { "style:style-name": "Standard", children: e.props.url ? /* @__PURE__ */ n(
|
|
242
263
|
"text:a",
|
|
243
264
|
{
|
|
@@ -251,7 +272,7 @@ const C = (e) => Array.from({ length: e }, () => /* @__PURE__ */ n("text:tab", {
|
|
|
251
272
|
) : "Open file" }),
|
|
252
273
|
e.props.caption && /* @__PURE__ */ n("text:p", { "text:style-name": "Caption", children: e.props.caption })
|
|
253
274
|
] }),
|
|
254
|
-
video: (e) => /* @__PURE__ */
|
|
275
|
+
video: (e) => /* @__PURE__ */ f(h, { children: [
|
|
255
276
|
/* @__PURE__ */ n("text:p", { "style:style-name": "Standard", children: /* @__PURE__ */ n(
|
|
256
277
|
"text:a",
|
|
257
278
|
{
|
|
@@ -265,7 +286,7 @@ const C = (e) => Array.from({ length: e }, () => /* @__PURE__ */ n("text:tab", {
|
|
|
265
286
|
) }),
|
|
266
287
|
e.props.caption && /* @__PURE__ */ n("text:p", { "text:style-name": "Caption", children: e.props.caption })
|
|
267
288
|
] }),
|
|
268
|
-
audio: (e) => /* @__PURE__ */
|
|
289
|
+
audio: (e) => /* @__PURE__ */ f(h, { children: [
|
|
269
290
|
/* @__PURE__ */ n("text:p", { "style:style-name": "Standard", children: /* @__PURE__ */ n(
|
|
270
291
|
"text:a",
|
|
271
292
|
{
|
|
@@ -279,7 +300,7 @@ const C = (e) => Array.from({ length: e }, () => /* @__PURE__ */ n("text:tab", {
|
|
|
279
300
|
) }),
|
|
280
301
|
e.props.caption && /* @__PURE__ */ n("text:p", { "text:style-name": "Caption", children: e.props.caption })
|
|
281
302
|
] })
|
|
282
|
-
},
|
|
303
|
+
}, R = {
|
|
283
304
|
link: (e, t) => {
|
|
284
305
|
const l = e.content.map((s) => t.transformStyledText(s));
|
|
285
306
|
return /* @__PURE__ */ n(
|
|
@@ -303,25 +324,19 @@ const C = (e) => Array.from({ length: e }, () => /* @__PURE__ */ n("text:tab", {
|
|
|
303
324
|
textColor: (e, t) => e ? { "fo:color": t.options.colors[e].text } : {},
|
|
304
325
|
backgroundColor: (e, t) => e ? { "fo:background-color": t.options.colors[e].background } : {},
|
|
305
326
|
code: (e) => e ? { "style:font-name": "Courier New" } : {}
|
|
306
|
-
},
|
|
307
|
-
blockMapping:
|
|
308
|
-
inlineContentMapping:
|
|
327
|
+
}, J = {
|
|
328
|
+
blockMapping: O,
|
|
329
|
+
inlineContentMapping: R,
|
|
309
330
|
styleMapping: D
|
|
310
331
|
};
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
if (E.NODE_ENV === "test") {
|
|
314
|
-
const t = require("fs");
|
|
315
|
-
let l = e.default;
|
|
316
|
-
return l.startsWith("/@fs/") && (l = l.substring(4)), t.readFileSync(l);
|
|
317
|
-
} else {
|
|
332
|
+
async function H(e) {
|
|
333
|
+
{
|
|
318
334
|
const t = e.default;
|
|
319
335
|
return await (await fetch(t)).arrayBuffer();
|
|
320
336
|
}
|
|
321
337
|
}
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
if (typeof window < "u" && U.NODE_ENV !== "test") {
|
|
338
|
+
async function U(e) {
|
|
339
|
+
if (typeof window < "u") {
|
|
325
340
|
const t = await createImageBitmap(e), { width: l, height: s } = t;
|
|
326
341
|
return t.close(), { width: l, height: s };
|
|
327
342
|
} else {
|
|
@@ -331,7 +346,7 @@ async function j(e) {
|
|
|
331
346
|
return { width: s.width, height: s.height };
|
|
332
347
|
}
|
|
333
348
|
}
|
|
334
|
-
const
|
|
349
|
+
const j = `<?xml version="1.0" encoding="UTF-8"?>
|
|
335
350
|
<office:document-styles xmlns:css3t="http://www.w3.org/TR/css3-text/"
|
|
336
351
|
xmlns:grddl="http://www.w3.org/2003/g/data-view#" xmlns:xhtml="http://www.w3.org/1999/xhtml"
|
|
337
352
|
xmlns:dom="http://www.w3.org/2001/xml-events"
|
|
@@ -1409,7 +1424,7 @@ const G = `<?xml version="1.0" encoding="UTF-8"?>
|
|
|
1409
1424
|
draw:style-name="Mdp1" />
|
|
1410
1425
|
</office:master-styles>
|
|
1411
1426
|
</office:document-styles>`;
|
|
1412
|
-
class
|
|
1427
|
+
class K extends M {
|
|
1413
1428
|
constructor(l, s, a) {
|
|
1414
1429
|
const o = {
|
|
1415
1430
|
colors: B
|
|
@@ -1417,18 +1432,18 @@ class Y extends M {
|
|
|
1417
1432
|
super(l, s, { ...o, ...a });
|
|
1418
1433
|
// "Styles" to be added to the AutomaticStyles section of the ODT file
|
|
1419
1434
|
// Keyed by the style name
|
|
1420
|
-
|
|
1435
|
+
u(this, "automaticStyles", /* @__PURE__ */ new Map());
|
|
1421
1436
|
// "Pictures" to be added to the Pictures folder in the ODT file
|
|
1422
1437
|
// Keyed by the original image URL
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1438
|
+
u(this, "pictures", /* @__PURE__ */ new Map());
|
|
1439
|
+
u(this, "styleCounter", 0);
|
|
1440
|
+
u(this, "options");
|
|
1426
1441
|
this.schema = l, this.options = { ...o, ...a };
|
|
1427
1442
|
}
|
|
1428
1443
|
async loadFonts() {
|
|
1429
|
-
const l = await
|
|
1444
|
+
const l = await H(
|
|
1430
1445
|
await import("./Inter_18pt-Regular-byxnNS-8.js")
|
|
1431
|
-
), s = await
|
|
1446
|
+
), s = await H(
|
|
1432
1447
|
await import("./GeistMono-Regular-D4rKXxwr.js")
|
|
1433
1448
|
);
|
|
1434
1449
|
return [
|
|
@@ -1457,26 +1472,26 @@ class Y extends M {
|
|
|
1457
1472
|
async transformBlocks(l, s = 0) {
|
|
1458
1473
|
const a = [];
|
|
1459
1474
|
let o = 0;
|
|
1460
|
-
for (const
|
|
1461
|
-
|
|
1475
|
+
for (const m of l) {
|
|
1476
|
+
m.type === "numberedListItem" ? o++ : o = 0;
|
|
1462
1477
|
const i = await this.transformBlocks(
|
|
1463
|
-
|
|
1478
|
+
m.children,
|
|
1464
1479
|
s + 1
|
|
1465
|
-
),
|
|
1466
|
-
|
|
1480
|
+
), r = await this.mapBlock(
|
|
1481
|
+
m,
|
|
1467
1482
|
s,
|
|
1468
1483
|
o
|
|
1469
1484
|
);
|
|
1470
|
-
a.push(
|
|
1485
|
+
a.push(r), i.length > 0 && a.push(...i);
|
|
1471
1486
|
}
|
|
1472
1487
|
return a;
|
|
1473
1488
|
}
|
|
1474
1489
|
async toODTDocument(l, s) {
|
|
1475
|
-
const a = (
|
|
1490
|
+
const a = (p) => {
|
|
1476
1491
|
const z = /<([a-zA-Z0-9:]+)\s+?(?:xml)ns(?::[a-zA-Z0-9]+)?=".*"(.*)>/g;
|
|
1477
1492
|
let w = "";
|
|
1478
|
-
return typeof
|
|
1479
|
-
}, o = await this.transformBlocks(l),
|
|
1493
|
+
return typeof p == "string" ? w = p : w = new XMLSerializer().serializeToString(p), w.replace(z, "<$1$2>");
|
|
1494
|
+
}, o = await this.transformBlocks(l), m = Array.from(this.automaticStyles.values()), i = Array.from(this.pictures.values()), r = await this.loadFonts(), y = a((s == null ? void 0 : s.header) || ""), x = a((s == null ? void 0 : s.footer) || ""), b = /* @__PURE__ */ f(
|
|
1480
1495
|
"office:document-content",
|
|
1481
1496
|
{
|
|
1482
1497
|
"xmlns:office": "urn:oasis:names:tc:opendocument:xmlns:office:1.0",
|
|
@@ -1490,16 +1505,16 @@ class Y extends M {
|
|
|
1490
1505
|
"xmlns:loext": "urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0",
|
|
1491
1506
|
"office:version": "1.3",
|
|
1492
1507
|
children: [
|
|
1493
|
-
/* @__PURE__ */ n("office:font-face-decls", { children:
|
|
1508
|
+
/* @__PURE__ */ n("office:font-face-decls", { children: r.map((p) => /* @__PURE__ */ n(
|
|
1494
1509
|
"style:font-face",
|
|
1495
1510
|
{
|
|
1496
|
-
"style:name":
|
|
1497
|
-
"svg:font-family":
|
|
1511
|
+
"style:name": p.name,
|
|
1512
|
+
"svg:font-family": p.name,
|
|
1498
1513
|
"style:font-pitch": "variable",
|
|
1499
1514
|
children: /* @__PURE__ */ n("svg:font-face-src", { children: /* @__PURE__ */ n(
|
|
1500
1515
|
"svg:font-face-uri",
|
|
1501
1516
|
{
|
|
1502
|
-
"xlink:href": `Fonts/${
|
|
1517
|
+
"xlink:href": `Fonts/${p.fileName}`,
|
|
1503
1518
|
"xlink:type": "simple",
|
|
1504
1519
|
"loext:font-style": "normal",
|
|
1505
1520
|
"loext:font-weight": "normal",
|
|
@@ -1508,27 +1523,27 @@ class Y extends M {
|
|
|
1508
1523
|
) })
|
|
1509
1524
|
}
|
|
1510
1525
|
)) }),
|
|
1511
|
-
/* @__PURE__ */ n("office:automatic-styles", { children:
|
|
1512
|
-
(
|
|
1526
|
+
/* @__PURE__ */ n("office:automatic-styles", { children: m }),
|
|
1527
|
+
(y || x) && /* @__PURE__ */ n("office:master-styles", { children: /* @__PURE__ */ f(
|
|
1513
1528
|
"style:master-page",
|
|
1514
1529
|
{
|
|
1515
1530
|
"style:name": "Standard",
|
|
1516
1531
|
"style:page-layout-name": "Mpm1",
|
|
1517
1532
|
"draw:style-name": "Mdp1",
|
|
1518
1533
|
children: [
|
|
1519
|
-
|
|
1534
|
+
y && /* @__PURE__ */ n(
|
|
1520
1535
|
"style:header",
|
|
1521
1536
|
{
|
|
1522
1537
|
dangerouslySetInnerHTML: {
|
|
1523
|
-
__html:
|
|
1538
|
+
__html: y
|
|
1524
1539
|
}
|
|
1525
1540
|
}
|
|
1526
1541
|
),
|
|
1527
|
-
|
|
1542
|
+
x && /* @__PURE__ */ n(
|
|
1528
1543
|
"style:footer",
|
|
1529
1544
|
{
|
|
1530
1545
|
dangerouslySetInnerHTML: {
|
|
1531
|
-
__html:
|
|
1546
|
+
__html: x
|
|
1532
1547
|
}
|
|
1533
1548
|
}
|
|
1534
1549
|
)
|
|
@@ -1538,7 +1553,7 @@ class Y extends M {
|
|
|
1538
1553
|
/* @__PURE__ */ n("office:body", { children: /* @__PURE__ */ n("office:text", { children: o }) })
|
|
1539
1554
|
]
|
|
1540
1555
|
}
|
|
1541
|
-
),
|
|
1556
|
+
), g = /* @__PURE__ */ f(
|
|
1542
1557
|
"manifest:manifest",
|
|
1543
1558
|
{
|
|
1544
1559
|
"xmlns:manifest": "urn:oasis:names:tc:opendocument:xmlns:manifest:1.0",
|
|
@@ -1565,24 +1580,24 @@ class Y extends M {
|
|
|
1565
1580
|
"manifest:full-path": "styles.xml"
|
|
1566
1581
|
}
|
|
1567
1582
|
),
|
|
1568
|
-
i.map((
|
|
1583
|
+
i.map((p) => /* @__PURE__ */ n(
|
|
1569
1584
|
"manifest:file-entry",
|
|
1570
1585
|
{
|
|
1571
|
-
"manifest:media-type":
|
|
1572
|
-
"manifest:full-path": `Pictures/${
|
|
1586
|
+
"manifest:media-type": p.file.type,
|
|
1587
|
+
"manifest:full-path": `Pictures/${p.fileName}`
|
|
1573
1588
|
}
|
|
1574
1589
|
)),
|
|
1575
|
-
|
|
1590
|
+
r.map((p) => /* @__PURE__ */ n(
|
|
1576
1591
|
"manifest:file-entry",
|
|
1577
1592
|
{
|
|
1578
1593
|
"manifest:media-type": "application/x-font-ttf",
|
|
1579
|
-
"manifest:full-path": `Fonts/${
|
|
1594
|
+
"manifest:full-path": `Fonts/${p.fileName}`
|
|
1580
1595
|
}
|
|
1581
1596
|
))
|
|
1582
1597
|
]
|
|
1583
1598
|
}
|
|
1584
|
-
), c = new
|
|
1585
|
-
new
|
|
1599
|
+
), c = new $(
|
|
1600
|
+
new A("application/vnd.oasis.opendocument.text")
|
|
1586
1601
|
);
|
|
1587
1602
|
c.add(
|
|
1588
1603
|
"mimetype",
|
|
@@ -1594,13 +1609,13 @@ class Y extends M {
|
|
|
1594
1609
|
extendedTimestamp: !1
|
|
1595
1610
|
}
|
|
1596
1611
|
);
|
|
1597
|
-
const _ =
|
|
1598
|
-
return c.add("content.xml", new v(_)), c.add("styles.xml", new v(
|
|
1599
|
-
c.add(`Fonts/${
|
|
1600
|
-
}), i.forEach((
|
|
1612
|
+
const _ = C(b), F = C(g);
|
|
1613
|
+
return c.add("content.xml", new v(_)), c.add("styles.xml", new v(j)), c.add("META-INF/manifest.xml", new v(F)), r.forEach((p) => {
|
|
1614
|
+
c.add(`Fonts/${p.fileName}`, new k(p.data));
|
|
1615
|
+
}), i.forEach((p) => {
|
|
1601
1616
|
c.add(
|
|
1602
|
-
`Pictures/${
|
|
1603
|
-
new
|
|
1617
|
+
`Pictures/${p.fileName}`,
|
|
1618
|
+
new k(p.file)
|
|
1604
1619
|
);
|
|
1605
1620
|
}), c.close();
|
|
1606
1621
|
}
|
|
@@ -1622,25 +1637,25 @@ class Y extends M {
|
|
|
1622
1637
|
"image/webp": "webp"
|
|
1623
1638
|
};
|
|
1624
1639
|
if (this.pictures.has(l)) {
|
|
1625
|
-
const
|
|
1640
|
+
const y = this.pictures.get(l);
|
|
1626
1641
|
return {
|
|
1627
|
-
path: `Pictures/${
|
|
1628
|
-
mimeType:
|
|
1629
|
-
height:
|
|
1630
|
-
width:
|
|
1642
|
+
path: `Pictures/${y.fileName}`,
|
|
1643
|
+
mimeType: y.file.type,
|
|
1644
|
+
height: y.height,
|
|
1645
|
+
width: y.width
|
|
1631
1646
|
};
|
|
1632
1647
|
}
|
|
1633
|
-
const a = await this.resolveFile(l), o = s[a.type] || "png",
|
|
1648
|
+
const a = await this.resolveFile(l), o = s[a.type] || "png", m = `picture-${this.pictures.size}.${o}`, { width: i, height: r } = await U(a);
|
|
1634
1649
|
return this.pictures.set(l, {
|
|
1635
1650
|
file: a,
|
|
1636
|
-
fileName:
|
|
1637
|
-
height:
|
|
1651
|
+
fileName: m,
|
|
1652
|
+
height: r,
|
|
1638
1653
|
width: i
|
|
1639
|
-
}), { path: `Pictures/${
|
|
1654
|
+
}), { path: `Pictures/${m}`, mimeType: a.type, height: r, width: i };
|
|
1640
1655
|
}
|
|
1641
1656
|
}
|
|
1642
1657
|
export {
|
|
1643
|
-
|
|
1644
|
-
|
|
1658
|
+
K as ODTExporter,
|
|
1659
|
+
J as odtDefaultSchemaMappings
|
|
1645
1660
|
};
|
|
1646
1661
|
//# sourceMappingURL=blocknote-xl-odt-exporter.js.map
|