@blocknote/xl-odt-exporter 0.32.0 → 0.34.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/blocknote-xl-odt-exporter.js +188 -144
- package/dist/blocknote-xl-odt-exporter.js.map +1 -1
- package/dist/blocknote-xl-odt-exporter.umd.cjs +2 -2
- package/dist/blocknote-xl-odt-exporter.umd.cjs.map +1 -1
- package/dist/webpack-stats.json +1 -1
- package/package.json +7 -6
- package/src/odt/__snapshots__/withMultiColumn/content.xml +91 -0
- package/src/odt/__snapshots__/withMultiColumn/styles.xml +599 -0
- package/src/odt/defaultSchema/blocks.tsx +68 -1
- package/src/odt/odtExporter.test.ts +80 -0
- package/src/odt/odtExporter.tsx +27 -15
- package/types/src/odt/defaultSchema/blocks.d.ts +2 -1
- package/types/src/odt/defaultSchema/index.d.ts +33 -0
- package/types/src/odt/odtExporter.d.ts +1 -1
|
@@ -1,55 +1,55 @@
|
|
|
1
1
|
var I = Object.defineProperty;
|
|
2
|
-
var N = (e, t,
|
|
3
|
-
var
|
|
4
|
-
import { jsxs as f, Fragment as h, jsx as
|
|
2
|
+
var N = (e, t, n) => t in e ? I(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
3
|
+
var b = (e, t, n) => N(e, typeof t != "symbol" ? t + "" : t, n);
|
|
4
|
+
import { jsxs as f, Fragment as h, jsx as l } from "react/jsx-runtime";
|
|
5
5
|
import { mapTableCell as T, Exporter as M, COLORS_DEFAULT as B } from "@blocknote/core";
|
|
6
|
-
import { ZipWriter as $, BlobWriter as
|
|
6
|
+
import { ZipWriter as $, BlobWriter as W, TextReader as v, BlobReader as k } from "@zip.js/zip.js";
|
|
7
7
|
import { renderToString as C } from "react-dom/server";
|
|
8
|
-
const L = (e) => Array.from({ length: e }, () => /* @__PURE__ */
|
|
9
|
-
const
|
|
8
|
+
const L = (e) => Array.from({ length: e }, () => /* @__PURE__ */ l("text:tab", {})), g = (e, t, n = "Standard", s = {}, a = {}, o = {}) => {
|
|
9
|
+
const y = {
|
|
10
10
|
...a
|
|
11
11
|
}, i = { ...o };
|
|
12
12
|
if (t.textAlignment && t.textAlignment !== "left") {
|
|
13
|
-
const
|
|
13
|
+
const m = {
|
|
14
14
|
left: "start",
|
|
15
15
|
center: "center",
|
|
16
16
|
right: "end",
|
|
17
17
|
justify: "justify"
|
|
18
18
|
};
|
|
19
|
-
|
|
19
|
+
y["fo:text-align"] = m[t.textAlignment];
|
|
20
20
|
}
|
|
21
21
|
const r = t.backgroundColor && t.backgroundColor !== "default" ? e.options.colors[t.backgroundColor].background : void 0;
|
|
22
|
-
if (r && (
|
|
23
|
-
const
|
|
24
|
-
i["fo:color"] =
|
|
22
|
+
if (r && (y["fo:background-color"] = r), t.textColor && t.textColor !== "default") {
|
|
23
|
+
const m = e.options.colors[t.textColor].text;
|
|
24
|
+
i["fo:color"] = m;
|
|
25
25
|
}
|
|
26
|
-
return !r && !Object.keys(s).length && !Object.keys(
|
|
26
|
+
return !r && !Object.keys(s).length && !Object.keys(y).length && !Object.keys(i).length ? n || "Standard" : e.registerStyle((m) => /* @__PURE__ */ f(
|
|
27
27
|
"style:style",
|
|
28
28
|
{
|
|
29
29
|
"style:family": "paragraph",
|
|
30
|
-
"style:name":
|
|
31
|
-
"style:parent-style-name":
|
|
30
|
+
"style:name": m,
|
|
31
|
+
"style:parent-style-name": n,
|
|
32
32
|
...s,
|
|
33
33
|
children: [
|
|
34
|
-
r && /* @__PURE__ */
|
|
34
|
+
r && /* @__PURE__ */ l(
|
|
35
35
|
"loext:graphic-properties",
|
|
36
36
|
{
|
|
37
37
|
"draw:fill": "solid",
|
|
38
38
|
"draw:fill-color": r
|
|
39
39
|
}
|
|
40
40
|
),
|
|
41
|
-
Object.keys(
|
|
42
|
-
Object.keys(i).length > 0 && /* @__PURE__ */
|
|
41
|
+
Object.keys(y).length > 0 && /* @__PURE__ */ l("style:paragraph-properties", { ...y }),
|
|
42
|
+
Object.keys(i).length > 0 && /* @__PURE__ */ l("style:text-properties", { ...i })
|
|
43
43
|
]
|
|
44
44
|
}
|
|
45
45
|
));
|
|
46
|
-
},
|
|
46
|
+
}, A = (e) => {
|
|
47
47
|
const t = /* @__PURE__ */ new Map();
|
|
48
|
-
return (
|
|
49
|
-
const s = `${
|
|
48
|
+
return (n) => {
|
|
49
|
+
const s = `${n.props.backgroundColor}-${n.props.textColor}-${n.props.textAlignment}`;
|
|
50
50
|
if (t.has(s))
|
|
51
51
|
return t.get(s);
|
|
52
|
-
const a = e.registerStyle((o) => /* @__PURE__ */
|
|
52
|
+
const a = e.registerStyle((o) => /* @__PURE__ */ l("style:style", { "style:family": "table-cell", "style:name": o, children: /* @__PURE__ */ l(
|
|
53
53
|
"style:table-cell-properties",
|
|
54
54
|
{
|
|
55
55
|
"fo:border": "0.5pt solid #000000",
|
|
@@ -58,32 +58,32 @@ const L = (e) => Array.from({ length: e }, () => /* @__PURE__ */ n("text:tab", {
|
|
|
58
58
|
"fo:padding-left": "0.075in",
|
|
59
59
|
"fo:padding-bottom": "0in",
|
|
60
60
|
"fo:padding-right": "0.075in",
|
|
61
|
-
"fo:background-color":
|
|
62
|
-
"fo:color":
|
|
61
|
+
"fo:background-color": n.props.backgroundColor !== "default" && n.props.backgroundColor ? e.options.colors[n.props.backgroundColor].background : void 0,
|
|
62
|
+
"fo:color": n.props.textColor !== "default" && n.props.textColor ? e.options.colors[n.props.textColor].text : void 0
|
|
63
63
|
}
|
|
64
64
|
) }));
|
|
65
65
|
return t.set(s, a), a;
|
|
66
66
|
};
|
|
67
|
-
},
|
|
67
|
+
}, P = (e, t) => e.registerStyle((s) => /* @__PURE__ */ l("style:style", { "style:family": "table", "style:name": s, children: /* @__PURE__ */ l(
|
|
68
68
|
"style:table-properties",
|
|
69
69
|
{
|
|
70
70
|
"table:align": "left",
|
|
71
71
|
"style:writing-mode": "lr-tb",
|
|
72
72
|
"style:width": `${t.width}pt`
|
|
73
73
|
}
|
|
74
|
-
) })), S = (e, t) => t <= 0 ? e : /* @__PURE__ */
|
|
75
|
-
paragraph: (e, t,
|
|
76
|
-
const s =
|
|
74
|
+
) })), S = (e, t) => t <= 0 ? e : /* @__PURE__ */ l("text:list", { children: /* @__PURE__ */ l("text:list-item", { children: S(e, t - 1) }) }), O = {
|
|
75
|
+
paragraph: (e, t, n) => {
|
|
76
|
+
const s = g(
|
|
77
77
|
t,
|
|
78
78
|
e.props
|
|
79
79
|
);
|
|
80
80
|
return /* @__PURE__ */ f("text:p", { "text:style-name": s, children: [
|
|
81
|
-
L(
|
|
81
|
+
L(n),
|
|
82
82
|
t.transformInlineContent(e.content)
|
|
83
83
|
] });
|
|
84
84
|
},
|
|
85
|
-
heading: (e, t,
|
|
86
|
-
const a =
|
|
85
|
+
heading: (e, t, n) => {
|
|
86
|
+
const a = g(
|
|
87
87
|
t,
|
|
88
88
|
e.props,
|
|
89
89
|
"Heading_20_" + e.props.level
|
|
@@ -94,14 +94,14 @@ const L = (e) => Array.from({ length: e }, () => /* @__PURE__ */ n("text:tab", {
|
|
|
94
94
|
"text:outline-level": `${e.props.level}`,
|
|
95
95
|
"text:style-name": a,
|
|
96
96
|
children: [
|
|
97
|
-
L(
|
|
97
|
+
L(n),
|
|
98
98
|
t.transformInlineContent(e.content)
|
|
99
99
|
]
|
|
100
100
|
}
|
|
101
101
|
);
|
|
102
102
|
},
|
|
103
|
-
quote: (e, t,
|
|
104
|
-
const a =
|
|
103
|
+
quote: (e, t, n) => {
|
|
104
|
+
const a = g(
|
|
105
105
|
t,
|
|
106
106
|
e.props,
|
|
107
107
|
"Standard",
|
|
@@ -115,7 +115,7 @@ const L = (e) => Array.from({ length: e }, () => /* @__PURE__ */ n("text:tab", {
|
|
|
115
115
|
}
|
|
116
116
|
);
|
|
117
117
|
return /* @__PURE__ */ f("text:p", { "text:style-name": a, children: [
|
|
118
|
-
L(
|
|
118
|
+
L(n),
|
|
119
119
|
t.transformInlineContent(e.content)
|
|
120
120
|
] });
|
|
121
121
|
},
|
|
@@ -133,37 +133,37 @@ const L = (e) => Array.from({ length: e }, () => /* @__PURE__ */ n("text:tab", {
|
|
|
133
133
|
"> ",
|
|
134
134
|
t.transformInlineContent(e.content)
|
|
135
135
|
] }),
|
|
136
|
-
bulletListItem: (e, t,
|
|
137
|
-
const s =
|
|
136
|
+
bulletListItem: (e, t, n) => {
|
|
137
|
+
const s = g(
|
|
138
138
|
t,
|
|
139
139
|
e.props,
|
|
140
140
|
"Standard",
|
|
141
141
|
{ "style:list-style-name": "WWNum1" }
|
|
142
142
|
);
|
|
143
|
-
return /* @__PURE__ */
|
|
144
|
-
/* @__PURE__ */
|
|
145
|
-
|
|
143
|
+
return /* @__PURE__ */ l("text:list", { "text:style-name": "WWNum1", children: /* @__PURE__ */ l("text:list-item", { children: S(
|
|
144
|
+
/* @__PURE__ */ l("text:p", { "text:style-name": s, children: t.transformInlineContent(e.content) }),
|
|
145
|
+
n
|
|
146
146
|
) }) });
|
|
147
147
|
},
|
|
148
|
-
numberedListItem: (e, t,
|
|
149
|
-
const a =
|
|
148
|
+
numberedListItem: (e, t, n, s) => {
|
|
149
|
+
const a = g(
|
|
150
150
|
t,
|
|
151
151
|
e.props
|
|
152
152
|
), o = (s || 0) > 1 ? "true" : "false";
|
|
153
|
-
return /* @__PURE__ */
|
|
153
|
+
return /* @__PURE__ */ l(
|
|
154
154
|
"text:list",
|
|
155
155
|
{
|
|
156
156
|
"text:style-name": "No_20_List",
|
|
157
157
|
"text:continue-numbering": o,
|
|
158
|
-
children: /* @__PURE__ */
|
|
158
|
+
children: /* @__PURE__ */ l(
|
|
159
159
|
"text:list-item",
|
|
160
160
|
{
|
|
161
161
|
...o === "false" && {
|
|
162
162
|
"text:start-value": e.props.start
|
|
163
163
|
},
|
|
164
164
|
children: S(
|
|
165
|
-
/* @__PURE__ */
|
|
166
|
-
|
|
165
|
+
/* @__PURE__ */ l("text:p", { "text:style-name": a, children: t.transformInlineContent(e.content) }),
|
|
166
|
+
n
|
|
167
167
|
)
|
|
168
168
|
}
|
|
169
169
|
)
|
|
@@ -174,13 +174,48 @@ const L = (e) => Array.from({ length: e }, () => /* @__PURE__ */ n("text:tab", {
|
|
|
174
174
|
e.props.checked ? "☒ " : "☐ ",
|
|
175
175
|
t.transformInlineContent(e.content)
|
|
176
176
|
] }),
|
|
177
|
-
pageBreak: async () => /* @__PURE__ */
|
|
177
|
+
pageBreak: async () => /* @__PURE__ */ l("text:p", { "text:style-name": "PageBreak" }),
|
|
178
|
+
column: (e, t, n, s, a) => {
|
|
179
|
+
const y = t.registerStyle((i) => /* @__PURE__ */ l("style:style", { "style:name": i, "style:family": "table-cell", children: /* @__PURE__ */ l(
|
|
180
|
+
"style:table-cell-properties",
|
|
181
|
+
{
|
|
182
|
+
"style:writing-mode": "lr-tb",
|
|
183
|
+
"fo:border": "none",
|
|
184
|
+
"fo:padding-top": "0in",
|
|
185
|
+
"fo:padding-left": "0.075in",
|
|
186
|
+
"fo:padding-bottom": "0in",
|
|
187
|
+
"fo:padding-right": "0.075in"
|
|
188
|
+
}
|
|
189
|
+
) }));
|
|
190
|
+
return /* @__PURE__ */ l("table:table-cell", { "table:style-name": y, children: a });
|
|
191
|
+
},
|
|
192
|
+
columnList: (e, t, n, s, a) => {
|
|
193
|
+
const o = e, y = t, i = y.registerStyle((r) => /* @__PURE__ */ l("style:style", { "style:name": r, "style:family": "table", children: /* @__PURE__ */ l(
|
|
194
|
+
"style:table-properties",
|
|
195
|
+
{
|
|
196
|
+
"table:align": "margins",
|
|
197
|
+
"style:writing-mode": "lr-tb"
|
|
198
|
+
}
|
|
199
|
+
) }));
|
|
200
|
+
return /* @__PURE__ */ f("table:table", { "table:name": e.id, "table:style-name": i, children: [
|
|
201
|
+
(o.children || []).map((r, m) => {
|
|
202
|
+
const x = y.registerStyle((d) => /* @__PURE__ */ l("style:style", { "style:name": d, "style:family": "table-column", children: /* @__PURE__ */ l(
|
|
203
|
+
"style:table-column-properties",
|
|
204
|
+
{
|
|
205
|
+
"style:rel-column-width": `${r.props.width * 100}*`
|
|
206
|
+
}
|
|
207
|
+
) }));
|
|
208
|
+
return /* @__PURE__ */ l("table:table-column", { "table:style-name": x }, m);
|
|
209
|
+
}),
|
|
210
|
+
/* @__PURE__ */ l("table:table-row", { children: a })
|
|
211
|
+
] });
|
|
212
|
+
},
|
|
178
213
|
image: async (e, t) => {
|
|
179
|
-
const
|
|
214
|
+
const n = t, { path: s, mimeType: a, ...o } = await n.registerPicture(e.props.url), y = g(
|
|
180
215
|
t,
|
|
181
216
|
e.props
|
|
182
|
-
), i = e.props.previewWidth || o.width, r = o.height / o.width * i,
|
|
183
|
-
/* @__PURE__ */
|
|
217
|
+
), i = e.props.previewWidth || o.width, r = o.height / o.width * i, m = 20, x = /* @__PURE__ */ f("text:p", { "text:style-name": e.props.caption ? "Caption" : y, children: [
|
|
218
|
+
/* @__PURE__ */ l(
|
|
184
219
|
"draw:frame",
|
|
185
220
|
{
|
|
186
221
|
"draw:style-name": "Frame",
|
|
@@ -191,7 +226,7 @@ const L = (e) => Array.from({ length: e }, () => /* @__PURE__ */ n("text:tab", {
|
|
|
191
226
|
...!e.props.caption && {
|
|
192
227
|
"text:anchor-type": "as-char"
|
|
193
228
|
},
|
|
194
|
-
children: /* @__PURE__ */
|
|
229
|
+
children: /* @__PURE__ */ l(
|
|
195
230
|
"draw:image",
|
|
196
231
|
{
|
|
197
232
|
"xlink:type": "simple",
|
|
@@ -203,67 +238,67 @@ const L = (e) => Array.from({ length: e }, () => /* @__PURE__ */ n("text:tab", {
|
|
|
203
238
|
)
|
|
204
239
|
}
|
|
205
240
|
),
|
|
206
|
-
/* @__PURE__ */
|
|
207
|
-
/* @__PURE__ */
|
|
241
|
+
/* @__PURE__ */ l("text:line-break", {}),
|
|
242
|
+
/* @__PURE__ */ l("text:span", { "text:style-name": "Caption", children: e.props.caption })
|
|
208
243
|
] });
|
|
209
|
-
return e.props.caption ? /* @__PURE__ */
|
|
244
|
+
return e.props.caption ? /* @__PURE__ */ l("text:p", { "text:style-name": y, children: /* @__PURE__ */ l(
|
|
210
245
|
"draw:frame",
|
|
211
246
|
{
|
|
212
247
|
"draw:style-name": "Frame",
|
|
213
248
|
"style:rel-height": "scale",
|
|
214
249
|
"style:rel-width": `${i}px`,
|
|
215
250
|
"svg:width": `${i}px`,
|
|
216
|
-
"svg:height": `${r +
|
|
251
|
+
"svg:height": `${r + m}px`,
|
|
217
252
|
"text:anchor-type": "as-char",
|
|
218
|
-
children: /* @__PURE__ */
|
|
253
|
+
children: /* @__PURE__ */ l("draw:text-box", { children: x })
|
|
219
254
|
}
|
|
220
255
|
) }) : x;
|
|
221
256
|
},
|
|
222
257
|
table: (e, t) => {
|
|
223
258
|
var r;
|
|
224
259
|
const a = (e.content.columnWidths.reduce(
|
|
225
|
-
(
|
|
260
|
+
(m, x) => (m || 0) + (x || 120),
|
|
226
261
|
0
|
|
227
|
-
) || 0) * 0.75, o = t,
|
|
262
|
+
) || 0) * 0.75, o = t, y = A(o), i = P(o, { width: a });
|
|
228
263
|
return /* @__PURE__ */ f("table:table", { "table:name": e.id, "table:style-name": i, children: [
|
|
229
|
-
(r = e.content.rows[0]) == null ? void 0 : r.cells.map((
|
|
230
|
-
const
|
|
264
|
+
(r = e.content.rows[0]) == null ? void 0 : r.cells.map((m, x) => {
|
|
265
|
+
const u = (e.content.columnWidths[x] || 120) * 0.75, c = o.registerStyle((_) => /* @__PURE__ */ l("style:style", { "style:name": _, "style:family": "table-column", children: /* @__PURE__ */ l(
|
|
231
266
|
"style:table-column-properties",
|
|
232
267
|
{
|
|
233
|
-
"style:column-width": `${
|
|
268
|
+
"style:column-width": `${u}pt`
|
|
234
269
|
}
|
|
235
270
|
) }));
|
|
236
|
-
return /* @__PURE__ */
|
|
271
|
+
return /* @__PURE__ */ l("table:table-column", { "table:style-name": c }, x);
|
|
237
272
|
}),
|
|
238
|
-
e.content.rows.map((
|
|
239
|
-
const c = T(
|
|
240
|
-
return /* @__PURE__ */
|
|
273
|
+
e.content.rows.map((m, x) => /* @__PURE__ */ l("table:table-row", { children: m.cells.map((d, u) => {
|
|
274
|
+
const c = T(d);
|
|
275
|
+
return /* @__PURE__ */ l(
|
|
241
276
|
"table:table-cell",
|
|
242
277
|
{
|
|
243
|
-
"table:style-name":
|
|
278
|
+
"table:style-name": y(c),
|
|
244
279
|
"office:value-type": "string",
|
|
245
280
|
"style:text-align-source": "fix",
|
|
246
281
|
"style:paragraph-properties-text-align": c.props.textAlignment,
|
|
247
|
-
children: /* @__PURE__ */
|
|
282
|
+
children: /* @__PURE__ */ l("text:p", { "text:style-name": "Standard", children: t.transformInlineContent(c.content) })
|
|
248
283
|
},
|
|
249
|
-
`${x}-${
|
|
284
|
+
`${x}-${u}`
|
|
250
285
|
);
|
|
251
286
|
}) }, x))
|
|
252
287
|
] });
|
|
253
288
|
},
|
|
254
289
|
codeBlock: (e) => {
|
|
255
|
-
var
|
|
256
|
-
const t = ((
|
|
290
|
+
var n;
|
|
291
|
+
const t = ((n = e.content[0]) == null ? void 0 : n.text) || "";
|
|
257
292
|
return /* @__PURE__ */ f("text:p", { "text:style-name": "Codeblock", children: [
|
|
258
293
|
...t.split(`
|
|
259
294
|
`).map((s, a) => /* @__PURE__ */ f(h, { children: [
|
|
260
|
-
a !== 0 && /* @__PURE__ */
|
|
295
|
+
a !== 0 && /* @__PURE__ */ l("text:line-break", {}),
|
|
261
296
|
s
|
|
262
297
|
] }))
|
|
263
298
|
] });
|
|
264
299
|
},
|
|
265
300
|
file: async (e) => /* @__PURE__ */ f(h, { children: [
|
|
266
|
-
/* @__PURE__ */
|
|
301
|
+
/* @__PURE__ */ l("text:p", { "style:style-name": "Standard", children: e.props.url ? /* @__PURE__ */ l(
|
|
267
302
|
"text:a",
|
|
268
303
|
{
|
|
269
304
|
"xlink:type": "simple",
|
|
@@ -271,13 +306,13 @@ const L = (e) => Array.from({ length: e }, () => /* @__PURE__ */ n("text:tab", {
|
|
|
271
306
|
"office:target-frame-name": "_top",
|
|
272
307
|
"xlink:show": "replace",
|
|
273
308
|
"xlink:href": e.props.url,
|
|
274
|
-
children: /* @__PURE__ */
|
|
309
|
+
children: /* @__PURE__ */ l("text:span", { "text:style-name": "Internet_20_link", children: "Open file" })
|
|
275
310
|
}
|
|
276
311
|
) : "Open file" }),
|
|
277
|
-
e.props.caption && /* @__PURE__ */
|
|
312
|
+
e.props.caption && /* @__PURE__ */ l("text:p", { "text:style-name": "Caption", children: e.props.caption })
|
|
278
313
|
] }),
|
|
279
314
|
video: (e) => /* @__PURE__ */ f(h, { children: [
|
|
280
|
-
/* @__PURE__ */
|
|
315
|
+
/* @__PURE__ */ l("text:p", { "style:style-name": "Standard", children: /* @__PURE__ */ l(
|
|
281
316
|
"text:a",
|
|
282
317
|
{
|
|
283
318
|
"xlink:type": "simple",
|
|
@@ -285,13 +320,13 @@ const L = (e) => Array.from({ length: e }, () => /* @__PURE__ */ n("text:tab", {
|
|
|
285
320
|
"office:target-frame-name": "_top",
|
|
286
321
|
"xlink:show": "replace",
|
|
287
322
|
"xlink:href": e.props.url,
|
|
288
|
-
children: /* @__PURE__ */
|
|
323
|
+
children: /* @__PURE__ */ l("text:span", { "text:style-name": "Internet_20_link", children: "Open video" })
|
|
289
324
|
}
|
|
290
325
|
) }),
|
|
291
|
-
e.props.caption && /* @__PURE__ */
|
|
326
|
+
e.props.caption && /* @__PURE__ */ l("text:p", { "text:style-name": "Caption", children: e.props.caption })
|
|
292
327
|
] }),
|
|
293
328
|
audio: (e) => /* @__PURE__ */ f(h, { children: [
|
|
294
|
-
/* @__PURE__ */
|
|
329
|
+
/* @__PURE__ */ l("text:p", { "style:style-name": "Standard", children: /* @__PURE__ */ l(
|
|
295
330
|
"text:a",
|
|
296
331
|
{
|
|
297
332
|
"xlink:type": "simple",
|
|
@@ -299,15 +334,15 @@ const L = (e) => Array.from({ length: e }, () => /* @__PURE__ */ n("text:tab", {
|
|
|
299
334
|
"office:target-frame-name": "_top",
|
|
300
335
|
"xlink:show": "replace",
|
|
301
336
|
"xlink:href": e.props.url,
|
|
302
|
-
children: /* @__PURE__ */
|
|
337
|
+
children: /* @__PURE__ */ l("text:span", { "text:style-name": "Internet_20_link", children: "Open audio" })
|
|
303
338
|
}
|
|
304
339
|
) }),
|
|
305
|
-
e.props.caption && /* @__PURE__ */
|
|
340
|
+
e.props.caption && /* @__PURE__ */ l("text:p", { "text:style-name": "Caption", children: e.props.caption })
|
|
306
341
|
] })
|
|
307
342
|
}, R = {
|
|
308
343
|
link: (e, t) => {
|
|
309
|
-
const
|
|
310
|
-
return /* @__PURE__ */
|
|
344
|
+
const n = e.content.map((s) => t.transformStyledText(s));
|
|
345
|
+
return /* @__PURE__ */ l(
|
|
311
346
|
"text:a",
|
|
312
347
|
{
|
|
313
348
|
"xlink:type": "simple",
|
|
@@ -315,7 +350,7 @@ const L = (e) => Array.from({ length: e }, () => /* @__PURE__ */ n("text:tab", {
|
|
|
315
350
|
"office:target-frame-name": "_top",
|
|
316
351
|
"xlink:show": "replace",
|
|
317
352
|
"xlink:href": e.href,
|
|
318
|
-
children:
|
|
353
|
+
children: n
|
|
319
354
|
}
|
|
320
355
|
);
|
|
321
356
|
},
|
|
@@ -341,10 +376,10 @@ async function H(e) {
|
|
|
341
376
|
}
|
|
342
377
|
async function U(e) {
|
|
343
378
|
if (typeof window < "u") {
|
|
344
|
-
const t = await createImageBitmap(e), { width:
|
|
345
|
-
return t.close(), { width:
|
|
379
|
+
const t = await createImageBitmap(e), { width: n, height: s } = t;
|
|
380
|
+
return t.close(), { width: n, height: s };
|
|
346
381
|
} else {
|
|
347
|
-
const t = (await import("image-meta")).imageMeta,
|
|
382
|
+
const t = (await import("image-meta")).imageMeta, n = new Uint8Array(await e.arrayBuffer()), s = t(n);
|
|
348
383
|
if (!s.width || !s.height)
|
|
349
384
|
throw new Error("Image dimensions not found");
|
|
350
385
|
return { width: s.width, height: s.height };
|
|
@@ -1429,23 +1464,23 @@ const j = `<?xml version="1.0" encoding="UTF-8"?>
|
|
|
1429
1464
|
</office:master-styles>
|
|
1430
1465
|
</office:document-styles>`;
|
|
1431
1466
|
class K extends M {
|
|
1432
|
-
constructor(
|
|
1467
|
+
constructor(n, s, a) {
|
|
1433
1468
|
const o = {
|
|
1434
1469
|
colors: B
|
|
1435
1470
|
};
|
|
1436
|
-
super(
|
|
1471
|
+
super(n, s, { ...o, ...a });
|
|
1437
1472
|
// "Styles" to be added to the AutomaticStyles section of the ODT file
|
|
1438
1473
|
// Keyed by the style name
|
|
1439
|
-
|
|
1474
|
+
b(this, "automaticStyles", /* @__PURE__ */ new Map());
|
|
1440
1475
|
// "Pictures" to be added to the Pictures folder in the ODT file
|
|
1441
1476
|
// Keyed by the original image URL
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
this.schema =
|
|
1477
|
+
b(this, "pictures", /* @__PURE__ */ new Map());
|
|
1478
|
+
b(this, "styleCounter", 0);
|
|
1479
|
+
b(this, "options");
|
|
1480
|
+
this.schema = n, this.options = { ...o, ...a };
|
|
1446
1481
|
}
|
|
1447
1482
|
async loadFonts() {
|
|
1448
|
-
const
|
|
1483
|
+
const n = await H(
|
|
1449
1484
|
await import("./Inter_18pt-Regular-byxnNS-8.js")
|
|
1450
1485
|
), s = await H(
|
|
1451
1486
|
await import("./GeistMono-Regular-D4rKXxwr.js")
|
|
@@ -1454,7 +1489,7 @@ class K extends M {
|
|
|
1454
1489
|
{
|
|
1455
1490
|
name: "Inter 18pt",
|
|
1456
1491
|
fileName: "Inter_18pt-Regular.ttf",
|
|
1457
|
-
data: new Blob([
|
|
1492
|
+
data: new Blob([n], { type: "font/ttf" })
|
|
1458
1493
|
},
|
|
1459
1494
|
{
|
|
1460
1495
|
name: "Geist Mono",
|
|
@@ -1463,39 +1498,48 @@ class K extends M {
|
|
|
1463
1498
|
}
|
|
1464
1499
|
];
|
|
1465
1500
|
}
|
|
1466
|
-
transformStyledText(
|
|
1467
|
-
const s = this.mapStyles(
|
|
1501
|
+
transformStyledText(n) {
|
|
1502
|
+
const s = this.mapStyles(n.styles), a = Object.assign({}, ...s);
|
|
1468
1503
|
if (Object.keys(a).length === 0)
|
|
1469
|
-
return
|
|
1504
|
+
return n.text;
|
|
1470
1505
|
const o = `BN_T${++this.styleCounter}`;
|
|
1471
1506
|
return this.automaticStyles.set(
|
|
1472
1507
|
o,
|
|
1473
|
-
/* @__PURE__ */
|
|
1474
|
-
), /* @__PURE__ */
|
|
1508
|
+
/* @__PURE__ */ l("style:style", { "style:name": o, "style:family": "text", children: /* @__PURE__ */ l("style:text-properties", { ...a }) })
|
|
1509
|
+
), /* @__PURE__ */ l("text:span", { "text:style-name": o, children: n.text });
|
|
1475
1510
|
}
|
|
1476
|
-
async transformBlocks(
|
|
1511
|
+
async transformBlocks(n, s = 0) {
|
|
1477
1512
|
const a = [];
|
|
1478
1513
|
let o = 0;
|
|
1479
|
-
for (const
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1514
|
+
for (const y of n)
|
|
1515
|
+
if (y.type === "numberedListItem" ? o++ : o = 0, ["columnList", "column"].includes(y.type)) {
|
|
1516
|
+
const i = await this.transformBlocks(y.children, 0), r = await this.mapBlock(
|
|
1517
|
+
y,
|
|
1518
|
+
0,
|
|
1519
|
+
o,
|
|
1520
|
+
i
|
|
1521
|
+
);
|
|
1522
|
+
a.push(r);
|
|
1523
|
+
} else {
|
|
1524
|
+
const i = await this.transformBlocks(
|
|
1525
|
+
y.children,
|
|
1526
|
+
s + 1
|
|
1527
|
+
), r = await this.mapBlock(
|
|
1528
|
+
y,
|
|
1529
|
+
s,
|
|
1530
|
+
o,
|
|
1531
|
+
i
|
|
1532
|
+
);
|
|
1533
|
+
a.push(r), i.length > 0 && a.push(...i);
|
|
1534
|
+
}
|
|
1491
1535
|
return a;
|
|
1492
1536
|
}
|
|
1493
|
-
async toODTDocument(
|
|
1537
|
+
async toODTDocument(n, s) {
|
|
1494
1538
|
const a = (p) => {
|
|
1495
1539
|
const z = /<([a-zA-Z0-9:]+)\s+?(?:xml)ns(?::[a-zA-Z0-9]+)?=".*"(.*)>/g;
|
|
1496
1540
|
let w = "";
|
|
1497
1541
|
return typeof p == "string" ? w = p : w = new XMLSerializer().serializeToString(p), w.replace(z, "<$1$2>");
|
|
1498
|
-
}, o = await this.transformBlocks(
|
|
1542
|
+
}, o = await this.transformBlocks(n), y = Array.from(this.automaticStyles.values()), i = Array.from(this.pictures.values()), r = await this.loadFonts(), m = a((s == null ? void 0 : s.header) || ""), x = a((s == null ? void 0 : s.footer) || ""), d = /* @__PURE__ */ f(
|
|
1499
1543
|
"office:document-content",
|
|
1500
1544
|
{
|
|
1501
1545
|
"xmlns:office": "urn:oasis:names:tc:opendocument:xmlns:office:1.0",
|
|
@@ -1509,41 +1553,41 @@ class K extends M {
|
|
|
1509
1553
|
"xmlns:loext": "urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0",
|
|
1510
1554
|
"office:version": "1.3",
|
|
1511
1555
|
children: [
|
|
1512
|
-
/* @__PURE__ */
|
|
1556
|
+
/* @__PURE__ */ l("office:font-face-decls", { children: r.map((p) => /* @__PURE__ */ l(
|
|
1513
1557
|
"style:font-face",
|
|
1514
1558
|
{
|
|
1515
1559
|
"style:name": p.name,
|
|
1516
1560
|
"svg:font-family": p.name,
|
|
1517
1561
|
"style:font-pitch": "variable",
|
|
1518
|
-
children: /* @__PURE__ */
|
|
1562
|
+
children: /* @__PURE__ */ l("svg:font-face-src", { children: /* @__PURE__ */ l(
|
|
1519
1563
|
"svg:font-face-uri",
|
|
1520
1564
|
{
|
|
1521
1565
|
"xlink:href": `Fonts/${p.fileName}`,
|
|
1522
1566
|
"xlink:type": "simple",
|
|
1523
1567
|
"loext:font-style": "normal",
|
|
1524
1568
|
"loext:font-weight": "normal",
|
|
1525
|
-
children: /* @__PURE__ */
|
|
1569
|
+
children: /* @__PURE__ */ l("svg:font-face-format", { "svg:string": "truetype" })
|
|
1526
1570
|
}
|
|
1527
1571
|
) })
|
|
1528
1572
|
}
|
|
1529
1573
|
)) }),
|
|
1530
|
-
/* @__PURE__ */
|
|
1531
|
-
(
|
|
1574
|
+
/* @__PURE__ */ l("office:automatic-styles", { children: y }),
|
|
1575
|
+
(m || x) && /* @__PURE__ */ l("office:master-styles", { children: /* @__PURE__ */ f(
|
|
1532
1576
|
"style:master-page",
|
|
1533
1577
|
{
|
|
1534
1578
|
"style:name": "Standard",
|
|
1535
1579
|
"style:page-layout-name": "Mpm1",
|
|
1536
1580
|
"draw:style-name": "Mdp1",
|
|
1537
1581
|
children: [
|
|
1538
|
-
|
|
1582
|
+
m && /* @__PURE__ */ l(
|
|
1539
1583
|
"style:header",
|
|
1540
1584
|
{
|
|
1541
1585
|
dangerouslySetInnerHTML: {
|
|
1542
|
-
__html:
|
|
1586
|
+
__html: m
|
|
1543
1587
|
}
|
|
1544
1588
|
}
|
|
1545
1589
|
),
|
|
1546
|
-
x && /* @__PURE__ */
|
|
1590
|
+
x && /* @__PURE__ */ l(
|
|
1547
1591
|
"style:footer",
|
|
1548
1592
|
{
|
|
1549
1593
|
dangerouslySetInnerHTML: {
|
|
@@ -1554,44 +1598,44 @@ class K extends M {
|
|
|
1554
1598
|
]
|
|
1555
1599
|
}
|
|
1556
1600
|
) }),
|
|
1557
|
-
/* @__PURE__ */
|
|
1601
|
+
/* @__PURE__ */ l("office:body", { children: /* @__PURE__ */ l("office:text", { children: o }) })
|
|
1558
1602
|
]
|
|
1559
1603
|
}
|
|
1560
|
-
),
|
|
1604
|
+
), u = /* @__PURE__ */ f(
|
|
1561
1605
|
"manifest:manifest",
|
|
1562
1606
|
{
|
|
1563
1607
|
"xmlns:manifest": "urn:oasis:names:tc:opendocument:xmlns:manifest:1.0",
|
|
1564
1608
|
"manifest:version": "1.3",
|
|
1565
1609
|
children: [
|
|
1566
|
-
/* @__PURE__ */
|
|
1610
|
+
/* @__PURE__ */ l(
|
|
1567
1611
|
"manifest:file-entry",
|
|
1568
1612
|
{
|
|
1569
1613
|
"manifest:media-type": "application/vnd.oasis.opendocument.text",
|
|
1570
1614
|
"manifest:full-path": "/"
|
|
1571
1615
|
}
|
|
1572
1616
|
),
|
|
1573
|
-
/* @__PURE__ */
|
|
1617
|
+
/* @__PURE__ */ l(
|
|
1574
1618
|
"manifest:file-entry",
|
|
1575
1619
|
{
|
|
1576
1620
|
"manifest:media-type": "text/xml",
|
|
1577
1621
|
"manifest:full-path": "content.xml"
|
|
1578
1622
|
}
|
|
1579
1623
|
),
|
|
1580
|
-
/* @__PURE__ */
|
|
1624
|
+
/* @__PURE__ */ l(
|
|
1581
1625
|
"manifest:file-entry",
|
|
1582
1626
|
{
|
|
1583
1627
|
"manifest:media-type": "text/xml",
|
|
1584
1628
|
"manifest:full-path": "styles.xml"
|
|
1585
1629
|
}
|
|
1586
1630
|
),
|
|
1587
|
-
i.map((p) => /* @__PURE__ */
|
|
1631
|
+
i.map((p) => /* @__PURE__ */ l(
|
|
1588
1632
|
"manifest:file-entry",
|
|
1589
1633
|
{
|
|
1590
1634
|
"manifest:media-type": p.file.type,
|
|
1591
1635
|
"manifest:full-path": `Pictures/${p.fileName}`
|
|
1592
1636
|
}
|
|
1593
1637
|
)),
|
|
1594
|
-
r.map((p) => /* @__PURE__ */
|
|
1638
|
+
r.map((p) => /* @__PURE__ */ l(
|
|
1595
1639
|
"manifest:file-entry",
|
|
1596
1640
|
{
|
|
1597
1641
|
"manifest:media-type": "application/x-font-ttf",
|
|
@@ -1601,7 +1645,7 @@ class K extends M {
|
|
|
1601
1645
|
]
|
|
1602
1646
|
}
|
|
1603
1647
|
), c = new $(
|
|
1604
|
-
new
|
|
1648
|
+
new W("application/vnd.oasis.opendocument.text")
|
|
1605
1649
|
);
|
|
1606
1650
|
c.add(
|
|
1607
1651
|
"mimetype",
|
|
@@ -1613,7 +1657,7 @@ class K extends M {
|
|
|
1613
1657
|
extendedTimestamp: !1
|
|
1614
1658
|
}
|
|
1615
1659
|
);
|
|
1616
|
-
const _ = C(
|
|
1660
|
+
const _ = C(d), F = C(u);
|
|
1617
1661
|
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) => {
|
|
1618
1662
|
c.add(`Fonts/${p.fileName}`, new k(p.data));
|
|
1619
1663
|
}), i.forEach((p) => {
|
|
@@ -1623,11 +1667,11 @@ class K extends M {
|
|
|
1623
1667
|
);
|
|
1624
1668
|
}), c.close();
|
|
1625
1669
|
}
|
|
1626
|
-
registerStyle(
|
|
1670
|
+
registerStyle(n) {
|
|
1627
1671
|
const s = `BN_S${++this.styleCounter}`;
|
|
1628
|
-
return this.automaticStyles.set(s,
|
|
1672
|
+
return this.automaticStyles.set(s, n(s)), s;
|
|
1629
1673
|
}
|
|
1630
|
-
async registerPicture(
|
|
1674
|
+
async registerPicture(n) {
|
|
1631
1675
|
const s = {
|
|
1632
1676
|
"image/apng": "apng",
|
|
1633
1677
|
"image/avif": "avif",
|
|
@@ -1640,22 +1684,22 @@ class K extends M {
|
|
|
1640
1684
|
"image/tiff": "tiff",
|
|
1641
1685
|
"image/webp": "webp"
|
|
1642
1686
|
};
|
|
1643
|
-
if (this.pictures.has(
|
|
1644
|
-
const
|
|
1687
|
+
if (this.pictures.has(n)) {
|
|
1688
|
+
const m = this.pictures.get(n);
|
|
1645
1689
|
return {
|
|
1646
|
-
path: `Pictures/${
|
|
1647
|
-
mimeType:
|
|
1648
|
-
height:
|
|
1649
|
-
width:
|
|
1690
|
+
path: `Pictures/${m.fileName}`,
|
|
1691
|
+
mimeType: m.file.type,
|
|
1692
|
+
height: m.height,
|
|
1693
|
+
width: m.width
|
|
1650
1694
|
};
|
|
1651
1695
|
}
|
|
1652
|
-
const a = await this.resolveFile(
|
|
1653
|
-
return this.pictures.set(
|
|
1696
|
+
const a = await this.resolveFile(n), o = s[a.type] || "png", y = `picture-${this.pictures.size}.${o}`, { width: i, height: r } = await U(a);
|
|
1697
|
+
return this.pictures.set(n, {
|
|
1654
1698
|
file: a,
|
|
1655
|
-
fileName:
|
|
1699
|
+
fileName: y,
|
|
1656
1700
|
height: r,
|
|
1657
1701
|
width: i
|
|
1658
|
-
}), { path: `Pictures/${
|
|
1702
|
+
}), { path: `Pictures/${y}`, mimeType: a.type, height: r, width: i };
|
|
1659
1703
|
}
|
|
1660
1704
|
}
|
|
1661
1705
|
export {
|