documents.js 1.67.16 → 1.70.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.
Files changed (161) hide show
  1. package/README.md +3 -3
  2. package/dist/color-BHhGSqAh.d.ts +2 -0
  3. package/dist/edit/docx/content.cjs +6 -1
  4. package/dist/edit/docx/content.d.cts +2 -0
  5. package/dist/edit/docx/content.d.ts +2 -0
  6. package/dist/edit/docx/content.js +7 -2
  7. package/dist/edit/docx/editor.cjs +6 -2
  8. package/dist/edit/docx/editor.d.cts +6 -2
  9. package/dist/edit/docx/editor.d.ts +6 -2
  10. package/dist/edit/docx/editor.js +6 -2
  11. package/dist/edit/docx/paragraph.d.ts +1 -1
  12. package/dist/edit/docx/props.d.ts +1 -1
  13. package/dist/edit/docx/run.d.ts +1 -1
  14. package/dist/edit/docx/scaffold.cjs +5 -2
  15. package/dist/edit/docx/scaffold.d.cts +6 -2
  16. package/dist/edit/docx/scaffold.d.ts +6 -2
  17. package/dist/edit/docx/scaffold.js +5 -2
  18. package/dist/edit/drawingml/vector.cjs +145 -0
  19. package/dist/edit/drawingml/vector.d.cts +3 -2
  20. package/dist/edit/drawingml/vector.d.ts +3 -2
  21. package/dist/edit/drawingml/vector.js +147 -3
  22. package/dist/edit/odg/content.cjs +7 -2
  23. package/dist/edit/odg/content.d.cts +6 -2
  24. package/dist/edit/odg/content.d.ts +6 -2
  25. package/dist/edit/odg/content.js +8 -3
  26. package/dist/edit/odg/editor.cjs +6 -2
  27. package/dist/edit/odg/editor.d.cts +6 -2
  28. package/dist/edit/odg/editor.d.ts +6 -2
  29. package/dist/edit/odg/editor.js +6 -2
  30. package/dist/edit/odg/page.d.ts +1 -1
  31. package/dist/edit/odg/scaffold.cjs +17 -4
  32. package/dist/edit/odg/scaffold.d.cts +6 -2
  33. package/dist/edit/odg/scaffold.d.ts +6 -2
  34. package/dist/edit/odg/scaffold.js +18 -5
  35. package/dist/edit/odp/content.cjs +7 -2
  36. package/dist/edit/odp/content.d.cts +6 -2
  37. package/dist/edit/odp/content.d.ts +6 -2
  38. package/dist/edit/odp/content.js +8 -3
  39. package/dist/edit/odp/editor.cjs +6 -2
  40. package/dist/edit/odp/editor.d.cts +6 -2
  41. package/dist/edit/odp/editor.d.ts +6 -2
  42. package/dist/edit/odp/editor.js +6 -2
  43. package/dist/edit/odp/scaffold.cjs +17 -4
  44. package/dist/edit/odp/scaffold.d.cts +6 -2
  45. package/dist/edit/odp/scaffold.d.ts +6 -2
  46. package/dist/edit/odp/scaffold.js +18 -5
  47. package/dist/edit/odp/shape.d.ts +1 -1
  48. package/dist/edit/odp/slide.d.ts +2 -2
  49. package/dist/edit/ods/content.cjs +7 -2
  50. package/dist/edit/ods/content.d.cts +6 -2
  51. package/dist/edit/ods/content.d.ts +6 -2
  52. package/dist/edit/ods/content.js +8 -3
  53. package/dist/edit/ods/editor.cjs +6 -2
  54. package/dist/edit/ods/editor.d.cts +6 -2
  55. package/dist/edit/ods/editor.d.ts +6 -2
  56. package/dist/edit/ods/editor.js +6 -2
  57. package/dist/edit/ods/scaffold.cjs +17 -4
  58. package/dist/edit/ods/scaffold.d.cts +6 -2
  59. package/dist/edit/ods/scaffold.d.ts +6 -2
  60. package/dist/edit/ods/scaffold.js +18 -5
  61. package/dist/edit/odt/content.cjs +7 -2
  62. package/dist/edit/odt/content.d.cts +6 -2
  63. package/dist/edit/odt/content.d.ts +8 -4
  64. package/dist/edit/odt/content.js +8 -3
  65. package/dist/edit/odt/editor.cjs +6 -2
  66. package/dist/edit/odt/editor.d.cts +6 -2
  67. package/dist/edit/odt/editor.d.ts +9 -5
  68. package/dist/edit/odt/editor.js +6 -2
  69. package/dist/edit/odt/list.d.ts +1 -1
  70. package/dist/edit/odt/paragraph.d.ts +1 -1
  71. package/dist/edit/odt/run.d.ts +1 -1
  72. package/dist/edit/odt/scaffold.cjs +17 -4
  73. package/dist/edit/odt/scaffold.d.cts +6 -2
  74. package/dist/edit/odt/scaffold.d.ts +6 -2
  75. package/dist/edit/odt/scaffold.js +18 -5
  76. package/dist/edit/odt/table.d.ts +1 -1
  77. package/dist/edit/pptx/content.cjs +7 -2
  78. package/dist/edit/pptx/content.d.cts +6 -2
  79. package/dist/edit/pptx/content.d.ts +6 -2
  80. package/dist/edit/pptx/content.js +8 -3
  81. package/dist/edit/pptx/editor.cjs +6 -2
  82. package/dist/edit/pptx/editor.d.cts +6 -2
  83. package/dist/edit/pptx/editor.d.ts +6 -2
  84. package/dist/edit/pptx/editor.js +6 -2
  85. package/dist/edit/pptx/scaffold.cjs +3 -1
  86. package/dist/edit/pptx/scaffold.d.cts +6 -2
  87. package/dist/edit/pptx/scaffold.d.ts +6 -2
  88. package/dist/edit/pptx/scaffold.js +3 -1
  89. package/dist/edit/pptx/shape.d.ts +1 -1
  90. package/dist/edit/pptx/slide.d.ts +2 -2
  91. package/dist/edit/pptx/table.d.ts +1 -1
  92. package/dist/formula-B_4mdCuK.d.ts +12 -0
  93. package/dist/formula-DFc2Ofsk.d.cts +12 -0
  94. package/dist/index.cjs +3 -1
  95. package/dist/index.d.cts +20 -13
  96. package/dist/index.d.ts +29 -22
  97. package/dist/index.js +3 -2
  98. package/dist/layout/sheets.js +3 -3
  99. package/dist/{list-nlhN5bat.d.ts → list-BJVehfU8.d.ts} +1 -1
  100. package/dist/mathml/layout.cjs +42 -3
  101. package/dist/mathml/layout.js +42 -3
  102. package/dist/mathml/operators.cjs +12 -0
  103. package/dist/mathml/operators.js +12 -0
  104. package/dist/model/block-splice.cjs +18 -0
  105. package/dist/model/block-splice.d.cts +9 -0
  106. package/dist/model/block-splice.d.ts +9 -0
  107. package/dist/model/block-splice.js +17 -0
  108. package/dist/model/color.d.ts +1 -1
  109. package/dist/model/metadata.cjs +13 -0
  110. package/dist/model/metadata.d.cts +6 -0
  111. package/dist/model/metadata.d.ts +6 -0
  112. package/dist/model/metadata.js +12 -0
  113. package/dist/odf/odp/read.cjs +38 -0
  114. package/dist/odf/odp/read.js +38 -0
  115. package/dist/odf/odt/read.cjs +100 -35
  116. package/dist/odf/odt/read.js +100 -35
  117. package/dist/odf/vector/detect.cjs +52 -0
  118. package/dist/odf/vector/detect.d.cts +12 -0
  119. package/dist/odf/vector/detect.d.ts +12 -0
  120. package/dist/odf/vector/detect.js +49 -0
  121. package/dist/ooxml/docx/embedded-objects.cjs +92 -0
  122. package/dist/ooxml/docx/embedded-objects.d.cts +7 -0
  123. package/dist/ooxml/docx/embedded-objects.d.ts +7 -0
  124. package/dist/ooxml/docx/embedded-objects.js +91 -0
  125. package/dist/ooxml/docx/formula.cjs +3 -58
  126. package/dist/ooxml/docx/formula.d.cts +2 -2
  127. package/dist/ooxml/docx/formula.d.ts +2 -2
  128. package/dist/ooxml/docx/formula.js +1 -58
  129. package/dist/ooxml/docx/read.cjs +2 -2
  130. package/dist/ooxml/docx/read.d.cts +1 -1
  131. package/dist/ooxml/docx/read.d.ts +1 -1
  132. package/dist/ooxml/docx/read.js +2 -2
  133. package/dist/ooxml/docx/vector.cjs +63 -0
  134. package/dist/ooxml/docx/vector.d.cts +10 -0
  135. package/dist/ooxml/docx/vector.d.ts +10 -0
  136. package/dist/ooxml/docx/vector.js +62 -0
  137. package/dist/ooxml/pptx/read.cjs +25 -1
  138. package/dist/ooxml/pptx/read.js +26 -2
  139. package/dist/ooxml/pptx/vector.cjs +96 -0
  140. package/dist/ooxml/pptx/vector.d.cts +6 -0
  141. package/dist/ooxml/pptx/vector.d.ts +6 -0
  142. package/dist/ooxml/pptx/vector.js +95 -0
  143. package/dist/opc/core-properties.cjs +65 -0
  144. package/dist/opc/core-properties.d.cts +6 -0
  145. package/dist/opc/core-properties.d.ts +6 -0
  146. package/dist/opc/core-properties.js +64 -0
  147. package/dist/opc/rels.cjs +11 -4
  148. package/dist/opc/rels.d.cts +2 -1
  149. package/dist/opc/rels.d.ts +2 -1
  150. package/dist/opc/rels.js +11 -5
  151. package/dist/{paragraph-DndYbWuT.d.ts → paragraph-CjtZP77X.d.ts} +1 -1
  152. package/dist/{run-BhYv2wJf.d.ts → run-DDe7miD5.d.ts} +1 -1
  153. package/dist/{run-DtrwZwN6.d.ts → run-wB22_F5w.d.ts} +1 -1
  154. package/dist/{shape-B-TjU_Ej.d.ts → shape-BjX3wlig.d.ts} +1 -1
  155. package/dist/{shape-XGp__l-J.d.ts → shape-GV8i37zL.d.ts} +2 -2
  156. package/dist/{table-DQpKafyl.d.ts → table-Db91eorq.d.ts} +1 -1
  157. package/dist/{table-BHeUmLzZ.d.ts → table-Vf6nCixr.d.ts} +1 -1
  158. package/package.json +1 -1
  159. package/dist/color-C98dn-pT.d.ts +0 -2
  160. package/dist/formula-CgydMiTt.d.ts +0 -10
  161. package/dist/formula-CiwPw8nY.d.cts +0 -10
@@ -0,0 +1,95 @@
1
+ import { readDrawingMlVector } from "../../edit/drawingml/vector.js";
2
+ import { buildDrawingBlock } from "../../model/embedded-drawing.js";
3
+ import { childrenWithTag } from "ooxml.js";
4
+ //#region src/ooxml/pptx/vector.ts
5
+ function isBlankParagraphBlocks(blocks) {
6
+ return blocks.length === 0 || blocks.every((block) => block.kind === "paragraph" && block.runs.every((run) => run.text.trim().length === 0));
7
+ }
8
+ function collectVectorOnlyShapes(children, shapes, state, out) {
9
+ for (const node of children) {
10
+ if (node.type !== "element") continue;
11
+ if (node.tag === "p:sp") {
12
+ const shapeIndex = state.shapeIndex;
13
+ state.shapeIndex += 1;
14
+ const shape = shapes[shapeIndex];
15
+ if (shape !== void 0 && isBlankParagraphBlocks(shape.blocks)) {
16
+ const spPr = childrenWithTag(node, "p:spPr")[0];
17
+ const vector = spPr === void 0 ? void 0 : readDrawingMlVector(spPr);
18
+ if (vector !== void 0) out.push({
19
+ shapeIndex,
20
+ vector
21
+ });
22
+ }
23
+ } else if (node.tag === "p:pic" || node.tag === "p:graphicFrame") state.shapeIndex += 1;
24
+ else if (node.tag === "p:grpSp") collectVectorOnlyShapes(node.children, shapes, state, out);
25
+ }
26
+ }
27
+ function collectSlideVectorGroups(spTreeChildren, shapes) {
28
+ const state = { shapeIndex: 0 };
29
+ const found = [];
30
+ collectVectorOnlyShapes(spTreeChildren, shapes, state, found);
31
+ const groups = [];
32
+ for (const item of found) {
33
+ const last = groups[groups.length - 1];
34
+ if (last !== void 0 && last.insertAt + last.length === item.shapeIndex) {
35
+ last.vectors.push(item.vector);
36
+ last.length += 1;
37
+ continue;
38
+ }
39
+ groups.push({
40
+ insertAt: item.shapeIndex,
41
+ length: 1,
42
+ vectors: [item.vector]
43
+ });
44
+ }
45
+ return groups.map((group) => ({
46
+ insertAt: group.insertAt,
47
+ length: group.length,
48
+ vectors: group.vectors.map((vector, index) => ({
49
+ ...vector,
50
+ paintOrder: index
51
+ }))
52
+ }));
53
+ }
54
+ function collapseVectorShapeRuns(slide, slideIndex, spTreeChildren) {
55
+ const groups = collectSlideVectorGroups(spTreeChildren, slide.shapes);
56
+ if (groups.length === 0) return slide;
57
+ const shapes = [];
58
+ let index = 0;
59
+ let groupIndex = 0;
60
+ while (index < slide.shapes.length) {
61
+ const group = groups[groupIndex];
62
+ if (group?.insertAt === index && group !== void 0) {
63
+ const sourcePath = `slides[${slideIndex}].shapes[${shapes.length}]`;
64
+ shapes.push({
65
+ frame: {
66
+ xPt: 0,
67
+ yPt: 0,
68
+ widthPt: slide.size.widthPt,
69
+ heightPt: slide.size.heightPt
70
+ },
71
+ insetLeftPt: 0,
72
+ insetTopPt: 0,
73
+ insetRightPt: 0,
74
+ insetBottomPt: 0,
75
+ blocks: [{
76
+ ...buildDrawingBlock(slide.size, group.vectors),
77
+ sourcePath
78
+ }],
79
+ sourcePath
80
+ });
81
+ index += group.length;
82
+ groupIndex += 1;
83
+ continue;
84
+ }
85
+ const shape = slide.shapes[index];
86
+ if (shape !== void 0) shapes.push(shape);
87
+ index += 1;
88
+ }
89
+ return {
90
+ ...slide,
91
+ shapes
92
+ };
93
+ }
94
+ //#endregion
95
+ export { collapseVectorShapeRuns };
@@ -0,0 +1,65 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_xml_fragment = require("../xml/fragment.cjs");
3
+ const require_xml_entities = require("../xml/entities.cjs");
4
+ const require_opc_rels = require("./rels.cjs");
5
+ const require_opc_content_types = require("./content-types.cjs");
6
+ //#region src/opc/core-properties.ts
7
+ const CORE_PROPERTIES_PART_PATH = "docProps/core.xml";
8
+ const CORE_PROPERTIES_CONTENT_TYPE = "application/vnd.openxmlformats-package.core-properties+xml";
9
+ const CORE_PROPERTIES_REL_TYPE = "http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties";
10
+ const CP_NS = "http://schemas.openxmlformats.org/package/2006/metadata/core-properties";
11
+ const DC_NS = "http://purl.org/dc/elements/1.1/";
12
+ const DCTERMS_NS = "http://purl.org/dc/terms/";
13
+ const XSI_NS = "http://www.w3.org/2001/XMLSchema-instance";
14
+ const W3CDTF_TYPE = "dcterms:W3CDTF";
15
+ function declaration() {
16
+ return {
17
+ type: "declaration",
18
+ attributes: [
19
+ {
20
+ name: "version",
21
+ value: "1.0"
22
+ },
23
+ {
24
+ name: "encoding",
25
+ value: "UTF-8"
26
+ },
27
+ {
28
+ name: "standalone",
29
+ value: "yes"
30
+ }
31
+ ]
32
+ };
33
+ }
34
+ function textElement(tag, value) {
35
+ return require_xml_fragment.el(tag, {}, [require_xml_fragment.txt(require_xml_entities.encodeXmlText(value))]);
36
+ }
37
+ function dateElement(tag, isoValue) {
38
+ return require_xml_fragment.el(tag, { "xsi:type": W3CDTF_TYPE }, [require_xml_fragment.txt(require_xml_entities.encodeXmlText(isoValue))]);
39
+ }
40
+ function addCoreProperties(pkg, metadata) {
41
+ const children = [];
42
+ if (metadata.title !== void 0) children.push(textElement("dc:title", metadata.title));
43
+ if (metadata.author !== void 0) children.push(textElement("dc:creator", metadata.author));
44
+ if (metadata.subject !== void 0) children.push(textElement("dc:subject", metadata.subject));
45
+ if (metadata.keywords !== void 0 && metadata.keywords.length > 0) children.push(textElement("cp:keywords", metadata.keywords.join(", ")));
46
+ if (metadata.createdIso !== void 0) children.push(dateElement("dcterms:created", metadata.createdIso));
47
+ if (metadata.modifiedIso !== void 0) children.push(dateElement("dcterms:modified", metadata.modifiedIso));
48
+ const root = require_xml_fragment.el("cp:coreProperties", {
49
+ "xmlns:cp": CP_NS,
50
+ "xmlns:dc": DC_NS,
51
+ "xmlns:dcterms": DCTERMS_NS,
52
+ "xmlns:xsi": XSI_NS
53
+ }, children);
54
+ pkg.parts[CORE_PROPERTIES_PART_PATH] = {
55
+ kind: "xml",
56
+ nodes: [declaration(), root]
57
+ };
58
+ require_opc_content_types.ensureContentTypeOverride(pkg, CORE_PROPERTIES_PART_PATH, CORE_PROPERTIES_CONTENT_TYPE);
59
+ require_opc_rels.addRootRelationship(pkg, {
60
+ type: CORE_PROPERTIES_REL_TYPE,
61
+ target: CORE_PROPERTIES_PART_PATH
62
+ });
63
+ }
64
+ //#endregion
65
+ exports.addCoreProperties = addCoreProperties;
@@ -0,0 +1,6 @@
1
+ import { LayoutMetadata } from "document-schema.js";
2
+ import { Package } from "ooxml.js";
3
+ //#region src/opc/core-properties.d.ts
4
+ declare function addCoreProperties(pkg: Package, metadata: LayoutMetadata): void;
5
+ //#endregion
6
+ export { addCoreProperties };
@@ -0,0 +1,6 @@
1
+ import { Package } from "ooxml.js";
2
+ import { LayoutMetadata } from "document-schema.js";
3
+ //#region src/opc/core-properties.d.ts
4
+ declare function addCoreProperties(pkg: Package, metadata: LayoutMetadata): void;
5
+ //#endregion
6
+ export { addCoreProperties };
@@ -0,0 +1,64 @@
1
+ import { el, txt } from "../xml/fragment.js";
2
+ import { encodeXmlText } from "../xml/entities.js";
3
+ import { addRootRelationship } from "./rels.js";
4
+ import { ensureContentTypeOverride } from "./content-types.js";
5
+ //#region src/opc/core-properties.ts
6
+ const CORE_PROPERTIES_PART_PATH = "docProps/core.xml";
7
+ const CORE_PROPERTIES_CONTENT_TYPE = "application/vnd.openxmlformats-package.core-properties+xml";
8
+ const CORE_PROPERTIES_REL_TYPE = "http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties";
9
+ const CP_NS = "http://schemas.openxmlformats.org/package/2006/metadata/core-properties";
10
+ const DC_NS = "http://purl.org/dc/elements/1.1/";
11
+ const DCTERMS_NS = "http://purl.org/dc/terms/";
12
+ const XSI_NS = "http://www.w3.org/2001/XMLSchema-instance";
13
+ const W3CDTF_TYPE = "dcterms:W3CDTF";
14
+ function declaration() {
15
+ return {
16
+ type: "declaration",
17
+ attributes: [
18
+ {
19
+ name: "version",
20
+ value: "1.0"
21
+ },
22
+ {
23
+ name: "encoding",
24
+ value: "UTF-8"
25
+ },
26
+ {
27
+ name: "standalone",
28
+ value: "yes"
29
+ }
30
+ ]
31
+ };
32
+ }
33
+ function textElement(tag, value) {
34
+ return el(tag, {}, [txt(encodeXmlText(value))]);
35
+ }
36
+ function dateElement(tag, isoValue) {
37
+ return el(tag, { "xsi:type": W3CDTF_TYPE }, [txt(encodeXmlText(isoValue))]);
38
+ }
39
+ function addCoreProperties(pkg, metadata) {
40
+ const children = [];
41
+ if (metadata.title !== void 0) children.push(textElement("dc:title", metadata.title));
42
+ if (metadata.author !== void 0) children.push(textElement("dc:creator", metadata.author));
43
+ if (metadata.subject !== void 0) children.push(textElement("dc:subject", metadata.subject));
44
+ if (metadata.keywords !== void 0 && metadata.keywords.length > 0) children.push(textElement("cp:keywords", metadata.keywords.join(", ")));
45
+ if (metadata.createdIso !== void 0) children.push(dateElement("dcterms:created", metadata.createdIso));
46
+ if (metadata.modifiedIso !== void 0) children.push(dateElement("dcterms:modified", metadata.modifiedIso));
47
+ const root = el("cp:coreProperties", {
48
+ "xmlns:cp": CP_NS,
49
+ "xmlns:dc": DC_NS,
50
+ "xmlns:dcterms": DCTERMS_NS,
51
+ "xmlns:xsi": XSI_NS
52
+ }, children);
53
+ pkg.parts[CORE_PROPERTIES_PART_PATH] = {
54
+ kind: "xml",
55
+ nodes: [declaration(), root]
56
+ };
57
+ ensureContentTypeOverride(pkg, CORE_PROPERTIES_PART_PATH, CORE_PROPERTIES_CONTENT_TYPE);
58
+ addRootRelationship(pkg, {
59
+ type: CORE_PROPERTIES_REL_TYPE,
60
+ target: CORE_PROPERTIES_PART_PATH
61
+ });
62
+ }
63
+ //#endregion
64
+ export { addCoreProperties };
package/dist/opc/rels.cjs CHANGED
@@ -5,8 +5,8 @@ let ooxml_js = require("ooxml.js");
5
5
  //#region src/opc/rels.ts
6
6
  const RELATIONSHIPS_NAMESPACE = "http://schemas.openxmlformats.org/package/2006/relationships";
7
7
  const RELATIONSHIP_ID_PATTERN = /^rId(\d+)$/;
8
- function ensureRelationshipsRoot(pkg, partPath) {
9
- const relsPath = require_opc_paths.relsPathFor(partPath);
8
+ const ROOT_RELS_PART_PATH = "_rels/.rels";
9
+ function ensureRelationshipsRootAtPath(pkg, relsPath) {
10
10
  const existingRoot = (0, ooxml_js.rootElement)(pkg.parts[relsPath]);
11
11
  if (existingRoot !== void 0) return existingRoot;
12
12
  const root = require_xml_fragment.el("Relationships", { xmlns: RELATIONSHIPS_NAMESPACE });
@@ -31,8 +31,8 @@ function allocateRelationshipId(relationshipsRoot) {
31
31
  }
32
32
  return `rId${max + 1}`;
33
33
  }
34
- function addRelationship(pkg, partPath, rel) {
35
- const root = ensureRelationshipsRoot(pkg, partPath);
34
+ function addRelationshipAtPath(pkg, relsPath, rel) {
35
+ const root = ensureRelationshipsRootAtPath(pkg, relsPath);
36
36
  const id = allocateRelationshipId(root);
37
37
  const attrs = {
38
38
  Id: id,
@@ -43,5 +43,12 @@ function addRelationship(pkg, partPath, rel) {
43
43
  root.children.push(require_xml_fragment.el("Relationship", attrs));
44
44
  return id;
45
45
  }
46
+ function addRelationship(pkg, partPath, rel) {
47
+ return addRelationshipAtPath(pkg, require_opc_paths.relsPathFor(partPath), rel);
48
+ }
49
+ function addRootRelationship(pkg, rel) {
50
+ return addRelationshipAtPath(pkg, ROOT_RELS_PART_PATH, rel);
51
+ }
46
52
  //#endregion
47
53
  exports.addRelationship = addRelationship;
54
+ exports.addRootRelationship = addRootRelationship;
@@ -6,5 +6,6 @@ interface NewRelationship {
6
6
  readonly targetMode?: 'External';
7
7
  }
8
8
  declare function addRelationship(pkg: Package, partPath: string, rel: NewRelationship): string;
9
+ declare function addRootRelationship(pkg: Package, rel: NewRelationship): string;
9
10
  //#endregion
10
- export { NewRelationship, addRelationship };
11
+ export { NewRelationship, addRelationship, addRootRelationship };
@@ -6,5 +6,6 @@ interface NewRelationship {
6
6
  readonly targetMode?: 'External';
7
7
  }
8
8
  declare function addRelationship(pkg: Package, partPath: string, rel: NewRelationship): string;
9
+ declare function addRootRelationship(pkg: Package, rel: NewRelationship): string;
9
10
  //#endregion
10
- export { NewRelationship, addRelationship };
11
+ export { NewRelationship, addRelationship, addRootRelationship };
package/dist/opc/rels.js CHANGED
@@ -4,8 +4,8 @@ import { attr, rootElement } from "ooxml.js";
4
4
  //#region src/opc/rels.ts
5
5
  const RELATIONSHIPS_NAMESPACE = "http://schemas.openxmlformats.org/package/2006/relationships";
6
6
  const RELATIONSHIP_ID_PATTERN = /^rId(\d+)$/;
7
- function ensureRelationshipsRoot(pkg, partPath) {
8
- const relsPath = relsPathFor(partPath);
7
+ const ROOT_RELS_PART_PATH = "_rels/.rels";
8
+ function ensureRelationshipsRootAtPath(pkg, relsPath) {
9
9
  const existingRoot = rootElement(pkg.parts[relsPath]);
10
10
  if (existingRoot !== void 0) return existingRoot;
11
11
  const root = el("Relationships", { xmlns: RELATIONSHIPS_NAMESPACE });
@@ -30,8 +30,8 @@ function allocateRelationshipId(relationshipsRoot) {
30
30
  }
31
31
  return `rId${max + 1}`;
32
32
  }
33
- function addRelationship(pkg, partPath, rel) {
34
- const root = ensureRelationshipsRoot(pkg, partPath);
33
+ function addRelationshipAtPath(pkg, relsPath, rel) {
34
+ const root = ensureRelationshipsRootAtPath(pkg, relsPath);
35
35
  const id = allocateRelationshipId(root);
36
36
  const attrs = {
37
37
  Id: id,
@@ -42,5 +42,11 @@ function addRelationship(pkg, partPath, rel) {
42
42
  root.children.push(el("Relationship", attrs));
43
43
  return id;
44
44
  }
45
+ function addRelationship(pkg, partPath, rel) {
46
+ return addRelationshipAtPath(pkg, relsPathFor(partPath), rel);
47
+ }
48
+ function addRootRelationship(pkg, rel) {
49
+ return addRelationshipAtPath(pkg, ROOT_RELS_PART_PATH, rel);
50
+ }
45
51
  //#endregion
46
- export { addRelationship };
52
+ export { addRelationship, addRootRelationship };
@@ -1,5 +1,5 @@
1
1
  import { t as Alignment } from "./style-DkamR3aY.js";
2
- import { n as RunInit, t as OdtRun } from "./run-DtrwZwN6.js";
2
+ import { n as RunInit, t as OdtRun } from "./run-wB22_F5w.js";
3
3
  import { Package, XmlElement, XmlNode } from "odf.js";
4
4
  //#region src/edit/odt/paragraph.d.ts
5
5
  interface ParagraphInit {
@@ -1,4 +1,4 @@
1
- import { n as LayoutColor } from "./color-C98dn-pT.js";
1
+ import { n as LayoutColor } from "./color-BHhGSqAh.js";
2
2
  import { XmlElement, XmlNode } from "ooxml.js";
3
3
  //#region src/edit/docx/run.d.ts
4
4
  declare function wordprocessingText(element: XmlElement): string;
@@ -1,4 +1,4 @@
1
- import { n as LayoutColor } from "./color-C98dn-pT.js";
1
+ import { n as LayoutColor } from "./color-BHhGSqAh.js";
2
2
  import { Package, XmlElement, XmlNode } from "odf.js";
3
3
  //#region src/edit/odt/run.d.ts
4
4
  interface RunInit {
@@ -1,4 +1,4 @@
1
- import { n as LayoutColor } from "./color-C98dn-pT.js";
1
+ import { n as LayoutColor } from "./color-BHhGSqAh.js";
2
2
  import { t as Box } from "./geometry-DaJr8yQW.js";
3
3
  import { t as Alignment } from "./style-DkamR3aY.js";
4
4
  import { XmlElement, XmlNode } from "ooxml.js";
@@ -1,6 +1,6 @@
1
1
  import { t as Box } from "./geometry-DaJr8yQW.js";
2
- import { n as ParagraphInit, t as OdtParagraph } from "./paragraph-DndYbWuT.js";
3
- import { t as OdtList } from "./list-nlhN5bat.js";
2
+ import { n as ParagraphInit, t as OdtParagraph } from "./paragraph-CjtZP77X.js";
3
+ import { t as OdtList } from "./list-BJVehfU8.js";
4
4
  import { Package, XmlElement, XmlNode } from "odf.js";
5
5
  //#region src/edit/odp/shape.d.ts
6
6
  declare class OdpShape {
@@ -1,5 +1,5 @@
1
1
  import { t as Box } from "./geometry-DaJr8yQW.js";
2
- import { t as DrawingParagraphInit } from "./shape-B-TjU_Ej.js";
2
+ import { t as DrawingParagraphInit } from "./shape-BjX3wlig.js";
3
3
  import { XmlElement } from "ooxml.js";
4
4
  //#region src/edit/pptx/table.d.ts
5
5
  interface PptxTableInit {
@@ -1,4 +1,4 @@
1
- import { n as ParagraphInit, t as OdtParagraph } from "./paragraph-DndYbWuT.js";
1
+ import { n as ParagraphInit, t as OdtParagraph } from "./paragraph-CjtZP77X.js";
2
2
  import { Package, XmlElement, XmlNode } from "odf.js";
3
3
  //#region src/edit/odt/table.d.ts
4
4
  interface TableInit {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "documents.js",
3
- "version": "1.67.16",
3
+ "version": "1.70.0",
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": {
@@ -1,2 +0,0 @@
1
- import { COLOR_BLACK as COLOR_BLACK$1, Color as LayoutColor, ColorSchema as LayoutColorSchema, colorToRgbHex as colorToRgbHex$1, rgbHexToColor } from "document-schema.js";
2
- export { rgbHexToColor as a, colorToRgbHex$1 as i, LayoutColor as n, LayoutColorSchema as r, COLOR_BLACK$1 as t };
@@ -1,10 +0,0 @@
1
- import { t as OmmlDiagnostic } from "./shared-DUOzjwcL.js";
2
- import { XmlNode } from "ooxml.js";
3
- import { ContentSection } from "document-schema.js";
4
- //#region src/ooxml/docx/formula.d.ts
5
- type OmmlDiagnosticSink = (diagnostic: OmmlDiagnostic, context: {
6
- readonly sourcePath?: string;
7
- }) => void;
8
- declare function spliceDocxFormulas(sections: readonly ContentSection[], bodyChildren: readonly XmlNode[], onMathDiagnostic?: OmmlDiagnosticSink): ContentSection[];
9
- //#endregion
10
- export { spliceDocxFormulas as n, OmmlDiagnosticSink as t };
@@ -1,10 +0,0 @@
1
- import { t as OmmlDiagnostic } from "./shared-DLZ3IQUl.cjs";
2
- import { ContentSection } from "document-schema.js";
3
- import { XmlNode } from "ooxml.js";
4
- //#region src/ooxml/docx/formula.d.ts
5
- type OmmlDiagnosticSink = (diagnostic: OmmlDiagnostic, context: {
6
- readonly sourcePath?: string;
7
- }) => void;
8
- declare function spliceDocxFormulas(sections: readonly ContentSection[], bodyChildren: readonly XmlNode[], onMathDiagnostic?: OmmlDiagnosticSink): ContentSection[];
9
- //#endregion
10
- export { spliceDocxFormulas as n, OmmlDiagnosticSink as t };