js.documents 1.60.3 → 1.62.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 +84 -44
- package/dist/{blr-types-CYYC3yYU.d.cts → blr-types-DVgO1DQ9.d.cts} +1 -1
- package/dist/{blr-types-CYYC3yYU.d.ts → blr-types-DVgO1DQ9.d.ts} +1 -1
- package/dist/convert/capability.cjs +1 -0
- package/dist/convert/capability.d.cts +1 -1
- package/dist/convert/capability.d.ts +1 -1
- package/dist/convert/capability.js +1 -0
- package/dist/convert/convert.cjs +29 -27
- package/dist/convert/convert.d.cts +9 -3
- package/dist/convert/convert.d.ts +9 -3
- package/dist/convert/convert.js +29 -27
- package/dist/edit/docx/content.cjs +75 -13
- package/dist/edit/docx/content.d.cts +8 -2
- package/dist/edit/docx/content.d.ts +8 -2
- package/dist/edit/docx/content.js +75 -13
- package/dist/edit/docx/paragraph.cjs +14 -0
- package/dist/edit/docx/paragraph.d.cts +5 -0
- package/dist/edit/docx/paragraph.d.ts +5 -0
- package/dist/edit/docx/paragraph.js +14 -0
- package/dist/edit/docx/run.cjs +1 -1
- package/dist/edit/docx/run.js +1 -1
- package/dist/edit/docx/table.cjs +41 -0
- package/dist/edit/docx/table.d.cts +7 -1
- package/dist/edit/docx/table.d.ts +7 -1
- package/dist/edit/docx/table.js +42 -1
- package/dist/edit/geometry.cjs +38 -0
- package/dist/edit/geometry.d.cts +7 -0
- package/dist/edit/geometry.d.ts +7 -0
- package/dist/edit/geometry.js +36 -0
- package/dist/edit/odg/content.cjs +15 -12
- package/dist/edit/odg/content.js +15 -12
- package/dist/edit/odg/editor.d.cts +1 -1
- package/dist/edit/odg/editor.d.ts +1 -1
- package/dist/edit/odg/page.d.cts +3 -3
- package/dist/edit/odg/page.d.ts +3 -3
- package/dist/edit/odg/vector.cjs +22 -13
- package/dist/edit/odg/vector.d.cts +1 -1
- package/dist/edit/odg/vector.d.ts +1 -1
- package/dist/edit/odg/vector.js +23 -14
- package/dist/edit/odp/content.cjs +15 -0
- package/dist/edit/odp/content.js +16 -1
- package/dist/edit/odp/editor.d.cts +1 -1
- package/dist/edit/odp/editor.d.ts +1 -1
- package/dist/edit/odp/image.d.cts +1 -1
- package/dist/edit/odp/image.d.ts +1 -1
- package/dist/edit/odp/shape.cjs +11 -30
- package/dist/edit/odp/shape.d.cts +2 -2
- package/dist/edit/odp/shape.d.ts +2 -2
- package/dist/edit/odp/shape.js +13 -33
- package/dist/edit/odp/slide.cjs +11 -0
- package/dist/edit/odp/slide.d.cts +14 -4
- package/dist/edit/odp/slide.d.ts +14 -4
- package/dist/edit/odp/slide.js +12 -1
- package/dist/edit/odt/content.cjs +56 -16
- package/dist/edit/odt/content.d.cts +4 -2
- package/dist/edit/odt/content.d.ts +4 -2
- package/dist/edit/odt/content.js +56 -17
- package/dist/edit/odt/editor.d.cts +1 -1
- package/dist/edit/odt/editor.d.ts +1 -1
- package/dist/edit/odt/table.cjs +36 -0
- package/dist/edit/odt/table.d.cts +1 -36
- package/dist/edit/odt/table.d.ts +1 -36
- package/dist/edit/odt/table.js +37 -1
- package/dist/edit/pptx/content.cjs +71 -3
- package/dist/edit/pptx/content.js +71 -3
- package/dist/edit/pptx/editor.d.cts +1 -1
- package/dist/edit/pptx/editor.d.ts +1 -1
- package/dist/edit/pptx/image.d.cts +1 -1
- package/dist/edit/pptx/image.d.ts +1 -1
- package/dist/edit/pptx/shape.cjs +23 -1
- package/dist/edit/pptx/shape.d.cts +2 -2
- package/dist/edit/pptx/shape.d.ts +2 -2
- package/dist/edit/pptx/shape.js +23 -3
- package/dist/edit/pptx/slide.cjs +10 -1
- package/dist/edit/pptx/slide.d.cts +11 -4
- package/dist/edit/pptx/slide.d.ts +11 -4
- package/dist/edit/pptx/slide.js +10 -1
- package/dist/edit/pptx/table.cjs +136 -0
- package/dist/edit/pptx/table.d.cts +2 -0
- package/dist/edit/pptx/table.d.ts +2 -0
- package/dist/edit/pptx/table.js +131 -0
- package/dist/firebird/backup.d.cts +1 -1
- package/dist/firebird/backup.d.ts +1 -1
- package/dist/firebird/blr-types.cjs +2 -2
- package/dist/firebird/blr-types.d.cts +1 -1
- package/dist/firebird/blr-types.d.ts +1 -1
- package/dist/firebird/blr-types.js +2 -2
- package/dist/firebird/data.cjs +68 -14
- package/dist/firebird/data.d.cts +1 -1
- package/dist/firebird/data.d.ts +1 -1
- package/dist/firebird/data.js +68 -14
- package/dist/firebird/schema.cjs +13 -1
- package/dist/firebird/schema.d.cts +1 -1
- package/dist/firebird/schema.d.ts +1 -1
- package/dist/firebird/schema.js +13 -1
- package/dist/{geometry-DvwdrIij.d.cts → geometry-DaJr8yQW.d.cts} +2 -2
- package/dist/{geometry-DvwdrIij.d.ts → geometry-DaJr8yQW.d.ts} +2 -2
- package/dist/hsqldb/binary-script.cjs +154 -0
- package/dist/hsqldb/binary-script.d.cts +15 -0
- package/dist/hsqldb/binary-script.d.ts +15 -0
- package/dist/hsqldb/binary-script.js +151 -0
- package/dist/hsqldb/cache.cjs +18 -11
- package/dist/hsqldb/cache.d.cts +9 -4
- package/dist/hsqldb/cache.d.ts +9 -4
- package/dist/hsqldb/cache.js +18 -11
- package/dist/hsqldb/rowformat.cjs +60 -16
- package/dist/hsqldb/rowformat.d.cts +2 -21
- package/dist/hsqldb/rowformat.d.ts +2 -21
- package/dist/hsqldb/rowformat.js +60 -17
- package/dist/{image-BZDy72Jb.d.cts → image-7snmKIxn.d.cts} +1 -1
- package/dist/{image-B-xQWYYS.d.ts → image-Cs8xF753.d.ts} +1 -1
- package/dist/{image-CeqwL-Qs.d.ts → image-DHcA9kaK.d.ts} +1 -1
- package/dist/{image-DWX6cNOD.d.cts → image-M5SezZVI.d.cts} +1 -1
- package/dist/index.cjs +54 -3
- package/dist/index.d.cts +28 -20
- package/dist/index.d.ts +27 -19
- package/dist/index.js +13 -4
- package/dist/layout/cell-typing.cjs +209 -0
- package/dist/layout/cell-typing.d.cts +22 -0
- package/dist/layout/cell-typing.d.ts +22 -0
- package/dist/layout/cell-typing.js +208 -0
- package/dist/layout/drawing.cjs +193 -17
- package/dist/layout/drawing.js +193 -17
- package/dist/layout/engine.cjs +46 -29
- package/dist/layout/engine.d.cts +0 -2
- package/dist/layout/engine.d.ts +0 -2
- package/dist/layout/engine.js +47 -30
- package/dist/layout/lattice.cjs +139 -0
- package/dist/layout/lattice.d.cts +20 -0
- package/dist/layout/lattice.d.ts +20 -0
- package/dist/layout/lattice.js +135 -0
- package/dist/layout/reconstruct.cjs +176 -113
- package/dist/layout/reconstruct.d.cts +2 -0
- package/dist/layout/reconstruct.d.ts +2 -0
- package/dist/layout/reconstruct.js +173 -110
- package/dist/layout/shared.cjs +52 -0
- package/dist/layout/shared.d.cts +4 -2
- package/dist/layout/shared.d.ts +4 -2
- package/dist/layout/shared.js +51 -1
- package/dist/layout/sheets.cjs +45 -11
- package/dist/layout/sheets.js +46 -12
- package/dist/layout/slides.cjs +7 -7
- package/dist/layout/slides.d.cts +0 -3
- package/dist/layout/slides.d.ts +0 -3
- package/dist/layout/slides.js +7 -7
- package/dist/markdown/write.cjs +19 -6
- package/dist/markdown/write.js +19 -6
- package/dist/mathml/layout.cjs +43 -9
- package/dist/mathml/layout.d.cts +1 -1
- package/dist/mathml/layout.d.ts +1 -1
- package/dist/mathml/layout.js +43 -9
- package/dist/mathml/variant.cjs +48 -5
- package/dist/mathml/variant.js +48 -5
- package/dist/model/embedded-drawing.cjs +32 -0
- package/dist/model/embedded-drawing.d.cts +8 -0
- package/dist/model/embedded-drawing.d.ts +8 -0
- package/dist/model/embedded-drawing.js +30 -0
- package/dist/model/formula.cjs +31 -0
- package/dist/model/formula.d.cts +6 -6
- package/dist/model/formula.d.ts +6 -6
- package/dist/model/formula.js +27 -0
- package/dist/model/geometry.d.cts +1 -1
- package/dist/model/geometry.d.ts +1 -1
- package/dist/model/paint-order.cjs +15 -0
- package/dist/model/paint-order.d.cts +14 -0
- package/dist/model/paint-order.d.ts +14 -0
- package/dist/model/paint-order.js +14 -0
- package/dist/odb/components.cjs +12 -0
- package/dist/odb/components.d.cts +6 -0
- package/dist/odb/components.d.ts +6 -0
- package/dist/odb/components.js +10 -0
- package/dist/odb/read.cjs +11 -7
- package/dist/odb/read.d.cts +3 -2
- package/dist/odb/read.d.ts +3 -2
- package/dist/odb/read.js +11 -7
- package/dist/odf/formula/detect.cjs +86 -18
- package/dist/odf/formula/detect.d.cts +10 -6
- package/dist/odf/formula/detect.d.ts +10 -6
- package/dist/odf/formula/detect.js +86 -19
- package/dist/odf/formula/read.cjs +4 -16
- package/dist/odf/formula/read.d.cts +4 -8
- package/dist/odf/formula/read.d.ts +4 -8
- package/dist/odf/formula/read.js +5 -17
- package/dist/odf/odp/read.cjs +9 -19
- package/dist/odf/odp/read.d.cts +2 -7
- package/dist/odf/odp/read.d.ts +2 -7
- package/dist/odf/odp/read.js +10 -20
- package/dist/odf/odt/read.cjs +63 -23
- package/dist/odf/odt/read.d.cts +2 -7
- package/dist/odf/odt/read.d.ts +2 -7
- package/dist/odf/odt/read.js +64 -24
- package/dist/omml/write.cjs +258 -0
- package/dist/omml/write.d.cts +2 -0
- package/dist/omml/write.d.ts +2 -0
- package/dist/omml/write.js +256 -0
- package/dist/rowformat-Cl2exlEh.d.cts +25 -0
- package/dist/rowformat-Cl2exlEh.d.ts +25 -0
- package/dist/{schema-Acco3Ezi.d.cts → schema-BeR_KJ0X.d.cts} +3 -1
- package/dist/{schema-VkAA6pF5.d.ts → schema-CSKwSb_v.d.ts} +3 -1
- package/dist/{shape-BUfjw5eZ.d.cts → shape-BhkP6HB8.d.cts} +6 -2
- package/dist/{shape-CTkl6kt8.d.ts → shape-BkVcwPcf.d.ts} +6 -2
- package/dist/{shape-BfN3m52m.d.ts → shape-CVXedeL7.d.ts} +3 -2
- package/dist/{shape-CN2ycxOo.d.cts → shape-CXZ6fejV.d.cts} +3 -2
- package/dist/table-C3CPZ--2.d.cts +35 -0
- package/dist/table-DjYcNOFm.d.cts +44 -0
- package/dist/table-DqfqMkVq.d.ts +44 -0
- package/dist/table-DvS_7UQS.d.ts +35 -0
- package/dist/{vector-ClohqsOe.d.cts → vector-Puuqu_IT.d.cts} +4 -0
- package/dist/{vector-ClohqsOe.d.ts → vector-Puuqu_IT.d.ts} +4 -0
- package/dist/write-DuyfnbL_.d.cts +16 -0
- package/dist/write-Zqwx6pka.d.ts +16 -0
- package/package.json +4 -4
- package/dist/odf/formula/placeholder.cjs +0 -36
- package/dist/odf/formula/placeholder.d.cts +0 -14
- package/dist/odf/formula/placeholder.d.ts +0 -14
- package/dist/odf/formula/placeholder.js +0 -36
|
@@ -1,12 +1,16 @@
|
|
|
1
|
-
import { t as Box } from "../../geometry-
|
|
2
|
-
import {
|
|
1
|
+
import { t as Box$1 } from "../../geometry-DaJr8yQW.cjs";
|
|
2
|
+
import { ContentFormula } from "document-schema.js";
|
|
3
3
|
import { Package, XmlElement, XmlNode } from "odf.js";
|
|
4
4
|
//#region src/odf/formula/detect.d.ts
|
|
5
5
|
interface DetectedFormulaFrame {
|
|
6
6
|
readonly frameElement: XmlElement;
|
|
7
|
-
readonly formula:
|
|
8
|
-
readonly frame: Box;
|
|
7
|
+
readonly formula: ContentFormula;
|
|
8
|
+
readonly frame: Box$1;
|
|
9
9
|
}
|
|
10
|
-
|
|
10
|
+
interface DetectedSlideFormulaFrame extends DetectedFormulaFrame {
|
|
11
|
+
readonly shapeIndex: number;
|
|
12
|
+
}
|
|
13
|
+
declare function collectFormulaFrames(nodes: readonly XmlNode[], pkg: Package): readonly DetectedFormulaFrame[];
|
|
14
|
+
declare function collectSlideFormulaFrames(pageChildren: readonly XmlNode[], pkg: Package): readonly DetectedSlideFormulaFrame[];
|
|
11
15
|
//#endregion
|
|
12
|
-
export { DetectedFormulaFrame,
|
|
16
|
+
export { DetectedFormulaFrame, DetectedSlideFormulaFrame, collectFormulaFrames, collectSlideFormulaFrames };
|
|
@@ -1,12 +1,16 @@
|
|
|
1
|
-
import { t as Box } from "../../geometry-
|
|
2
|
-
import {
|
|
1
|
+
import { t as Box$1 } from "../../geometry-DaJr8yQW.js";
|
|
2
|
+
import { ContentFormula } from "document-schema.js";
|
|
3
3
|
import { Package, XmlElement, XmlNode } from "odf.js";
|
|
4
4
|
//#region src/odf/formula/detect.d.ts
|
|
5
5
|
interface DetectedFormulaFrame {
|
|
6
6
|
readonly frameElement: XmlElement;
|
|
7
|
-
readonly formula:
|
|
8
|
-
readonly frame: Box;
|
|
7
|
+
readonly formula: ContentFormula;
|
|
8
|
+
readonly frame: Box$1;
|
|
9
9
|
}
|
|
10
|
-
|
|
10
|
+
interface DetectedSlideFormulaFrame extends DetectedFormulaFrame {
|
|
11
|
+
readonly shapeIndex: number;
|
|
12
|
+
}
|
|
13
|
+
declare function collectFormulaFrames(nodes: readonly XmlNode[], pkg: Package): readonly DetectedFormulaFrame[];
|
|
14
|
+
declare function collectSlideFormulaFrames(pageChildren: readonly XmlNode[], pkg: Package): readonly DetectedSlideFormulaFrame[];
|
|
11
15
|
//#endregion
|
|
12
|
-
export { DetectedFormulaFrame,
|
|
16
|
+
export { DetectedFormulaFrame, DetectedSlideFormulaFrame, collectFormulaFrames, collectSlideFormulaFrames };
|
|
@@ -1,28 +1,95 @@
|
|
|
1
1
|
import { readOdfEmbeddedFormula } from "./read.js";
|
|
2
|
-
import { attrValue, childrenWithTag, readDrawFrame } from "odf.js";
|
|
2
|
+
import { attrValue, childrenWithTag, parseOdfLength, parseOdfTransform, readDrawFrame } from "odf.js";
|
|
3
3
|
//#region src/odf/formula/detect.ts
|
|
4
4
|
function subPackagePathFromHref(href) {
|
|
5
5
|
return href.replace(/^#?\.\//, "");
|
|
6
6
|
}
|
|
7
|
-
function
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
7
|
+
function formulaOfFrame(frame, pkg) {
|
|
8
|
+
const objectElement = childrenWithTag(frame, "draw:object")[0];
|
|
9
|
+
if (objectElement === void 0) return;
|
|
10
|
+
const href = attrValue(objectElement, "xlink:href");
|
|
11
|
+
if (href === void 0) return;
|
|
12
|
+
return readOdfEmbeddedFormula(pkg, subPackagePathFromHref(href));
|
|
13
|
+
}
|
|
14
|
+
function flowAnchoredFrameBox(frame) {
|
|
15
|
+
const widthValue = attrValue(frame, "svg:width");
|
|
16
|
+
const heightValue = attrValue(frame, "svg:height");
|
|
17
|
+
if (widthValue === void 0 || heightValue === void 0) return;
|
|
18
|
+
const widthPt = parseOdfLength(widthValue);
|
|
19
|
+
const heightPt = parseOdfLength(heightValue);
|
|
20
|
+
if (widthPt === void 0 || heightPt === void 0) return;
|
|
21
|
+
return {
|
|
22
|
+
xPt: 0,
|
|
23
|
+
yPt: 0,
|
|
24
|
+
widthPt,
|
|
25
|
+
heightPt
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
function nestedGroupFunctions(group, groupFunctions) {
|
|
29
|
+
const value = attrValue(group, "draw:transform");
|
|
30
|
+
const own = value === void 0 ? [] : parseOdfTransform(value);
|
|
31
|
+
return own.length === 0 ? groupFunctions : [...own, ...groupFunctions];
|
|
32
|
+
}
|
|
33
|
+
function readFormulaFrame(frame, groupFunctions, pkg, allowFlowAnchored) {
|
|
34
|
+
const formula = formulaOfFrame(frame, pkg);
|
|
35
|
+
if (formula === void 0) return;
|
|
36
|
+
const box = readDrawFrame(frame, groupFunctions, pkg)?.frame ?? (allowFlowAnchored ? flowAnchoredFrameBox(frame) : void 0);
|
|
37
|
+
if (box === void 0) return;
|
|
38
|
+
return {
|
|
39
|
+
frameElement: frame,
|
|
40
|
+
formula,
|
|
41
|
+
frame: box
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
function walkForFormulaFrames(nodes, groupFunctions, pkg, out) {
|
|
45
|
+
for (const node of nodes) {
|
|
46
|
+
if (node.type !== "element") continue;
|
|
47
|
+
if (node.tag === "draw:frame") {
|
|
48
|
+
const detected = readFormulaFrame(node, groupFunctions, pkg, true);
|
|
49
|
+
if (detected !== void 0) {
|
|
50
|
+
out.push(detected);
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
walkForFormulaFrames(node.children, groupFunctions, pkg, out);
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
if (node.tag === "draw:g") {
|
|
57
|
+
walkForFormulaFrames(node.children, nestedGroupFunctions(node, groupFunctions), pkg, out);
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
walkForFormulaFrames(node.children, groupFunctions, pkg, out);
|
|
24
61
|
}
|
|
62
|
+
}
|
|
63
|
+
function collectFormulaFrames(nodes, pkg) {
|
|
64
|
+
const out = [];
|
|
65
|
+
walkForFormulaFrames(nodes, [], pkg, out);
|
|
66
|
+
return out;
|
|
67
|
+
}
|
|
68
|
+
function collectSlideFormulaFrames(pageChildren, pkg) {
|
|
69
|
+
const out = [];
|
|
70
|
+
const state = { nextShapeIndex: 0 };
|
|
71
|
+
const walk = (nodes, groupFunctions) => {
|
|
72
|
+
for (const node of nodes) {
|
|
73
|
+
if (node.type !== "element") continue;
|
|
74
|
+
if (node.tag === "draw:frame") {
|
|
75
|
+
const shape = readDrawFrame(node, groupFunctions, pkg);
|
|
76
|
+
if (shape === void 0) continue;
|
|
77
|
+
const shapeIndex = state.nextShapeIndex;
|
|
78
|
+
state.nextShapeIndex += 1;
|
|
79
|
+
const formula = formulaOfFrame(node, pkg);
|
|
80
|
+
if (formula !== void 0) out.push({
|
|
81
|
+
frameElement: node,
|
|
82
|
+
formula,
|
|
83
|
+
frame: shape.frame,
|
|
84
|
+
shapeIndex
|
|
85
|
+
});
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
if (node.tag === "draw:g") walk(node.children, nestedGroupFunctions(node, groupFunctions));
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
walk(pageChildren, []);
|
|
25
92
|
return out;
|
|
26
93
|
}
|
|
27
94
|
//#endregion
|
|
28
|
-
export {
|
|
95
|
+
export { collectFormulaFrames, collectSlideFormulaFrames };
|
|
@@ -2,27 +2,15 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
2
2
|
let odf_js = require("odf.js");
|
|
3
3
|
//#region src/odf/formula/read.ts
|
|
4
4
|
function readOdfFormulaContent(pkg) {
|
|
5
|
-
|
|
6
|
-
return {
|
|
7
|
-
mathml: formula.mathml,
|
|
8
|
-
starMath: formula.starMath,
|
|
9
|
-
metadata: formula.metadata
|
|
10
|
-
};
|
|
5
|
+
return (0, odf_js.readOdfFormulaDocument)(pkg);
|
|
11
6
|
}
|
|
12
7
|
function readOdfEmbeddedFormula(outerPkg, subPackagePath) {
|
|
13
8
|
const contentPart = outerPkg.parts[`${subPackagePath}/content.xml`];
|
|
14
9
|
if (contentPart?.kind !== "xml") return;
|
|
15
|
-
const
|
|
16
|
-
const subPkg = { parts: metaPart?.kind === "xml" ? {
|
|
17
|
-
"content.xml": contentPart,
|
|
18
|
-
"meta.xml": metaPart
|
|
19
|
-
} : { "content.xml": contentPart } };
|
|
10
|
+
const subPkg = { parts: { "content.xml": contentPart } };
|
|
20
11
|
try {
|
|
21
|
-
const
|
|
22
|
-
return
|
|
23
|
-
mathml: formula.mathml,
|
|
24
|
-
starMath: formula.starMath
|
|
25
|
-
};
|
|
12
|
+
const document = (0, odf_js.readOdfFormulaDocument)(subPkg);
|
|
13
|
+
return document.kind === "formula" ? document.formula : void 0;
|
|
26
14
|
} catch {
|
|
27
15
|
return;
|
|
28
16
|
}
|
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { LayoutMetadata } from "document-schema.js";
|
|
1
|
+
import { ContentDocument, ContentFormula } from "document-schema.js";
|
|
3
2
|
import { Package } from "odf.js";
|
|
4
3
|
//#region src/odf/formula/read.d.ts
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
declare function readOdfFormulaContent(pkg: Package): StandaloneFormulaContent;
|
|
9
|
-
declare function readOdfEmbeddedFormula(outerPkg: Package, subPackagePath: string): EmbeddedFormula | undefined;
|
|
4
|
+
declare function readOdfFormulaContent(pkg: Package): ContentDocument;
|
|
5
|
+
declare function readOdfEmbeddedFormula(outerPkg: Package, subPackagePath: string): ContentFormula | undefined;
|
|
10
6
|
//#endregion
|
|
11
|
-
export {
|
|
7
|
+
export { readOdfEmbeddedFormula, readOdfFormulaContent };
|
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { LayoutMetadata } from "document-schema.js";
|
|
1
|
+
import { ContentDocument, ContentFormula } from "document-schema.js";
|
|
3
2
|
import { Package } from "odf.js";
|
|
4
3
|
//#region src/odf/formula/read.d.ts
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
declare function readOdfFormulaContent(pkg: Package): StandaloneFormulaContent;
|
|
9
|
-
declare function readOdfEmbeddedFormula(outerPkg: Package, subPackagePath: string): EmbeddedFormula | undefined;
|
|
4
|
+
declare function readOdfFormulaContent(pkg: Package): ContentDocument;
|
|
5
|
+
declare function readOdfEmbeddedFormula(outerPkg: Package, subPackagePath: string): ContentFormula | undefined;
|
|
10
6
|
//#endregion
|
|
11
|
-
export {
|
|
7
|
+
export { readOdfEmbeddedFormula, readOdfFormulaContent };
|
package/dist/odf/formula/read.js
CHANGED
|
@@ -1,27 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { readOdfFormulaDocument } from "odf.js";
|
|
2
2
|
//#region src/odf/formula/read.ts
|
|
3
3
|
function readOdfFormulaContent(pkg) {
|
|
4
|
-
|
|
5
|
-
return {
|
|
6
|
-
mathml: formula.mathml,
|
|
7
|
-
starMath: formula.starMath,
|
|
8
|
-
metadata: formula.metadata
|
|
9
|
-
};
|
|
4
|
+
return readOdfFormulaDocument(pkg);
|
|
10
5
|
}
|
|
11
6
|
function readOdfEmbeddedFormula(outerPkg, subPackagePath) {
|
|
12
7
|
const contentPart = outerPkg.parts[`${subPackagePath}/content.xml`];
|
|
13
8
|
if (contentPart?.kind !== "xml") return;
|
|
14
|
-
const
|
|
15
|
-
const subPkg = { parts: metaPart?.kind === "xml" ? {
|
|
16
|
-
"content.xml": contentPart,
|
|
17
|
-
"meta.xml": metaPart
|
|
18
|
-
} : { "content.xml": contentPart } };
|
|
9
|
+
const subPkg = { parts: { "content.xml": contentPart } };
|
|
19
10
|
try {
|
|
20
|
-
const
|
|
21
|
-
return
|
|
22
|
-
mathml: formula.mathml,
|
|
23
|
-
starMath: formula.starMath
|
|
24
|
-
};
|
|
11
|
+
const document = readOdfFormulaDocument(subPkg);
|
|
12
|
+
return document.kind === "formula" ? document.formula : void 0;
|
|
25
13
|
} catch {
|
|
26
14
|
return;
|
|
27
15
|
}
|
package/dist/odf/odp/read.cjs
CHANGED
|
@@ -1,44 +1,34 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_model_formula = require("../../model/formula.cjs");
|
|
2
3
|
const require_odf_formula_detect = require("../formula/detect.cjs");
|
|
3
|
-
const require_odf_formula_placeholder = require("../formula/placeholder.cjs");
|
|
4
4
|
let document_schema_js = require("document-schema.js");
|
|
5
5
|
let odf_js = require("odf.js");
|
|
6
6
|
//#region src/odf/odp/read.ts
|
|
7
7
|
function readOdpContent(pkg) {
|
|
8
8
|
const odpDoc = (0, odf_js.readOdp)(pkg);
|
|
9
|
-
const formulas = /* @__PURE__ */ new Map();
|
|
10
9
|
const contentPart = pkg.parts["content.xml"];
|
|
11
10
|
if (contentPart?.kind === "xml") {
|
|
12
11
|
const root = (0, odf_js.rootElement)(contentPart.nodes);
|
|
13
12
|
const body = root === void 0 ? void 0 : (0, odf_js.findChildElement)(root.children, "office:body");
|
|
14
13
|
const presentation = body === void 0 ? void 0 : (0, odf_js.findChildElement)(body.children, "office:presentation");
|
|
15
14
|
(presentation === void 0 ? [] : (0, odf_js.childrenWithTag)(presentation, "draw:page")).forEach((pageElement, slideIndex) => {
|
|
16
|
-
if ((0, odf_js.childrenWithTag)(pageElement, "draw:g").length > 0) return;
|
|
17
15
|
const slide = odpDoc.slides[slideIndex];
|
|
18
16
|
if (slide === void 0) return;
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
for (const found of detected) {
|
|
22
|
-
const shapeIndex = frameElements.indexOf(found.frameElement);
|
|
23
|
-
const shape = slide.shapes[shapeIndex];
|
|
17
|
+
for (const found of require_odf_formula_detect.collectSlideFormulaFrames(pageElement.children, pkg)) {
|
|
18
|
+
const shape = slide.shapes[found.shapeIndex];
|
|
24
19
|
if (shape === void 0) continue;
|
|
25
|
-
|
|
26
|
-
slide.shapes[shapeIndex] = {
|
|
20
|
+
slide.shapes[found.shapeIndex] = {
|
|
27
21
|
...shape,
|
|
28
|
-
blocks: [
|
|
22
|
+
blocks: [require_model_formula.buildFormulaBlock(found.formula, found.frame, `slides[${slideIndex}].shapes[${found.shapeIndex}]`)]
|
|
29
23
|
};
|
|
30
|
-
formulas.set(sourcePath, found.formula);
|
|
31
24
|
}
|
|
32
25
|
});
|
|
33
26
|
}
|
|
34
27
|
return {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
slides: odpDoc.slides
|
|
40
|
-
},
|
|
41
|
-
formulas
|
|
28
|
+
kind: "presentation",
|
|
29
|
+
formatVersion: document_schema_js.CONTENT_FORMAT_VERSION,
|
|
30
|
+
metadata: { ...odpDoc.metadata },
|
|
31
|
+
slides: odpDoc.slides
|
|
42
32
|
};
|
|
43
33
|
}
|
|
44
34
|
//#endregion
|
package/dist/odf/odp/read.d.cts
CHANGED
|
@@ -1,11 +1,6 @@
|
|
|
1
|
-
import { EmbeddedFormula } from "../../model/formula.cjs";
|
|
2
1
|
import { ContentDocument } from "document-schema.js";
|
|
3
2
|
import { Package } from "odf.js";
|
|
4
3
|
//#region src/odf/odp/read.d.ts
|
|
5
|
-
|
|
6
|
-
readonly document: ContentDocument;
|
|
7
|
-
readonly formulas: ReadonlyMap<string, EmbeddedFormula>;
|
|
8
|
-
}
|
|
9
|
-
declare function readOdpContent(pkg: Package): OdpContentResult;
|
|
4
|
+
declare function readOdpContent(pkg: Package): ContentDocument;
|
|
10
5
|
//#endregion
|
|
11
|
-
export {
|
|
6
|
+
export { readOdpContent };
|
package/dist/odf/odp/read.d.ts
CHANGED
|
@@ -1,11 +1,6 @@
|
|
|
1
|
-
import { EmbeddedFormula } from "../../model/formula.js";
|
|
2
1
|
import { ContentDocument } from "document-schema.js";
|
|
3
2
|
import { Package } from "odf.js";
|
|
4
3
|
//#region src/odf/odp/read.d.ts
|
|
5
|
-
|
|
6
|
-
readonly document: ContentDocument;
|
|
7
|
-
readonly formulas: ReadonlyMap<string, EmbeddedFormula>;
|
|
8
|
-
}
|
|
9
|
-
declare function readOdpContent(pkg: Package): OdpContentResult;
|
|
4
|
+
declare function readOdpContent(pkg: Package): ContentDocument;
|
|
10
5
|
//#endregion
|
|
11
|
-
export {
|
|
6
|
+
export { readOdpContent };
|
package/dist/odf/odp/read.js
CHANGED
|
@@ -1,43 +1,33 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { buildFormulaBlock } from "../../model/formula.js";
|
|
2
|
+
import { collectSlideFormulaFrames } from "../formula/detect.js";
|
|
3
3
|
import { CONTENT_FORMAT_VERSION } from "document-schema.js";
|
|
4
4
|
import { childrenWithTag, findChildElement, readOdp, rootElement } from "odf.js";
|
|
5
5
|
//#region src/odf/odp/read.ts
|
|
6
6
|
function readOdpContent(pkg) {
|
|
7
7
|
const odpDoc = readOdp(pkg);
|
|
8
|
-
const formulas = /* @__PURE__ */ new Map();
|
|
9
8
|
const contentPart = pkg.parts["content.xml"];
|
|
10
9
|
if (contentPart?.kind === "xml") {
|
|
11
10
|
const root = rootElement(contentPart.nodes);
|
|
12
11
|
const body = root === void 0 ? void 0 : findChildElement(root.children, "office:body");
|
|
13
12
|
const presentation = body === void 0 ? void 0 : findChildElement(body.children, "office:presentation");
|
|
14
13
|
(presentation === void 0 ? [] : childrenWithTag(presentation, "draw:page")).forEach((pageElement, slideIndex) => {
|
|
15
|
-
if (childrenWithTag(pageElement, "draw:g").length > 0) return;
|
|
16
14
|
const slide = odpDoc.slides[slideIndex];
|
|
17
15
|
if (slide === void 0) return;
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
for (const found of detected) {
|
|
21
|
-
const shapeIndex = frameElements.indexOf(found.frameElement);
|
|
22
|
-
const shape = slide.shapes[shapeIndex];
|
|
16
|
+
for (const found of collectSlideFormulaFrames(pageElement.children, pkg)) {
|
|
17
|
+
const shape = slide.shapes[found.shapeIndex];
|
|
23
18
|
if (shape === void 0) continue;
|
|
24
|
-
|
|
25
|
-
slide.shapes[shapeIndex] = {
|
|
19
|
+
slide.shapes[found.shapeIndex] = {
|
|
26
20
|
...shape,
|
|
27
|
-
blocks: [
|
|
21
|
+
blocks: [buildFormulaBlock(found.formula, found.frame, `slides[${slideIndex}].shapes[${found.shapeIndex}]`)]
|
|
28
22
|
};
|
|
29
|
-
formulas.set(sourcePath, found.formula);
|
|
30
23
|
}
|
|
31
24
|
});
|
|
32
25
|
}
|
|
33
26
|
return {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
slides: odpDoc.slides
|
|
39
|
-
},
|
|
40
|
-
formulas
|
|
27
|
+
kind: "presentation",
|
|
28
|
+
formatVersion: CONTENT_FORMAT_VERSION,
|
|
29
|
+
metadata: { ...odpDoc.metadata },
|
|
30
|
+
slides: odpDoc.slides
|
|
41
31
|
};
|
|
42
32
|
}
|
|
43
33
|
//#endregion
|
package/dist/odf/odt/read.cjs
CHANGED
|
@@ -1,43 +1,83 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_model_formula = require("../../model/formula.cjs");
|
|
2
3
|
const require_odf_formula_detect = require("../formula/detect.cjs");
|
|
3
|
-
const require_odf_formula_placeholder = require("../formula/placeholder.cjs");
|
|
4
4
|
let document_schema_js = require("document-schema.js");
|
|
5
5
|
let odf_js = require("odf.js");
|
|
6
6
|
//#region src/odf/odt/read.ts
|
|
7
7
|
function readOdtContent(pkg) {
|
|
8
8
|
const odtDoc = (0, odf_js.readOdt)(pkg);
|
|
9
|
-
const formulas = /* @__PURE__ */ new Map();
|
|
10
9
|
const contentPart = pkg.parts["content.xml"];
|
|
11
10
|
if (contentPart?.kind === "xml" && odtDoc.sections.length === 1) {
|
|
12
11
|
const root = (0, odf_js.rootElement)(contentPart.nodes);
|
|
13
12
|
const body = root === void 0 ? void 0 : (0, odf_js.findChildElement)(root.children, "office:body");
|
|
14
13
|
const text = body === void 0 ? void 0 : (0, odf_js.findChildElement)(body.children, "office:text");
|
|
15
14
|
if (text !== void 0) {
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
blocks.push(require_odf_formula_placeholder.buildFormulaPlaceholderBlock(found.formula, found.frame, sourcePath));
|
|
23
|
-
formulas.set(sourcePath, found.formula);
|
|
24
|
-
}
|
|
25
|
-
odtDoc.sections[0] = {
|
|
26
|
-
...section,
|
|
27
|
-
blocks
|
|
28
|
-
};
|
|
29
|
-
}
|
|
15
|
+
const section = odtDoc.sections[0];
|
|
16
|
+
const placements = collectFormulaPlacements(text.children, pkg);
|
|
17
|
+
if (placements.length > 0) odtDoc.sections[0] = {
|
|
18
|
+
...section,
|
|
19
|
+
blocks: spliceFormulaBlocks(section.blocks, placements)
|
|
20
|
+
};
|
|
30
21
|
}
|
|
31
22
|
}
|
|
32
23
|
return {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
sections: odtDoc.sections
|
|
38
|
-
},
|
|
39
|
-
formulas
|
|
24
|
+
kind: "wordprocessing",
|
|
25
|
+
formatVersion: document_schema_js.CONTENT_FORMAT_VERSION,
|
|
26
|
+
metadata: { ...odtDoc.metadata },
|
|
27
|
+
sections: odtDoc.sections
|
|
40
28
|
};
|
|
41
29
|
}
|
|
30
|
+
function pushPlacements(out, index, detected) {
|
|
31
|
+
for (const frame of detected) out.push({
|
|
32
|
+
index,
|
|
33
|
+
detected: frame
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
function collectFormulaPlacements(nodes, pkg) {
|
|
37
|
+
const out = [];
|
|
38
|
+
walkForPlacements(nodes, pkg, { blockCount: 0 }, out);
|
|
39
|
+
return out;
|
|
40
|
+
}
|
|
41
|
+
function walkForPlacements(nodes, pkg, state, out) {
|
|
42
|
+
for (const node of nodes) {
|
|
43
|
+
if (node.type !== "element") continue;
|
|
44
|
+
if (node.tag === "text:p" || node.tag === "text:h") {
|
|
45
|
+
state.blockCount += 1;
|
|
46
|
+
pushPlacements(out, state.blockCount, require_odf_formula_detect.collectFormulaFrames(node.children, pkg));
|
|
47
|
+
} else if (node.tag === "text:list") walkListForPlacements(node.children, pkg, state, out);
|
|
48
|
+
else if (node.tag === "table:table") {
|
|
49
|
+
state.blockCount += 1;
|
|
50
|
+
pushPlacements(out, state.blockCount, require_odf_formula_detect.collectFormulaFrames(node.children, pkg));
|
|
51
|
+
} else if (node.tag === "text:section") walkForPlacements(node.children, pkg, state, out);
|
|
52
|
+
else pushPlacements(out, state.blockCount, require_odf_formula_detect.collectFormulaFrames([node], pkg));
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
function walkListForPlacements(itemNodes, pkg, state, out) {
|
|
56
|
+
for (const item of itemNodes) {
|
|
57
|
+
if (item.type !== "element" || item.tag !== "text:list-item") continue;
|
|
58
|
+
for (const itemChild of item.children) {
|
|
59
|
+
if (itemChild.type !== "element") continue;
|
|
60
|
+
if (itemChild.tag === "text:p" || itemChild.tag === "text:h") {
|
|
61
|
+
state.blockCount += 1;
|
|
62
|
+
pushPlacements(out, state.blockCount, require_odf_formula_detect.collectFormulaFrames(itemChild.children, pkg));
|
|
63
|
+
} else if (itemChild.tag === "text:list") walkListForPlacements(itemChild.children, pkg, state, out);
|
|
64
|
+
else pushPlacements(out, state.blockCount, require_odf_formula_detect.collectFormulaFrames([itemChild], pkg));
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
function spliceFormulaBlocks(blocks, placements) {
|
|
69
|
+
const out = [];
|
|
70
|
+
let next = 0;
|
|
71
|
+
for (let index = 0; index <= blocks.length; index++) {
|
|
72
|
+
while (next < placements.length && placements[next].index === index) {
|
|
73
|
+
const { detected } = placements[next];
|
|
74
|
+
out.push(require_model_formula.buildFormulaBlock(detected.formula, detected.frame, `sections[0].blocks[${out.length}]`));
|
|
75
|
+
next += 1;
|
|
76
|
+
}
|
|
77
|
+
const block = blocks[index];
|
|
78
|
+
if (block !== void 0) out.push(block);
|
|
79
|
+
}
|
|
80
|
+
return out;
|
|
81
|
+
}
|
|
42
82
|
//#endregion
|
|
43
83
|
exports.readOdtContent = readOdtContent;
|
package/dist/odf/odt/read.d.cts
CHANGED
|
@@ -1,11 +1,6 @@
|
|
|
1
|
-
import { EmbeddedFormula } from "../../model/formula.cjs";
|
|
2
1
|
import { ContentDocument } from "document-schema.js";
|
|
3
2
|
import { Package } from "odf.js";
|
|
4
3
|
//#region src/odf/odt/read.d.ts
|
|
5
|
-
|
|
6
|
-
readonly document: ContentDocument;
|
|
7
|
-
readonly formulas: ReadonlyMap<string, EmbeddedFormula>;
|
|
8
|
-
}
|
|
9
|
-
declare function readOdtContent(pkg: Package): OdtContentResult;
|
|
4
|
+
declare function readOdtContent(pkg: Package): ContentDocument;
|
|
10
5
|
//#endregion
|
|
11
|
-
export {
|
|
6
|
+
export { readOdtContent };
|
package/dist/odf/odt/read.d.ts
CHANGED
|
@@ -1,11 +1,6 @@
|
|
|
1
|
-
import { EmbeddedFormula } from "../../model/formula.js";
|
|
2
1
|
import { ContentDocument } from "document-schema.js";
|
|
3
2
|
import { Package } from "odf.js";
|
|
4
3
|
//#region src/odf/odt/read.d.ts
|
|
5
|
-
|
|
6
|
-
readonly document: ContentDocument;
|
|
7
|
-
readonly formulas: ReadonlyMap<string, EmbeddedFormula>;
|
|
8
|
-
}
|
|
9
|
-
declare function readOdtContent(pkg: Package): OdtContentResult;
|
|
4
|
+
declare function readOdtContent(pkg: Package): ContentDocument;
|
|
10
5
|
//#endregion
|
|
11
|
-
export {
|
|
6
|
+
export { readOdtContent };
|
package/dist/odf/odt/read.js
CHANGED
|
@@ -1,42 +1,82 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { buildFormulaBlock } from "../../model/formula.js";
|
|
2
|
+
import { collectFormulaFrames } from "../formula/detect.js";
|
|
3
3
|
import { CONTENT_FORMAT_VERSION } from "document-schema.js";
|
|
4
4
|
import { findChildElement, readOdt, rootElement } from "odf.js";
|
|
5
5
|
//#region src/odf/odt/read.ts
|
|
6
6
|
function readOdtContent(pkg) {
|
|
7
7
|
const odtDoc = readOdt(pkg);
|
|
8
|
-
const formulas = /* @__PURE__ */ new Map();
|
|
9
8
|
const contentPart = pkg.parts["content.xml"];
|
|
10
9
|
if (contentPart?.kind === "xml" && odtDoc.sections.length === 1) {
|
|
11
10
|
const root = rootElement(contentPart.nodes);
|
|
12
11
|
const body = root === void 0 ? void 0 : findChildElement(root.children, "office:body");
|
|
13
12
|
const text = body === void 0 ? void 0 : findChildElement(body.children, "office:text");
|
|
14
13
|
if (text !== void 0) {
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
blocks.push(buildFormulaPlaceholderBlock(found.formula, found.frame, sourcePath));
|
|
22
|
-
formulas.set(sourcePath, found.formula);
|
|
23
|
-
}
|
|
24
|
-
odtDoc.sections[0] = {
|
|
25
|
-
...section,
|
|
26
|
-
blocks
|
|
27
|
-
};
|
|
28
|
-
}
|
|
14
|
+
const section = odtDoc.sections[0];
|
|
15
|
+
const placements = collectFormulaPlacements(text.children, pkg);
|
|
16
|
+
if (placements.length > 0) odtDoc.sections[0] = {
|
|
17
|
+
...section,
|
|
18
|
+
blocks: spliceFormulaBlocks(section.blocks, placements)
|
|
19
|
+
};
|
|
29
20
|
}
|
|
30
21
|
}
|
|
31
22
|
return {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
sections: odtDoc.sections
|
|
37
|
-
},
|
|
38
|
-
formulas
|
|
23
|
+
kind: "wordprocessing",
|
|
24
|
+
formatVersion: CONTENT_FORMAT_VERSION,
|
|
25
|
+
metadata: { ...odtDoc.metadata },
|
|
26
|
+
sections: odtDoc.sections
|
|
39
27
|
};
|
|
40
28
|
}
|
|
29
|
+
function pushPlacements(out, index, detected) {
|
|
30
|
+
for (const frame of detected) out.push({
|
|
31
|
+
index,
|
|
32
|
+
detected: frame
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
function collectFormulaPlacements(nodes, pkg) {
|
|
36
|
+
const out = [];
|
|
37
|
+
walkForPlacements(nodes, pkg, { blockCount: 0 }, out);
|
|
38
|
+
return out;
|
|
39
|
+
}
|
|
40
|
+
function walkForPlacements(nodes, pkg, state, out) {
|
|
41
|
+
for (const node of nodes) {
|
|
42
|
+
if (node.type !== "element") continue;
|
|
43
|
+
if (node.tag === "text:p" || node.tag === "text:h") {
|
|
44
|
+
state.blockCount += 1;
|
|
45
|
+
pushPlacements(out, state.blockCount, collectFormulaFrames(node.children, pkg));
|
|
46
|
+
} else if (node.tag === "text:list") walkListForPlacements(node.children, pkg, state, out);
|
|
47
|
+
else if (node.tag === "table:table") {
|
|
48
|
+
state.blockCount += 1;
|
|
49
|
+
pushPlacements(out, state.blockCount, collectFormulaFrames(node.children, pkg));
|
|
50
|
+
} else if (node.tag === "text:section") walkForPlacements(node.children, pkg, state, out);
|
|
51
|
+
else pushPlacements(out, state.blockCount, collectFormulaFrames([node], pkg));
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
function walkListForPlacements(itemNodes, pkg, state, out) {
|
|
55
|
+
for (const item of itemNodes) {
|
|
56
|
+
if (item.type !== "element" || item.tag !== "text:list-item") continue;
|
|
57
|
+
for (const itemChild of item.children) {
|
|
58
|
+
if (itemChild.type !== "element") continue;
|
|
59
|
+
if (itemChild.tag === "text:p" || itemChild.tag === "text:h") {
|
|
60
|
+
state.blockCount += 1;
|
|
61
|
+
pushPlacements(out, state.blockCount, collectFormulaFrames(itemChild.children, pkg));
|
|
62
|
+
} else if (itemChild.tag === "text:list") walkListForPlacements(itemChild.children, pkg, state, out);
|
|
63
|
+
else pushPlacements(out, state.blockCount, collectFormulaFrames([itemChild], pkg));
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
function spliceFormulaBlocks(blocks, placements) {
|
|
68
|
+
const out = [];
|
|
69
|
+
let next = 0;
|
|
70
|
+
for (let index = 0; index <= blocks.length; index++) {
|
|
71
|
+
while (next < placements.length && placements[next].index === index) {
|
|
72
|
+
const { detected } = placements[next];
|
|
73
|
+
out.push(buildFormulaBlock(detected.formula, detected.frame, `sections[0].blocks[${out.length}]`));
|
|
74
|
+
next += 1;
|
|
75
|
+
}
|
|
76
|
+
const block = blocks[index];
|
|
77
|
+
if (block !== void 0) out.push(block);
|
|
78
|
+
}
|
|
79
|
+
return out;
|
|
80
|
+
}
|
|
41
81
|
//#endregion
|
|
42
82
|
export { readOdtContent };
|