js.documents 1.74.0 → 1.74.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/markdown/read.cjs +1 -5
- package/dist/markdown/read.js +1 -5
- package/dist/markdown/write.cjs +14 -27
- package/dist/markdown/write.js +14 -27
- package/package.json +2 -2
package/dist/markdown/read.cjs
CHANGED
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
let document_schema_js = require("document-schema.js");
|
|
3
2
|
let markdown_codec = require("markdown-codec");
|
|
4
3
|
//#region src/markdown/read.ts
|
|
5
4
|
function readMarkdownContent(text, options) {
|
|
6
5
|
const { document } = (0, markdown_codec.readMarkdown)(text, options);
|
|
7
6
|
if (document.kind !== "wordprocessing") throw new Error("readMarkdown returned a non-wordprocessing ContentDocument");
|
|
8
|
-
return
|
|
9
|
-
...document,
|
|
10
|
-
formatVersion: document_schema_js.CONTENT_FORMAT_VERSION
|
|
11
|
-
});
|
|
7
|
+
return document;
|
|
12
8
|
}
|
|
13
9
|
//#endregion
|
|
14
10
|
exports.readMarkdownContent = readMarkdownContent;
|
package/dist/markdown/read.js
CHANGED
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
import { CONTENT_FORMAT_VERSION, ContentDocumentSchema } from "document-schema.js";
|
|
2
1
|
import { readMarkdown } from "markdown-codec";
|
|
3
2
|
//#region src/markdown/read.ts
|
|
4
3
|
function readMarkdownContent(text, options) {
|
|
5
4
|
const { document } = readMarkdown(text, options);
|
|
6
5
|
if (document.kind !== "wordprocessing") throw new Error("readMarkdown returned a non-wordprocessing ContentDocument");
|
|
7
|
-
return
|
|
8
|
-
...document,
|
|
9
|
-
formatVersion: CONTENT_FORMAT_VERSION
|
|
10
|
-
});
|
|
6
|
+
return document;
|
|
11
7
|
}
|
|
12
8
|
//#endregion
|
|
13
9
|
export { readMarkdownContent };
|
package/dist/markdown/write.cjs
CHANGED
|
@@ -1,54 +1,41 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_model_embedded_drawing = require("../model/embedded-drawing.cjs");
|
|
3
2
|
const require_model_formula = require("../model/formula.cjs");
|
|
4
3
|
let markdown_codec = require("markdown-codec");
|
|
5
4
|
//#region src/markdown/write.ts
|
|
6
|
-
function
|
|
7
|
-
if (document.kind !== "wordprocessing") throw new markdown_codec.MarkdownUnsupportedDocumentKindError(document.kind);
|
|
8
|
-
return toLegacyWordprocessingDocument(document);
|
|
9
|
-
}
|
|
10
|
-
function toLegacyBlock(block) {
|
|
5
|
+
function markdownBlock(block) {
|
|
11
6
|
if (block.kind === "table") return {
|
|
12
7
|
...block,
|
|
13
8
|
rows: block.rows.map((row) => ({
|
|
14
9
|
...row,
|
|
15
|
-
cells: row.cells.map(
|
|
16
|
-
...cell,
|
|
17
|
-
blocks: toLegacyBlocks(cell.blocks)
|
|
18
|
-
}))
|
|
10
|
+
cells: row.cells.map(markdownTableCell)
|
|
19
11
|
}))
|
|
20
12
|
};
|
|
21
13
|
if (block.kind === "embeddedObject") {
|
|
22
|
-
if (require_model_embedded_drawing.drawingOfBlock(block) !== void 0) return;
|
|
23
14
|
const formula = require_model_formula.formulaOfBlock(block);
|
|
24
15
|
if (formula !== void 0) return {
|
|
25
16
|
kind: "paragraph",
|
|
26
17
|
runs: [{ text: require_model_formula.formulaPlaceholderText(formula) }]
|
|
27
18
|
};
|
|
28
|
-
return
|
|
29
|
-
...block,
|
|
30
|
-
document: toLegacyEmbeddedDocument(block.document)
|
|
31
|
-
};
|
|
19
|
+
return block;
|
|
32
20
|
}
|
|
33
21
|
return block;
|
|
34
22
|
}
|
|
35
|
-
function
|
|
36
|
-
return blocks.map(toLegacyBlock).filter((block) => block !== void 0);
|
|
37
|
-
}
|
|
38
|
-
function toLegacyWordprocessingDocument(document) {
|
|
23
|
+
function markdownTableCell(cell) {
|
|
39
24
|
return {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
metadata: document.metadata,
|
|
43
|
-
sections: document.sections.map((section) => ({
|
|
44
|
-
...section,
|
|
45
|
-
blocks: toLegacyBlocks(section.blocks)
|
|
46
|
-
}))
|
|
25
|
+
...cell,
|
|
26
|
+
blocks: cell.blocks.map(markdownBlock)
|
|
47
27
|
};
|
|
48
28
|
}
|
|
49
29
|
function buildMarkdownText(document, options) {
|
|
50
30
|
if (document.kind !== "wordprocessing") throw new markdown_codec.MarkdownUnsupportedDocumentKindError(document.kind);
|
|
51
|
-
|
|
31
|
+
const sections = document.sections.map((section) => ({
|
|
32
|
+
...section,
|
|
33
|
+
blocks: section.blocks.map(markdownBlock)
|
|
34
|
+
}));
|
|
35
|
+
return (0, markdown_codec.writeMarkdown)({
|
|
36
|
+
...document,
|
|
37
|
+
sections
|
|
38
|
+
}, options);
|
|
52
39
|
}
|
|
53
40
|
//#endregion
|
|
54
41
|
exports.buildMarkdownText = buildMarkdownText;
|
package/dist/markdown/write.js
CHANGED
|
@@ -1,53 +1,40 @@
|
|
|
1
|
-
import { drawingOfBlock } from "../model/embedded-drawing.js";
|
|
2
1
|
import { formulaOfBlock, formulaPlaceholderText } from "../model/formula.js";
|
|
3
2
|
import { MarkdownUnsupportedDocumentKindError, writeMarkdown } from "markdown-codec";
|
|
4
3
|
//#region src/markdown/write.ts
|
|
5
|
-
function
|
|
6
|
-
if (document.kind !== "wordprocessing") throw new MarkdownUnsupportedDocumentKindError(document.kind);
|
|
7
|
-
return toLegacyWordprocessingDocument(document);
|
|
8
|
-
}
|
|
9
|
-
function toLegacyBlock(block) {
|
|
4
|
+
function markdownBlock(block) {
|
|
10
5
|
if (block.kind === "table") return {
|
|
11
6
|
...block,
|
|
12
7
|
rows: block.rows.map((row) => ({
|
|
13
8
|
...row,
|
|
14
|
-
cells: row.cells.map(
|
|
15
|
-
...cell,
|
|
16
|
-
blocks: toLegacyBlocks(cell.blocks)
|
|
17
|
-
}))
|
|
9
|
+
cells: row.cells.map(markdownTableCell)
|
|
18
10
|
}))
|
|
19
11
|
};
|
|
20
12
|
if (block.kind === "embeddedObject") {
|
|
21
|
-
if (drawingOfBlock(block) !== void 0) return;
|
|
22
13
|
const formula = formulaOfBlock(block);
|
|
23
14
|
if (formula !== void 0) return {
|
|
24
15
|
kind: "paragraph",
|
|
25
16
|
runs: [{ text: formulaPlaceholderText(formula) }]
|
|
26
17
|
};
|
|
27
|
-
return
|
|
28
|
-
...block,
|
|
29
|
-
document: toLegacyEmbeddedDocument(block.document)
|
|
30
|
-
};
|
|
18
|
+
return block;
|
|
31
19
|
}
|
|
32
20
|
return block;
|
|
33
21
|
}
|
|
34
|
-
function
|
|
35
|
-
return blocks.map(toLegacyBlock).filter((block) => block !== void 0);
|
|
36
|
-
}
|
|
37
|
-
function toLegacyWordprocessingDocument(document) {
|
|
22
|
+
function markdownTableCell(cell) {
|
|
38
23
|
return {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
metadata: document.metadata,
|
|
42
|
-
sections: document.sections.map((section) => ({
|
|
43
|
-
...section,
|
|
44
|
-
blocks: toLegacyBlocks(section.blocks)
|
|
45
|
-
}))
|
|
24
|
+
...cell,
|
|
25
|
+
blocks: cell.blocks.map(markdownBlock)
|
|
46
26
|
};
|
|
47
27
|
}
|
|
48
28
|
function buildMarkdownText(document, options) {
|
|
49
29
|
if (document.kind !== "wordprocessing") throw new MarkdownUnsupportedDocumentKindError(document.kind);
|
|
50
|
-
|
|
30
|
+
const sections = document.sections.map((section) => ({
|
|
31
|
+
...section,
|
|
32
|
+
blocks: section.blocks.map(markdownBlock)
|
|
33
|
+
}));
|
|
34
|
+
return writeMarkdown({
|
|
35
|
+
...document,
|
|
36
|
+
sections
|
|
37
|
+
}, options);
|
|
51
38
|
}
|
|
52
39
|
//#endregion
|
|
53
40
|
export { buildMarkdownText };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "js.documents",
|
|
3
|
-
"version": "1.74.
|
|
3
|
+
"version": "1.74.1",
|
|
4
4
|
"description": "Bidirectional docx/pptx <-> PDF conversion and a read+write editable OOXML document model, built on ooxml.js and Zod 4 codecs.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"dependencies": {
|
|
61
61
|
"document-schema.js": "^2.2.4",
|
|
62
62
|
"fflate": "^0.8.3",
|
|
63
|
-
"markdown-codec": "^1.
|
|
63
|
+
"markdown-codec": "^1.1.0",
|
|
64
64
|
"odf.js": "^2.3.0",
|
|
65
65
|
"ooxml.js": "^2.6.10",
|
|
66
66
|
"pdf-codec": "^1.10.10",
|