ooxml.js 2.0.4 → 2.1.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/index.cjs CHANGED
@@ -874,6 +874,22 @@ function applyGroupTransform(group, childFrame) {
874
874
  };
875
875
  }
876
876
  //#endregion
877
+ //#region src/typed/shared/source-path.ts
878
+ function assignSourcePaths(blocks, prefix) {
879
+ blocks.forEach((block, blockIndex) => {
880
+ const blockPath = `${prefix}.blocks[${blockIndex}]`;
881
+ block.sourcePath = blockPath;
882
+ if (block.kind === "paragraph") block.runs.forEach((run, runIndex) => {
883
+ run.sourcePath = `${blockPath}.runs[${runIndex}]`;
884
+ });
885
+ else if (block.kind === "table") block.rows.forEach((row, rowIndex) => {
886
+ row.cells.forEach((cell, cellIndex) => {
887
+ assignSourcePaths(cell.blocks, `${blockPath}.rows[${rowIndex}].cells[${cellIndex}]`);
888
+ });
889
+ });
890
+ });
891
+ }
892
+ //#endregion
877
893
  //#region src/typed/docx/styles.ts
878
894
  function mergeParagraphLayer(base, layer) {
879
895
  return {
@@ -1267,6 +1283,7 @@ function readSections(body, context, rels) {
1267
1283
  margins: DEFAULT_MARGINS,
1268
1284
  blocks: currentBlocks
1269
1285
  });
1286
+ sections.forEach((section, sectionIndex) => assignSourcePaths(section.blocks, `sections[${sectionIndex}]`));
1270
1287
  return sections;
1271
1288
  }
1272
1289
  function readDocumentTheme(pkg, docRels) {
@@ -1758,6 +1775,13 @@ function readPptx(pkg) {
1758
1775
  const presentationRoot = rootElement(pkg.parts[PRESENTATION_PATH]);
1759
1776
  const size = readSlideSize(presentationRoot);
1760
1777
  const slides = readSlidePathsInOrder(pkg, presentationRoot).map((slidePath) => readSlide(pkg, slidePath, size));
1778
+ slides.forEach((slide, slideIndex) => {
1779
+ slide.shapes.forEach((shape, shapeIndex) => {
1780
+ const shapePath = `slides[${slideIndex}].shapes[${shapeIndex}]`;
1781
+ shape.sourcePath = shapePath;
1782
+ assignSourcePaths(shape.blocks, shapePath);
1783
+ });
1784
+ });
1761
1785
  return {
1762
1786
  metadata: readCoreProperties(pkg),
1763
1787
  slides
package/dist/index.d.cts CHANGED
@@ -463,6 +463,7 @@ declare const PptxDocumentSchema: z.ZodObject<{
463
463
  insetBottomPt: z.ZodNumber;
464
464
  fontScale: z.ZodOptional<z.ZodNumber>;
465
465
  lineSpacingReduction: z.ZodOptional<z.ZodNumber>;
466
+ sourcePath: z.ZodOptional<z.ZodString>;
466
467
  blocks: z.ZodArray<z.ZodCustom<ContentBlock$1, ContentBlock$1>>;
467
468
  }, z.core.$strip>>;
468
469
  notes: z.ZodString;
package/dist/index.d.ts CHANGED
@@ -463,6 +463,7 @@ declare const PptxDocumentSchema: z.ZodObject<{
463
463
  insetBottomPt: z.ZodNumber;
464
464
  fontScale: z.ZodOptional<z.ZodNumber>;
465
465
  lineSpacingReduction: z.ZodOptional<z.ZodNumber>;
466
+ sourcePath: z.ZodOptional<z.ZodString>;
466
467
  blocks: z.ZodArray<z.ZodCustom<ContentBlock$1, ContentBlock$1>>;
467
468
  }, z.core.$strip>>;
468
469
  notes: z.ZodString;
package/dist/index.js CHANGED
@@ -873,6 +873,22 @@ function applyGroupTransform(group, childFrame) {
873
873
  };
874
874
  }
875
875
  //#endregion
876
+ //#region src/typed/shared/source-path.ts
877
+ function assignSourcePaths(blocks, prefix) {
878
+ blocks.forEach((block, blockIndex) => {
879
+ const blockPath = `${prefix}.blocks[${blockIndex}]`;
880
+ block.sourcePath = blockPath;
881
+ if (block.kind === "paragraph") block.runs.forEach((run, runIndex) => {
882
+ run.sourcePath = `${blockPath}.runs[${runIndex}]`;
883
+ });
884
+ else if (block.kind === "table") block.rows.forEach((row, rowIndex) => {
885
+ row.cells.forEach((cell, cellIndex) => {
886
+ assignSourcePaths(cell.blocks, `${blockPath}.rows[${rowIndex}].cells[${cellIndex}]`);
887
+ });
888
+ });
889
+ });
890
+ }
891
+ //#endregion
876
892
  //#region src/typed/docx/styles.ts
877
893
  function mergeParagraphLayer(base, layer) {
878
894
  return {
@@ -1266,6 +1282,7 @@ function readSections(body, context, rels) {
1266
1282
  margins: DEFAULT_MARGINS,
1267
1283
  blocks: currentBlocks
1268
1284
  });
1285
+ sections.forEach((section, sectionIndex) => assignSourcePaths(section.blocks, `sections[${sectionIndex}]`));
1269
1286
  return sections;
1270
1287
  }
1271
1288
  function readDocumentTheme(pkg, docRels) {
@@ -1757,6 +1774,13 @@ function readPptx(pkg) {
1757
1774
  const presentationRoot = rootElement(pkg.parts[PRESENTATION_PATH]);
1758
1775
  const size = readSlideSize(presentationRoot);
1759
1776
  const slides = readSlidePathsInOrder(pkg, presentationRoot).map((slidePath) => readSlide(pkg, slidePath, size));
1777
+ slides.forEach((slide, slideIndex) => {
1778
+ slide.shapes.forEach((shape, shapeIndex) => {
1779
+ const shapePath = `slides[${slideIndex}].shapes[${shapeIndex}]`;
1780
+ shape.sourcePath = shapePath;
1781
+ assignSourcePaths(shape.blocks, shapePath);
1782
+ });
1783
+ });
1760
1784
  return {
1761
1785
  metadata: readCoreProperties(pkg),
1762
1786
  slides
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ooxml.js",
3
- "version": "2.0.4",
3
+ "version": "2.1.0",
4
4
  "description": "Type-safe, lossless round-trip conversion between OOXML packages (docx, pptx, xlsx) and JSON, built on Zod 4 codecs.",
5
5
  "type": "module",
6
6
  "repository": {
@@ -61,7 +61,7 @@
61
61
  "license": "MIT",
62
62
  "packageManager": "pnpm@11.6.0",
63
63
  "dependencies": {
64
- "document-content-model": "^1.0.0",
64
+ "document-content-model": "^1.1.0",
65
65
  "fast-xml-parser": "^5.10.1",
66
66
  "fflate": "^0.8.3",
67
67
  "zod": "^4.4.3"