documents.js 1.58.0 → 1.60.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/README.md +65 -26
- package/dist/convert/capability.cjs +239 -0
- package/dist/convert/capability.d.cts +42 -0
- package/dist/convert/capability.d.ts +42 -0
- package/dist/convert/capability.js +236 -0
- package/dist/convert/codec.cjs +20 -0
- package/dist/convert/codec.d.cts +5 -1
- package/dist/convert/codec.d.ts +5 -1
- package/dist/convert/codec.js +19 -3
- package/dist/convert/convert.cjs +114 -0
- package/dist/convert/convert.d.cts +9 -1
- package/dist/convert/convert.d.ts +9 -1
- package/dist/convert/convert.js +107 -1
- package/dist/convert/local.cjs +26 -335
- package/dist/convert/local.js +26 -335
- package/dist/convert/port.d.cts +1 -1
- package/dist/convert/port.d.ts +1 -1
- package/dist/edit/ods/column-row.cjs +31 -0
- package/dist/edit/ods/column-row.d.cts +6 -0
- package/dist/edit/ods/column-row.d.ts +6 -0
- package/dist/edit/ods/column-row.js +29 -0
- package/dist/edit/ods/content.cjs +2 -0
- package/dist/edit/ods/content.js +2 -0
- package/dist/edit/ods/sheet.cjs +7 -0
- package/dist/edit/ods/sheet.d.cts +2 -0
- package/dist/edit/ods/sheet.d.ts +2 -0
- package/dist/edit/ods/sheet.js +7 -0
- package/dist/index.cjs +20 -0
- package/dist/index.d.cts +7 -4
- package/dist/index.d.ts +7 -4
- package/dist/index.js +7 -4
- package/dist/markdown/read.cjs +16 -0
- package/dist/markdown/read.d.cts +6 -0
- package/dist/markdown/read.d.ts +6 -0
- package/dist/markdown/read.js +15 -0
- package/dist/markdown/text.cjs +16 -0
- package/dist/markdown/text.d.cts +5 -0
- package/dist/markdown/text.d.ts +5 -0
- package/dist/markdown/text.js +14 -0
- package/dist/markdown/write.cjs +8 -0
- package/dist/markdown/write.d.cts +6 -0
- package/dist/markdown/write.d.ts +6 -0
- package/dist/markdown/write.js +7 -0
- package/dist/model/bytes.cjs +10 -0
- package/dist/model/bytes.d.cts +2 -1
- package/dist/model/bytes.d.ts +2 -1
- package/dist/model/bytes.js +10 -1
- package/package.json +2 -1
package/dist/convert/convert.cjs
CHANGED
|
@@ -17,6 +17,9 @@ const require_odf_odt_read = require("../odf/odt/read.cjs");
|
|
|
17
17
|
const require_odf_odp_read = require("../odf/odp/read.cjs");
|
|
18
18
|
const require_odf_ods_read = require("../odf/ods/read.cjs");
|
|
19
19
|
const require_odf_odg_read = require("../odf/odg/read.cjs");
|
|
20
|
+
const require_markdown_text = require("../markdown/text.cjs");
|
|
21
|
+
const require_markdown_read = require("../markdown/read.cjs");
|
|
22
|
+
const require_markdown_write = require("../markdown/write.cjs");
|
|
20
23
|
const require_layout_engine = require("../layout/engine.cjs");
|
|
21
24
|
const require_layout_slides = require("../layout/slides.cjs");
|
|
22
25
|
const require_ports_abort = require("../ports/abort.cjs");
|
|
@@ -133,6 +136,23 @@ function odgToPdf(bytes, options) {
|
|
|
133
136
|
onSubstitution: options?.onSubstitution
|
|
134
137
|
});
|
|
135
138
|
}
|
|
139
|
+
function markdownToPdf(bytes, options) {
|
|
140
|
+
require_ports_abort.throwIfAborted(options?.signal);
|
|
141
|
+
const text = require_markdown_text.decodeMarkdownText(bytes);
|
|
142
|
+
const content = require_markdown_read.readMarkdownContent(text, { signal: options?.signal });
|
|
143
|
+
if (content.kind !== "wordprocessing") throw new Error("readMarkdownContent returned a non-wordprocessing ContentDocument");
|
|
144
|
+
const { document: layout, formulas } = require_layout_engine.convertWordprocessingToLayout(content, { measurer: (0, pdf_codec.createStandardFontMeasurer)() });
|
|
145
|
+
options?.onDocument?.({
|
|
146
|
+
formatVersion: document_schema_js.DOCUMENT_PACKAGE_FORMAT_VERSION,
|
|
147
|
+
content,
|
|
148
|
+
layout
|
|
149
|
+
});
|
|
150
|
+
return (0, pdf_codec.writePdf)(layout, {
|
|
151
|
+
signal: options?.signal,
|
|
152
|
+
onSubstitution: options?.onSubstitution,
|
|
153
|
+
formulas
|
|
154
|
+
});
|
|
155
|
+
}
|
|
136
156
|
const STANDALONE_FORMULA_SIZE_PT = 18;
|
|
137
157
|
const STANDALONE_FORMULA_MARGIN_PT = 72;
|
|
138
158
|
function odfToPdf(bytes, options) {
|
|
@@ -250,6 +270,20 @@ function pdfToOds(bytes, options) {
|
|
|
250
270
|
});
|
|
251
271
|
return (0, odf_js.encodePackage)(require_edit_ods_content.buildOdsPackage(content));
|
|
252
272
|
}
|
|
273
|
+
function pdfToMarkdown(bytes, options) {
|
|
274
|
+
const layout = (0, pdf_codec.readPdf)(bytes, {
|
|
275
|
+
signal: options?.signal,
|
|
276
|
+
sink: options?.sink
|
|
277
|
+
});
|
|
278
|
+
const content = require_layout_reconstruct.reconstructWordprocessing(layout, { signal: options?.signal });
|
|
279
|
+
options?.onDocument?.({
|
|
280
|
+
formatVersion: document_schema_js.DOCUMENT_PACKAGE_FORMAT_VERSION,
|
|
281
|
+
content,
|
|
282
|
+
layout
|
|
283
|
+
});
|
|
284
|
+
const text = require_markdown_write.buildMarkdownText(content);
|
|
285
|
+
return require_markdown_text.encodeMarkdownText(text);
|
|
286
|
+
}
|
|
253
287
|
function odtToDocx(bytes, options) {
|
|
254
288
|
require_ports_abort.throwIfAborted(options?.signal);
|
|
255
289
|
const pkg = (0, odf_js.decodePackage)(bytes);
|
|
@@ -322,6 +356,78 @@ function xlsxToOds(bytes, options) {
|
|
|
322
356
|
});
|
|
323
357
|
return (0, odf_js.encodePackage)(require_edit_ods_content.buildOdsPackage(content));
|
|
324
358
|
}
|
|
359
|
+
function markdownToDocx(bytes, options) {
|
|
360
|
+
require_ports_abort.throwIfAborted(options?.signal);
|
|
361
|
+
const text = require_markdown_text.decodeMarkdownText(bytes);
|
|
362
|
+
const content = require_markdown_read.readMarkdownContent(text, { signal: options?.signal });
|
|
363
|
+
if (content.kind !== "wordprocessing") throw new Error("readMarkdownContent returned a non-wordprocessing ContentDocument");
|
|
364
|
+
require_ports_abort.throwIfAborted(options?.signal);
|
|
365
|
+
options?.onDocument?.({
|
|
366
|
+
formatVersion: document_schema_js.DOCUMENT_PACKAGE_FORMAT_VERSION,
|
|
367
|
+
content
|
|
368
|
+
});
|
|
369
|
+
return (0, ooxml_js.encodePackage)(require_edit_docx_content.buildDocxPackage(content));
|
|
370
|
+
}
|
|
371
|
+
function docxToMarkdown(bytes, options) {
|
|
372
|
+
require_ports_abort.throwIfAborted(options?.signal);
|
|
373
|
+
const pkg = (0, ooxml_js.decodePackage)(bytes);
|
|
374
|
+
const content = require_ooxml_docx_read.readDocxContent(pkg);
|
|
375
|
+
if (content.kind !== "wordprocessing") throw new Error("readDocxContent returned a non-wordprocessing ContentDocument");
|
|
376
|
+
require_ports_abort.throwIfAborted(options?.signal);
|
|
377
|
+
options?.onDocument?.({
|
|
378
|
+
formatVersion: document_schema_js.DOCUMENT_PACKAGE_FORMAT_VERSION,
|
|
379
|
+
content
|
|
380
|
+
});
|
|
381
|
+
const text = require_markdown_write.buildMarkdownText(content);
|
|
382
|
+
return require_markdown_text.encodeMarkdownText(text);
|
|
383
|
+
}
|
|
384
|
+
function markdownToOdt(bytes, options) {
|
|
385
|
+
require_ports_abort.throwIfAborted(options?.signal);
|
|
386
|
+
const text = require_markdown_text.decodeMarkdownText(bytes);
|
|
387
|
+
const content = require_markdown_read.readMarkdownContent(text, { signal: options?.signal });
|
|
388
|
+
if (content.kind !== "wordprocessing") throw new Error("readMarkdownContent returned a non-wordprocessing ContentDocument");
|
|
389
|
+
require_ports_abort.throwIfAborted(options?.signal);
|
|
390
|
+
options?.onDocument?.({
|
|
391
|
+
formatVersion: document_schema_js.DOCUMENT_PACKAGE_FORMAT_VERSION,
|
|
392
|
+
content
|
|
393
|
+
});
|
|
394
|
+
return (0, odf_js.encodePackage)(require_edit_odt_content.buildOdtPackage(content));
|
|
395
|
+
}
|
|
396
|
+
function odtToMarkdown(bytes, options) {
|
|
397
|
+
require_ports_abort.throwIfAborted(options?.signal);
|
|
398
|
+
const pkg = (0, odf_js.decodePackage)(bytes);
|
|
399
|
+
const content = require_odf_odt_read.readOdtContent(pkg).document;
|
|
400
|
+
if (content.kind !== "wordprocessing") throw new Error("readOdtContent returned a non-wordprocessing ContentDocument");
|
|
401
|
+
require_ports_abort.throwIfAborted(options?.signal);
|
|
402
|
+
options?.onDocument?.({
|
|
403
|
+
formatVersion: document_schema_js.DOCUMENT_PACKAGE_FORMAT_VERSION,
|
|
404
|
+
content
|
|
405
|
+
});
|
|
406
|
+
const text = require_markdown_write.buildMarkdownText(content);
|
|
407
|
+
return require_markdown_text.encodeMarkdownText(text);
|
|
408
|
+
}
|
|
409
|
+
function xlsxToPdf(bytes, options) {
|
|
410
|
+
require_ports_abort.throwIfAborted(options?.signal);
|
|
411
|
+
const odsBytes = xlsxToOds(bytes, { signal: options?.signal });
|
|
412
|
+
require_ports_abort.throwIfAborted(options?.signal);
|
|
413
|
+
return odsToPdf(odsBytes, {
|
|
414
|
+
signal: options?.signal,
|
|
415
|
+
onSubstitution: options?.onSubstitution,
|
|
416
|
+
onDocument: options?.onDocument
|
|
417
|
+
});
|
|
418
|
+
}
|
|
419
|
+
function pdfToXlsx(bytes, options) {
|
|
420
|
+
require_ports_abort.throwIfAborted(options?.signal);
|
|
421
|
+
const odsBytes = pdfToOds(bytes, {
|
|
422
|
+
signal: options?.signal,
|
|
423
|
+
sink: options?.sink
|
|
424
|
+
});
|
|
425
|
+
require_ports_abort.throwIfAborted(options?.signal);
|
|
426
|
+
return odsToXlsx(odsBytes, {
|
|
427
|
+
signal: options?.signal,
|
|
428
|
+
onDocument: options?.onDocument
|
|
429
|
+
});
|
|
430
|
+
}
|
|
325
431
|
var OdmUnresolvedSectionError = class extends Error {
|
|
326
432
|
hrefs;
|
|
327
433
|
constructor(hrefs) {
|
|
@@ -418,9 +524,13 @@ function odbToCsv(bytes, options) {
|
|
|
418
524
|
}
|
|
419
525
|
//#endregion
|
|
420
526
|
exports.OdmUnresolvedSectionError = OdmUnresolvedSectionError;
|
|
527
|
+
exports.docxToMarkdown = docxToMarkdown;
|
|
421
528
|
exports.docxToOdt = docxToOdt;
|
|
422
529
|
exports.docxToPdf = docxToPdf;
|
|
423
530
|
exports.inlineOdmSectionToContentSection = inlineOdmSectionToContentSection;
|
|
531
|
+
exports.markdownToDocx = markdownToDocx;
|
|
532
|
+
exports.markdownToOdt = markdownToOdt;
|
|
533
|
+
exports.markdownToPdf = markdownToPdf;
|
|
424
534
|
exports.odbToCsv = odbToCsv;
|
|
425
535
|
exports.odbToXlsx = odbToXlsx;
|
|
426
536
|
exports.odfToPdf = odfToPdf;
|
|
@@ -431,13 +541,17 @@ exports.odpToPptx = odpToPptx;
|
|
|
431
541
|
exports.odsToPdf = odsToPdf;
|
|
432
542
|
exports.odsToXlsx = odsToXlsx;
|
|
433
543
|
exports.odtToDocx = odtToDocx;
|
|
544
|
+
exports.odtToMarkdown = odtToMarkdown;
|
|
434
545
|
exports.odtToPdf = odtToPdf;
|
|
435
546
|
exports.pdfToDocx = pdfToDocx;
|
|
547
|
+
exports.pdfToMarkdown = pdfToMarkdown;
|
|
436
548
|
exports.pdfToOdg = pdfToOdg;
|
|
437
549
|
exports.pdfToOdp = pdfToOdp;
|
|
438
550
|
exports.pdfToOds = pdfToOds;
|
|
439
551
|
exports.pdfToOdt = pdfToOdt;
|
|
440
552
|
exports.pdfToPptx = pdfToPptx;
|
|
553
|
+
exports.pdfToXlsx = pdfToXlsx;
|
|
441
554
|
exports.pptxToOdp = pptxToOdp;
|
|
442
555
|
exports.pptxToPdf = pptxToPdf;
|
|
443
556
|
exports.xlsxToOds = xlsxToOds;
|
|
557
|
+
exports.xlsxToPdf = xlsxToPdf;
|
|
@@ -15,6 +15,7 @@ declare function pptxToPdf(bytes: Uint8Array<ArrayBuffer>, options?: DocumentToP
|
|
|
15
15
|
declare function odpToPdf(bytes: Uint8Array<ArrayBuffer>, options?: DocumentToPdfOptions): Uint8Array<ArrayBuffer>;
|
|
16
16
|
declare function odsToPdf(bytes: Uint8Array<ArrayBuffer>, options?: DocumentToPdfOptions): Uint8Array<ArrayBuffer>;
|
|
17
17
|
declare function odgToPdf(bytes: Uint8Array<ArrayBuffer>, options?: DocumentToPdfOptions): Uint8Array<ArrayBuffer>;
|
|
18
|
+
declare function markdownToPdf(bytes: Uint8Array<ArrayBuffer>, options?: DocumentToPdfOptions): Uint8Array<ArrayBuffer>;
|
|
18
19
|
declare function odfToPdf(bytes: Uint8Array<ArrayBuffer>, options?: DocumentToPdfOptions): Uint8Array<ArrayBuffer>;
|
|
19
20
|
interface PdfToDocumentOptions {
|
|
20
21
|
readonly signal?: AbortSignal;
|
|
@@ -27,6 +28,7 @@ declare function pdfToOdt(bytes: Uint8Array<ArrayBuffer>, options?: PdfToDocumen
|
|
|
27
28
|
declare function pdfToOdp(bytes: Uint8Array<ArrayBuffer>, options?: PdfToDocumentOptions): Uint8Array<ArrayBuffer>;
|
|
28
29
|
declare function pdfToOdg(bytes: Uint8Array<ArrayBuffer>, options?: PdfToDocumentOptions): Uint8Array<ArrayBuffer>;
|
|
29
30
|
declare function pdfToOds(bytes: Uint8Array<ArrayBuffer>, options?: PdfToDocumentOptions): Uint8Array<ArrayBuffer>;
|
|
31
|
+
declare function pdfToMarkdown(bytes: Uint8Array<ArrayBuffer>, options?: PdfToDocumentOptions): Uint8Array<ArrayBuffer>;
|
|
30
32
|
interface DocumentBridgeOptions {
|
|
31
33
|
readonly signal?: AbortSignal;
|
|
32
34
|
readonly onDocument?: (pkg: DocumentPackage) => void;
|
|
@@ -37,6 +39,12 @@ declare function odpToPptx(bytes: Uint8Array<ArrayBuffer>, options?: DocumentBri
|
|
|
37
39
|
declare function pptxToOdp(bytes: Uint8Array<ArrayBuffer>, options?: DocumentBridgeOptions): Uint8Array<ArrayBuffer>;
|
|
38
40
|
declare function odsToXlsx(bytes: Uint8Array<ArrayBuffer>, options?: DocumentBridgeOptions): Uint8Array<ArrayBuffer>;
|
|
39
41
|
declare function xlsxToOds(bytes: Uint8Array<ArrayBuffer>, options?: DocumentBridgeOptions): Uint8Array<ArrayBuffer>;
|
|
42
|
+
declare function markdownToDocx(bytes: Uint8Array<ArrayBuffer>, options?: DocumentBridgeOptions): Uint8Array<ArrayBuffer>;
|
|
43
|
+
declare function docxToMarkdown(bytes: Uint8Array<ArrayBuffer>, options?: DocumentBridgeOptions): Uint8Array<ArrayBuffer>;
|
|
44
|
+
declare function markdownToOdt(bytes: Uint8Array<ArrayBuffer>, options?: DocumentBridgeOptions): Uint8Array<ArrayBuffer>;
|
|
45
|
+
declare function odtToMarkdown(bytes: Uint8Array<ArrayBuffer>, options?: DocumentBridgeOptions): Uint8Array<ArrayBuffer>;
|
|
46
|
+
declare function xlsxToPdf(bytes: Uint8Array<ArrayBuffer>, options?: DocumentToPdfOptions): Uint8Array<ArrayBuffer>;
|
|
47
|
+
declare function pdfToXlsx(bytes: Uint8Array<ArrayBuffer>, options?: PdfToDocumentOptions): Uint8Array<ArrayBuffer>;
|
|
40
48
|
interface OdmToPdfOptions extends DocumentToPdfOptions {
|
|
41
49
|
readonly resolveSubDocument?: (href: string) => Uint8Array<ArrayBuffer> | undefined;
|
|
42
50
|
}
|
|
@@ -52,4 +60,4 @@ interface OdbToCsvOptions extends DocumentBridgeOptions {
|
|
|
52
60
|
}
|
|
53
61
|
declare function odbToCsv(bytes: Uint8Array<ArrayBuffer>, options?: OdbToCsvOptions): Uint8Array<ArrayBuffer>;
|
|
54
62
|
//#endregion
|
|
55
|
-
export { DocumentBridgeOptions, DocumentToPdfOptions, OdbToCsvOptions, OdmToPdfOptions, OdmUnresolvedSectionError, PdfToDocumentOptions, docxToOdt, docxToPdf, inlineOdmSectionToContentSection, odbToCsv, odbToXlsx, odfToPdf, odgToPdf, odmToPdf, odpToPdf, odpToPptx, odsToPdf, odsToXlsx, odtToDocx, odtToPdf, pdfToDocx, pdfToOdg, pdfToOdp, pdfToOds, pdfToOdt, pdfToPptx, pptxToOdp, pptxToPdf, xlsxToOds };
|
|
63
|
+
export { DocumentBridgeOptions, DocumentToPdfOptions, OdbToCsvOptions, OdmToPdfOptions, OdmUnresolvedSectionError, PdfToDocumentOptions, docxToMarkdown, docxToOdt, docxToPdf, inlineOdmSectionToContentSection, markdownToDocx, markdownToOdt, markdownToPdf, odbToCsv, odbToXlsx, odfToPdf, odgToPdf, odmToPdf, odpToPdf, odpToPptx, odsToPdf, odsToXlsx, odtToDocx, odtToMarkdown, odtToPdf, pdfToDocx, pdfToMarkdown, pdfToOdg, pdfToOdp, pdfToOds, pdfToOdt, pdfToPptx, pdfToXlsx, pptxToOdp, pptxToPdf, xlsxToOds, xlsxToPdf };
|
|
@@ -15,6 +15,7 @@ declare function pptxToPdf(bytes: Uint8Array<ArrayBuffer>, options?: DocumentToP
|
|
|
15
15
|
declare function odpToPdf(bytes: Uint8Array<ArrayBuffer>, options?: DocumentToPdfOptions): Uint8Array<ArrayBuffer>;
|
|
16
16
|
declare function odsToPdf(bytes: Uint8Array<ArrayBuffer>, options?: DocumentToPdfOptions): Uint8Array<ArrayBuffer>;
|
|
17
17
|
declare function odgToPdf(bytes: Uint8Array<ArrayBuffer>, options?: DocumentToPdfOptions): Uint8Array<ArrayBuffer>;
|
|
18
|
+
declare function markdownToPdf(bytes: Uint8Array<ArrayBuffer>, options?: DocumentToPdfOptions): Uint8Array<ArrayBuffer>;
|
|
18
19
|
declare function odfToPdf(bytes: Uint8Array<ArrayBuffer>, options?: DocumentToPdfOptions): Uint8Array<ArrayBuffer>;
|
|
19
20
|
interface PdfToDocumentOptions {
|
|
20
21
|
readonly signal?: AbortSignal;
|
|
@@ -27,6 +28,7 @@ declare function pdfToOdt(bytes: Uint8Array<ArrayBuffer>, options?: PdfToDocumen
|
|
|
27
28
|
declare function pdfToOdp(bytes: Uint8Array<ArrayBuffer>, options?: PdfToDocumentOptions): Uint8Array<ArrayBuffer>;
|
|
28
29
|
declare function pdfToOdg(bytes: Uint8Array<ArrayBuffer>, options?: PdfToDocumentOptions): Uint8Array<ArrayBuffer>;
|
|
29
30
|
declare function pdfToOds(bytes: Uint8Array<ArrayBuffer>, options?: PdfToDocumentOptions): Uint8Array<ArrayBuffer>;
|
|
31
|
+
declare function pdfToMarkdown(bytes: Uint8Array<ArrayBuffer>, options?: PdfToDocumentOptions): Uint8Array<ArrayBuffer>;
|
|
30
32
|
interface DocumentBridgeOptions {
|
|
31
33
|
readonly signal?: AbortSignal;
|
|
32
34
|
readonly onDocument?: (pkg: DocumentPackage) => void;
|
|
@@ -37,6 +39,12 @@ declare function odpToPptx(bytes: Uint8Array<ArrayBuffer>, options?: DocumentBri
|
|
|
37
39
|
declare function pptxToOdp(bytes: Uint8Array<ArrayBuffer>, options?: DocumentBridgeOptions): Uint8Array<ArrayBuffer>;
|
|
38
40
|
declare function odsToXlsx(bytes: Uint8Array<ArrayBuffer>, options?: DocumentBridgeOptions): Uint8Array<ArrayBuffer>;
|
|
39
41
|
declare function xlsxToOds(bytes: Uint8Array<ArrayBuffer>, options?: DocumentBridgeOptions): Uint8Array<ArrayBuffer>;
|
|
42
|
+
declare function markdownToDocx(bytes: Uint8Array<ArrayBuffer>, options?: DocumentBridgeOptions): Uint8Array<ArrayBuffer>;
|
|
43
|
+
declare function docxToMarkdown(bytes: Uint8Array<ArrayBuffer>, options?: DocumentBridgeOptions): Uint8Array<ArrayBuffer>;
|
|
44
|
+
declare function markdownToOdt(bytes: Uint8Array<ArrayBuffer>, options?: DocumentBridgeOptions): Uint8Array<ArrayBuffer>;
|
|
45
|
+
declare function odtToMarkdown(bytes: Uint8Array<ArrayBuffer>, options?: DocumentBridgeOptions): Uint8Array<ArrayBuffer>;
|
|
46
|
+
declare function xlsxToPdf(bytes: Uint8Array<ArrayBuffer>, options?: DocumentToPdfOptions): Uint8Array<ArrayBuffer>;
|
|
47
|
+
declare function pdfToXlsx(bytes: Uint8Array<ArrayBuffer>, options?: PdfToDocumentOptions): Uint8Array<ArrayBuffer>;
|
|
40
48
|
interface OdmToPdfOptions extends DocumentToPdfOptions {
|
|
41
49
|
readonly resolveSubDocument?: (href: string) => Uint8Array<ArrayBuffer> | undefined;
|
|
42
50
|
}
|
|
@@ -52,4 +60,4 @@ interface OdbToCsvOptions extends DocumentBridgeOptions {
|
|
|
52
60
|
}
|
|
53
61
|
declare function odbToCsv(bytes: Uint8Array<ArrayBuffer>, options?: OdbToCsvOptions): Uint8Array<ArrayBuffer>;
|
|
54
62
|
//#endregion
|
|
55
|
-
export { DocumentBridgeOptions, DocumentToPdfOptions, OdbToCsvOptions, OdmToPdfOptions, OdmUnresolvedSectionError, PdfToDocumentOptions, docxToOdt, docxToPdf, inlineOdmSectionToContentSection, odbToCsv, odbToXlsx, odfToPdf, odgToPdf, odmToPdf, odpToPdf, odpToPptx, odsToPdf, odsToXlsx, odtToDocx, odtToPdf, pdfToDocx, pdfToOdg, pdfToOdp, pdfToOds, pdfToOdt, pdfToPptx, pptxToOdp, pptxToPdf, xlsxToOds };
|
|
63
|
+
export { DocumentBridgeOptions, DocumentToPdfOptions, OdbToCsvOptions, OdmToPdfOptions, OdmUnresolvedSectionError, PdfToDocumentOptions, docxToMarkdown, docxToOdt, docxToPdf, inlineOdmSectionToContentSection, markdownToDocx, markdownToOdt, markdownToPdf, odbToCsv, odbToXlsx, odfToPdf, odgToPdf, odmToPdf, odpToPdf, odpToPptx, odsToPdf, odsToXlsx, odtToDocx, odtToMarkdown, odtToPdf, pdfToDocx, pdfToMarkdown, pdfToOdg, pdfToOdp, pdfToOds, pdfToOdt, pdfToPptx, pdfToXlsx, pptxToOdp, pptxToPdf, xlsxToOds, xlsxToPdf };
|
package/dist/convert/convert.js
CHANGED
|
@@ -16,6 +16,9 @@ import { readOdtContent } from "../odf/odt/read.js";
|
|
|
16
16
|
import { readOdpContent } from "../odf/odp/read.js";
|
|
17
17
|
import { readOdsContent } from "../odf/ods/read.js";
|
|
18
18
|
import { readOdgContent } from "../odf/odg/read.js";
|
|
19
|
+
import { decodeMarkdownText, encodeMarkdownText } from "../markdown/text.js";
|
|
20
|
+
import { readMarkdownContent } from "../markdown/read.js";
|
|
21
|
+
import { buildMarkdownText } from "../markdown/write.js";
|
|
19
22
|
import { convertWordprocessingToLayout } from "../layout/engine.js";
|
|
20
23
|
import { convertPresentationToLayout } from "../layout/slides.js";
|
|
21
24
|
import { throwIfAborted } from "../ports/abort.js";
|
|
@@ -132,6 +135,23 @@ function odgToPdf(bytes, options) {
|
|
|
132
135
|
onSubstitution: options?.onSubstitution
|
|
133
136
|
});
|
|
134
137
|
}
|
|
138
|
+
function markdownToPdf(bytes, options) {
|
|
139
|
+
throwIfAborted(options?.signal);
|
|
140
|
+
const text = decodeMarkdownText(bytes);
|
|
141
|
+
const content = readMarkdownContent(text, { signal: options?.signal });
|
|
142
|
+
if (content.kind !== "wordprocessing") throw new Error("readMarkdownContent returned a non-wordprocessing ContentDocument");
|
|
143
|
+
const { document: layout, formulas } = convertWordprocessingToLayout(content, { measurer: createStandardFontMeasurer() });
|
|
144
|
+
options?.onDocument?.({
|
|
145
|
+
formatVersion: DOCUMENT_PACKAGE_FORMAT_VERSION,
|
|
146
|
+
content,
|
|
147
|
+
layout
|
|
148
|
+
});
|
|
149
|
+
return writePdf(layout, {
|
|
150
|
+
signal: options?.signal,
|
|
151
|
+
onSubstitution: options?.onSubstitution,
|
|
152
|
+
formulas
|
|
153
|
+
});
|
|
154
|
+
}
|
|
135
155
|
const STANDALONE_FORMULA_SIZE_PT = 18;
|
|
136
156
|
const STANDALONE_FORMULA_MARGIN_PT = 72;
|
|
137
157
|
function odfToPdf(bytes, options) {
|
|
@@ -249,6 +269,20 @@ function pdfToOds(bytes, options) {
|
|
|
249
269
|
});
|
|
250
270
|
return encodePackage$1(buildOdsPackage(content));
|
|
251
271
|
}
|
|
272
|
+
function pdfToMarkdown(bytes, options) {
|
|
273
|
+
const layout = readPdf(bytes, {
|
|
274
|
+
signal: options?.signal,
|
|
275
|
+
sink: options?.sink
|
|
276
|
+
});
|
|
277
|
+
const content = reconstructWordprocessing(layout, { signal: options?.signal });
|
|
278
|
+
options?.onDocument?.({
|
|
279
|
+
formatVersion: DOCUMENT_PACKAGE_FORMAT_VERSION,
|
|
280
|
+
content,
|
|
281
|
+
layout
|
|
282
|
+
});
|
|
283
|
+
const text = buildMarkdownText(content);
|
|
284
|
+
return encodeMarkdownText(text);
|
|
285
|
+
}
|
|
252
286
|
function odtToDocx(bytes, options) {
|
|
253
287
|
throwIfAborted(options?.signal);
|
|
254
288
|
const pkg = decodePackage$1(bytes);
|
|
@@ -321,6 +355,78 @@ function xlsxToOds(bytes, options) {
|
|
|
321
355
|
});
|
|
322
356
|
return encodePackage$1(buildOdsPackage(content));
|
|
323
357
|
}
|
|
358
|
+
function markdownToDocx(bytes, options) {
|
|
359
|
+
throwIfAborted(options?.signal);
|
|
360
|
+
const text = decodeMarkdownText(bytes);
|
|
361
|
+
const content = readMarkdownContent(text, { signal: options?.signal });
|
|
362
|
+
if (content.kind !== "wordprocessing") throw new Error("readMarkdownContent returned a non-wordprocessing ContentDocument");
|
|
363
|
+
throwIfAborted(options?.signal);
|
|
364
|
+
options?.onDocument?.({
|
|
365
|
+
formatVersion: DOCUMENT_PACKAGE_FORMAT_VERSION,
|
|
366
|
+
content
|
|
367
|
+
});
|
|
368
|
+
return encodePackage(buildDocxPackage(content));
|
|
369
|
+
}
|
|
370
|
+
function docxToMarkdown(bytes, options) {
|
|
371
|
+
throwIfAborted(options?.signal);
|
|
372
|
+
const pkg = decodePackage(bytes);
|
|
373
|
+
const content = readDocxContent(pkg);
|
|
374
|
+
if (content.kind !== "wordprocessing") throw new Error("readDocxContent returned a non-wordprocessing ContentDocument");
|
|
375
|
+
throwIfAborted(options?.signal);
|
|
376
|
+
options?.onDocument?.({
|
|
377
|
+
formatVersion: DOCUMENT_PACKAGE_FORMAT_VERSION,
|
|
378
|
+
content
|
|
379
|
+
});
|
|
380
|
+
const text = buildMarkdownText(content);
|
|
381
|
+
return encodeMarkdownText(text);
|
|
382
|
+
}
|
|
383
|
+
function markdownToOdt(bytes, options) {
|
|
384
|
+
throwIfAborted(options?.signal);
|
|
385
|
+
const text = decodeMarkdownText(bytes);
|
|
386
|
+
const content = readMarkdownContent(text, { signal: options?.signal });
|
|
387
|
+
if (content.kind !== "wordprocessing") throw new Error("readMarkdownContent returned a non-wordprocessing ContentDocument");
|
|
388
|
+
throwIfAborted(options?.signal);
|
|
389
|
+
options?.onDocument?.({
|
|
390
|
+
formatVersion: DOCUMENT_PACKAGE_FORMAT_VERSION,
|
|
391
|
+
content
|
|
392
|
+
});
|
|
393
|
+
return encodePackage$1(buildOdtPackage(content));
|
|
394
|
+
}
|
|
395
|
+
function odtToMarkdown(bytes, options) {
|
|
396
|
+
throwIfAborted(options?.signal);
|
|
397
|
+
const pkg = decodePackage$1(bytes);
|
|
398
|
+
const content = readOdtContent(pkg).document;
|
|
399
|
+
if (content.kind !== "wordprocessing") throw new Error("readOdtContent returned a non-wordprocessing ContentDocument");
|
|
400
|
+
throwIfAborted(options?.signal);
|
|
401
|
+
options?.onDocument?.({
|
|
402
|
+
formatVersion: DOCUMENT_PACKAGE_FORMAT_VERSION,
|
|
403
|
+
content
|
|
404
|
+
});
|
|
405
|
+
const text = buildMarkdownText(content);
|
|
406
|
+
return encodeMarkdownText(text);
|
|
407
|
+
}
|
|
408
|
+
function xlsxToPdf(bytes, options) {
|
|
409
|
+
throwIfAborted(options?.signal);
|
|
410
|
+
const odsBytes = xlsxToOds(bytes, { signal: options?.signal });
|
|
411
|
+
throwIfAborted(options?.signal);
|
|
412
|
+
return odsToPdf(odsBytes, {
|
|
413
|
+
signal: options?.signal,
|
|
414
|
+
onSubstitution: options?.onSubstitution,
|
|
415
|
+
onDocument: options?.onDocument
|
|
416
|
+
});
|
|
417
|
+
}
|
|
418
|
+
function pdfToXlsx(bytes, options) {
|
|
419
|
+
throwIfAborted(options?.signal);
|
|
420
|
+
const odsBytes = pdfToOds(bytes, {
|
|
421
|
+
signal: options?.signal,
|
|
422
|
+
sink: options?.sink
|
|
423
|
+
});
|
|
424
|
+
throwIfAborted(options?.signal);
|
|
425
|
+
return odsToXlsx(odsBytes, {
|
|
426
|
+
signal: options?.signal,
|
|
427
|
+
onDocument: options?.onDocument
|
|
428
|
+
});
|
|
429
|
+
}
|
|
324
430
|
var OdmUnresolvedSectionError = class extends Error {
|
|
325
431
|
hrefs;
|
|
326
432
|
constructor(hrefs) {
|
|
@@ -416,4 +522,4 @@ function odbToCsv(bytes, options) {
|
|
|
416
522
|
return buildOdbTableCsv(tables, options?.table);
|
|
417
523
|
}
|
|
418
524
|
//#endregion
|
|
419
|
-
export { OdmUnresolvedSectionError, docxToOdt, docxToPdf, inlineOdmSectionToContentSection, odbToCsv, odbToXlsx, odfToPdf, odgToPdf, odmToPdf, odpToPdf, odpToPptx, odsToPdf, odsToXlsx, odtToDocx, odtToPdf, pdfToDocx, pdfToOdg, pdfToOdp, pdfToOds, pdfToOdt, pdfToPptx, pptxToOdp, pptxToPdf, xlsxToOds };
|
|
525
|
+
export { OdmUnresolvedSectionError, docxToMarkdown, docxToOdt, docxToPdf, inlineOdmSectionToContentSection, markdownToDocx, markdownToOdt, markdownToPdf, odbToCsv, odbToXlsx, odfToPdf, odgToPdf, odmToPdf, odpToPdf, odpToPptx, odsToPdf, odsToXlsx, odtToDocx, odtToMarkdown, odtToPdf, pdfToDocx, pdfToMarkdown, pdfToOdg, pdfToOdp, pdfToOds, pdfToOdt, pdfToPptx, pdfToXlsx, pptxToOdp, pptxToPdf, xlsxToOds, xlsxToPdf };
|