ooxml.js 2.11.33 → 2.12.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.
@@ -194,6 +194,7 @@ function readParagraph(paragraph, context, rels) {
194
194
  kind: "paragraph",
195
195
  runs: readParagraphRuns(paragraph, context, rels),
196
196
  styleId: pStyleEl === void 0 ? void 0 : require_typed_util.attr(pStyleEl, "w:val"),
197
+ headingLevel: props.outlineLvl === void 0 ? void 0 : (0, document_schema_js.clampHeadingLevel)(props.outlineLvl + 1),
197
198
  alignment: props.alignment,
198
199
  list: readListMembership(pPr),
199
200
  spacingBeforePt: props.spacingBeforePt,
@@ -8,7 +8,7 @@ import { assignSourcePaths } from "../shared/source-path.js";
8
8
  import { resolveParagraphProperties, resolveRunProperties } from "./styles.js";
9
9
  import { NumberingDefinitionSchema, readNumberingDefinitions } from "./numbering.js";
10
10
  import { z } from "zod";
11
- import { COLOR_BLACK, ContentSectionSchema, PAGE_SIZE_LETTER, rgbHexToColor } from "document-schema.js";
11
+ import { COLOR_BLACK, ContentSectionSchema, PAGE_SIZE_LETTER, clampHeadingLevel, rgbHexToColor } from "document-schema.js";
12
12
  //#region src/typed/docx/read.ts
13
13
  const CommentSchema = z.object({
14
14
  author: z.string().optional(),
@@ -193,6 +193,7 @@ function readParagraph(paragraph, context, rels) {
193
193
  kind: "paragraph",
194
194
  runs: readParagraphRuns(paragraph, context, rels),
195
195
  styleId: pStyleEl === void 0 ? void 0 : attr(pStyleEl, "w:val"),
196
+ headingLevel: props.outlineLvl === void 0 ? void 0 : clampHeadingLevel(props.outlineLvl + 1),
196
197
  alignment: props.alignment,
197
198
  list: readListMembership(pPr),
198
199
  spacingBeforePt: props.spacingBeforePt,
@@ -10,7 +10,8 @@ function mergeParagraphLayer(base, layer) {
10
10
  spacingAfterPt: layer.spacingAfterPt ?? base.spacingAfterPt,
11
11
  lineSpacing: layer.lineSpacing ?? base.lineSpacing,
12
12
  indentLeftPt: layer.indentLeftPt ?? base.indentLeftPt,
13
- indentFirstLinePt: layer.indentFirstLinePt ?? base.indentFirstLinePt
13
+ indentFirstLinePt: layer.indentFirstLinePt ?? base.indentFirstLinePt,
14
+ outlineLvl: layer.outlineLvl ?? base.outlineLvl
14
15
  };
15
16
  }
16
17
  function mergeRunLayer(base, layer) {
@@ -103,13 +104,16 @@ function readParagraphPropertiesLayer(pPr) {
103
104
  const left = ind === void 0 ? void 0 : require_typed_util.attr(ind, "w:left") ?? require_typed_util.attr(ind, "w:start");
104
105
  const firstLine = ind === void 0 ? void 0 : require_typed_util.attr(ind, "w:firstLine");
105
106
  const hanging = ind === void 0 ? void 0 : require_typed_util.attr(ind, "w:hanging");
107
+ const outlineLvl = require_typed_util.childrenWithTag(pPr, "w:outlineLvl")[0];
108
+ const outlineLvlVal = outlineLvl === void 0 ? void 0 : require_typed_util.attr(outlineLvl, "w:val");
106
109
  return {
107
110
  alignment: readAlignment(require_typed_util.childrenWithTag(pPr, "w:jc")[0]),
108
111
  spacingBeforePt: before === void 0 ? void 0 : require_typed_shared_units.twipsToPt(Number(before)),
109
112
  spacingAfterPt: after === void 0 ? void 0 : require_typed_shared_units.twipsToPt(Number(after)),
110
113
  lineSpacing: line === void 0 || lineRule === "exact" || lineRule === "atLeast" ? void 0 : require_typed_shared_units.lineUnitsToMultiplier(Number(line)),
111
114
  indentLeftPt: left === void 0 ? void 0 : require_typed_shared_units.twipsToPt(Number(left)),
112
- indentFirstLinePt: firstLine !== void 0 ? require_typed_shared_units.twipsToPt(Number(firstLine)) : hanging !== void 0 ? -require_typed_shared_units.twipsToPt(Number(hanging)) : void 0
115
+ indentFirstLinePt: firstLine !== void 0 ? require_typed_shared_units.twipsToPt(Number(firstLine)) : hanging !== void 0 ? -require_typed_shared_units.twipsToPt(Number(hanging)) : void 0,
116
+ outlineLvl: outlineLvlVal === void 0 ? void 0 : Number(outlineLvlVal)
113
117
  };
114
118
  }
115
119
  function findStyle(stylesRoot, styleId, type) {
@@ -13,6 +13,7 @@ interface ResolvedParagraphProperties {
13
13
  readonly lineSpacing?: number;
14
14
  readonly indentLeftPt?: number;
15
15
  readonly indentFirstLinePt?: number;
16
+ readonly outlineLvl?: number;
16
17
  }
17
18
  interface ResolvedRunProperties {
18
19
  readonly bold?: boolean;
@@ -13,6 +13,7 @@ interface ResolvedParagraphProperties {
13
13
  readonly lineSpacing?: number;
14
14
  readonly indentLeftPt?: number;
15
15
  readonly indentFirstLinePt?: number;
16
+ readonly outlineLvl?: number;
16
17
  }
17
18
  interface ResolvedRunProperties {
18
19
  readonly bold?: boolean;
@@ -9,7 +9,8 @@ function mergeParagraphLayer(base, layer) {
9
9
  spacingAfterPt: layer.spacingAfterPt ?? base.spacingAfterPt,
10
10
  lineSpacing: layer.lineSpacing ?? base.lineSpacing,
11
11
  indentLeftPt: layer.indentLeftPt ?? base.indentLeftPt,
12
- indentFirstLinePt: layer.indentFirstLinePt ?? base.indentFirstLinePt
12
+ indentFirstLinePt: layer.indentFirstLinePt ?? base.indentFirstLinePt,
13
+ outlineLvl: layer.outlineLvl ?? base.outlineLvl
13
14
  };
14
15
  }
15
16
  function mergeRunLayer(base, layer) {
@@ -102,13 +103,16 @@ function readParagraphPropertiesLayer(pPr) {
102
103
  const left = ind === void 0 ? void 0 : attr(ind, "w:left") ?? attr(ind, "w:start");
103
104
  const firstLine = ind === void 0 ? void 0 : attr(ind, "w:firstLine");
104
105
  const hanging = ind === void 0 ? void 0 : attr(ind, "w:hanging");
106
+ const outlineLvl = childrenWithTag(pPr, "w:outlineLvl")[0];
107
+ const outlineLvlVal = outlineLvl === void 0 ? void 0 : attr(outlineLvl, "w:val");
105
108
  return {
106
109
  alignment: readAlignment(childrenWithTag(pPr, "w:jc")[0]),
107
110
  spacingBeforePt: before === void 0 ? void 0 : twipsToPt(Number(before)),
108
111
  spacingAfterPt: after === void 0 ? void 0 : twipsToPt(Number(after)),
109
112
  lineSpacing: line === void 0 || lineRule === "exact" || lineRule === "atLeast" ? void 0 : lineUnitsToMultiplier(Number(line)),
110
113
  indentLeftPt: left === void 0 ? void 0 : twipsToPt(Number(left)),
111
- indentFirstLinePt: firstLine !== void 0 ? twipsToPt(Number(firstLine)) : hanging !== void 0 ? -twipsToPt(Number(hanging)) : void 0
114
+ indentFirstLinePt: firstLine !== void 0 ? twipsToPt(Number(firstLine)) : hanging !== void 0 ? -twipsToPt(Number(hanging)) : void 0,
115
+ outlineLvl: outlineLvlVal === void 0 ? void 0 : Number(outlineLvlVal)
112
116
  };
113
117
  }
114
118
  function findStyle(stylesRoot, styleId, type) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ooxml.js",
3
- "version": "2.11.33",
3
+ "version": "2.12.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": {