odf.js 2.6.12 → 2.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/typed/odt/read.cjs +21 -1
- package/dist/typed/odt/read.js +21 -1
- package/package.json +1 -1
package/dist/typed/odt/read.cjs
CHANGED
|
@@ -35,13 +35,33 @@ function readListItems(listElement, context, pkg, blocks) {
|
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
|
+
function resolveListKind(pkg, styleName) {
|
|
39
|
+
if (styleName === void 0) return void 0;
|
|
40
|
+
for (const partPath of AUTOMATIC_STYLE_PARTS) {
|
|
41
|
+
const part = pkg.parts[partPath];
|
|
42
|
+
if (part?.kind !== "xml") continue;
|
|
43
|
+
const root = require_xml_query.rootElement(part.nodes);
|
|
44
|
+
if (root === void 0) continue;
|
|
45
|
+
for (const containerTag of ["office:automatic-styles", "office:styles"]) {
|
|
46
|
+
const container = require_xml_query.findChildElement(root.children, containerTag);
|
|
47
|
+
if (container === void 0) continue;
|
|
48
|
+
const listStyle = require_xml_query.childrenWithTag(container, "text:list-style").find((el) => require_xml_query.attrValue(el, "style:name") === styleName);
|
|
49
|
+
if (listStyle === void 0) continue;
|
|
50
|
+
if (require_xml_query.childrenWithTag(listStyle, "text:list-level-style-number").some((el) => require_xml_query.attrValue(el, "text:level") === "1")) return "ordered";
|
|
51
|
+
if (require_xml_query.childrenWithTag(listStyle, "text:list-level-style-bullet").some((el) => require_xml_query.attrValue(el, "text:level") === "1")) return "bullet";
|
|
52
|
+
if (require_xml_query.childrenWithTag(listStyle, "text:list-level-style-image").some((el) => require_xml_query.attrValue(el, "text:level") === "1")) return "bullet";
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
38
57
|
function readBlocks(nodes, pkg, listIdState) {
|
|
39
58
|
const blocks = [];
|
|
40
59
|
for (const node of nodes) {
|
|
41
60
|
if (node.type !== "element") continue;
|
|
42
61
|
if (node.tag === "text:p" || node.tag === "text:h") blocks.push(readParagraphOrHeading(node, pkg, void 0));
|
|
43
62
|
else if (node.tag === "text:list") {
|
|
44
|
-
const
|
|
63
|
+
const kind = resolveListKind(pkg, require_xml_query.attrValue(node, "text:style-name"));
|
|
64
|
+
const numId = kind !== void 0 ? `${kind}:list${listIdState.next}` : `list${listIdState.next}`;
|
|
45
65
|
listIdState.next += 1;
|
|
46
66
|
readListItems(node, {
|
|
47
67
|
numId,
|
package/dist/typed/odt/read.js
CHANGED
|
@@ -34,13 +34,33 @@ function readListItems(listElement, context, pkg, blocks) {
|
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
|
+
function resolveListKind(pkg, styleName) {
|
|
38
|
+
if (styleName === void 0) return void 0;
|
|
39
|
+
for (const partPath of AUTOMATIC_STYLE_PARTS) {
|
|
40
|
+
const part = pkg.parts[partPath];
|
|
41
|
+
if (part?.kind !== "xml") continue;
|
|
42
|
+
const root = rootElement(part.nodes);
|
|
43
|
+
if (root === void 0) continue;
|
|
44
|
+
for (const containerTag of ["office:automatic-styles", "office:styles"]) {
|
|
45
|
+
const container = findChildElement(root.children, containerTag);
|
|
46
|
+
if (container === void 0) continue;
|
|
47
|
+
const listStyle = childrenWithTag(container, "text:list-style").find((el) => attrValue(el, "style:name") === styleName);
|
|
48
|
+
if (listStyle === void 0) continue;
|
|
49
|
+
if (childrenWithTag(listStyle, "text:list-level-style-number").some((el) => attrValue(el, "text:level") === "1")) return "ordered";
|
|
50
|
+
if (childrenWithTag(listStyle, "text:list-level-style-bullet").some((el) => attrValue(el, "text:level") === "1")) return "bullet";
|
|
51
|
+
if (childrenWithTag(listStyle, "text:list-level-style-image").some((el) => attrValue(el, "text:level") === "1")) return "bullet";
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
37
56
|
function readBlocks(nodes, pkg, listIdState) {
|
|
38
57
|
const blocks = [];
|
|
39
58
|
for (const node of nodes) {
|
|
40
59
|
if (node.type !== "element") continue;
|
|
41
60
|
if (node.tag === "text:p" || node.tag === "text:h") blocks.push(readParagraphOrHeading(node, pkg, void 0));
|
|
42
61
|
else if (node.tag === "text:list") {
|
|
43
|
-
const
|
|
62
|
+
const kind = resolveListKind(pkg, attrValue(node, "text:style-name"));
|
|
63
|
+
const numId = kind !== void 0 ? `${kind}:list${listIdState.next}` : `list${listIdState.next}`;
|
|
44
64
|
listIdState.next += 1;
|
|
45
65
|
readListItems(node, {
|
|
46
66
|
numId,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "odf.js",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.7.0",
|
|
4
4
|
"description": "Type-safe, lossless round-trip conversion between OpenDocument Format packages (odt, ods, odp) and JSON, hand-written and dependency-minimal, built on Zod 4 codecs.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|