@blocknote/xl-odt-exporter 0.29.1 → 0.30.1
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 +1 -1
- package/dist/blocknote-xl-odt-exporter.js.map +1 -1
- package/dist/blocknote-xl-odt-exporter.umd.cjs +1 -1
- package/dist/blocknote-xl-odt-exporter.umd.cjs.map +1 -1
- package/dist/webpack-stats.json +1 -1
- package/package.json +4 -4
- package/src/odt/__snapshots__/basic/content.xml +2 -2
- package/src/odt/__snapshots__/withCustomOptions/content.xml +2 -2
- package/src/odt/defaultSchema/blocks.tsx +34 -24
- package/src/odt/defaultSchema/inlineContent.tsx +2 -1
- package/src/odt/odtExporter.test.ts +7 -7
- package/src/odt/odtExporter.tsx +26 -19
- package/src/odt/util/jsx.d.ts +2 -2
- package/types/src/odt/defaultSchema/index.d.ts +8 -4
package/dist/webpack-stats.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"builtAt":
|
|
1
|
+
{"builtAt":1747749761795,"assets":[{"name":"blocknote-xl-odt-exporter.umd.cjs","size":698981},{"name":"blocknote-xl-odt-exporter.umd.cjs.map","size":747283}],"chunks":[{"id":"642be88","entry":true,"initial":true,"files":["blocknote-xl-odt-exporter.umd.cjs"],"names":["index"]}],"modules":[{"name":"./src/odt/defaultSchema/blocks.tsx","size":14213,"chunks":["642be88"]},{"name":"./src/odt/defaultSchema/inlineContent.tsx","size":533,"chunks":["642be88"]},{"name":"./src/odt/defaultSchema/styles.ts","size":963,"chunks":["642be88"]},{"name":"./src/odt/defaultSchema/index.ts","size":199,"chunks":["642be88"]},{"name":"../../shared/util/fileUtil.ts","size":214,"chunks":["642be88"]},{"name":"../../shared/util/imageUtil.ts","size":592,"chunks":["642be88"]},{"name":"./src/odt/template/styles.xml?raw","size":76781,"chunks":["642be88"]},{"name":"./src/odt/odtExporter.tsx","size":9974,"chunks":["642be88"]},{"name":"./src/index.ts","size":0,"chunks":["642be88"]},{"name":"../../shared/assets/fonts/inter/Inter_18pt-Regular.ttf","size":456958,"chunks":["642be88"]},{"name":"../../shared/assets/fonts/GeistMono-Regular.ttf","size":155049,"chunks":["642be88"]}]}
|
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"directory": "packages/xl-odt-exporter"
|
|
10
10
|
},
|
|
11
11
|
"license": "AGPL-3.0 OR PROPRIETARY",
|
|
12
|
-
"version": "0.
|
|
12
|
+
"version": "0.30.1",
|
|
13
13
|
"files": [
|
|
14
14
|
"dist",
|
|
15
15
|
"types",
|
|
@@ -44,11 +44,12 @@
|
|
|
44
44
|
},
|
|
45
45
|
"./style.css": {
|
|
46
46
|
"import": "./dist/style.css",
|
|
47
|
-
"require": "./dist/style.css"
|
|
47
|
+
"require": "./dist/style.css",
|
|
48
|
+
"style": "./dist/style.css"
|
|
48
49
|
}
|
|
49
50
|
},
|
|
50
51
|
"dependencies": {
|
|
51
|
-
"@blocknote/core": "0.
|
|
52
|
+
"@blocknote/core": "0.30.1",
|
|
52
53
|
"@zip.js/zip.js": "^2.7.57",
|
|
53
54
|
"buffer": "^6.0.3",
|
|
54
55
|
"image-meta": "^0.2.1"
|
|
@@ -57,7 +58,6 @@
|
|
|
57
58
|
"@testing-library/react": "^16.0.1",
|
|
58
59
|
"@types/react": "^18.0.25",
|
|
59
60
|
"@types/react-dom": "^18.0.9",
|
|
60
|
-
"prettier": "^2.7.1",
|
|
61
61
|
"rollup-plugin-webpack-stats": "^0.2.2",
|
|
62
62
|
"typescript": "^5.0.4",
|
|
63
63
|
"vite": "^5.3.4",
|
|
@@ -313,10 +313,10 @@
|
|
|
313
313
|
Open file
|
|
314
314
|
</text:p>
|
|
315
315
|
<text:p text:style-name="Standard">
|
|
316
|
-
<draw:frame draw:style-name="Frame" style:rel-height="scale" style:rel-width="
|
|
316
|
+
<draw:frame draw:style-name="Frame" style:rel-height="scale" style:rel-width="332px" svg:width="332px" svg:height="352px" text:anchor-type="as-char">
|
|
317
317
|
<draw:text-box>
|
|
318
318
|
<text:p text:style-name="Caption">
|
|
319
|
-
<draw:frame draw:style-name="Frame" style:rel-height="scale" svg:width="
|
|
319
|
+
<draw:frame draw:style-name="Frame" style:rel-height="scale" svg:width="332px" svg:height="332px" style:rel-width="100%">
|
|
320
320
|
<draw:image xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad" xlink:href="Pictures/picture-0.jpg" draw:mime-type="image/jpeg"></draw:image>
|
|
321
321
|
</draw:frame>
|
|
322
322
|
<text:line-break></text:line-break>
|
|
@@ -327,10 +327,10 @@
|
|
|
327
327
|
Open file
|
|
328
328
|
</text:p>
|
|
329
329
|
<text:p text:style-name="Standard">
|
|
330
|
-
<draw:frame draw:style-name="Frame" style:rel-height="scale" style:rel-width="
|
|
330
|
+
<draw:frame draw:style-name="Frame" style:rel-height="scale" style:rel-width="332px" svg:width="332px" svg:height="352px" text:anchor-type="as-char">
|
|
331
331
|
<draw:text-box>
|
|
332
332
|
<text:p text:style-name="Caption">
|
|
333
|
-
<draw:frame draw:style-name="Frame" style:rel-height="scale" svg:width="
|
|
333
|
+
<draw:frame draw:style-name="Frame" style:rel-height="scale" svg:width="332px" svg:height="332px" style:rel-width="100%">
|
|
334
334
|
<draw:image xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad" xlink:href="Pictures/picture-0.jpg" draw:mime-type="image/jpeg"></draw:image>
|
|
335
335
|
</draw:frame>
|
|
336
336
|
<text:line-break></text:line-break>
|
|
@@ -19,7 +19,7 @@ const createParagraphStyle = (
|
|
|
19
19
|
parentStyleName = "Standard",
|
|
20
20
|
styleAttributes: Record<string, string> = {},
|
|
21
21
|
paragraphStyleAttributes: Record<string, string> = {},
|
|
22
|
-
textStyleAttributes: Record<string, string> = {}
|
|
22
|
+
textStyleAttributes: Record<string, string> = {},
|
|
23
23
|
) => {
|
|
24
24
|
const paragraphStyles: Record<string, string> = {
|
|
25
25
|
...paragraphStyleAttributes,
|
|
@@ -70,7 +70,8 @@ const createParagraphStyle = (
|
|
|
70
70
|
style:family="paragraph"
|
|
71
71
|
style:name={name}
|
|
72
72
|
style:parent-style-name={parentStyleName}
|
|
73
|
-
{...styleAttributes}
|
|
73
|
+
{...styleAttributes}
|
|
74
|
+
>
|
|
74
75
|
{backgroundColor && (
|
|
75
76
|
<loext:graphic-properties
|
|
76
77
|
draw:fill="solid"
|
|
@@ -88,7 +89,7 @@ const createParagraphStyle = (
|
|
|
88
89
|
};
|
|
89
90
|
|
|
90
91
|
const createTableCellStyle = (
|
|
91
|
-
exporter: ODTExporter<any, any, any
|
|
92
|
+
exporter: ODTExporter<any, any, any>,
|
|
92
93
|
): ((cell: TableCell<any, any>) => string) => {
|
|
93
94
|
// To not create a new style for each cell within a table, we cache the styles based on unique cell properties
|
|
94
95
|
const cellStyleCache = new Map<string, string>();
|
|
@@ -137,7 +138,7 @@ const createTableCellStyle = (
|
|
|
137
138
|
};
|
|
138
139
|
const createTableStyle = (
|
|
139
140
|
exporter: ODTExporter<any, any, any>,
|
|
140
|
-
options: { width: number }
|
|
141
|
+
options: { width: number },
|
|
141
142
|
) => {
|
|
142
143
|
const tableStyleName = exporter.registerStyle((name) => (
|
|
143
144
|
<style:style style:family="table" style:name={name}>
|
|
@@ -154,7 +155,7 @@ const createTableStyle = (
|
|
|
154
155
|
|
|
155
156
|
const wrapWithLists = (
|
|
156
157
|
content: React.ReactNode,
|
|
157
|
-
level: number
|
|
158
|
+
level: number,
|
|
158
159
|
): React.ReactNode => {
|
|
159
160
|
if (level <= 0) {
|
|
160
161
|
return content;
|
|
@@ -176,7 +177,7 @@ export const odtBlockMappingForDefaultSchema: BlockMapping<
|
|
|
176
177
|
paragraph: (block, exporter, nestingLevel) => {
|
|
177
178
|
const styleName = createParagraphStyle(
|
|
178
179
|
exporter as ODTExporter<any, any, any>,
|
|
179
|
-
block.props
|
|
180
|
+
block.props,
|
|
180
181
|
);
|
|
181
182
|
|
|
182
183
|
return (
|
|
@@ -191,14 +192,15 @@ export const odtBlockMappingForDefaultSchema: BlockMapping<
|
|
|
191
192
|
const customStyleName = createParagraphStyle(
|
|
192
193
|
exporter as ODTExporter<any, any, any>,
|
|
193
194
|
block.props,
|
|
194
|
-
"Heading_20_" + block.props.level
|
|
195
|
+
"Heading_20_" + block.props.level,
|
|
195
196
|
);
|
|
196
197
|
const styleName = customStyleName;
|
|
197
198
|
|
|
198
199
|
return (
|
|
199
200
|
<text:h
|
|
200
201
|
text:outline-level={`${block.props.level}`}
|
|
201
|
-
text:style-name={styleName}
|
|
202
|
+
text:style-name={styleName}
|
|
203
|
+
>
|
|
202
204
|
{getTabs(nestingLevel)}
|
|
203
205
|
{exporter.transformInlineContent(block.content)}
|
|
204
206
|
</text:h>
|
|
@@ -217,7 +219,7 @@ export const odtBlockMappingForDefaultSchema: BlockMapping<
|
|
|
217
219
|
},
|
|
218
220
|
{
|
|
219
221
|
"fo:color": "#7D797A",
|
|
220
|
-
}
|
|
222
|
+
},
|
|
221
223
|
);
|
|
222
224
|
const styleName = customStyleName;
|
|
223
225
|
|
|
@@ -244,7 +246,7 @@ export const odtBlockMappingForDefaultSchema: BlockMapping<
|
|
|
244
246
|
exporter as ODTExporter<any, any, any>,
|
|
245
247
|
block.props,
|
|
246
248
|
"Standard",
|
|
247
|
-
{ "style:list-style-name": "WWNum1" }
|
|
249
|
+
{ "style:list-style-name": "WWNum1" },
|
|
248
250
|
);
|
|
249
251
|
return (
|
|
250
252
|
<text:list text:style-name="WWNum1">
|
|
@@ -253,7 +255,7 @@ export const odtBlockMappingForDefaultSchema: BlockMapping<
|
|
|
253
255
|
<text:p text:style-name={styleName}>
|
|
254
256
|
{exporter.transformInlineContent(block.content)}
|
|
255
257
|
</text:p>,
|
|
256
|
-
nestingLevel
|
|
258
|
+
nestingLevel,
|
|
257
259
|
)}
|
|
258
260
|
</text:list-item>
|
|
259
261
|
</text:list>
|
|
@@ -263,7 +265,7 @@ export const odtBlockMappingForDefaultSchema: BlockMapping<
|
|
|
263
265
|
numberedListItem: (block, exporter, nestingLevel, numberedListIndex) => {
|
|
264
266
|
const styleName = createParagraphStyle(
|
|
265
267
|
exporter as ODTExporter<any, any, any>,
|
|
266
|
-
block.props
|
|
268
|
+
block.props,
|
|
267
269
|
);
|
|
268
270
|
// continue numbering from the previous list item if this is not the first item
|
|
269
271
|
const continueNumbering = (numberedListIndex || 0) > 1 ? "true" : "false";
|
|
@@ -271,16 +273,18 @@ export const odtBlockMappingForDefaultSchema: BlockMapping<
|
|
|
271
273
|
return (
|
|
272
274
|
<text:list
|
|
273
275
|
text:style-name="No_20_List"
|
|
274
|
-
text:continue-numbering={continueNumbering}
|
|
276
|
+
text:continue-numbering={continueNumbering}
|
|
277
|
+
>
|
|
275
278
|
<text:list-item
|
|
276
279
|
{...(continueNumbering === "false" && {
|
|
277
280
|
"text:start-value": block.props.start,
|
|
278
|
-
})}
|
|
281
|
+
})}
|
|
282
|
+
>
|
|
279
283
|
{wrapWithLists(
|
|
280
284
|
<text:p text:style-name={styleName}>
|
|
281
285
|
{exporter.transformInlineContent(block.content)}
|
|
282
286
|
</text:p>,
|
|
283
|
-
nestingLevel
|
|
287
|
+
nestingLevel,
|
|
284
288
|
)}
|
|
285
289
|
</text:list-item>
|
|
286
290
|
</text:list>
|
|
@@ -305,9 +309,9 @@ export const odtBlockMappingForDefaultSchema: BlockMapping<
|
|
|
305
309
|
await odtExporter.registerPicture(block.props.url);
|
|
306
310
|
const styleName = createParagraphStyle(
|
|
307
311
|
exporter as ODTExporter<any, any, any>,
|
|
308
|
-
block.props
|
|
312
|
+
block.props,
|
|
309
313
|
);
|
|
310
|
-
const width = block.props.previewWidth;
|
|
314
|
+
const width = block.props.previewWidth || originalDimensions.width;
|
|
311
315
|
const height =
|
|
312
316
|
(originalDimensions.height / originalDimensions.width) * width;
|
|
313
317
|
const captionHeight = 20;
|
|
@@ -321,7 +325,8 @@ export const odtBlockMappingForDefaultSchema: BlockMapping<
|
|
|
321
325
|
style:rel-width={block.props.caption ? "100%" : `${width}px`}
|
|
322
326
|
{...(!block.props.caption && {
|
|
323
327
|
"text:anchor-type": "as-char",
|
|
324
|
-
})}
|
|
328
|
+
})}
|
|
329
|
+
>
|
|
325
330
|
<draw:image
|
|
326
331
|
xlink:type="simple"
|
|
327
332
|
xlink:show="embed"
|
|
@@ -344,7 +349,8 @@ export const odtBlockMappingForDefaultSchema: BlockMapping<
|
|
|
344
349
|
style:rel-width={`${width}px`}
|
|
345
350
|
svg:width={`${width}px`}
|
|
346
351
|
svg:height={`${height + captionHeight}px`}
|
|
347
|
-
text:anchor-type="as-char"
|
|
352
|
+
text:anchor-type="as-char"
|
|
353
|
+
>
|
|
348
354
|
<draw:text-box>{imageFrame}</draw:text-box>
|
|
349
355
|
</draw:frame>
|
|
350
356
|
</text:p>
|
|
@@ -360,7 +366,7 @@ export const odtBlockMappingForDefaultSchema: BlockMapping<
|
|
|
360
366
|
block.content.columnWidths.reduce(
|
|
361
367
|
(totalWidth, colWidth) =>
|
|
362
368
|
(totalWidth || 0) + (colWidth || DEFAULT_COLUMN_WIDTH_PX),
|
|
363
|
-
0
|
|
369
|
+
0,
|
|
364
370
|
) || 0;
|
|
365
371
|
const tableWidthPT = tableWidthPX * 0.75;
|
|
366
372
|
const ex = exporter as ODTExporter<any, any, any>;
|
|
@@ -394,7 +400,8 @@ export const odtBlockMappingForDefaultSchema: BlockMapping<
|
|
|
394
400
|
style:text-align-source="fix"
|
|
395
401
|
style:paragraph-properties-text-align={
|
|
396
402
|
cell.props.textAlignment
|
|
397
|
-
}
|
|
403
|
+
}
|
|
404
|
+
>
|
|
398
405
|
<text:p text:style-name="Standard">
|
|
399
406
|
{exporter.transformInlineContent(cell.content)}
|
|
400
407
|
</text:p>
|
|
@@ -434,7 +441,8 @@ export const odtBlockMappingForDefaultSchema: BlockMapping<
|
|
|
434
441
|
text:style-name="Internet_20_link"
|
|
435
442
|
office:target-frame-name="_top"
|
|
436
443
|
xlink:show="replace"
|
|
437
|
-
xlink:href={block.props.url}
|
|
444
|
+
xlink:href={block.props.url}
|
|
445
|
+
>
|
|
438
446
|
<text:span text:style-name="Internet_20_link">
|
|
439
447
|
Open file
|
|
440
448
|
</text:span>
|
|
@@ -458,7 +466,8 @@ export const odtBlockMappingForDefaultSchema: BlockMapping<
|
|
|
458
466
|
text:style-name="Internet_20_link"
|
|
459
467
|
office:target-frame-name="_top"
|
|
460
468
|
xlink:show="replace"
|
|
461
|
-
xlink:href={block.props.url}
|
|
469
|
+
xlink:href={block.props.url}
|
|
470
|
+
>
|
|
462
471
|
<text:span text:style-name="Internet_20_link">Open video</text:span>
|
|
463
472
|
</text:a>
|
|
464
473
|
</text:p>
|
|
@@ -476,7 +485,8 @@ export const odtBlockMappingForDefaultSchema: BlockMapping<
|
|
|
476
485
|
text:style-name="Internet_20_link"
|
|
477
486
|
office:target-frame-name="_top"
|
|
478
487
|
xlink:show="replace"
|
|
479
|
-
xlink:href={block.props.url}
|
|
488
|
+
xlink:href={block.props.url}
|
|
489
|
+
>
|
|
480
490
|
<text:span text:style-name="Internet_20_link">Open audio</text:span>
|
|
481
491
|
</text:a>
|
|
482
492
|
</text:p>
|
|
@@ -18,7 +18,8 @@ export const odtInlineContentMappingForDefaultSchema: InlineContentMapping<
|
|
|
18
18
|
text:style-name="Internet_20_link"
|
|
19
19
|
office:target-frame-name="_top"
|
|
20
20
|
xlink:show="replace"
|
|
21
|
-
xlink:href={ic.href}
|
|
21
|
+
xlink:href={ic.href}
|
|
22
|
+
>
|
|
22
23
|
{content}
|
|
23
24
|
</text:a>
|
|
24
25
|
);
|
|
@@ -17,7 +17,7 @@ describe("exporter", () => {
|
|
|
17
17
|
BlockNoteSchema.create({
|
|
18
18
|
blockSpecs: { ...defaultBlockSpecs, pageBreak: PageBreak },
|
|
19
19
|
}),
|
|
20
|
-
odtDefaultSchemaMappings
|
|
20
|
+
odtDefaultSchemaMappings,
|
|
21
21
|
);
|
|
22
22
|
const odt = await exporter.toODTDocument(testDocument);
|
|
23
23
|
await testODTDocumentAgainstSnapshot(odt, {
|
|
@@ -34,14 +34,14 @@ describe("exporter", () => {
|
|
|
34
34
|
BlockNoteSchema.create({
|
|
35
35
|
blockSpecs: { ...defaultBlockSpecs, pageBreak: PageBreak },
|
|
36
36
|
}),
|
|
37
|
-
odtDefaultSchemaMappings
|
|
37
|
+
odtDefaultSchemaMappings,
|
|
38
38
|
);
|
|
39
39
|
|
|
40
40
|
const odt = await exporter.toODTDocument(testDocument, {
|
|
41
41
|
footer: "<text:p>FOOTER</text:p>",
|
|
42
42
|
header: new DOMParser().parseFromString(
|
|
43
43
|
`<text:p xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0">HEADER</text:p>`,
|
|
44
|
-
"text/xml"
|
|
44
|
+
"text/xml",
|
|
45
45
|
),
|
|
46
46
|
});
|
|
47
47
|
|
|
@@ -49,7 +49,7 @@ describe("exporter", () => {
|
|
|
49
49
|
styles: "__snapshots__/withCustomOptions/styles.xml",
|
|
50
50
|
content: "__snapshots__/withCustomOptions/content.xml",
|
|
51
51
|
});
|
|
52
|
-
}
|
|
52
|
+
},
|
|
53
53
|
);
|
|
54
54
|
});
|
|
55
55
|
|
|
@@ -58,7 +58,7 @@ async function testODTDocumentAgainstSnapshot(
|
|
|
58
58
|
snapshots: {
|
|
59
59
|
styles: string;
|
|
60
60
|
content: string;
|
|
61
|
-
}
|
|
61
|
+
},
|
|
62
62
|
) {
|
|
63
63
|
const zipReader = new ZipReader(new BlobReader(odt));
|
|
64
64
|
const entries = await zipReader.getEntries();
|
|
@@ -72,9 +72,9 @@ async function testODTDocumentAgainstSnapshot(
|
|
|
72
72
|
expect(stylesXML).toBeDefined();
|
|
73
73
|
expect(contentXML).toBeDefined();
|
|
74
74
|
expect(
|
|
75
|
-
xmlFormat(await stylesXML!.getData!(stylesXMLWriter))
|
|
75
|
+
xmlFormat(await stylesXML!.getData!(stylesXMLWriter)),
|
|
76
76
|
).toMatchFileSnapshot(snapshots.styles);
|
|
77
77
|
expect(
|
|
78
|
-
xmlFormat(await contentXML!.getData!(contentXMLWriter))
|
|
78
|
+
xmlFormat(await contentXML!.getData!(contentXMLWriter)),
|
|
79
79
|
).toMatchFileSnapshot(snapshots.content);
|
|
80
80
|
}
|
package/src/odt/odtExporter.tsx
CHANGED
|
@@ -18,7 +18,7 @@ import stylesXml from "./template/styles.xml?raw";
|
|
|
18
18
|
export class ODTExporter<
|
|
19
19
|
B extends BlockSchema,
|
|
20
20
|
S extends StyleSchema,
|
|
21
|
-
I extends InlineContentSchema
|
|
21
|
+
I extends InlineContentSchema,
|
|
22
22
|
> extends Exporter<
|
|
23
23
|
B,
|
|
24
24
|
I,
|
|
@@ -59,7 +59,7 @@ export class ODTExporter<
|
|
|
59
59
|
Record<string, string>,
|
|
60
60
|
React.ReactNode
|
|
61
61
|
>["mappings"],
|
|
62
|
-
options?: Partial<ExporterOptions
|
|
62
|
+
options?: Partial<ExporterOptions>,
|
|
63
63
|
) {
|
|
64
64
|
const defaults = {
|
|
65
65
|
colors: COLORS_DEFAULT,
|
|
@@ -71,10 +71,10 @@ export class ODTExporter<
|
|
|
71
71
|
|
|
72
72
|
protected async loadFonts() {
|
|
73
73
|
const interFont = await loadFileBuffer(
|
|
74
|
-
await import("@shared/assets/fonts/inter/Inter_18pt-Regular.ttf")
|
|
74
|
+
await import("@shared/assets/fonts/inter/Inter_18pt-Regular.ttf"),
|
|
75
75
|
);
|
|
76
76
|
const geistMonoFont = await loadFileBuffer(
|
|
77
|
-
await import("@shared/assets/fonts/GeistMono-Regular.ttf")
|
|
77
|
+
await import("@shared/assets/fonts/GeistMono-Regular.ttf"),
|
|
78
78
|
);
|
|
79
79
|
|
|
80
80
|
return [
|
|
@@ -106,7 +106,7 @@ export class ODTExporter<
|
|
|
106
106
|
styleName,
|
|
107
107
|
<style:style style:name={styleName} style:family="text">
|
|
108
108
|
<style:text-properties {...styles} />
|
|
109
|
-
</style:style
|
|
109
|
+
</style:style>,
|
|
110
110
|
);
|
|
111
111
|
|
|
112
112
|
return <text:span text:style-name={styleName}>{styledText.text}</text:span>;
|
|
@@ -114,7 +114,7 @@ export class ODTExporter<
|
|
|
114
114
|
|
|
115
115
|
public async transformBlocks(
|
|
116
116
|
blocks: Block<B, I, S>[],
|
|
117
|
-
nestingLevel = 0
|
|
117
|
+
nestingLevel = 0,
|
|
118
118
|
): Promise<React.ReactNode[]> {
|
|
119
119
|
const ret: React.ReactNode[] = [];
|
|
120
120
|
let numberedListIndex = 0;
|
|
@@ -128,13 +128,13 @@ export class ODTExporter<
|
|
|
128
128
|
|
|
129
129
|
const children = await this.transformBlocks(
|
|
130
130
|
block.children,
|
|
131
|
-
nestingLevel + 1
|
|
131
|
+
nestingLevel + 1,
|
|
132
132
|
);
|
|
133
133
|
|
|
134
134
|
const content = await this.mapBlock(
|
|
135
135
|
block as any,
|
|
136
136
|
nestingLevel,
|
|
137
|
-
numberedListIndex
|
|
137
|
+
numberedListIndex,
|
|
138
138
|
);
|
|
139
139
|
|
|
140
140
|
ret.push(content);
|
|
@@ -151,7 +151,7 @@ export class ODTExporter<
|
|
|
151
151
|
options?: {
|
|
152
152
|
header?: string | XMLDocument;
|
|
153
153
|
footer?: string | XMLDocument;
|
|
154
|
-
}
|
|
154
|
+
},
|
|
155
155
|
): Promise<Blob> {
|
|
156
156
|
const xmlOptionToString = (xmlDocument: string | XMLDocument) => {
|
|
157
157
|
const xmlNamespacesRegEx =
|
|
@@ -187,20 +187,23 @@ export class ODTExporter<
|
|
|
187
187
|
xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0"
|
|
188
188
|
xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0"
|
|
189
189
|
xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0"
|
|
190
|
-
office:version="1.3"
|
|
190
|
+
office:version="1.3"
|
|
191
|
+
>
|
|
191
192
|
<office:font-face-decls>
|
|
192
193
|
{fonts.map((font) => {
|
|
193
194
|
return (
|
|
194
195
|
<style:font-face
|
|
195
196
|
style:name={font.name}
|
|
196
197
|
svg:font-family={font.name}
|
|
197
|
-
style:font-pitch="variable"
|
|
198
|
+
style:font-pitch="variable"
|
|
199
|
+
>
|
|
198
200
|
<svg:font-face-src>
|
|
199
201
|
<svg:font-face-uri
|
|
200
202
|
xlink:href={`Fonts/${font.fileName}`}
|
|
201
203
|
xlink:type="simple"
|
|
202
204
|
loext:font-style="normal"
|
|
203
|
-
loext:font-weight="normal"
|
|
205
|
+
loext:font-weight="normal"
|
|
206
|
+
>
|
|
204
207
|
<svg:font-face-format svg:string="truetype" />
|
|
205
208
|
</svg:font-face-uri>
|
|
206
209
|
</svg:font-face-src>
|
|
@@ -214,18 +217,21 @@ export class ODTExporter<
|
|
|
214
217
|
<style:master-page
|
|
215
218
|
style:name="Standard"
|
|
216
219
|
style:page-layout-name="Mpm1"
|
|
217
|
-
draw:style-name="Mdp1"
|
|
220
|
+
draw:style-name="Mdp1"
|
|
221
|
+
>
|
|
218
222
|
{header && (
|
|
219
223
|
<style:header
|
|
220
224
|
dangerouslySetInnerHTML={{
|
|
221
225
|
__html: header,
|
|
222
|
-
}}
|
|
226
|
+
}}
|
|
227
|
+
></style:header>
|
|
223
228
|
)}
|
|
224
229
|
{footer && (
|
|
225
230
|
<style:footer
|
|
226
231
|
dangerouslySetInnerHTML={{
|
|
227
232
|
__html: footer,
|
|
228
|
-
}}
|
|
233
|
+
}}
|
|
234
|
+
></style:footer>
|
|
229
235
|
)}
|
|
230
236
|
</style:master-page>
|
|
231
237
|
</office:master-styles>
|
|
@@ -239,7 +245,8 @@ export class ODTExporter<
|
|
|
239
245
|
const manifestNode = (
|
|
240
246
|
<manifest:manifest
|
|
241
247
|
xmlns:manifest="urn:oasis:names:tc:opendocument:xmlns:manifest:1.0"
|
|
242
|
-
manifest:version="1.3"
|
|
248
|
+
manifest:version="1.3"
|
|
249
|
+
>
|
|
243
250
|
<manifest:file-entry
|
|
244
251
|
manifest:media-type="application/vnd.oasis.opendocument.text"
|
|
245
252
|
manifest:full-path="/"
|
|
@@ -271,7 +278,7 @@ export class ODTExporter<
|
|
|
271
278
|
</manifest:manifest>
|
|
272
279
|
);
|
|
273
280
|
const zipWriter = new ZipWriter(
|
|
274
|
-
new BlobWriter("application/vnd.oasis.opendocument.text")
|
|
281
|
+
new BlobWriter("application/vnd.oasis.opendocument.text"),
|
|
275
282
|
);
|
|
276
283
|
|
|
277
284
|
// Add mimetype first, uncompressed
|
|
@@ -283,7 +290,7 @@ export class ODTExporter<
|
|
|
283
290
|
level: 0,
|
|
284
291
|
dataDescriptor: false,
|
|
285
292
|
extendedTimestamp: false,
|
|
286
|
-
}
|
|
293
|
+
},
|
|
287
294
|
);
|
|
288
295
|
|
|
289
296
|
const contentXml = renderToString(content);
|
|
@@ -298,7 +305,7 @@ export class ODTExporter<
|
|
|
298
305
|
pictures.forEach((picture) => {
|
|
299
306
|
zipWriter.add(
|
|
300
307
|
`Pictures/${picture.fileName}`,
|
|
301
|
-
new BlobReader(picture.file)
|
|
308
|
+
new BlobReader(picture.file),
|
|
302
309
|
);
|
|
303
310
|
});
|
|
304
311
|
|
package/src/odt/util/jsx.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
declare module
|
|
1
|
+
declare module "react/jsx-runtime" {
|
|
2
2
|
namespace JSX {
|
|
3
3
|
interface IntrinsicElements {
|
|
4
4
|
"office:document-content": any;
|
|
@@ -54,4 +54,4 @@ declare module 'react/jsx-runtime' {
|
|
|
54
54
|
"fo:padding"?: string;
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
|
-
}
|
|
57
|
+
}
|
|
@@ -330,7 +330,8 @@ export declare const odtDefaultSchemaMappings: {
|
|
|
330
330
|
default: true;
|
|
331
331
|
};
|
|
332
332
|
previewWidth: {
|
|
333
|
-
default:
|
|
333
|
+
default: undefined;
|
|
334
|
+
type: "number";
|
|
334
335
|
};
|
|
335
336
|
};
|
|
336
337
|
content: "none";
|
|
@@ -360,7 +361,8 @@ export declare const odtDefaultSchemaMappings: {
|
|
|
360
361
|
default: true;
|
|
361
362
|
};
|
|
362
363
|
previewWidth: {
|
|
363
|
-
default:
|
|
364
|
+
default: undefined;
|
|
365
|
+
type: "number";
|
|
364
366
|
};
|
|
365
367
|
};
|
|
366
368
|
content: "none";
|
|
@@ -392,7 +394,8 @@ export declare const odtDefaultSchemaMappings: {
|
|
|
392
394
|
default: true;
|
|
393
395
|
};
|
|
394
396
|
previewWidth: {
|
|
395
|
-
default:
|
|
397
|
+
default: undefined;
|
|
398
|
+
type: "number";
|
|
396
399
|
};
|
|
397
400
|
};
|
|
398
401
|
content: "none";
|
|
@@ -422,7 +425,8 @@ export declare const odtDefaultSchemaMappings: {
|
|
|
422
425
|
default: true;
|
|
423
426
|
};
|
|
424
427
|
previewWidth: {
|
|
425
|
-
default:
|
|
428
|
+
default: undefined;
|
|
429
|
+
type: "number";
|
|
426
430
|
};
|
|
427
431
|
};
|
|
428
432
|
content: "none";
|