ooxml.js 2.5.2 → 2.6.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 +1 -1
- package/dist/index.cjs +22 -0
- package/dist/index.d.cts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +3 -2
- package/dist/typed/docx/numbering.cjs +86 -0
- package/dist/typed/docx/numbering.d.cts +23 -0
- package/dist/typed/docx/numbering.d.ts +23 -0
- package/dist/typed/docx/numbering.js +83 -0
- package/dist/typed/docx/read.cjs +115 -15
- package/dist/typed/docx/read.d.cts +8 -0
- package/dist/typed/docx/read.d.ts +8 -0
- package/dist/typed/docx/read.js +117 -17
- package/dist/typed/docx/styles.cjs +26 -2
- package/dist/typed/docx/styles.js +26 -2
- package/dist/typed/pptx/read.cjs +5 -20
- package/dist/typed/pptx/read.js +5 -20
- package/dist/typed/shared/drawingml.cjs +112 -5
- package/dist/typed/shared/drawingml.d.cts +19 -2
- package/dist/typed/shared/drawingml.d.ts +19 -2
- package/dist/typed/shared/drawingml.js +111 -6
- package/dist/typed/shared/units.cjs +10 -0
- package/dist/typed/shared/units.d.cts +4 -1
- package/dist/typed/shared/units.d.ts +4 -1
- package/dist/typed/shared/units.js +8 -1
- package/dist/typed/xlsx/build.cjs +83 -55
- package/dist/typed/xlsx/build.js +83 -55
- package/dist/typed/xlsx/content.cjs +85 -15
- package/dist/typed/xlsx/content.js +85 -15
- package/dist/typed/xlsx/number-format.cjs +324 -0
- package/dist/typed/xlsx/number-format.d.cts +52 -0
- package/dist/typed/xlsx/number-format.d.ts +52 -0
- package/dist/typed/xlsx/number-format.js +312 -0
- package/dist/typed/xlsx/serial.cjs +109 -0
- package/dist/typed/xlsx/serial.d.cts +11 -0
- package/dist/typed/xlsx/serial.d.ts +11 -0
- package/dist/typed/xlsx/serial.js +102 -0
- package/dist/typed/xlsx/styles.cjs +73 -0
- package/dist/typed/xlsx/styles.d.cts +21 -0
- package/dist/typed/xlsx/styles.d.ts +21 -0
- package/dist/typed/xlsx/styles.js +69 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -219,7 +219,7 @@ The package is layered from a lossless core outward to lossy convenience views:
|
|
|
219
219
|
- **`src/codec.ts`** — the public round-trip surface: `packageCodec`/`xmlCodec` are `z.codec()` pairs, and `decodePackage`/`encodePackage` are the ergonomic wrappers around them.
|
|
220
220
|
- **`src/compact.ts`** — the ooxml.js format: `compactCodec` (`z.codec(PackageSchema, CompactPackageSchema, …)`) maps `Package ⇄ CompactPackage`, with `toCompact`/`fromCompact` as the ergonomic wrappers. `compactPackageCodec` composes `packageCodec` and `compactCodec` into a direct bytes ⇄ `CompactPackage` codec (`decodeCompactPackage`/`encodeCompactPackage`), so all three format pairs — bytes/`Package`, `Package`/`CompactPackage`, bytes/`CompactPackage` — have a named codec rather than requiring callers to chain two.
|
|
221
221
|
- **`src/typed/`** — one-way, lossy projections that read the generic `Package` into ergonomic document/presentation/workbook models. `docx/` and `pptx/` share one block content model — `ContentParagraph`/`ContentTable`/`ContentImageBlock`/`ContentPageBreak`, discriminated as `ContentBlock`, imported from the sibling [`document-schema.js`](https://github.com/ExaDev/document-schema.js) package rather than defined here (see below) — instead of each keeping its own, disjoint shape: `readDocx` resolves the full WordprocessingML style cascade (`docx/styles.ts`: `docDefaults` → named-style `basedOn` chains → paragraph-mark run properties → character styles → direct formatting) into ordered `sections` of paragraphs/tables/page-breaks (document order preserved, including inside tables), plus `comments`, `footnotes`, and `headers`/`footers`; `readPptx` resolves the placeholder → layout → master → theme inheritance cascade (`pptx/inherit.ts`) into `slides` of positioned, styled `shapes` (geometry, run/paragraph formatting, embedded images, tables, speaker notes) in presentation order (`p:sldIdLst`, never slide filename order); `readXlsx` covers cell values and formulas, merged ranges and defined names. `typed/shared/` holds the OOXML-specific primitives both `docx/` and `pptx/` build on: `drawingml.ts` (DrawingML `a:xfrm` geometry, theme/colour resolution, group-transform composition — including `ColorTransform`/`applyColorTransforms`, the shade/tint/lumMod/lumOff cascade maths, which stays here rather than in `document-schema.js` since it's OOXML-cascade-resolution logic, not a content-model shape), `units.ts` (OOXML unit conversions — EMU/twip/half-point), `metadata.ts` (`docProps/core.xml` + `docProps/app.xml` → `DocumentMetadata`, shared verbatim across docx/pptx/xlsx), and `source-path.ts` (stamps a deterministic, document-order path like `sections[0].blocks[2].runs[1]` onto every `ContentRun`/`ContentBlock`/`ContentShape`, so a downstream consumer can trace a rendered item back to where it came from — see `document-schema.js`'s own `sourcePath` field). Geometry (`Box`/`PageSize`/`Margins`), colour (`Color`/`ColorSchema`), and alignment (`Alignment`) types are imported from `document-schema.js`, not defined locally. `src/image/sniff.ts` (magic-byte PNG/JPEG detection) supports `readPptx`'s picture-shape reading. None of `readDocx`/`readPptx`/`readXlsx` can be encoded back to a `Package` — round-tripping those always goes through `decodePackage`/`encodePackage`, never through a typed view; see `src/typed/xlsx/` below for this package's one write-back exception. `typed/util.ts` holds the shared XML-walking helpers (`walk`, `elementsWithTag`, `childrenWithTag`, `attr`, `rootElement`, `textContent`, entity decoding, `resolveRelationships`) every typed reader builds on.
|
|
222
|
-
- **`src/typed/xlsx/`** — a second, `ContentDocument`-shaped xlsx pair alongside the lossy `readXlsx` above, not a replacement for it (both stay exported; they serve different callers). `content.ts`'s `readXlsxContent` reads a `Package` straight into `ContentDocument` (`kind: 'spreadsheet'`): real column widths, row heights, hidden rows/columns, merged ranges (resolved onto the anchor cell's `colSpan`/`rowSpan`), every cell value kind xlsx itself distinguishes, and a genuinely populated `ContentSheetPrintSettings` — matching the bar the sibling `odf.js` package's own `readOds` already sets, rather than `readXlsx`'s flattened `XlsxWorkbook`/`XlsxCell` shape. `build.ts`'s `buildXlsxPackage` is `readXlsxContent`'s write-side inverse and this package's first writer of genuinely new content: given a `ContentDocument`, it constructs a complete xlsx `Package` from scratch — workbook, worksheets, a minimal-but-real `xl/styles.xml`, shared strings, core/app properties — via `xml/fragment.ts`'s `el`/`txt`, rather than editing whatever package `readXlsxContent` itself decoded.
|
|
222
|
+
- **`src/typed/xlsx/`** — a second, `ContentDocument`-shaped xlsx pair alongside the lossy `readXlsx` above, not a replacement for it (both stay exported; they serve different callers). `content.ts`'s `readXlsxContent` reads a `Package` straight into `ContentDocument` (`kind: 'spreadsheet'`): real column widths, row heights, hidden rows/columns, merged ranges (resolved onto the anchor cell's `colSpan`/`rowSpan`), every cell value kind xlsx itself distinguishes, and a genuinely populated `ContentSheetPrintSettings` — matching the bar the sibling `odf.js` package's own `readOds` already sets, rather than `readXlsx`'s flattened `XlsxWorkbook`/`XlsxCell` shape. `build.ts`'s `buildXlsxPackage` is `readXlsxContent`'s write-side inverse and this package's first writer of genuinely new content: given a `ContentDocument`, it constructs a complete xlsx `Package` from scratch — workbook, worksheets, a minimal-but-real `xl/styles.xml`, shared strings, core/app properties — via `xml/fragment.ts`'s `el`/`txt`, rather than editing whatever package `readXlsxContent` itself decoded. `number-format.ts`/`styles.ts`/`serial.ts` are the number-format engine, and run both ways: xlsx has no cell type for a percentage, an amount of money, a date, or a time — all four are plain numeric cells wearing a `numFmt` style — so, reading, `styles.ts` resolves a cell's own style index to a format code, `number-format.ts` tokenizes and classifies that code (its `BUILTIN_NUMBER_FORMATS` table for `numFmtId` 0-49 is fed through the same classifier as a producer-declared code, never a second table of pre-decided kinds), and `serial.ts` converts a date/time serial to the canonical ISO spelling `document-schema.js` fixes. Writing, the same three run in reverse: `number-format.ts` holds the small vocabulary of formats `buildXlsxPackage` emits (built-in ids for a percentage and a time of day; ISO-ordered date/dateTime codes; `[$GBP]#,##0.00` for a currency, so the ISO code itself survives where a bare symbol would not; LibreOffice's own `"TRUE";"TRUE";"FALSE"` for a boolean, so real Excel and Calc display one as TRUE/FALSE rather than as a bare 1/0), `styles.ts`'s `CellFormatTable` interns them on demand into a real `<numFmts>`/`<cellXfs>` pair (a `SharedStringTable` for cell formats — same format, same index; no custom format used, no `<numFmts>` element written at all), and `serial.ts` converts an ISO spelling back to the serial the cell actually carries. Every code the writer emits is fed back through the reader's own classifier in the test suite, so the two halves cannot drift. It classifies rather than renders: `displayText` stays the plain typed-value spelling, not the producer's own formatted string. The remaining scope limits: a `currency` value naming no ISO 4217 code writes as a plain amount format and so reads back as a `number` (nothing in `#,##0.00` says money, and prefixing every such amount with a generic ¤ to keep the kind would change a file's appearance for something its author never asked for); a temporal value that is not the canonical `ContentCellValue` spelling, or that names a moment with no serial, degrades to a text cell carrying the original string verbatim rather than to a fabricated serial; and no per-cell rich-text runs on either side.
|
|
223
223
|
|
|
224
224
|
## Conventions
|
|
225
225
|
|
package/dist/index.cjs
CHANGED
|
@@ -15,6 +15,7 @@ const require_typed_util = require("./typed/util.cjs");
|
|
|
15
15
|
const require_typed_shared_color = require("./typed/shared/color.cjs");
|
|
16
16
|
const require_typed_shared_metadata = require("./typed/shared/metadata.cjs");
|
|
17
17
|
const require_image_sniff = require("./image/sniff.cjs");
|
|
18
|
+
const require_typed_docx_numbering = require("./typed/docx/numbering.cjs");
|
|
18
19
|
const require_typed_docx_read = require("./typed/docx/read.cjs");
|
|
19
20
|
const require_typed_pptx_read = require("./typed/pptx/read.cjs");
|
|
20
21
|
const require_typed_xlsx = require("./typed/xlsx.cjs");
|
|
@@ -63,6 +64,18 @@ Object.defineProperty(exports, "ContentBlockSchema", {
|
|
|
63
64
|
return document_schema_js.ContentBlockSchema;
|
|
64
65
|
}
|
|
65
66
|
});
|
|
67
|
+
Object.defineProperty(exports, "ContentBorderSchema", {
|
|
68
|
+
enumerable: true,
|
|
69
|
+
get: function() {
|
|
70
|
+
return document_schema_js.ContentBorderSchema;
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
Object.defineProperty(exports, "ContentCellBordersSchema", {
|
|
74
|
+
enumerable: true,
|
|
75
|
+
get: function() {
|
|
76
|
+
return document_schema_js.ContentCellBordersSchema;
|
|
77
|
+
}
|
|
78
|
+
});
|
|
66
79
|
Object.defineProperty(exports, "ContentCellValueSchema", {
|
|
67
80
|
enumerable: true,
|
|
68
81
|
get: function() {
|
|
@@ -171,6 +184,12 @@ Object.defineProperty(exports, "ContentSlideSchema", {
|
|
|
171
184
|
return document_schema_js.ContentSlideSchema;
|
|
172
185
|
}
|
|
173
186
|
});
|
|
187
|
+
Object.defineProperty(exports, "ContentStrokeStyleSchema", {
|
|
188
|
+
enumerable: true,
|
|
189
|
+
get: function() {
|
|
190
|
+
return document_schema_js.ContentStrokeStyleSchema;
|
|
191
|
+
}
|
|
192
|
+
});
|
|
174
193
|
Object.defineProperty(exports, "ContentTableCellSchema", {
|
|
175
194
|
enumerable: true,
|
|
176
195
|
get: function() {
|
|
@@ -199,6 +218,8 @@ Object.defineProperty(exports, "MarginsSchema", {
|
|
|
199
218
|
return document_schema_js.MarginsSchema;
|
|
200
219
|
}
|
|
201
220
|
});
|
|
221
|
+
exports.NumberingDefinitionSchema = require_typed_docx_numbering.NumberingDefinitionSchema;
|
|
222
|
+
exports.NumberingLevelSchema = require_typed_docx_numbering.NumberingLevelSchema;
|
|
202
223
|
Object.defineProperty(exports, "PAGE_SIZE_A4", {
|
|
203
224
|
enumerable: true,
|
|
204
225
|
get: function() {
|
|
@@ -279,6 +300,7 @@ exports.packageCodec = require_codec.packageCodec;
|
|
|
279
300
|
exports.parsePackage = require_package_io_read.parsePackage;
|
|
280
301
|
exports.parseXml = require_xml_parse.parseXml;
|
|
281
302
|
exports.readDocx = require_typed_docx_read.readDocx;
|
|
303
|
+
exports.readNumberingDefinitions = require_typed_docx_numbering.readNumberingDefinitions;
|
|
282
304
|
exports.readPptx = require_typed_pptx_read.readPptx;
|
|
283
305
|
exports.readXlsx = require_typed_xlsx.readXlsx;
|
|
284
306
|
exports.readXlsxContent = require_typed_xlsx_content.readXlsxContent;
|
package/dist/index.d.cts
CHANGED
|
@@ -15,9 +15,10 @@ import { Relationship, attr, childrenWithTag, decodeEntities, elementsWithTag, r
|
|
|
15
15
|
import { ColorTransform, applyColorTransforms } from "./typed/shared/color.cjs";
|
|
16
16
|
import { DocumentMetadata, DocumentMetadataSchema } from "./typed/shared/metadata.cjs";
|
|
17
17
|
import { Comment, CommentSchema, DocxDocument, DocxDocumentSchema, Footnote, FootnoteSchema, readDocx } from "./typed/docx/read.cjs";
|
|
18
|
+
import { NumberingDefinition, NumberingDefinitionSchema, NumberingDefinitions, NumberingLevel, NumberingLevelSchema, readNumberingDefinitions } from "./typed/docx/numbering.cjs";
|
|
18
19
|
import { PptxDocument, PptxDocumentSchema, readPptx } from "./typed/pptx/read.cjs";
|
|
19
20
|
import { DefinedName, DefinedNameSchema, XlsxCell, XlsxCellSchema, XlsxSheet, XlsxSheetSchema, XlsxWorkbook, XlsxWorkbookSchema, readXlsx } from "./typed/xlsx.cjs";
|
|
20
21
|
import { readXlsxContent } from "./typed/xlsx/content.cjs";
|
|
21
22
|
import { buildXlsxPackage } from "./typed/xlsx/build.cjs";
|
|
22
|
-
import { Alignment, AlignmentSchema, Box, BoxSchema, COLOR_BLACK, CONTENT_FORMAT_VERSION, Color, ColorSchema, ContentBlock, ContentBlockSchema, ContentCellValue, ContentCellValueSchema, ContentDocument, ContentDocumentSchema, ContentImageBlock, ContentImageBlockSchema, ContentListMembership, ContentListMembershipSchema, ContentPageBreak, ContentPageBreakSchema, ContentParagraph, ContentParagraphSchema, ContentRun, ContentRunSchema, ContentSection, ContentSectionSchema, ContentShape, ContentShapeSchema, ContentSheet, ContentSheetCell, ContentSheetCellSchema, ContentSheetColumn, ContentSheetColumnSchema, ContentSheetImage, ContentSheetImageSchema, ContentSheetPrintRange, ContentSheetPrintRangeSchema, ContentSheetPrintSettings, ContentSheetPrintSettingsSchema, ContentSheetRepeatRange, ContentSheetRepeatRangeSchema, ContentSheetRow, ContentSheetRowSchema, ContentSheetSchema, ContentSlide, ContentSlideSchema, ContentTable, ContentTableCell, ContentTableCellSchema, ContentTableRow, ContentTableRowSchema, ContentTableSchema, Margins, MarginsSchema, PAGE_SIZE_A4, PAGE_SIZE_LETTER, PageSize, PageSizeSchema, SLIDE_SIZE_STANDARD, SLIDE_SIZE_WIDESCREEN, colorToRgbHex, isContentBlock, rgbHexToColor } from "document-schema.js";
|
|
23
|
-
export { type Alignment, AlignmentSchema, type Attribute, AttributeSchema, type BinaryPart, BinaryPartSchema, type Box, BoxSchema, COLOR_BLACK, CONTENT_FORMAT_VERSION, type Color, ColorSchema, type ColorTransform, type Comment, CommentSchema, type CompactAttrPairs, type CompactPackage, CompactPackageSchema, type CompactPart, CompactPartSchema, type CompactXmlNode, CompactXmlNodeSchema, type ContentBlock, ContentBlockSchema, type ContentCellValue, ContentCellValueSchema, type ContentDocument, ContentDocumentSchema, type ContentImageBlock, ContentImageBlockSchema, type ContentListMembership, ContentListMembershipSchema, type ContentPageBreak, ContentPageBreakSchema, type ContentParagraph, ContentParagraphSchema, type ContentRun, ContentRunSchema, type ContentSection, ContentSectionSchema, type ContentShape, ContentShapeSchema, type ContentSheet, type ContentSheetCell, ContentSheetCellSchema, type ContentSheetColumn, ContentSheetColumnSchema, type ContentSheetImage, ContentSheetImageSchema, type ContentSheetPrintRange, ContentSheetPrintRangeSchema, type ContentSheetPrintSettings, ContentSheetPrintSettingsSchema, type ContentSheetRepeatRange, ContentSheetRepeatRangeSchema, type ContentSheetRow, ContentSheetRowSchema, ContentSheetSchema, type ContentSlide, ContentSlideSchema, type ContentTable, type ContentTableCell, ContentTableCellSchema, type ContentTableRow, ContentTableRowSchema, ContentTableSchema, type DefinedName, DefinedNameSchema, type DocumentMetadata, DocumentMetadataSchema, type DocxDocument, DocxDocumentSchema, type Footnote, FootnoteSchema, type ImageFormat, type Margins, MarginsSchema, PAGE_SIZE_A4, PAGE_SIZE_LETTER, type Package, PackageSchema, type PageSize, PageSizeSchema, type Part, PartSchema, type PptxDocument, PptxDocumentSchema, type Relationship, SLIDE_SIZE_STANDARD, SLIDE_SIZE_WIDESCREEN, type XlsxCell, XlsxCellSchema, type XlsxSheet, XlsxSheetSchema, type XlsxWorkbook, XlsxWorkbookSchema, type XmlCdata, XmlCdataSchema, type XmlComment, XmlCommentSchema, type XmlDeclaration, XmlDeclarationSchema, type XmlElement, XmlElementSchema, type XmlNode, XmlNodeSchema, type XmlPart, XmlPartSchema, type XmlPi, XmlPiSchema, type XmlText, XmlTextSchema, applyColorTransforms, attr, base64ToBytes, buildXlsxPackage, buildXml, bytesToBase64, childrenWithTag, colorToRgbHex, compactCodec, compactPackageCodec, decodeCompactPackage, decodeEntities, decodePackage, el, elementsWithTag, encodeCompactPackage, encodePackage, encodeXmlText, fromCompact, isCompactXmlNode, isContentBlock, isXmlNode, packageCodec, parsePackage, parseXml, readDocx, readPptx, readXlsx, readXlsxContent, resolveRelationships, rgbHexToColor, rootElement, serializePackage, sniffImageFormat, textContent, toCompact, txt, unzipPackage, walk, xmlCodec, zipPackage };
|
|
23
|
+
import { Alignment, AlignmentSchema, Box, BoxSchema, COLOR_BLACK, CONTENT_FORMAT_VERSION, Color, ColorSchema, ContentBlock, ContentBlockSchema, ContentBorder, ContentBorderSchema, ContentCellBorders, ContentCellBordersSchema, ContentCellValue, ContentCellValueSchema, ContentDocument, ContentDocumentSchema, ContentImageBlock, ContentImageBlockSchema, ContentListMembership, ContentListMembershipSchema, ContentPageBreak, ContentPageBreakSchema, ContentParagraph, ContentParagraphSchema, ContentRun, ContentRunSchema, ContentSection, ContentSectionSchema, ContentShape, ContentShapeSchema, ContentSheet, ContentSheetCell, ContentSheetCellSchema, ContentSheetColumn, ContentSheetColumnSchema, ContentSheetImage, ContentSheetImageSchema, ContentSheetPrintRange, ContentSheetPrintRangeSchema, ContentSheetPrintSettings, ContentSheetPrintSettingsSchema, ContentSheetRepeatRange, ContentSheetRepeatRangeSchema, ContentSheetRow, ContentSheetRowSchema, ContentSheetSchema, ContentSlide, ContentSlideSchema, ContentStrokeStyle, ContentStrokeStyleSchema, ContentTable, ContentTableCell, ContentTableCellSchema, ContentTableRow, ContentTableRowSchema, ContentTableSchema, Margins, MarginsSchema, PAGE_SIZE_A4, PAGE_SIZE_LETTER, PageSize, PageSizeSchema, SLIDE_SIZE_STANDARD, SLIDE_SIZE_WIDESCREEN, colorToRgbHex, isContentBlock, rgbHexToColor } from "document-schema.js";
|
|
24
|
+
export { type Alignment, AlignmentSchema, type Attribute, AttributeSchema, type BinaryPart, BinaryPartSchema, type Box, BoxSchema, COLOR_BLACK, CONTENT_FORMAT_VERSION, type Color, ColorSchema, type ColorTransform, type Comment, CommentSchema, type CompactAttrPairs, type CompactPackage, CompactPackageSchema, type CompactPart, CompactPartSchema, type CompactXmlNode, CompactXmlNodeSchema, type ContentBlock, ContentBlockSchema, type ContentBorder, ContentBorderSchema, type ContentCellBorders, ContentCellBordersSchema, type ContentCellValue, ContentCellValueSchema, type ContentDocument, ContentDocumentSchema, type ContentImageBlock, ContentImageBlockSchema, type ContentListMembership, ContentListMembershipSchema, type ContentPageBreak, ContentPageBreakSchema, type ContentParagraph, ContentParagraphSchema, type ContentRun, ContentRunSchema, type ContentSection, ContentSectionSchema, type ContentShape, ContentShapeSchema, type ContentSheet, type ContentSheetCell, ContentSheetCellSchema, type ContentSheetColumn, ContentSheetColumnSchema, type ContentSheetImage, ContentSheetImageSchema, type ContentSheetPrintRange, ContentSheetPrintRangeSchema, type ContentSheetPrintSettings, ContentSheetPrintSettingsSchema, type ContentSheetRepeatRange, ContentSheetRepeatRangeSchema, type ContentSheetRow, ContentSheetRowSchema, ContentSheetSchema, type ContentSlide, ContentSlideSchema, type ContentStrokeStyle, ContentStrokeStyleSchema, type ContentTable, type ContentTableCell, ContentTableCellSchema, type ContentTableRow, ContentTableRowSchema, ContentTableSchema, type DefinedName, DefinedNameSchema, type DocumentMetadata, DocumentMetadataSchema, type DocxDocument, DocxDocumentSchema, type Footnote, FootnoteSchema, type ImageFormat, type Margins, MarginsSchema, type NumberingDefinition, NumberingDefinitionSchema, type NumberingDefinitions, type NumberingLevel, NumberingLevelSchema, PAGE_SIZE_A4, PAGE_SIZE_LETTER, type Package, PackageSchema, type PageSize, PageSizeSchema, type Part, PartSchema, type PptxDocument, PptxDocumentSchema, type Relationship, SLIDE_SIZE_STANDARD, SLIDE_SIZE_WIDESCREEN, type XlsxCell, XlsxCellSchema, type XlsxSheet, XlsxSheetSchema, type XlsxWorkbook, XlsxWorkbookSchema, type XmlCdata, XmlCdataSchema, type XmlComment, XmlCommentSchema, type XmlDeclaration, XmlDeclarationSchema, type XmlElement, XmlElementSchema, type XmlNode, XmlNodeSchema, type XmlPart, XmlPartSchema, type XmlPi, XmlPiSchema, type XmlText, XmlTextSchema, applyColorTransforms, attr, base64ToBytes, buildXlsxPackage, buildXml, bytesToBase64, childrenWithTag, colorToRgbHex, compactCodec, compactPackageCodec, decodeCompactPackage, decodeEntities, decodePackage, el, elementsWithTag, encodeCompactPackage, encodePackage, encodeXmlText, fromCompact, isCompactXmlNode, isContentBlock, isXmlNode, packageCodec, parsePackage, parseXml, readDocx, readNumberingDefinitions, readPptx, readXlsx, readXlsxContent, resolveRelationships, rgbHexToColor, rootElement, serializePackage, sniffImageFormat, textContent, toCompact, txt, unzipPackage, walk, xmlCodec, zipPackage };
|
package/dist/index.d.ts
CHANGED
|
@@ -15,9 +15,10 @@ import { Relationship, attr, childrenWithTag, decodeEntities, elementsWithTag, r
|
|
|
15
15
|
import { ColorTransform, applyColorTransforms } from "./typed/shared/color.js";
|
|
16
16
|
import { DocumentMetadata, DocumentMetadataSchema } from "./typed/shared/metadata.js";
|
|
17
17
|
import { Comment, CommentSchema, DocxDocument, DocxDocumentSchema, Footnote, FootnoteSchema, readDocx } from "./typed/docx/read.js";
|
|
18
|
+
import { NumberingDefinition, NumberingDefinitionSchema, NumberingDefinitions, NumberingLevel, NumberingLevelSchema, readNumberingDefinitions } from "./typed/docx/numbering.js";
|
|
18
19
|
import { PptxDocument, PptxDocumentSchema, readPptx } from "./typed/pptx/read.js";
|
|
19
20
|
import { DefinedName, DefinedNameSchema, XlsxCell, XlsxCellSchema, XlsxSheet, XlsxSheetSchema, XlsxWorkbook, XlsxWorkbookSchema, readXlsx } from "./typed/xlsx.js";
|
|
20
21
|
import { readXlsxContent } from "./typed/xlsx/content.js";
|
|
21
22
|
import { buildXlsxPackage } from "./typed/xlsx/build.js";
|
|
22
|
-
import { Alignment, AlignmentSchema, Box, BoxSchema, COLOR_BLACK, CONTENT_FORMAT_VERSION, Color, ColorSchema, ContentBlock, ContentBlockSchema, ContentCellValue, ContentCellValueSchema, ContentDocument, ContentDocumentSchema, ContentImageBlock, ContentImageBlockSchema, ContentListMembership, ContentListMembershipSchema, ContentPageBreak, ContentPageBreakSchema, ContentParagraph, ContentParagraphSchema, ContentRun, ContentRunSchema, ContentSection, ContentSectionSchema, ContentShape, ContentShapeSchema, ContentSheet, ContentSheetCell, ContentSheetCellSchema, ContentSheetColumn, ContentSheetColumnSchema, ContentSheetImage, ContentSheetImageSchema, ContentSheetPrintRange, ContentSheetPrintRangeSchema, ContentSheetPrintSettings, ContentSheetPrintSettingsSchema, ContentSheetRepeatRange, ContentSheetRepeatRangeSchema, ContentSheetRow, ContentSheetRowSchema, ContentSheetSchema, ContentSlide, ContentSlideSchema, ContentTable, ContentTableCell, ContentTableCellSchema, ContentTableRow, ContentTableRowSchema, ContentTableSchema, Margins, MarginsSchema, PAGE_SIZE_A4, PAGE_SIZE_LETTER, PageSize, PageSizeSchema, SLIDE_SIZE_STANDARD, SLIDE_SIZE_WIDESCREEN, colorToRgbHex, isContentBlock, rgbHexToColor } from "document-schema.js";
|
|
23
|
-
export { type Alignment, AlignmentSchema, type Attribute, AttributeSchema, type BinaryPart, BinaryPartSchema, type Box, BoxSchema, COLOR_BLACK, CONTENT_FORMAT_VERSION, type Color, ColorSchema, type ColorTransform, type Comment, CommentSchema, type CompactAttrPairs, type CompactPackage, CompactPackageSchema, type CompactPart, CompactPartSchema, type CompactXmlNode, CompactXmlNodeSchema, type ContentBlock, ContentBlockSchema, type ContentCellValue, ContentCellValueSchema, type ContentDocument, ContentDocumentSchema, type ContentImageBlock, ContentImageBlockSchema, type ContentListMembership, ContentListMembershipSchema, type ContentPageBreak, ContentPageBreakSchema, type ContentParagraph, ContentParagraphSchema, type ContentRun, ContentRunSchema, type ContentSection, ContentSectionSchema, type ContentShape, ContentShapeSchema, type ContentSheet, type ContentSheetCell, ContentSheetCellSchema, type ContentSheetColumn, ContentSheetColumnSchema, type ContentSheetImage, ContentSheetImageSchema, type ContentSheetPrintRange, ContentSheetPrintRangeSchema, type ContentSheetPrintSettings, ContentSheetPrintSettingsSchema, type ContentSheetRepeatRange, ContentSheetRepeatRangeSchema, type ContentSheetRow, ContentSheetRowSchema, ContentSheetSchema, type ContentSlide, ContentSlideSchema, type ContentTable, type ContentTableCell, ContentTableCellSchema, type ContentTableRow, ContentTableRowSchema, ContentTableSchema, type DefinedName, DefinedNameSchema, type DocumentMetadata, DocumentMetadataSchema, type DocxDocument, DocxDocumentSchema, type Footnote, FootnoteSchema, type ImageFormat, type Margins, MarginsSchema, PAGE_SIZE_A4, PAGE_SIZE_LETTER, type Package, PackageSchema, type PageSize, PageSizeSchema, type Part, PartSchema, type PptxDocument, PptxDocumentSchema, type Relationship, SLIDE_SIZE_STANDARD, SLIDE_SIZE_WIDESCREEN, type XlsxCell, XlsxCellSchema, type XlsxSheet, XlsxSheetSchema, type XlsxWorkbook, XlsxWorkbookSchema, type XmlCdata, XmlCdataSchema, type XmlComment, XmlCommentSchema, type XmlDeclaration, XmlDeclarationSchema, type XmlElement, XmlElementSchema, type XmlNode, XmlNodeSchema, type XmlPart, XmlPartSchema, type XmlPi, XmlPiSchema, type XmlText, XmlTextSchema, applyColorTransforms, attr, base64ToBytes, buildXlsxPackage, buildXml, bytesToBase64, childrenWithTag, colorToRgbHex, compactCodec, compactPackageCodec, decodeCompactPackage, decodeEntities, decodePackage, el, elementsWithTag, encodeCompactPackage, encodePackage, encodeXmlText, fromCompact, isCompactXmlNode, isContentBlock, isXmlNode, packageCodec, parsePackage, parseXml, readDocx, readPptx, readXlsx, readXlsxContent, resolveRelationships, rgbHexToColor, rootElement, serializePackage, sniffImageFormat, textContent, toCompact, txt, unzipPackage, walk, xmlCodec, zipPackage };
|
|
23
|
+
import { Alignment, AlignmentSchema, Box, BoxSchema, COLOR_BLACK, CONTENT_FORMAT_VERSION, Color, ColorSchema, ContentBlock, ContentBlockSchema, ContentBorder, ContentBorderSchema, ContentCellBorders, ContentCellBordersSchema, ContentCellValue, ContentCellValueSchema, ContentDocument, ContentDocumentSchema, ContentImageBlock, ContentImageBlockSchema, ContentListMembership, ContentListMembershipSchema, ContentPageBreak, ContentPageBreakSchema, ContentParagraph, ContentParagraphSchema, ContentRun, ContentRunSchema, ContentSection, ContentSectionSchema, ContentShape, ContentShapeSchema, ContentSheet, ContentSheetCell, ContentSheetCellSchema, ContentSheetColumn, ContentSheetColumnSchema, ContentSheetImage, ContentSheetImageSchema, ContentSheetPrintRange, ContentSheetPrintRangeSchema, ContentSheetPrintSettings, ContentSheetPrintSettingsSchema, ContentSheetRepeatRange, ContentSheetRepeatRangeSchema, ContentSheetRow, ContentSheetRowSchema, ContentSheetSchema, ContentSlide, ContentSlideSchema, ContentStrokeStyle, ContentStrokeStyleSchema, ContentTable, ContentTableCell, ContentTableCellSchema, ContentTableRow, ContentTableRowSchema, ContentTableSchema, Margins, MarginsSchema, PAGE_SIZE_A4, PAGE_SIZE_LETTER, PageSize, PageSizeSchema, SLIDE_SIZE_STANDARD, SLIDE_SIZE_WIDESCREEN, colorToRgbHex, isContentBlock, rgbHexToColor } from "document-schema.js";
|
|
24
|
+
export { type Alignment, AlignmentSchema, type Attribute, AttributeSchema, type BinaryPart, BinaryPartSchema, type Box, BoxSchema, COLOR_BLACK, CONTENT_FORMAT_VERSION, type Color, ColorSchema, type ColorTransform, type Comment, CommentSchema, type CompactAttrPairs, type CompactPackage, CompactPackageSchema, type CompactPart, CompactPartSchema, type CompactXmlNode, CompactXmlNodeSchema, type ContentBlock, ContentBlockSchema, type ContentBorder, ContentBorderSchema, type ContentCellBorders, ContentCellBordersSchema, type ContentCellValue, ContentCellValueSchema, type ContentDocument, ContentDocumentSchema, type ContentImageBlock, ContentImageBlockSchema, type ContentListMembership, ContentListMembershipSchema, type ContentPageBreak, ContentPageBreakSchema, type ContentParagraph, ContentParagraphSchema, type ContentRun, ContentRunSchema, type ContentSection, ContentSectionSchema, type ContentShape, ContentShapeSchema, type ContentSheet, type ContentSheetCell, ContentSheetCellSchema, type ContentSheetColumn, ContentSheetColumnSchema, type ContentSheetImage, ContentSheetImageSchema, type ContentSheetPrintRange, ContentSheetPrintRangeSchema, type ContentSheetPrintSettings, ContentSheetPrintSettingsSchema, type ContentSheetRepeatRange, ContentSheetRepeatRangeSchema, type ContentSheetRow, ContentSheetRowSchema, ContentSheetSchema, type ContentSlide, ContentSlideSchema, type ContentStrokeStyle, ContentStrokeStyleSchema, type ContentTable, type ContentTableCell, ContentTableCellSchema, type ContentTableRow, ContentTableRowSchema, ContentTableSchema, type DefinedName, DefinedNameSchema, type DocumentMetadata, DocumentMetadataSchema, type DocxDocument, DocxDocumentSchema, type Footnote, FootnoteSchema, type ImageFormat, type Margins, MarginsSchema, type NumberingDefinition, NumberingDefinitionSchema, type NumberingDefinitions, type NumberingLevel, NumberingLevelSchema, PAGE_SIZE_A4, PAGE_SIZE_LETTER, type Package, PackageSchema, type PageSize, PageSizeSchema, type Part, PartSchema, type PptxDocument, PptxDocumentSchema, type Relationship, SLIDE_SIZE_STANDARD, SLIDE_SIZE_WIDESCREEN, type XlsxCell, XlsxCellSchema, type XlsxSheet, XlsxSheetSchema, type XlsxWorkbook, XlsxWorkbookSchema, type XmlCdata, XmlCdataSchema, type XmlComment, XmlCommentSchema, type XmlDeclaration, XmlDeclarationSchema, type XmlElement, XmlElementSchema, type XmlNode, XmlNodeSchema, type XmlPart, XmlPartSchema, type XmlPi, XmlPiSchema, type XmlText, XmlTextSchema, applyColorTransforms, attr, base64ToBytes, buildXlsxPackage, buildXml, bytesToBase64, childrenWithTag, colorToRgbHex, compactCodec, compactPackageCodec, decodeCompactPackage, decodeEntities, decodePackage, el, elementsWithTag, encodeCompactPackage, encodePackage, encodeXmlText, fromCompact, isCompactXmlNode, isContentBlock, isXmlNode, packageCodec, parsePackage, parseXml, readDocx, readNumberingDefinitions, readPptx, readXlsx, readXlsxContent, resolveRelationships, rgbHexToColor, rootElement, serializePackage, sniffImageFormat, textContent, toCompact, txt, unzipPackage, walk, xmlCodec, zipPackage };
|
package/dist/index.js
CHANGED
|
@@ -14,10 +14,11 @@ import { attr, childrenWithTag, decodeEntities, elementsWithTag, resolveRelation
|
|
|
14
14
|
import { applyColorTransforms } from "./typed/shared/color.js";
|
|
15
15
|
import { DocumentMetadataSchema } from "./typed/shared/metadata.js";
|
|
16
16
|
import { sniffImageFormat } from "./image/sniff.js";
|
|
17
|
+
import { NumberingDefinitionSchema, NumberingLevelSchema, readNumberingDefinitions } from "./typed/docx/numbering.js";
|
|
17
18
|
import { CommentSchema, DocxDocumentSchema, FootnoteSchema, readDocx } from "./typed/docx/read.js";
|
|
18
19
|
import { PptxDocumentSchema, readPptx } from "./typed/pptx/read.js";
|
|
19
20
|
import { DefinedNameSchema, XlsxCellSchema, XlsxSheetSchema, XlsxWorkbookSchema, readXlsx } from "./typed/xlsx.js";
|
|
20
21
|
import { readXlsxContent } from "./typed/xlsx/content.js";
|
|
21
22
|
import { buildXlsxPackage } from "./typed/xlsx/build.js";
|
|
22
|
-
import { AlignmentSchema, BoxSchema, COLOR_BLACK, CONTENT_FORMAT_VERSION, ColorSchema, ContentBlockSchema, ContentCellValueSchema, ContentDocumentSchema, ContentImageBlockSchema, ContentListMembershipSchema, ContentPageBreakSchema, ContentParagraphSchema, ContentRunSchema, ContentSectionSchema, ContentShapeSchema, ContentSheetCellSchema, ContentSheetColumnSchema, ContentSheetImageSchema, ContentSheetPrintRangeSchema, ContentSheetPrintSettingsSchema, ContentSheetRepeatRangeSchema, ContentSheetRowSchema, ContentSheetSchema, ContentSlideSchema, ContentTableCellSchema, ContentTableRowSchema, ContentTableSchema, MarginsSchema, PAGE_SIZE_A4, PAGE_SIZE_LETTER, PageSizeSchema, SLIDE_SIZE_STANDARD, SLIDE_SIZE_WIDESCREEN, colorToRgbHex, isContentBlock, rgbHexToColor } from "document-schema.js";
|
|
23
|
-
export { AlignmentSchema, AttributeSchema, BinaryPartSchema, BoxSchema, COLOR_BLACK, CONTENT_FORMAT_VERSION, ColorSchema, CommentSchema, CompactPackageSchema, CompactPartSchema, CompactXmlNodeSchema, ContentBlockSchema, ContentCellValueSchema, ContentDocumentSchema, ContentImageBlockSchema, ContentListMembershipSchema, ContentPageBreakSchema, ContentParagraphSchema, ContentRunSchema, ContentSectionSchema, ContentShapeSchema, ContentSheetCellSchema, ContentSheetColumnSchema, ContentSheetImageSchema, ContentSheetPrintRangeSchema, ContentSheetPrintSettingsSchema, ContentSheetRepeatRangeSchema, ContentSheetRowSchema, ContentSheetSchema, ContentSlideSchema, ContentTableCellSchema, ContentTableRowSchema, ContentTableSchema, DefinedNameSchema, DocumentMetadataSchema, DocxDocumentSchema, FootnoteSchema, MarginsSchema, PAGE_SIZE_A4, PAGE_SIZE_LETTER, PackageSchema, PageSizeSchema, PartSchema, PptxDocumentSchema, SLIDE_SIZE_STANDARD, SLIDE_SIZE_WIDESCREEN, XlsxCellSchema, XlsxSheetSchema, XlsxWorkbookSchema, XmlCdataSchema, XmlCommentSchema, XmlDeclarationSchema, XmlElementSchema, XmlNodeSchema, XmlPartSchema, XmlPiSchema, XmlTextSchema, applyColorTransforms, attr, base64ToBytes, buildXlsxPackage, buildXml, bytesToBase64, childrenWithTag, colorToRgbHex, compactCodec, compactPackageCodec, decodeCompactPackage, decodeEntities, decodePackage, el, elementsWithTag, encodeCompactPackage, encodePackage, encodeXmlText, fromCompact, isCompactXmlNode, isContentBlock, isXmlNode, packageCodec, parsePackage, parseXml, readDocx, readPptx, readXlsx, readXlsxContent, resolveRelationships, rgbHexToColor, rootElement, serializePackage, sniffImageFormat, textContent, toCompact, txt, unzipPackage, walk, xmlCodec, zipPackage };
|
|
23
|
+
import { AlignmentSchema, BoxSchema, COLOR_BLACK, CONTENT_FORMAT_VERSION, ColorSchema, ContentBlockSchema, ContentBorderSchema, ContentCellBordersSchema, ContentCellValueSchema, ContentDocumentSchema, ContentImageBlockSchema, ContentListMembershipSchema, ContentPageBreakSchema, ContentParagraphSchema, ContentRunSchema, ContentSectionSchema, ContentShapeSchema, ContentSheetCellSchema, ContentSheetColumnSchema, ContentSheetImageSchema, ContentSheetPrintRangeSchema, ContentSheetPrintSettingsSchema, ContentSheetRepeatRangeSchema, ContentSheetRowSchema, ContentSheetSchema, ContentSlideSchema, ContentStrokeStyleSchema, ContentTableCellSchema, ContentTableRowSchema, ContentTableSchema, MarginsSchema, PAGE_SIZE_A4, PAGE_SIZE_LETTER, PageSizeSchema, SLIDE_SIZE_STANDARD, SLIDE_SIZE_WIDESCREEN, colorToRgbHex, isContentBlock, rgbHexToColor } from "document-schema.js";
|
|
24
|
+
export { AlignmentSchema, AttributeSchema, BinaryPartSchema, BoxSchema, COLOR_BLACK, CONTENT_FORMAT_VERSION, ColorSchema, CommentSchema, CompactPackageSchema, CompactPartSchema, CompactXmlNodeSchema, ContentBlockSchema, ContentBorderSchema, ContentCellBordersSchema, ContentCellValueSchema, ContentDocumentSchema, ContentImageBlockSchema, ContentListMembershipSchema, ContentPageBreakSchema, ContentParagraphSchema, ContentRunSchema, ContentSectionSchema, ContentShapeSchema, ContentSheetCellSchema, ContentSheetColumnSchema, ContentSheetImageSchema, ContentSheetPrintRangeSchema, ContentSheetPrintSettingsSchema, ContentSheetRepeatRangeSchema, ContentSheetRowSchema, ContentSheetSchema, ContentSlideSchema, ContentStrokeStyleSchema, ContentTableCellSchema, ContentTableRowSchema, ContentTableSchema, DefinedNameSchema, DocumentMetadataSchema, DocxDocumentSchema, FootnoteSchema, MarginsSchema, NumberingDefinitionSchema, NumberingLevelSchema, PAGE_SIZE_A4, PAGE_SIZE_LETTER, PackageSchema, PageSizeSchema, PartSchema, PptxDocumentSchema, SLIDE_SIZE_STANDARD, SLIDE_SIZE_WIDESCREEN, XlsxCellSchema, XlsxSheetSchema, XlsxWorkbookSchema, XmlCdataSchema, XmlCommentSchema, XmlDeclarationSchema, XmlElementSchema, XmlNodeSchema, XmlPartSchema, XmlPiSchema, XmlTextSchema, applyColorTransforms, attr, base64ToBytes, buildXlsxPackage, buildXml, bytesToBase64, childrenWithTag, colorToRgbHex, compactCodec, compactPackageCodec, decodeCompactPackage, decodeEntities, decodePackage, el, elementsWithTag, encodeCompactPackage, encodePackage, encodeXmlText, fromCompact, isCompactXmlNode, isContentBlock, isXmlNode, packageCodec, parsePackage, parseXml, readDocx, readNumberingDefinitions, readPptx, readXlsx, readXlsxContent, resolveRelationships, rgbHexToColor, rootElement, serializePackage, sniffImageFormat, textContent, toCompact, txt, unzipPackage, walk, xmlCodec, zipPackage };
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_typed_util = require("../util.cjs");
|
|
3
|
+
let zod = require("zod");
|
|
4
|
+
//#region src/typed/docx/numbering.ts
|
|
5
|
+
const NumberingLevelSchema = zod.z.object({
|
|
6
|
+
format: zod.z.string(),
|
|
7
|
+
text: zod.z.string(),
|
|
8
|
+
startAt: zod.z.number(),
|
|
9
|
+
restart: zod.z.number().optional()
|
|
10
|
+
});
|
|
11
|
+
const NumberingDefinitionSchema = zod.z.object({ levels: zod.z.record(zod.z.string(), NumberingLevelSchema) });
|
|
12
|
+
const NUMBERING_PART_PATH = "word/numbering.xml";
|
|
13
|
+
function readLevel(lvl) {
|
|
14
|
+
const numFmtEl = require_typed_util.childrenWithTag(lvl, "w:numFmt")[0];
|
|
15
|
+
const lvlTextEl = require_typed_util.childrenWithTag(lvl, "w:lvlText")[0];
|
|
16
|
+
const format = numFmtEl === void 0 ? void 0 : require_typed_util.attr(numFmtEl, "w:val");
|
|
17
|
+
const text = lvlTextEl === void 0 ? void 0 : require_typed_util.attr(lvlTextEl, "w:val");
|
|
18
|
+
if (format === void 0 || text === void 0) return;
|
|
19
|
+
const startEl = require_typed_util.childrenWithTag(lvl, "w:start")[0];
|
|
20
|
+
const startVal = startEl === void 0 ? void 0 : require_typed_util.attr(startEl, "w:val");
|
|
21
|
+
const restartEl = require_typed_util.childrenWithTag(lvl, "w:lvlRestart")[0];
|
|
22
|
+
const restartVal = restartEl === void 0 ? void 0 : require_typed_util.attr(restartEl, "w:val");
|
|
23
|
+
const level = {
|
|
24
|
+
format,
|
|
25
|
+
text,
|
|
26
|
+
startAt: startVal === void 0 ? 1 : Number(startVal)
|
|
27
|
+
};
|
|
28
|
+
if (restartVal !== void 0) level.restart = Number(restartVal);
|
|
29
|
+
return level;
|
|
30
|
+
}
|
|
31
|
+
function readAbstractNumLevels(abstractNum) {
|
|
32
|
+
const levels = {};
|
|
33
|
+
for (const lvl of require_typed_util.childrenWithTag(abstractNum, "w:lvl")) {
|
|
34
|
+
const ilvl = require_typed_util.attr(lvl, "w:ilvl");
|
|
35
|
+
if (ilvl === void 0) continue;
|
|
36
|
+
const level = readLevel(lvl);
|
|
37
|
+
if (level !== void 0) levels[ilvl] = level;
|
|
38
|
+
}
|
|
39
|
+
return levels;
|
|
40
|
+
}
|
|
41
|
+
function applyLevelOverrides(baseLevels, num) {
|
|
42
|
+
const levels = { ...baseLevels };
|
|
43
|
+
for (const override of require_typed_util.childrenWithTag(num, "w:lvlOverride")) {
|
|
44
|
+
const ilvl = require_typed_util.attr(override, "w:ilvl");
|
|
45
|
+
if (ilvl === void 0) continue;
|
|
46
|
+
const nestedLvl = require_typed_util.childrenWithTag(override, "w:lvl")[0];
|
|
47
|
+
if (nestedLvl !== void 0) {
|
|
48
|
+
const level = readLevel(nestedLvl);
|
|
49
|
+
if (level !== void 0) levels[ilvl] = level;
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
const startOverrideEl = require_typed_util.childrenWithTag(override, "w:startOverride")[0];
|
|
53
|
+
const startOverrideVal = startOverrideEl === void 0 ? void 0 : require_typed_util.attr(startOverrideEl, "w:val");
|
|
54
|
+
const base = levels[ilvl];
|
|
55
|
+
if (startOverrideVal !== void 0 && base !== void 0) levels[ilvl] = {
|
|
56
|
+
...base,
|
|
57
|
+
startAt: Number(startOverrideVal)
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
return levels;
|
|
61
|
+
}
|
|
62
|
+
function readNumberingDefinitions(pkg) {
|
|
63
|
+
const root = require_typed_util.rootElement(pkg.parts[NUMBERING_PART_PATH]);
|
|
64
|
+
if (root === void 0) return {};
|
|
65
|
+
const abstractNums = /* @__PURE__ */ new Map();
|
|
66
|
+
for (const abstractNum of require_typed_util.childrenWithTag(root, "w:abstractNum")) {
|
|
67
|
+
const abstractNumId = require_typed_util.attr(abstractNum, "w:abstractNumId");
|
|
68
|
+
if (abstractNumId === void 0) continue;
|
|
69
|
+
abstractNums.set(abstractNumId, readAbstractNumLevels(abstractNum));
|
|
70
|
+
}
|
|
71
|
+
const definitions = {};
|
|
72
|
+
for (const num of require_typed_util.childrenWithTag(root, "w:num")) {
|
|
73
|
+
const numId = require_typed_util.attr(num, "w:numId");
|
|
74
|
+
const abstractNumIdEl = require_typed_util.childrenWithTag(num, "w:abstractNumId")[0];
|
|
75
|
+
const abstractNumId = abstractNumIdEl === void 0 ? void 0 : require_typed_util.attr(abstractNumIdEl, "w:val");
|
|
76
|
+
if (numId === void 0 || abstractNumId === void 0) continue;
|
|
77
|
+
const baseLevels = abstractNums.get(abstractNumId);
|
|
78
|
+
if (baseLevels === void 0) continue;
|
|
79
|
+
definitions[numId] = { levels: applyLevelOverrides(baseLevels, num) };
|
|
80
|
+
}
|
|
81
|
+
return definitions;
|
|
82
|
+
}
|
|
83
|
+
//#endregion
|
|
84
|
+
exports.NumberingDefinitionSchema = NumberingDefinitionSchema;
|
|
85
|
+
exports.NumberingLevelSchema = NumberingLevelSchema;
|
|
86
|
+
exports.readNumberingDefinitions = readNumberingDefinitions;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { r as Package } from "../../package-L24lkba-.cjs";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
//#region src/typed/docx/numbering.d.ts
|
|
4
|
+
declare const NumberingLevelSchema: z.ZodObject<{
|
|
5
|
+
format: z.ZodString;
|
|
6
|
+
text: z.ZodString;
|
|
7
|
+
startAt: z.ZodNumber;
|
|
8
|
+
restart: z.ZodOptional<z.ZodNumber>;
|
|
9
|
+
}, z.core.$strip>;
|
|
10
|
+
type NumberingLevel = z.infer<typeof NumberingLevelSchema>;
|
|
11
|
+
declare const NumberingDefinitionSchema: z.ZodObject<{
|
|
12
|
+
levels: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
13
|
+
format: z.ZodString;
|
|
14
|
+
text: z.ZodString;
|
|
15
|
+
startAt: z.ZodNumber;
|
|
16
|
+
restart: z.ZodOptional<z.ZodNumber>;
|
|
17
|
+
}, z.core.$strip>>;
|
|
18
|
+
}, z.core.$strip>;
|
|
19
|
+
type NumberingDefinition = z.infer<typeof NumberingDefinitionSchema>;
|
|
20
|
+
type NumberingDefinitions = Readonly<Record<string, NumberingDefinition>>;
|
|
21
|
+
declare function readNumberingDefinitions(pkg: Package): NumberingDefinitions;
|
|
22
|
+
//#endregion
|
|
23
|
+
export { NumberingDefinition, NumberingDefinitionSchema, NumberingDefinitions, NumberingLevel, NumberingLevelSchema, readNumberingDefinitions };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { r as Package } from "../../package-BUojjTXf.js";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
//#region src/typed/docx/numbering.d.ts
|
|
4
|
+
declare const NumberingLevelSchema: z.ZodObject<{
|
|
5
|
+
format: z.ZodString;
|
|
6
|
+
text: z.ZodString;
|
|
7
|
+
startAt: z.ZodNumber;
|
|
8
|
+
restart: z.ZodOptional<z.ZodNumber>;
|
|
9
|
+
}, z.core.$strip>;
|
|
10
|
+
type NumberingLevel = z.infer<typeof NumberingLevelSchema>;
|
|
11
|
+
declare const NumberingDefinitionSchema: z.ZodObject<{
|
|
12
|
+
levels: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
13
|
+
format: z.ZodString;
|
|
14
|
+
text: z.ZodString;
|
|
15
|
+
startAt: z.ZodNumber;
|
|
16
|
+
restart: z.ZodOptional<z.ZodNumber>;
|
|
17
|
+
}, z.core.$strip>>;
|
|
18
|
+
}, z.core.$strip>;
|
|
19
|
+
type NumberingDefinition = z.infer<typeof NumberingDefinitionSchema>;
|
|
20
|
+
type NumberingDefinitions = Readonly<Record<string, NumberingDefinition>>;
|
|
21
|
+
declare function readNumberingDefinitions(pkg: Package): NumberingDefinitions;
|
|
22
|
+
//#endregion
|
|
23
|
+
export { NumberingDefinition, NumberingDefinitionSchema, NumberingDefinitions, NumberingLevel, NumberingLevelSchema, readNumberingDefinitions };
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { attr, childrenWithTag, rootElement } from "../util.js";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
//#region src/typed/docx/numbering.ts
|
|
4
|
+
const NumberingLevelSchema = z.object({
|
|
5
|
+
format: z.string(),
|
|
6
|
+
text: z.string(),
|
|
7
|
+
startAt: z.number(),
|
|
8
|
+
restart: z.number().optional()
|
|
9
|
+
});
|
|
10
|
+
const NumberingDefinitionSchema = z.object({ levels: z.record(z.string(), NumberingLevelSchema) });
|
|
11
|
+
const NUMBERING_PART_PATH = "word/numbering.xml";
|
|
12
|
+
function readLevel(lvl) {
|
|
13
|
+
const numFmtEl = childrenWithTag(lvl, "w:numFmt")[0];
|
|
14
|
+
const lvlTextEl = childrenWithTag(lvl, "w:lvlText")[0];
|
|
15
|
+
const format = numFmtEl === void 0 ? void 0 : attr(numFmtEl, "w:val");
|
|
16
|
+
const text = lvlTextEl === void 0 ? void 0 : attr(lvlTextEl, "w:val");
|
|
17
|
+
if (format === void 0 || text === void 0) return;
|
|
18
|
+
const startEl = childrenWithTag(lvl, "w:start")[0];
|
|
19
|
+
const startVal = startEl === void 0 ? void 0 : attr(startEl, "w:val");
|
|
20
|
+
const restartEl = childrenWithTag(lvl, "w:lvlRestart")[0];
|
|
21
|
+
const restartVal = restartEl === void 0 ? void 0 : attr(restartEl, "w:val");
|
|
22
|
+
const level = {
|
|
23
|
+
format,
|
|
24
|
+
text,
|
|
25
|
+
startAt: startVal === void 0 ? 1 : Number(startVal)
|
|
26
|
+
};
|
|
27
|
+
if (restartVal !== void 0) level.restart = Number(restartVal);
|
|
28
|
+
return level;
|
|
29
|
+
}
|
|
30
|
+
function readAbstractNumLevels(abstractNum) {
|
|
31
|
+
const levels = {};
|
|
32
|
+
for (const lvl of childrenWithTag(abstractNum, "w:lvl")) {
|
|
33
|
+
const ilvl = attr(lvl, "w:ilvl");
|
|
34
|
+
if (ilvl === void 0) continue;
|
|
35
|
+
const level = readLevel(lvl);
|
|
36
|
+
if (level !== void 0) levels[ilvl] = level;
|
|
37
|
+
}
|
|
38
|
+
return levels;
|
|
39
|
+
}
|
|
40
|
+
function applyLevelOverrides(baseLevels, num) {
|
|
41
|
+
const levels = { ...baseLevels };
|
|
42
|
+
for (const override of childrenWithTag(num, "w:lvlOverride")) {
|
|
43
|
+
const ilvl = attr(override, "w:ilvl");
|
|
44
|
+
if (ilvl === void 0) continue;
|
|
45
|
+
const nestedLvl = childrenWithTag(override, "w:lvl")[0];
|
|
46
|
+
if (nestedLvl !== void 0) {
|
|
47
|
+
const level = readLevel(nestedLvl);
|
|
48
|
+
if (level !== void 0) levels[ilvl] = level;
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
const startOverrideEl = childrenWithTag(override, "w:startOverride")[0];
|
|
52
|
+
const startOverrideVal = startOverrideEl === void 0 ? void 0 : attr(startOverrideEl, "w:val");
|
|
53
|
+
const base = levels[ilvl];
|
|
54
|
+
if (startOverrideVal !== void 0 && base !== void 0) levels[ilvl] = {
|
|
55
|
+
...base,
|
|
56
|
+
startAt: Number(startOverrideVal)
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
return levels;
|
|
60
|
+
}
|
|
61
|
+
function readNumberingDefinitions(pkg) {
|
|
62
|
+
const root = rootElement(pkg.parts[NUMBERING_PART_PATH]);
|
|
63
|
+
if (root === void 0) return {};
|
|
64
|
+
const abstractNums = /* @__PURE__ */ new Map();
|
|
65
|
+
for (const abstractNum of childrenWithTag(root, "w:abstractNum")) {
|
|
66
|
+
const abstractNumId = attr(abstractNum, "w:abstractNumId");
|
|
67
|
+
if (abstractNumId === void 0) continue;
|
|
68
|
+
abstractNums.set(abstractNumId, readAbstractNumLevels(abstractNum));
|
|
69
|
+
}
|
|
70
|
+
const definitions = {};
|
|
71
|
+
for (const num of childrenWithTag(root, "w:num")) {
|
|
72
|
+
const numId = attr(num, "w:numId");
|
|
73
|
+
const abstractNumIdEl = childrenWithTag(num, "w:abstractNumId")[0];
|
|
74
|
+
const abstractNumId = abstractNumIdEl === void 0 ? void 0 : attr(abstractNumIdEl, "w:val");
|
|
75
|
+
if (numId === void 0 || abstractNumId === void 0) continue;
|
|
76
|
+
const baseLevels = abstractNums.get(abstractNumId);
|
|
77
|
+
if (baseLevels === void 0) continue;
|
|
78
|
+
definitions[numId] = { levels: applyLevelOverrides(baseLevels, num) };
|
|
79
|
+
}
|
|
80
|
+
return definitions;
|
|
81
|
+
}
|
|
82
|
+
//#endregion
|
|
83
|
+
export { NumberingDefinitionSchema, NumberingLevelSchema, readNumberingDefinitions };
|
package/dist/typed/docx/read.cjs
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_util_base64 = require("../../util/base64.cjs");
|
|
2
3
|
const require_typed_util = require("../util.cjs");
|
|
3
4
|
const require_typed_shared_metadata = require("../shared/metadata.cjs");
|
|
5
|
+
const require_image_sniff = require("../../image/sniff.cjs");
|
|
4
6
|
const require_typed_shared_units = require("../shared/units.cjs");
|
|
5
7
|
const require_typed_shared_drawingml = require("../shared/drawingml.cjs");
|
|
6
8
|
const require_typed_shared_source_path = require("../shared/source-path.cjs");
|
|
7
9
|
const require_typed_docx_styles = require("./styles.cjs");
|
|
10
|
+
const require_typed_docx_numbering = require("./numbering.cjs");
|
|
8
11
|
let zod = require("zod");
|
|
9
12
|
let document_schema_js = require("document-schema.js");
|
|
10
13
|
//#region src/typed/docx/read.ts
|
|
@@ -22,7 +25,8 @@ const DocxDocumentSchema = zod.z.object({
|
|
|
22
25
|
comments: zod.z.array(CommentSchema),
|
|
23
26
|
footnotes: zod.z.array(FootnoteSchema),
|
|
24
27
|
headers: zod.z.array(zod.z.string()),
|
|
25
|
-
footers: zod.z.array(zod.z.string())
|
|
28
|
+
footers: zod.z.array(zod.z.string()),
|
|
29
|
+
numbering: zod.z.record(zod.z.string(), require_typed_docx_numbering.NumberingDefinitionSchema)
|
|
26
30
|
});
|
|
27
31
|
const DOCUMENT_PART_PATH = "word/document.xml";
|
|
28
32
|
const STYLES_PART_PATH = "word/styles.xml";
|
|
@@ -89,6 +93,53 @@ function readRunText(run) {
|
|
|
89
93
|
}
|
|
90
94
|
return text;
|
|
91
95
|
}
|
|
96
|
+
function readDrawingImage(drawing, rels, pkg) {
|
|
97
|
+
const container = require_typed_util.childrenWithTag(drawing, "wp:inline")[0] ?? require_typed_util.childrenWithTag(drawing, "wp:anchor")[0];
|
|
98
|
+
if (container === void 0) return;
|
|
99
|
+
const extent = require_typed_util.childrenWithTag(container, "wp:extent")[0];
|
|
100
|
+
const cx = extent === void 0 ? void 0 : require_typed_util.attr(extent, "cx");
|
|
101
|
+
const cy = extent === void 0 ? void 0 : require_typed_util.attr(extent, "cy");
|
|
102
|
+
if (cx === void 0 || cy === void 0) return;
|
|
103
|
+
const docPr = require_typed_util.childrenWithTag(container, "wp:docPr")[0];
|
|
104
|
+
const altText = docPr === void 0 ? void 0 : require_typed_util.attr(docPr, "descr") ?? require_typed_util.attr(docPr, "title");
|
|
105
|
+
const blip = require_typed_util.elementsWithTag(container.children, "a:blip")[0];
|
|
106
|
+
const rId = blip === void 0 ? void 0 : require_typed_util.attr(blip, "r:embed");
|
|
107
|
+
const rel = rId === void 0 ? void 0 : rels.get(rId);
|
|
108
|
+
const mediaPart = rel === void 0 ? void 0 : pkg.parts[rel.target];
|
|
109
|
+
if (mediaPart?.kind !== "binary") return;
|
|
110
|
+
const format = require_image_sniff.sniffImageFormat(require_util_base64.base64ToBytes(mediaPart.base64));
|
|
111
|
+
if (format === void 0) return;
|
|
112
|
+
const image = {
|
|
113
|
+
kind: "image",
|
|
114
|
+
format,
|
|
115
|
+
base64: mediaPart.base64,
|
|
116
|
+
widthPt: require_typed_shared_units.emuToPt(Number(cx)),
|
|
117
|
+
heightPt: require_typed_shared_units.emuToPt(Number(cy))
|
|
118
|
+
};
|
|
119
|
+
if (altText !== void 0) image.altText = altText;
|
|
120
|
+
return image;
|
|
121
|
+
}
|
|
122
|
+
function collectDrawings(nodes, out) {
|
|
123
|
+
for (const node of nodes) {
|
|
124
|
+
if (node.type !== "element") continue;
|
|
125
|
+
if (node.tag === "w:del") continue;
|
|
126
|
+
if (node.tag === "w:drawing") {
|
|
127
|
+
out.push(node);
|
|
128
|
+
continue;
|
|
129
|
+
}
|
|
130
|
+
collectDrawings(node.children, out);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
function readParagraphImages(paragraph, rels, pkg) {
|
|
134
|
+
const drawings = [];
|
|
135
|
+
collectDrawings(paragraph.children, drawings);
|
|
136
|
+
const images = [];
|
|
137
|
+
for (const drawing of drawings) {
|
|
138
|
+
const image = readDrawingImage(drawing, rels, pkg);
|
|
139
|
+
if (image !== void 0) images.push(image);
|
|
140
|
+
}
|
|
141
|
+
return images;
|
|
142
|
+
}
|
|
92
143
|
function readRun(run, paragraph, context) {
|
|
93
144
|
const props = require_typed_docx_styles.resolveRunProperties(run, paragraph, context);
|
|
94
145
|
return {
|
|
@@ -156,7 +207,51 @@ function readCellShading(tcPr) {
|
|
|
156
207
|
const fill = shd === void 0 ? void 0 : require_typed_util.attr(shd, "w:fill");
|
|
157
208
|
return fill === void 0 || fill === "auto" || fill === "none" ? void 0 : (0, document_schema_js.rgbHexToColor)(fill);
|
|
158
209
|
}
|
|
159
|
-
|
|
210
|
+
const BORDER_STYLE_MAP = /* @__PURE__ */ new Map([
|
|
211
|
+
["single", "solid"],
|
|
212
|
+
["thick", "solid"],
|
|
213
|
+
["triple", "solid"],
|
|
214
|
+
["outset", "solid"],
|
|
215
|
+
["inset", "solid"],
|
|
216
|
+
["threeDEmboss", "solid"],
|
|
217
|
+
["threeDEngrave", "solid"],
|
|
218
|
+
["dashed", "dashed"],
|
|
219
|
+
["dashSmallGap", "dashed"],
|
|
220
|
+
["dashDotStroked", "dashed"],
|
|
221
|
+
["dotDash", "dashed"],
|
|
222
|
+
["dotted", "dotted"],
|
|
223
|
+
["dotDotDash", "dotted"],
|
|
224
|
+
["double", "double"],
|
|
225
|
+
["doubleWave", "double"]
|
|
226
|
+
]);
|
|
227
|
+
const DEFAULT_BORDER_WIDTH_EIGHTH_POINTS = 4;
|
|
228
|
+
function readCellBorderEdge(tcBorders, tag) {
|
|
229
|
+
const edge = tcBorders === void 0 ? void 0 : require_typed_util.childrenWithTag(tcBorders, tag)[0];
|
|
230
|
+
const val = edge === void 0 ? void 0 : require_typed_util.attr(edge, "w:val");
|
|
231
|
+
if (edge === void 0 || val === void 0 || val === "nil" || val === "none") return;
|
|
232
|
+
const sz = require_typed_util.attr(edge, "w:sz");
|
|
233
|
+
const colorVal = require_typed_util.attr(edge, "w:color");
|
|
234
|
+
return {
|
|
235
|
+
color: colorVal === void 0 || colorVal === "auto" ? document_schema_js.COLOR_BLACK : (0, document_schema_js.rgbHexToColor)(colorVal),
|
|
236
|
+
widthPt: require_typed_shared_units.eighthPointsToPt(sz === void 0 ? DEFAULT_BORDER_WIDTH_EIGHTH_POINTS : Number(sz)),
|
|
237
|
+
style: BORDER_STYLE_MAP.get(val) ?? "solid"
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
function readCellBorders(tcPr) {
|
|
241
|
+
const tcBorders = tcPr === void 0 ? void 0 : require_typed_util.childrenWithTag(tcPr, "w:tcBorders")[0];
|
|
242
|
+
if (tcBorders === void 0) return;
|
|
243
|
+
const borders = {};
|
|
244
|
+
const left = readCellBorderEdge(tcBorders, "w:left") ?? readCellBorderEdge(tcBorders, "w:start");
|
|
245
|
+
const right = readCellBorderEdge(tcBorders, "w:right") ?? readCellBorderEdge(tcBorders, "w:end");
|
|
246
|
+
const top = readCellBorderEdge(tcBorders, "w:top");
|
|
247
|
+
const bottom = readCellBorderEdge(tcBorders, "w:bottom");
|
|
248
|
+
if (left !== void 0) borders.left = left;
|
|
249
|
+
if (right !== void 0) borders.right = right;
|
|
250
|
+
if (top !== void 0) borders.top = top;
|
|
251
|
+
if (bottom !== void 0) borders.bottom = bottom;
|
|
252
|
+
return Object.keys(borders).length === 0 ? void 0 : borders;
|
|
253
|
+
}
|
|
254
|
+
function readRawCell(tc, context, rels, pkg) {
|
|
160
255
|
const tcPr = require_typed_util.childrenWithTag(tc, "w:tcPr")[0];
|
|
161
256
|
const gridSpanEl = tcPr === void 0 ? void 0 : require_typed_util.childrenWithTag(tcPr, "w:gridSpan")[0];
|
|
162
257
|
const gridSpanVal = gridSpanEl === void 0 ? void 0 : require_typed_util.attr(gridSpanEl, "w:val");
|
|
@@ -166,13 +261,14 @@ function readRawCell(tc, context, rels) {
|
|
|
166
261
|
gridSpan: gridSpanVal === void 0 ? 1 : Number(gridSpanVal),
|
|
167
262
|
isVMergeContinuation: vMergeVal === "continue",
|
|
168
263
|
background: readCellShading(tcPr),
|
|
169
|
-
|
|
264
|
+
borders: readCellBorders(tcPr),
|
|
265
|
+
blocks: readBodyBlocks(tc.children, context, rels, pkg)
|
|
170
266
|
};
|
|
171
267
|
}
|
|
172
|
-
function readTable(tbl, context, rels) {
|
|
268
|
+
function readTable(tbl, context, rels, pkg) {
|
|
173
269
|
const tblGrid = require_typed_util.childrenWithTag(tbl, "w:tblGrid")[0];
|
|
174
270
|
const columnWidthsPt = tblGrid === void 0 ? [] : require_typed_util.childrenWithTag(tblGrid, "w:gridCol").map((col) => require_typed_shared_units.twipsToPt(Number(require_typed_util.attr(col, "w:w") ?? "0")));
|
|
175
|
-
const rawRows = require_typed_util.childrenWithTag(tbl, "w:tr").map((tr) => require_typed_util.childrenWithTag(tr, "w:tc").map((tc) => readRawCell(tc, context, rels)));
|
|
271
|
+
const rawRows = require_typed_util.childrenWithTag(tbl, "w:tr").map((tr) => require_typed_util.childrenWithTag(tr, "w:tc").map((tc) => readRawCell(tc, context, rels, pkg)));
|
|
176
272
|
const rowColumnIndices = rawRows.map((row) => {
|
|
177
273
|
const indices = [];
|
|
178
274
|
let col = 0;
|
|
@@ -198,31 +294,33 @@ function readTable(tbl, context, rels) {
|
|
|
198
294
|
blocks: cell.blocks,
|
|
199
295
|
colSpan: cell.gridSpan > 1 ? cell.gridSpan : void 0,
|
|
200
296
|
rowSpan: rowSpan > 1 ? rowSpan : void 0,
|
|
201
|
-
background: cell.background
|
|
297
|
+
background: cell.background,
|
|
298
|
+
borders: cell.borders
|
|
202
299
|
};
|
|
203
300
|
}) }))
|
|
204
301
|
};
|
|
205
302
|
}
|
|
206
|
-
function readBodyBlocks(nodes, context, rels) {
|
|
303
|
+
function readBodyBlocks(nodes, context, rels, pkg) {
|
|
207
304
|
const blocks = [];
|
|
208
305
|
for (const node of nodes) {
|
|
209
306
|
if (node.type !== "element") continue;
|
|
210
307
|
if (node.tag === "w:p") {
|
|
211
308
|
if (hasPageBreakBefore(node)) blocks.push({ kind: "pageBreak" });
|
|
212
309
|
blocks.push(readParagraph(node, context, rels));
|
|
213
|
-
|
|
310
|
+
blocks.push(...readParagraphImages(node, rels, pkg));
|
|
311
|
+
} else if (node.tag === "w:tbl") blocks.push(readTable(node, context, rels, pkg));
|
|
214
312
|
else if (node.tag === "w:sdt") {
|
|
215
313
|
const sdtContent = require_typed_util.childrenWithTag(node, "w:sdtContent")[0];
|
|
216
|
-
if (sdtContent !== void 0) blocks.push(...readBodyBlocks(sdtContent.children, context, rels));
|
|
217
|
-
} else if (node.tag === "w:ins") blocks.push(...readBodyBlocks(node.children, context, rels));
|
|
314
|
+
if (sdtContent !== void 0) blocks.push(...readBodyBlocks(sdtContent.children, context, rels, pkg));
|
|
315
|
+
} else if (node.tag === "w:ins") blocks.push(...readBodyBlocks(node.children, context, rels, pkg));
|
|
218
316
|
else if (node.tag === "mc:AlternateContent") {
|
|
219
317
|
const target = require_typed_util.childrenWithTag(node, "mc:Fallback")[0] ?? require_typed_util.childrenWithTag(node, "mc:Choice")[0];
|
|
220
|
-
if (target !== void 0) blocks.push(...readBodyBlocks(target.children, context, rels));
|
|
318
|
+
if (target !== void 0) blocks.push(...readBodyBlocks(target.children, context, rels, pkg));
|
|
221
319
|
}
|
|
222
320
|
}
|
|
223
321
|
return blocks;
|
|
224
322
|
}
|
|
225
|
-
function readSections(body, context, rels) {
|
|
323
|
+
function readSections(body, context, rels, pkg) {
|
|
226
324
|
const sections = [];
|
|
227
325
|
let currentBlocks = [];
|
|
228
326
|
for (const node of body.children) {
|
|
@@ -241,6 +339,7 @@ function readSections(body, context, rels) {
|
|
|
241
339
|
const sectPr = pPr === void 0 ? void 0 : require_typed_util.childrenWithTag(pPr, "w:sectPr")[0];
|
|
242
340
|
if (hasPageBreakBefore(node)) currentBlocks.push({ kind: "pageBreak" });
|
|
243
341
|
currentBlocks.push(readParagraph(node, context, rels));
|
|
342
|
+
currentBlocks.push(...readParagraphImages(node, rels, pkg));
|
|
244
343
|
if (sectPr !== void 0) {
|
|
245
344
|
sections.push({
|
|
246
345
|
pageSize: readPageSize(sectPr),
|
|
@@ -251,7 +350,7 @@ function readSections(body, context, rels) {
|
|
|
251
350
|
}
|
|
252
351
|
continue;
|
|
253
352
|
}
|
|
254
|
-
currentBlocks.push(...readBodyBlocks([node], context, rels));
|
|
353
|
+
currentBlocks.push(...readBodyBlocks([node], context, rels, pkg));
|
|
255
354
|
}
|
|
256
355
|
if (currentBlocks.length > 0 || sections.length === 0) sections.push({
|
|
257
356
|
pageSize: document_schema_js.PAGE_SIZE_LETTER,
|
|
@@ -318,11 +417,12 @@ function readDocx(pkg) {
|
|
|
318
417
|
};
|
|
319
418
|
return {
|
|
320
419
|
metadata: require_typed_shared_metadata.readCoreProperties(pkg),
|
|
321
|
-
sections: readSections(body, context, docRels),
|
|
420
|
+
sections: readSections(body, context, docRels, pkg),
|
|
322
421
|
comments: readComments(pkg),
|
|
323
422
|
footnotes: readFootnotes(pkg),
|
|
324
423
|
headers: readHeaderFooterText(pkg, "word/header"),
|
|
325
|
-
footers: readHeaderFooterText(pkg, "word/footer")
|
|
424
|
+
footers: readHeaderFooterText(pkg, "word/footer"),
|
|
425
|
+
numbering: require_typed_docx_numbering.readNumberingDefinitions(pkg)
|
|
326
426
|
};
|
|
327
427
|
}
|
|
328
428
|
//#endregion
|
|
@@ -45,6 +45,14 @@ declare const DocxDocumentSchema: z.ZodObject<{
|
|
|
45
45
|
}, z.core.$strip>>;
|
|
46
46
|
headers: z.ZodArray<z.ZodString>;
|
|
47
47
|
footers: z.ZodArray<z.ZodString>;
|
|
48
|
+
numbering: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
49
|
+
levels: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
50
|
+
format: z.ZodString;
|
|
51
|
+
text: z.ZodString;
|
|
52
|
+
startAt: z.ZodNumber;
|
|
53
|
+
restart: z.ZodOptional<z.ZodNumber>;
|
|
54
|
+
}, z.core.$strip>>;
|
|
55
|
+
}, z.core.$strip>>;
|
|
48
56
|
}, z.core.$strip>;
|
|
49
57
|
type DocxDocument = z.infer<typeof DocxDocumentSchema>;
|
|
50
58
|
declare function readDocx(pkg: Package): DocxDocument;
|
|
@@ -45,6 +45,14 @@ declare const DocxDocumentSchema: z.ZodObject<{
|
|
|
45
45
|
}, z.core.$strip>>;
|
|
46
46
|
headers: z.ZodArray<z.ZodString>;
|
|
47
47
|
footers: z.ZodArray<z.ZodString>;
|
|
48
|
+
numbering: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
49
|
+
levels: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
50
|
+
format: z.ZodString;
|
|
51
|
+
text: z.ZodString;
|
|
52
|
+
startAt: z.ZodNumber;
|
|
53
|
+
restart: z.ZodOptional<z.ZodNumber>;
|
|
54
|
+
}, z.core.$strip>>;
|
|
55
|
+
}, z.core.$strip>>;
|
|
48
56
|
}, z.core.$strip>;
|
|
49
57
|
type DocxDocument = z.infer<typeof DocxDocumentSchema>;
|
|
50
58
|
declare function readDocx(pkg: Package): DocxDocument;
|