ooxml.js 4.1.1 → 4.2.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 +4 -2
- package/dist/{codec-DxnbKt4O.d.ts → codec-BrTMlL0a.d.ts} +2 -2
- package/dist/{codec-DO0MNF45.d.cts → codec-DNjHjEDm.d.cts} +2 -2
- package/dist/codec.d.cts +1 -1
- package/dist/codec.d.ts +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +2 -2
- package/dist/{read-DY3Sm5T3.d.cts → read-BoV9SZy4.d.cts} +34 -0
- package/dist/{read-DPAy4uu8.cjs → read-C3AaxcT9.cjs} +11 -2
- package/dist/{read-ClIHv1ef.d.cts → read-CDX1WbiF.d.cts} +17 -0
- package/dist/{read-gB0H2bff.d.ts → read-CxMli3Om.d.ts} +17 -0
- package/dist/{read-DcJZITV9.d.ts → read-ZWJPDvG-.d.ts} +34 -0
- package/dist/{read-Legu2Pt-.js → read-fuJpC4BH.js} +12 -3
- package/dist/typed/document-package.cjs +2 -2
- package/dist/typed/document-package.js +2 -2
- package/dist/typed/docx/constructs.cjs +27 -5
- package/dist/typed/docx/constructs.js +27 -5
- package/dist/typed/docx/read.cjs +1 -1
- package/dist/typed/docx/read.d.cts +1 -1
- package/dist/typed/docx/read.d.ts +1 -1
- package/dist/typed/docx/read.js +1 -1
- package/dist/typed/docx/write.cjs +99 -5
- package/dist/typed/docx/write.js +99 -5
- package/dist/typed/embedded.cjs +1 -1
- package/dist/typed/embedded.js +1 -1
- package/dist/typed/pptx/read.cjs +1 -1
- package/dist/typed/pptx/read.d.cts +1 -1
- package/dist/typed/pptx/read.d.ts +1 -1
- package/dist/typed/pptx/read.js +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -146,6 +146,8 @@ Both docx readers read the block-scoped fidelity constructs — structured docum
|
|
|
146
146
|
|
|
147
147
|
A construct whose extent is a sub-sequence of one paragraph's runs — a field inside a sentence, a bookmark over three words, a few inserted words in an otherwise untouched paragraph — has no marker encoding: the marker pair brackets whole blocks, so those occurrences keep their existing treatment (the text still comes through; the construct itself does not). See the gotchas below.
|
|
148
148
|
|
|
149
|
+
A construct with format-specific specifics the harmonised vocabulary does not name carries them in the descriptor's quarantined `source` residue (`document-schema.js`'s residue channel): an SDT whose `w:docPartObj` gallery is not the Table of Contents degrades to a `richText` control with the whole `w:docPartObj` element carried verbatim, and the docx writer re-emits that element from the residue in place of the default `w:richText` type element — the restorable tier in action, the gallery name no longer lost to the round trip.
|
|
150
|
+
|
|
149
151
|
### Migrating from 3.x
|
|
150
152
|
|
|
151
153
|
The `DocumentPackage` readers and writers took the primary names, and the functions that held them were renamed rather than removed. Every one of them still behaves exactly as it did:
|
|
@@ -295,8 +297,8 @@ The package layers a lossless core outward to lossy convenience views:
|
|
|
295
297
|
|
|
296
298
|
- **A `Content` suffix means the flat form, not a lesser one.** `readDocx` and `readDocxContent` are the same read; the suffix says which shape comes back (`DocumentPackage` versus the flat `DocxDocument`/`ContentDocument`), never which is more faithful. The pair that genuinely differs in what it reads is `readXlsxWorkbook`, whose name says so by naming its own return type rather than taking a suffix.
|
|
297
299
|
- **A construct marker brackets whole blocks, never a sub-sequence of runs.** `document-schema.js`'s flat form has no run-level extent, so an inline field, a mid-paragraph bookmark, a run-level content control, or a few inserted words inside an otherwise untouched paragraph are read exactly as before — the text survives, the construct does not. So does an extent that crosses another, or that straddles a section break: neither is expressible as balanced brackets, and both are dropped rather than emitted at a position that would decode to a different nesting.
|
|
298
|
-
- **The docx pair round-trips `sections`, not a whole `DocxDocument`.** Numbering definitions, cell border styling/shading, and `w:themeColor` (without `themeShade`/`themeTint`) are read; images read into `ContentImageBlock` (floating `wp:anchor` position not recorded); `PAGE`/`NUMPAGES` fields resolve to Word's cached text. An inline `w:object`/`o:OLEObject` whose payload part is itself a ZIP archive — a modern producer's embedded xlsx/docx/pptx, detected by magic bytes through `archive-codec` — is decoded into a nested content document and emitted as a `ContentEmbeddedObjectBlock` beside its containing paragraph's own block, sized from `w:dxaOrig`/`w:dyaOrig`; the object's VML preview picture (`v:imagedata`)
|
|
299
|
-
- **pptx is read-only.** Connector shapes (`p:cxnSp`) are skipped; shape rotation composes through groups; a chart graphic frame reads its chart part's cached series/category model into a table block (header row = series names, one row per category index); a SmartArt graphic frame reads its diagram data model's node text as paragraphs in diagram order (depth-first over `parOf` connections, siblings by `srcOrd`); an OLE graphic frame reads the fallback picture its `mc:Fallback` carries (or, with none reachable, a paragraph naming the `p:oleObj`'s `progId`), and when the payload part is itself a ZIP archive — a modern producer's embedded xlsx/docx/pptx, detected by magic bytes through `archive-codec` — also decodes it into a nested content document and emits it as an `embeddedObject` block beside the picture, sized to the frame's own geometry;
|
|
300
|
+
- **The docx pair round-trips `sections`, not a whole `DocxDocument`.** Numbering definitions, cell border styling/shading, and `w:themeColor` (without `themeShade`/`themeTint`) are read; images read into `ContentImageBlock` (floating `wp:anchor` position not recorded); `PAGE`/`NUMPAGES` fields resolve to Word's cached text. An inline `w:object`/`o:OLEObject` whose payload part is itself a ZIP archive — a modern producer's embedded xlsx/docx/pptx, detected by magic bytes through `archive-codec` — or a classic OLE compound-file `.bin` whose root storage carries the embedded file as an OLE-packaged `Package` stream, read through `archive-codec`'s bounded CFB reader, is decoded into a nested content document and emitted as a `ContentEmbeddedObjectBlock` beside its containing paragraph's own block, sized from `w:dxaOrig`/`w:dyaOrig`; the object's VML preview picture (`v:imagedata`) and a `w:object` inside a header/footer/footnote (recovery walks the document body's block flow only) are not read, a compound file holding native legacy streams (BIFF and friends — no `Package` stream, or a packaged file that is not a ZIP) stays opaque, and a payload that does not decode as one of the three OOXML flavours (a plain archive, corrupt zip or compound-file data, a bodyless docx) degrades to no embedded block rather than failing the host read. The writer emits such a block back out as the inverse `w:object`/`o:OLEObject`: the nested document is re-serialised through its own format's builder into a fresh `word/embeddings/oleObject<N>.<docx|xlsx>` ZIP part carrying its relationship and content-type override, and `w:dxaOrig`/`w:dyaOrig` are derived from the block's frame (twips). An embedded presentation document has no serialiser here — pptx is read-only in this package — so a `ContentDocument` carrying one is refused with a thrown error rather than a silent drop, and no VML preview picture is regenerated (the reader never read one into the model, and real previews are WMF/EMF this ecosystem has no writer for; Word shows a blank until activated). The writer emits no `styles.xml`, `numbering.xml`, comments, footnotes, or headers/footers, so the `DocxDocument` fields outside `sections` do not come back — a paragraph's `styleId` is still written as a `w:pStyle` reference, resolving to nothing, since every property the style would have contributed is already spelled as direct formatting by then.
|
|
301
|
+
- **pptx is read-only.** Connector shapes (`p:cxnSp`) are skipped; shape rotation composes through groups; a chart graphic frame reads its chart part's cached series/category model into a table block (header row = series names, one row per category index); a SmartArt graphic frame reads its diagram data model's node text as paragraphs in diagram order (depth-first over `parOf` connections, siblings by `srcOrd`); an OLE graphic frame reads the fallback picture its `mc:Fallback` carries (or, with none reachable, a paragraph naming the `p:oleObj`'s `progId`), and when the payload part is itself a ZIP archive — a modern producer's embedded xlsx/docx/pptx, detected by magic bytes through `archive-codec` — or a classic OLE compound-file `.bin` whose root storage carries the embedded file as an OLE-packaged `Package` stream, read through `archive-codec`'s bounded CFB reader, also decodes it into a nested content document and emits it as an `embeddedObject` block beside the picture, sized to the frame's own geometry; a compound file holding native legacy streams (no `Package` stream, or a packaged file that is not a ZIP) stays opaque external-application data, and a payload that does not decode as one of the three OOXML flavours degrades to no embedded block rather than failing the slide read.
|
|
300
302
|
- **xlsx has no native percentage/currency/date/time cell type.** Both directions are closed via the number-format engine: reading classifies style → format code → kind; writing emits interned `numFmt` codes, fed back through the classifier in tests. `displayText` is the typed-value spelling, not the producer's rendered string.
|
|
301
303
|
- **`test:smoke` depends on a fresh build.** It runs `tsdown && vitest run --project smoke`, always rebuilding `dist/` first. A bare `vitest` runs both projects; `smoke` fails loudly (`Cannot find module '../dist/index.js'`) if `dist/` is unbuilt.
|
|
302
304
|
- **Binary-vs-XML part classification is a byte sniff, not an extension check.** `looksLikeXml` looks for a leading `<` after skipping a UTF-8 BOM and whitespace; any future binary format starting with `<` would misclassify.
|
|
@@ -10,10 +10,10 @@ import "./compact-f0TfhicN.js";
|
|
|
10
10
|
import "./color-fFIKAs-Y.js";
|
|
11
11
|
import "./metadata-o_WH9V_I.js";
|
|
12
12
|
import "./document-package-kartHoyl.js";
|
|
13
|
-
import "./read-
|
|
13
|
+
import "./read-CxMli3Om.js";
|
|
14
14
|
import "./write-97yEqc6w.js";
|
|
15
15
|
import "./numbering-D0YfuiOO.js";
|
|
16
|
-
import "./read-
|
|
16
|
+
import "./read-ZWJPDvG-.js";
|
|
17
17
|
import "./xlsx-DacFqZeF.js";
|
|
18
18
|
import "./content-t6ZfmfQM.js";
|
|
19
19
|
import "./build-q0qMH_ML.js";
|
|
@@ -10,10 +10,10 @@ import "./compact-B1qg9oex.cjs";
|
|
|
10
10
|
import "./color-fFIKAs-Y.cjs";
|
|
11
11
|
import "./metadata-D6o-kLpg.cjs";
|
|
12
12
|
import "./document-package-BDr3nkqJ.cjs";
|
|
13
|
-
import "./read-
|
|
13
|
+
import "./read-CDX1WbiF.cjs";
|
|
14
14
|
import "./write-BFEF46Ir.cjs";
|
|
15
15
|
import "./numbering-C53LT-Jx.cjs";
|
|
16
|
-
import "./read-
|
|
16
|
+
import "./read-BoV9SZy4.cjs";
|
|
17
17
|
import "./xlsx-CpX5nzGV.cjs";
|
|
18
18
|
import "./content-UlQ-Nhgi.cjs";
|
|
19
19
|
import "./build-D-ldsmtA.cjs";
|
package/dist/codec.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { i as xmlCodec, n as encodePackage, r as packageCodec, t as decodePackage } from "./codec-
|
|
1
|
+
import { i as xmlCodec, n as encodePackage, r as packageCodec, t as decodePackage } from "./codec-DNjHjEDm.cjs";
|
|
2
2
|
export { decodePackage, encodePackage, packageCodec, xmlCodec };
|
package/dist/codec.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { i as xmlCodec, n as encodePackage, r as packageCodec, t as decodePackage } from "./codec-
|
|
1
|
+
import { i as xmlCodec, n as encodePackage, r as packageCodec, t as decodePackage } from "./codec-BrTMlL0a.js";
|
|
2
2
|
export { decodePackage, encodePackage, packageCodec, xmlCodec };
|
package/dist/index.cjs
CHANGED
|
@@ -15,11 +15,11 @@ 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_read = require("./read-
|
|
18
|
+
const require_read = require("./read-C3AaxcT9.cjs");
|
|
19
19
|
const require_typed_xlsx_content = require("./typed/xlsx/content.cjs");
|
|
20
20
|
const require_typed_docx_numbering = require("./typed/docx/numbering.cjs");
|
|
21
|
-
const require_typed_docx_write = require("./typed/docx/write.cjs");
|
|
22
21
|
const require_typed_xlsx_build = require("./typed/xlsx/build.cjs");
|
|
22
|
+
const require_typed_docx_write = require("./typed/docx/write.cjs");
|
|
23
23
|
const require_typed_document_package = require("./typed/document-package.cjs");
|
|
24
24
|
const require_typed_xlsx = require("./typed/xlsx.cjs");
|
|
25
25
|
let document_schema_js = require("document-schema.js");
|
package/dist/index.d.cts
CHANGED
|
@@ -14,12 +14,12 @@ import { n as applyColorTransforms, t as ColorTransform } from "./color-fFIKAs-Y
|
|
|
14
14
|
import { n as DocumentMetadataSchema, t as DocumentMetadata } from "./metadata-D6o-kLpg.cjs";
|
|
15
15
|
import { n as sniffImageFormat, t as ImageFormat } from "./sniff-DjpnUZRp.cjs";
|
|
16
16
|
import { a as readXlsx, i as readPptx, n as buildXlsxPackage, r as readDocx, t as buildDocxPackage } from "./document-package-BDr3nkqJ.cjs";
|
|
17
|
-
import { a as Footnote, i as DocxDocumentSchema, n as CommentSchema, o as FootnoteSchema, r as DocxDocument, s as readDocxContent, t as Comment } from "./read-
|
|
17
|
+
import { a as Footnote, i as DocxDocumentSchema, n as CommentSchema, o as FootnoteSchema, r as DocxDocument, s as readDocxContent, t as Comment } from "./read-CDX1WbiF.cjs";
|
|
18
18
|
import { n as buildDocxPackageFromContent, t as DocxContent } from "./write-BFEF46Ir.cjs";
|
|
19
19
|
import { a as NumberingLevelSchema, i as NumberingLevel, n as NumberingDefinitionSchema, o as readNumberingDefinitions, r as NumberingDefinitions, t as NumberingDefinition } from "./numbering-C53LT-Jx.cjs";
|
|
20
|
-
import { n as PptxDocumentSchema, r as readPptxContent, t as PptxDocument } from "./read-
|
|
20
|
+
import { n as PptxDocumentSchema, r as readPptxContent, t as PptxDocument } from "./read-BoV9SZy4.cjs";
|
|
21
21
|
import { a as XlsxSheet, c as XlsxWorkbookSchema, i as XlsxCellSchema, l as readXlsxWorkbook, n as DefinedNameSchema, o as XlsxSheetSchema, r as XlsxCell, s as XlsxWorkbook, t as DefinedName } from "./xlsx-CpX5nzGV.cjs";
|
|
22
22
|
import { t as readXlsxContent } from "./content-UlQ-Nhgi.cjs";
|
|
23
23
|
import { t as buildXlsxPackageFromContent } from "./build-D-ldsmtA.cjs";
|
|
24
|
-
import { $ as ContentShapeSchema, $n as isHeadingGroupNode, $t as PackageChildren, A as ContentConstructStart, An as SlideDescriptor, At as DrawPageChild, B as ContentImageBlock, Bn as StylesTableSchema, Bt as LinkDescriptorSchema, C as ContentBorderSchema, Cn as ShapeDescriptor, Ct as ContentTableRow, D as ContentCellValueSchema, Dn as SheetDescriptor, Dt as DivisionDescriptorSchema, E as ContentCellValue, En as SheetChild, Et as DivisionDescriptor, F as ContentControlLockSchema, Fn as StyleParagraphProperties, Ft as FieldDescriptorSchema, G as ContentPageBreakSchema, Gn as decompose, Gt as ListGroupSchema, H as ContentListMembership, Hn as applyRunStyleProperties, Ht as LinkTargetSchema, I as ContentControlType, In as StyleParagraphPropertiesSchema, It as HeadingGroupNode, J as ContentRun, Jn as flattenPackage, Jt as MarginsSchema, K as ContentParagraph, Kn as factorStyles, Kt as ListParagraph, L as ContentControlTypeSchema, Ln as StyleRunProperties, Lt as HeadingGroupSchema, M as ContentControlDescriptor, Mn as SlideGroupSchema, Mt as DrawPageGroupNode, N as ContentControlDescriptorSchema, Nn as StyleEntry, Nt as DrawPageGroupSchema, O as ContentConstructEnd, On as SheetGroupNode, Ot as DocumentPackage, P as ContentControlLock, Pn as StyleEntrySchema, Pt as FieldDescriptor, Q as ContentShape, Qn as isDrawPageGroupNode, Qt as PackageBlockLeafSchema, R as ContentDocument, Rn as StyleRunPropertiesSchema, Rt as HeadingParagraph, S as ContentBorder, Sn as ShapeConstructGroupSchema, St as ContentTableCellSchema, T as ContentCellBordersSchema, Tn as ShapeGroupSchema, Tt as ContentTableSchema, U as ContentListMembershipSchema, Un as assemblePackage, Ut as ListChild, V as ContentImageBlockSchema, Vn as applyParagraphStyleProperties, Vt as LinkTarget, W as ContentPageBreak, Wn as colorToRgbHex, Wt as ListGroupNode, X as ContentSection, Xn as isContentConstructEnd, Xt as PAGE_SIZE_LETTER, Y as ContentRunSchema, Yn as isContentBlock, Yt as PAGE_SIZE_A4, Z as ContentSectionSchema, Zn as isContentConstructStart, Zt as PackageBlockLeaf, _ as ConstructDescriptorSchema, _n as SectionDescriptor, _t as ContentSlideSchema, a as Alignment, an as PackageNodeSchema, ar as isSectionConstructGroupNode, at as ContentSheetImage, b as ContentBlock, bn as ShapeChild, bt as ContentTable, c as AnchorDescriptorSchema, cn as ProvenanceChange, cr as isShapeGroupNode, ct as ContentSheetPrintRangeSchema, d as Box, dn as ProvenanceDescriptorSchema, dr as overlayStyleEntries, dt as ContentSheetRepeatRange, en as PackageGroup, er as isListGroupNode, et as ContentSheet, f as BoxSchema, fn as SLIDE_SIZE_STANDARD, fr as resolveStyleChain, ft as ContentSheetRepeatRangeSchema, g as ConstructDescriptor, gn as SectionConstructGroupSchema, gt as ContentSlide, h as ColorSchema, hn as SectionConstructGroupNode, ht as ContentSheetSchema, i as xmlCodec, in as PackageNode, ir as isPackageNode, it as ContentSheetColumnSchema, j as ContentConstructStartSchema, jn as SlideGroupNode, jt as DrawPageDescriptor, k as ContentConstructEndSchema, kn as SheetGroupSchema, kt as DocumentPackageSchema, l as AnchorType, ln as ProvenanceChangeSchema, lr as isSheetGroupNode, lt as ContentSheetPrintSettings, m as Color, mn as SectionChild, mt as ContentSheetRowSchema, n as encodePackage, nn as PackageLeaf, nr as isPackageGroup, nt as ContentSheetCellSchema, o as AlignmentSchema, on as PageSize, or as isSectionGroupNode, ot as ContentSheetImageSchema, p as COLOR_BLACK, pn as SLIDE_SIZE_WIDESCREEN, pr as rgbHexToColor, pt as ContentSheetRow, q as ContentParagraphSchema, qn as findConstructMarkerImbalance, qt as Margins, r as packageCodec, rn as PackageLeafSchema, rr as isPackageLeaf, rt as ContentSheetColumn, s as AnchorDescriptor, sn as PageSizeSchema, sr as isShapeConstructGroupNode, st as ContentSheetPrintRange, t as decodePackage, tn as PackageGroupSchema, tr as isPackageBlockLeaf, tt as ContentSheetCell, u as AnchorTypeSchema, un as ProvenanceDescriptor, ur as isSlideGroupNode, ut as ContentSheetPrintSettingsSchema, v as ConstructMarkerImbalance, vn as SectionGroupNode, vt as ContentStrokeStyle, w as ContentCellBorders, wn as ShapeGroupNode, wt as ContentTableRowSchema, x as ContentBlockSchema, xn as ShapeConstructGroupNode, xt as ContentTableCell, y as ConstructMarkerImbalanceError, yn as SectionGroupSchema, yt as ContentStrokeStyleSchema, z as ContentDocumentSchema, zn as StylesTable, zt as LinkDescriptor } from "./codec-
|
|
24
|
+
import { $ as ContentShapeSchema, $n as isHeadingGroupNode, $t as PackageChildren, A as ContentConstructStart, An as SlideDescriptor, At as DrawPageChild, B as ContentImageBlock, Bn as StylesTableSchema, Bt as LinkDescriptorSchema, C as ContentBorderSchema, Cn as ShapeDescriptor, Ct as ContentTableRow, D as ContentCellValueSchema, Dn as SheetDescriptor, Dt as DivisionDescriptorSchema, E as ContentCellValue, En as SheetChild, Et as DivisionDescriptor, F as ContentControlLockSchema, Fn as StyleParagraphProperties, Ft as FieldDescriptorSchema, G as ContentPageBreakSchema, Gn as decompose, Gt as ListGroupSchema, H as ContentListMembership, Hn as applyRunStyleProperties, Ht as LinkTargetSchema, I as ContentControlType, In as StyleParagraphPropertiesSchema, It as HeadingGroupNode, J as ContentRun, Jn as flattenPackage, Jt as MarginsSchema, K as ContentParagraph, Kn as factorStyles, Kt as ListParagraph, L as ContentControlTypeSchema, Ln as StyleRunProperties, Lt as HeadingGroupSchema, M as ContentControlDescriptor, Mn as SlideGroupSchema, Mt as DrawPageGroupNode, N as ContentControlDescriptorSchema, Nn as StyleEntry, Nt as DrawPageGroupSchema, O as ContentConstructEnd, On as SheetGroupNode, Ot as DocumentPackage, P as ContentControlLock, Pn as StyleEntrySchema, Pt as FieldDescriptor, Q as ContentShape, Qn as isDrawPageGroupNode, Qt as PackageBlockLeafSchema, R as ContentDocument, Rn as StyleRunPropertiesSchema, Rt as HeadingParagraph, S as ContentBorder, Sn as ShapeConstructGroupSchema, St as ContentTableCellSchema, T as ContentCellBordersSchema, Tn as ShapeGroupSchema, Tt as ContentTableSchema, U as ContentListMembershipSchema, Un as assemblePackage, Ut as ListChild, V as ContentImageBlockSchema, Vn as applyParagraphStyleProperties, Vt as LinkTarget, W as ContentPageBreak, Wn as colorToRgbHex, Wt as ListGroupNode, X as ContentSection, Xn as isContentConstructEnd, Xt as PAGE_SIZE_LETTER, Y as ContentRunSchema, Yn as isContentBlock, Yt as PAGE_SIZE_A4, Z as ContentSectionSchema, Zn as isContentConstructStart, Zt as PackageBlockLeaf, _ as ConstructDescriptorSchema, _n as SectionDescriptor, _t as ContentSlideSchema, a as Alignment, an as PackageNodeSchema, ar as isSectionConstructGroupNode, at as ContentSheetImage, b as ContentBlock, bn as ShapeChild, bt as ContentTable, c as AnchorDescriptorSchema, cn as ProvenanceChange, cr as isShapeGroupNode, ct as ContentSheetPrintRangeSchema, d as Box, dn as ProvenanceDescriptorSchema, dr as overlayStyleEntries, dt as ContentSheetRepeatRange, en as PackageGroup, er as isListGroupNode, et as ContentSheet, f as BoxSchema, fn as SLIDE_SIZE_STANDARD, fr as resolveStyleChain, ft as ContentSheetRepeatRangeSchema, g as ConstructDescriptor, gn as SectionConstructGroupSchema, gt as ContentSlide, h as ColorSchema, hn as SectionConstructGroupNode, ht as ContentSheetSchema, i as xmlCodec, in as PackageNode, ir as isPackageNode, it as ContentSheetColumnSchema, j as ContentConstructStartSchema, jn as SlideGroupNode, jt as DrawPageDescriptor, k as ContentConstructEndSchema, kn as SheetGroupSchema, kt as DocumentPackageSchema, l as AnchorType, ln as ProvenanceChangeSchema, lr as isSheetGroupNode, lt as ContentSheetPrintSettings, m as Color, mn as SectionChild, mt as ContentSheetRowSchema, n as encodePackage, nn as PackageLeaf, nr as isPackageGroup, nt as ContentSheetCellSchema, o as AlignmentSchema, on as PageSize, or as isSectionGroupNode, ot as ContentSheetImageSchema, p as COLOR_BLACK, pn as SLIDE_SIZE_WIDESCREEN, pr as rgbHexToColor, pt as ContentSheetRow, q as ContentParagraphSchema, qn as findConstructMarkerImbalance, qt as Margins, r as packageCodec, rn as PackageLeafSchema, rr as isPackageLeaf, rt as ContentSheetColumn, s as AnchorDescriptor, sn as PageSizeSchema, sr as isShapeConstructGroupNode, st as ContentSheetPrintRange, t as decodePackage, tn as PackageGroupSchema, tr as isPackageBlockLeaf, tt as ContentSheetCell, u as AnchorTypeSchema, un as ProvenanceDescriptor, ur as isSlideGroupNode, ut as ContentSheetPrintSettingsSchema, v as ConstructMarkerImbalance, vn as SectionGroupNode, vt as ContentStrokeStyle, w as ContentCellBorders, wn as ShapeGroupNode, wt as ContentTableRowSchema, x as ContentBlockSchema, xn as ShapeConstructGroupNode, xt as ContentTableCell, y as ConstructMarkerImbalanceError, yn as SectionGroupSchema, yt as ContentStrokeStyleSchema, z as ContentDocumentSchema, zn as StylesTable, zt as LinkDescriptor } from "./codec-DNjHjEDm.cjs";
|
|
25
25
|
export { type Alignment, AlignmentSchema, type AnchorDescriptor, AnchorDescriptorSchema, type AnchorType, AnchorTypeSchema, type Attribute, AttributeSchema, type BinaryPart, BinaryPartSchema, type Box, BoxSchema, COLOR_BLACK, type Color, ColorSchema, type ColorTransform, type Comment, CommentSchema, type CompactAttrPairs, type CompactPackage, CompactPackageSchema, type CompactPart, CompactPartSchema, type CompactXmlNode, CompactXmlNodeSchema, type ConstructDescriptor, ConstructDescriptorSchema, type ConstructMarkerImbalance, ConstructMarkerImbalanceError, type ContentBlock, ContentBlockSchema, type ContentBorder, ContentBorderSchema, type ContentCellBorders, ContentCellBordersSchema, type ContentCellValue, ContentCellValueSchema, type ContentConstructEnd, ContentConstructEndSchema, type ContentConstructStart, ContentConstructStartSchema, type ContentControlDescriptor, ContentControlDescriptorSchema, type ContentControlLock, ContentControlLockSchema, type ContentControlType, ContentControlTypeSchema, 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 DivisionDescriptor, DivisionDescriptorSchema, type DocumentMetadata, DocumentMetadataSchema, type DocumentPackage, DocumentPackageSchema, type DocxContent, type DocxDocument, DocxDocumentSchema, type DrawPageChild, type DrawPageDescriptor, type DrawPageGroupNode, DrawPageGroupSchema, type FieldDescriptor, FieldDescriptorSchema, type Footnote, FootnoteSchema, type HeadingGroupNode, HeadingGroupSchema, type HeadingParagraph, type ImageFormat, type LinkDescriptor, LinkDescriptorSchema, type LinkTarget, LinkTargetSchema, type ListChild, type ListGroupNode, ListGroupSchema, type ListParagraph, type Margins, MarginsSchema, type NumberingDefinition, NumberingDefinitionSchema, type NumberingDefinitions, type NumberingLevel, NumberingLevelSchema, PAGE_SIZE_A4, PAGE_SIZE_LETTER, type Package, type PackageBlockLeaf, PackageBlockLeafSchema, type PackageChildren, type PackageGroup, PackageGroupSchema, type PackageLeaf, PackageLeafSchema, type PackageNode, PackageNodeSchema, PackageSchema, type PageSize, PageSizeSchema, type Part, PartSchema, type PptxDocument, PptxDocumentSchema, type ProvenanceChange, ProvenanceChangeSchema, type ProvenanceDescriptor, ProvenanceDescriptorSchema, type Relationship, SLIDE_SIZE_STANDARD, SLIDE_SIZE_WIDESCREEN, type SectionChild, type SectionConstructGroupNode, SectionConstructGroupSchema, type SectionDescriptor, type SectionGroupNode, SectionGroupSchema, type ShapeChild, type ShapeConstructGroupNode, ShapeConstructGroupSchema, type ShapeDescriptor, type ShapeGroupNode, ShapeGroupSchema, type SheetChild, type SheetDescriptor, type SheetGroupNode, SheetGroupSchema, type SlideDescriptor, type SlideGroupNode, SlideGroupSchema, type StyleEntry, StyleEntrySchema, type StyleParagraphProperties, StyleParagraphPropertiesSchema, type StyleRunProperties, StyleRunPropertiesSchema, type StylesTable, StylesTableSchema, 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, applyParagraphStyleProperties, applyRunStyleProperties, assemblePackage, attr, base64ToBytes, buildDocxPackage, buildDocxPackageFromContent, buildXlsxPackage, buildXlsxPackageFromContent, buildXml, bytesToBase64, childrenWithTag, colorToRgbHex, compactCodec, compactPackageCodec, decodeCompactPackage, decodeEntities, decodePackage, decompose, el, elementsWithTag, encodeCompactPackage, encodePackage, encodeXmlText, factorStyles, findConstructMarkerImbalance, flattenPackage, fromCompact, isCompactXmlNode, isContentBlock, isContentConstructEnd, isContentConstructStart, isDrawPageGroupNode, isHeadingGroupNode, isListGroupNode, isPackageBlockLeaf, isPackageGroup, isPackageLeaf, isPackageNode, isSectionConstructGroupNode, isSectionGroupNode, isShapeConstructGroupNode, isShapeGroupNode, isSheetGroupNode, isSlideGroupNode, isXmlNode, overlayStyleEntries, packageCodec, parsePackage, parseXml, readDocx, readDocxContent, readNumberingDefinitions, readPptx, readPptxContent, readXlsx, readXlsxContent, readXlsxWorkbook, resolveRelationships, resolveStyleChain, rgbHexToColor, rootElement, serializePackage, sniffImageFormat, textContent, toCompact, txt, unzipPackage, walk, xmlCodec, zipPackage };
|
package/dist/index.d.ts
CHANGED
|
@@ -14,12 +14,12 @@ import { n as applyColorTransforms, t as ColorTransform } from "./color-fFIKAs-Y
|
|
|
14
14
|
import { n as DocumentMetadataSchema, t as DocumentMetadata } from "./metadata-o_WH9V_I.js";
|
|
15
15
|
import { n as sniffImageFormat, t as ImageFormat } from "./sniff-DjpnUZRp.js";
|
|
16
16
|
import { a as readXlsx, i as readPptx, n as buildXlsxPackage, r as readDocx, t as buildDocxPackage } from "./document-package-kartHoyl.js";
|
|
17
|
-
import { a as Footnote, i as DocxDocumentSchema, n as CommentSchema, o as FootnoteSchema, r as DocxDocument, s as readDocxContent, t as Comment } from "./read-
|
|
17
|
+
import { a as Footnote, i as DocxDocumentSchema, n as CommentSchema, o as FootnoteSchema, r as DocxDocument, s as readDocxContent, t as Comment } from "./read-CxMli3Om.js";
|
|
18
18
|
import { n as buildDocxPackageFromContent, t as DocxContent } from "./write-97yEqc6w.js";
|
|
19
19
|
import { a as NumberingLevelSchema, i as NumberingLevel, n as NumberingDefinitionSchema, o as readNumberingDefinitions, r as NumberingDefinitions, t as NumberingDefinition } from "./numbering-D0YfuiOO.js";
|
|
20
|
-
import { n as PptxDocumentSchema, r as readPptxContent, t as PptxDocument } from "./read-
|
|
20
|
+
import { n as PptxDocumentSchema, r as readPptxContent, t as PptxDocument } from "./read-ZWJPDvG-.js";
|
|
21
21
|
import { a as XlsxSheet, c as XlsxWorkbookSchema, i as XlsxCellSchema, l as readXlsxWorkbook, n as DefinedNameSchema, o as XlsxSheetSchema, r as XlsxCell, s as XlsxWorkbook, t as DefinedName } from "./xlsx-DacFqZeF.js";
|
|
22
22
|
import { t as readXlsxContent } from "./content-t6ZfmfQM.js";
|
|
23
23
|
import { t as buildXlsxPackageFromContent } from "./build-q0qMH_ML.js";
|
|
24
|
-
import { $ as ContentShapeSchema, $n as isHeadingGroupNode, $t as PackageChildren, A as ContentConstructStart, An as SlideDescriptor, At as DrawPageChild, B as ContentImageBlock, Bn as StylesTableSchema, Bt as LinkDescriptorSchema, C as ContentBorderSchema, Cn as ShapeDescriptor, Ct as ContentTableRow, D as ContentCellValueSchema, Dn as SheetDescriptor, Dt as DivisionDescriptorSchema, E as ContentCellValue, En as SheetChild, Et as DivisionDescriptor, F as ContentControlLockSchema, Fn as StyleParagraphProperties, Ft as FieldDescriptorSchema, G as ContentPageBreakSchema, Gn as decompose, Gt as ListGroupSchema, H as ContentListMembership, Hn as applyRunStyleProperties, Ht as LinkTargetSchema, I as ContentControlType, In as StyleParagraphPropertiesSchema, It as HeadingGroupNode, J as ContentRun, Jn as flattenPackage, Jt as MarginsSchema, K as ContentParagraph, Kn as factorStyles, Kt as ListParagraph, L as ContentControlTypeSchema, Ln as StyleRunProperties, Lt as HeadingGroupSchema, M as ContentControlDescriptor, Mn as SlideGroupSchema, Mt as DrawPageGroupNode, N as ContentControlDescriptorSchema, Nn as StyleEntry, Nt as DrawPageGroupSchema, O as ContentConstructEnd, On as SheetGroupNode, Ot as DocumentPackage, P as ContentControlLock, Pn as StyleEntrySchema, Pt as FieldDescriptor, Q as ContentShape, Qn as isDrawPageGroupNode, Qt as PackageBlockLeafSchema, R as ContentDocument, Rn as StyleRunPropertiesSchema, Rt as HeadingParagraph, S as ContentBorder, Sn as ShapeConstructGroupSchema, St as ContentTableCellSchema, T as ContentCellBordersSchema, Tn as ShapeGroupSchema, Tt as ContentTableSchema, U as ContentListMembershipSchema, Un as assemblePackage, Ut as ListChild, V as ContentImageBlockSchema, Vn as applyParagraphStyleProperties, Vt as LinkTarget, W as ContentPageBreak, Wn as colorToRgbHex, Wt as ListGroupNode, X as ContentSection, Xn as isContentConstructEnd, Xt as PAGE_SIZE_LETTER, Y as ContentRunSchema, Yn as isContentBlock, Yt as PAGE_SIZE_A4, Z as ContentSectionSchema, Zn as isContentConstructStart, Zt as PackageBlockLeaf, _ as ConstructDescriptorSchema, _n as SectionDescriptor, _t as ContentSlideSchema, a as Alignment, an as PackageNodeSchema, ar as isSectionConstructGroupNode, at as ContentSheetImage, b as ContentBlock, bn as ShapeChild, bt as ContentTable, c as AnchorDescriptorSchema, cn as ProvenanceChange, cr as isShapeGroupNode, ct as ContentSheetPrintRangeSchema, d as Box, dn as ProvenanceDescriptorSchema, dr as overlayStyleEntries, dt as ContentSheetRepeatRange, en as PackageGroup, er as isListGroupNode, et as ContentSheet, f as BoxSchema, fn as SLIDE_SIZE_STANDARD, fr as resolveStyleChain, ft as ContentSheetRepeatRangeSchema, g as ConstructDescriptor, gn as SectionConstructGroupSchema, gt as ContentSlide, h as ColorSchema, hn as SectionConstructGroupNode, ht as ContentSheetSchema, i as xmlCodec, in as PackageNode, ir as isPackageNode, it as ContentSheetColumnSchema, j as ContentConstructStartSchema, jn as SlideGroupNode, jt as DrawPageDescriptor, k as ContentConstructEndSchema, kn as SheetGroupSchema, kt as DocumentPackageSchema, l as AnchorType, ln as ProvenanceChangeSchema, lr as isSheetGroupNode, lt as ContentSheetPrintSettings, m as Color, mn as SectionChild, mt as ContentSheetRowSchema, n as encodePackage, nn as PackageLeaf, nr as isPackageGroup, nt as ContentSheetCellSchema, o as AlignmentSchema, on as PageSize, or as isSectionGroupNode, ot as ContentSheetImageSchema, p as COLOR_BLACK, pn as SLIDE_SIZE_WIDESCREEN, pr as rgbHexToColor, pt as ContentSheetRow, q as ContentParagraphSchema, qn as findConstructMarkerImbalance, qt as Margins, r as packageCodec, rn as PackageLeafSchema, rr as isPackageLeaf, rt as ContentSheetColumn, s as AnchorDescriptor, sn as PageSizeSchema, sr as isShapeConstructGroupNode, st as ContentSheetPrintRange, t as decodePackage, tn as PackageGroupSchema, tr as isPackageBlockLeaf, tt as ContentSheetCell, u as AnchorTypeSchema, un as ProvenanceDescriptor, ur as isSlideGroupNode, ut as ContentSheetPrintSettingsSchema, v as ConstructMarkerImbalance, vn as SectionGroupNode, vt as ContentStrokeStyle, w as ContentCellBorders, wn as ShapeGroupNode, wt as ContentTableRowSchema, x as ContentBlockSchema, xn as ShapeConstructGroupNode, xt as ContentTableCell, y as ConstructMarkerImbalanceError, yn as SectionGroupSchema, yt as ContentStrokeStyleSchema, z as ContentDocumentSchema, zn as StylesTable, zt as LinkDescriptor } from "./codec-
|
|
24
|
+
import { $ as ContentShapeSchema, $n as isHeadingGroupNode, $t as PackageChildren, A as ContentConstructStart, An as SlideDescriptor, At as DrawPageChild, B as ContentImageBlock, Bn as StylesTableSchema, Bt as LinkDescriptorSchema, C as ContentBorderSchema, Cn as ShapeDescriptor, Ct as ContentTableRow, D as ContentCellValueSchema, Dn as SheetDescriptor, Dt as DivisionDescriptorSchema, E as ContentCellValue, En as SheetChild, Et as DivisionDescriptor, F as ContentControlLockSchema, Fn as StyleParagraphProperties, Ft as FieldDescriptorSchema, G as ContentPageBreakSchema, Gn as decompose, Gt as ListGroupSchema, H as ContentListMembership, Hn as applyRunStyleProperties, Ht as LinkTargetSchema, I as ContentControlType, In as StyleParagraphPropertiesSchema, It as HeadingGroupNode, J as ContentRun, Jn as flattenPackage, Jt as MarginsSchema, K as ContentParagraph, Kn as factorStyles, Kt as ListParagraph, L as ContentControlTypeSchema, Ln as StyleRunProperties, Lt as HeadingGroupSchema, M as ContentControlDescriptor, Mn as SlideGroupSchema, Mt as DrawPageGroupNode, N as ContentControlDescriptorSchema, Nn as StyleEntry, Nt as DrawPageGroupSchema, O as ContentConstructEnd, On as SheetGroupNode, Ot as DocumentPackage, P as ContentControlLock, Pn as StyleEntrySchema, Pt as FieldDescriptor, Q as ContentShape, Qn as isDrawPageGroupNode, Qt as PackageBlockLeafSchema, R as ContentDocument, Rn as StyleRunPropertiesSchema, Rt as HeadingParagraph, S as ContentBorder, Sn as ShapeConstructGroupSchema, St as ContentTableCellSchema, T as ContentCellBordersSchema, Tn as ShapeGroupSchema, Tt as ContentTableSchema, U as ContentListMembershipSchema, Un as assemblePackage, Ut as ListChild, V as ContentImageBlockSchema, Vn as applyParagraphStyleProperties, Vt as LinkTarget, W as ContentPageBreak, Wn as colorToRgbHex, Wt as ListGroupNode, X as ContentSection, Xn as isContentConstructEnd, Xt as PAGE_SIZE_LETTER, Y as ContentRunSchema, Yn as isContentBlock, Yt as PAGE_SIZE_A4, Z as ContentSectionSchema, Zn as isContentConstructStart, Zt as PackageBlockLeaf, _ as ConstructDescriptorSchema, _n as SectionDescriptor, _t as ContentSlideSchema, a as Alignment, an as PackageNodeSchema, ar as isSectionConstructGroupNode, at as ContentSheetImage, b as ContentBlock, bn as ShapeChild, bt as ContentTable, c as AnchorDescriptorSchema, cn as ProvenanceChange, cr as isShapeGroupNode, ct as ContentSheetPrintRangeSchema, d as Box, dn as ProvenanceDescriptorSchema, dr as overlayStyleEntries, dt as ContentSheetRepeatRange, en as PackageGroup, er as isListGroupNode, et as ContentSheet, f as BoxSchema, fn as SLIDE_SIZE_STANDARD, fr as resolveStyleChain, ft as ContentSheetRepeatRangeSchema, g as ConstructDescriptor, gn as SectionConstructGroupSchema, gt as ContentSlide, h as ColorSchema, hn as SectionConstructGroupNode, ht as ContentSheetSchema, i as xmlCodec, in as PackageNode, ir as isPackageNode, it as ContentSheetColumnSchema, j as ContentConstructStartSchema, jn as SlideGroupNode, jt as DrawPageDescriptor, k as ContentConstructEndSchema, kn as SheetGroupSchema, kt as DocumentPackageSchema, l as AnchorType, ln as ProvenanceChangeSchema, lr as isSheetGroupNode, lt as ContentSheetPrintSettings, m as Color, mn as SectionChild, mt as ContentSheetRowSchema, n as encodePackage, nn as PackageLeaf, nr as isPackageGroup, nt as ContentSheetCellSchema, o as AlignmentSchema, on as PageSize, or as isSectionGroupNode, ot as ContentSheetImageSchema, p as COLOR_BLACK, pn as SLIDE_SIZE_WIDESCREEN, pr as rgbHexToColor, pt as ContentSheetRow, q as ContentParagraphSchema, qn as findConstructMarkerImbalance, qt as Margins, r as packageCodec, rn as PackageLeafSchema, rr as isPackageLeaf, rt as ContentSheetColumn, s as AnchorDescriptor, sn as PageSizeSchema, sr as isShapeConstructGroupNode, st as ContentSheetPrintRange, t as decodePackage, tn as PackageGroupSchema, tr as isPackageBlockLeaf, tt as ContentSheetCell, u as AnchorTypeSchema, un as ProvenanceDescriptor, ur as isSlideGroupNode, ut as ContentSheetPrintSettingsSchema, v as ConstructMarkerImbalance, vn as SectionGroupNode, vt as ContentStrokeStyle, w as ContentCellBorders, wn as ShapeGroupNode, wt as ContentTableRowSchema, x as ContentBlockSchema, xn as ShapeConstructGroupNode, xt as ContentTableCell, y as ConstructMarkerImbalanceError, yn as SectionGroupSchema, yt as ContentStrokeStyleSchema, z as ContentDocumentSchema, zn as StylesTable, zt as LinkDescriptor } from "./codec-BrTMlL0a.js";
|
|
25
25
|
export { type Alignment, AlignmentSchema, type AnchorDescriptor, AnchorDescriptorSchema, type AnchorType, AnchorTypeSchema, type Attribute, AttributeSchema, type BinaryPart, BinaryPartSchema, type Box, BoxSchema, COLOR_BLACK, type Color, ColorSchema, type ColorTransform, type Comment, CommentSchema, type CompactAttrPairs, type CompactPackage, CompactPackageSchema, type CompactPart, CompactPartSchema, type CompactXmlNode, CompactXmlNodeSchema, type ConstructDescriptor, ConstructDescriptorSchema, type ConstructMarkerImbalance, ConstructMarkerImbalanceError, type ContentBlock, ContentBlockSchema, type ContentBorder, ContentBorderSchema, type ContentCellBorders, ContentCellBordersSchema, type ContentCellValue, ContentCellValueSchema, type ContentConstructEnd, ContentConstructEndSchema, type ContentConstructStart, ContentConstructStartSchema, type ContentControlDescriptor, ContentControlDescriptorSchema, type ContentControlLock, ContentControlLockSchema, type ContentControlType, ContentControlTypeSchema, 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 DivisionDescriptor, DivisionDescriptorSchema, type DocumentMetadata, DocumentMetadataSchema, type DocumentPackage, DocumentPackageSchema, type DocxContent, type DocxDocument, DocxDocumentSchema, type DrawPageChild, type DrawPageDescriptor, type DrawPageGroupNode, DrawPageGroupSchema, type FieldDescriptor, FieldDescriptorSchema, type Footnote, FootnoteSchema, type HeadingGroupNode, HeadingGroupSchema, type HeadingParagraph, type ImageFormat, type LinkDescriptor, LinkDescriptorSchema, type LinkTarget, LinkTargetSchema, type ListChild, type ListGroupNode, ListGroupSchema, type ListParagraph, type Margins, MarginsSchema, type NumberingDefinition, NumberingDefinitionSchema, type NumberingDefinitions, type NumberingLevel, NumberingLevelSchema, PAGE_SIZE_A4, PAGE_SIZE_LETTER, type Package, type PackageBlockLeaf, PackageBlockLeafSchema, type PackageChildren, type PackageGroup, PackageGroupSchema, type PackageLeaf, PackageLeafSchema, type PackageNode, PackageNodeSchema, PackageSchema, type PageSize, PageSizeSchema, type Part, PartSchema, type PptxDocument, PptxDocumentSchema, type ProvenanceChange, ProvenanceChangeSchema, type ProvenanceDescriptor, ProvenanceDescriptorSchema, type Relationship, SLIDE_SIZE_STANDARD, SLIDE_SIZE_WIDESCREEN, type SectionChild, type SectionConstructGroupNode, SectionConstructGroupSchema, type SectionDescriptor, type SectionGroupNode, SectionGroupSchema, type ShapeChild, type ShapeConstructGroupNode, ShapeConstructGroupSchema, type ShapeDescriptor, type ShapeGroupNode, ShapeGroupSchema, type SheetChild, type SheetDescriptor, type SheetGroupNode, SheetGroupSchema, type SlideDescriptor, type SlideGroupNode, SlideGroupSchema, type StyleEntry, StyleEntrySchema, type StyleParagraphProperties, StyleParagraphPropertiesSchema, type StyleRunProperties, StyleRunPropertiesSchema, type StylesTable, StylesTableSchema, 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, applyParagraphStyleProperties, applyRunStyleProperties, assemblePackage, attr, base64ToBytes, buildDocxPackage, buildDocxPackageFromContent, buildXlsxPackage, buildXlsxPackageFromContent, buildXml, bytesToBase64, childrenWithTag, colorToRgbHex, compactCodec, compactPackageCodec, decodeCompactPackage, decodeEntities, decodePackage, decompose, el, elementsWithTag, encodeCompactPackage, encodePackage, encodeXmlText, factorStyles, findConstructMarkerImbalance, flattenPackage, fromCompact, isCompactXmlNode, isContentBlock, isContentConstructEnd, isContentConstructStart, isDrawPageGroupNode, isHeadingGroupNode, isListGroupNode, isPackageBlockLeaf, isPackageGroup, isPackageLeaf, isPackageNode, isSectionConstructGroupNode, isSectionGroupNode, isShapeConstructGroupNode, isShapeGroupNode, isSheetGroupNode, isSlideGroupNode, isXmlNode, overlayStyleEntries, packageCodec, parsePackage, parseXml, readDocx, readDocxContent, readNumberingDefinitions, readPptx, readPptxContent, readXlsx, readXlsxContent, readXlsxWorkbook, resolveRelationships, resolveStyleChain, rgbHexToColor, rootElement, serializePackage, sniffImageFormat, textContent, toCompact, txt, unzipPackage, walk, xmlCodec, zipPackage };
|
package/dist/index.js
CHANGED
|
@@ -14,11 +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 { c as readPptxContent, i as readDocxContent, n as DocxDocumentSchema, r as FootnoteSchema, s as PptxDocumentSchema, t as CommentSchema } from "./read-
|
|
17
|
+
import { c as readPptxContent, i as readDocxContent, n as DocxDocumentSchema, r as FootnoteSchema, s as PptxDocumentSchema, t as CommentSchema } from "./read-fuJpC4BH.js";
|
|
18
18
|
import { readXlsxContent } from "./typed/xlsx/content.js";
|
|
19
19
|
import { NumberingDefinitionSchema, NumberingLevelSchema, readNumberingDefinitions } from "./typed/docx/numbering.js";
|
|
20
|
-
import { buildDocxPackageFromContent } from "./typed/docx/write.js";
|
|
21
20
|
import { buildXlsxPackageFromContent } from "./typed/xlsx/build.js";
|
|
21
|
+
import { buildDocxPackageFromContent } from "./typed/docx/write.js";
|
|
22
22
|
import { buildDocxPackage, buildXlsxPackage, readDocx, readPptx, readXlsx } from "./typed/document-package.js";
|
|
23
23
|
import { DefinedNameSchema, XlsxCellSchema, XlsxSheetSchema, XlsxWorkbookSchema, readXlsxWorkbook } from "./typed/xlsx.js";
|
|
24
24
|
import { AlignmentSchema, AnchorDescriptorSchema, AnchorTypeSchema, BoxSchema, COLOR_BLACK, ColorSchema, ConstructDescriptorSchema, ConstructMarkerImbalanceError, ContentBlockSchema, ContentBorderSchema, ContentCellBordersSchema, ContentCellValueSchema, ContentConstructEndSchema, ContentConstructStartSchema, ContentControlDescriptorSchema, ContentControlLockSchema, ContentControlTypeSchema, ContentDocumentSchema, ContentImageBlockSchema, ContentListMembershipSchema, ContentPageBreakSchema, ContentParagraphSchema, ContentRunSchema, ContentSectionSchema, ContentShapeSchema, ContentSheetCellSchema, ContentSheetColumnSchema, ContentSheetImageSchema, ContentSheetPrintRangeSchema, ContentSheetPrintSettingsSchema, ContentSheetRepeatRangeSchema, ContentSheetRowSchema, ContentSheetSchema, ContentSlideSchema, ContentStrokeStyleSchema, ContentTableCellSchema, ContentTableRowSchema, ContentTableSchema, DivisionDescriptorSchema, DocumentPackageSchema, DrawPageGroupSchema, FieldDescriptorSchema, HeadingGroupSchema, LinkDescriptorSchema, LinkTargetSchema, ListGroupSchema, MarginsSchema, PAGE_SIZE_A4, PAGE_SIZE_LETTER, PackageBlockLeafSchema, PackageGroupSchema, PackageLeafSchema, PackageNodeSchema, PageSizeSchema, ProvenanceChangeSchema, ProvenanceDescriptorSchema, SLIDE_SIZE_STANDARD, SLIDE_SIZE_WIDESCREEN, SectionConstructGroupSchema, SectionGroupSchema, ShapeConstructGroupSchema, ShapeGroupSchema, SheetGroupSchema, SlideGroupSchema, StyleEntrySchema, StyleParagraphPropertiesSchema, StyleRunPropertiesSchema, StylesTableSchema, applyParagraphStyleProperties, applyRunStyleProperties, assemblePackage, colorToRgbHex, decompose, factorStyles, findConstructMarkerImbalance, flattenPackage, isContentBlock, isContentConstructEnd, isContentConstructStart, isDrawPageGroupNode, isHeadingGroupNode, isListGroupNode, isPackageBlockLeaf, isPackageGroup, isPackageLeaf, isPackageNode, isSectionConstructGroupNode, isSectionGroupNode, isShapeConstructGroupNode, isShapeGroupNode, isSheetGroupNode, isSlideGroupNode, overlayStyleEntries, resolveStyleChain, rgbHexToColor } from "document-schema.js";
|
|
@@ -34,6 +34,23 @@ declare const PptxDocumentSchema: z.ZodObject<{
|
|
|
34
34
|
lineSpacingReduction: z.ZodOptional<z.ZodNumber>;
|
|
35
35
|
paintOrder: z.ZodOptional<z.ZodNumber>;
|
|
36
36
|
sourcePath: z.ZodOptional<z.ZodString>;
|
|
37
|
+
source: z.ZodOptional<z.ZodObject<{
|
|
38
|
+
format: z.ZodEnum<{
|
|
39
|
+
docx: "docx";
|
|
40
|
+
pptx: "pptx";
|
|
41
|
+
xlsx: "xlsx";
|
|
42
|
+
odt: "odt";
|
|
43
|
+
ods: "ods";
|
|
44
|
+
odp: "odp";
|
|
45
|
+
odg: "odg";
|
|
46
|
+
odm: "odm";
|
|
47
|
+
odb: "odb";
|
|
48
|
+
odf: "odf";
|
|
49
|
+
markdown: "markdown";
|
|
50
|
+
pdf: "pdf";
|
|
51
|
+
}>;
|
|
52
|
+
xml: z.ZodString;
|
|
53
|
+
}, z.core.$strict>>;
|
|
37
54
|
frames: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
38
55
|
pageIndex: z.ZodNumber;
|
|
39
56
|
xPt: z.ZodNumber;
|
|
@@ -44,6 +61,23 @@ declare const PptxDocumentSchema: z.ZodObject<{
|
|
|
44
61
|
blocks: z.ZodArray<z.ZodCustom<ContentBlock, ContentBlock>>;
|
|
45
62
|
}, z.core.$strip>>;
|
|
46
63
|
notes: z.ZodString;
|
|
64
|
+
source: z.ZodOptional<z.ZodObject<{
|
|
65
|
+
format: z.ZodEnum<{
|
|
66
|
+
docx: "docx";
|
|
67
|
+
pptx: "pptx";
|
|
68
|
+
xlsx: "xlsx";
|
|
69
|
+
odt: "odt";
|
|
70
|
+
ods: "ods";
|
|
71
|
+
odp: "odp";
|
|
72
|
+
odg: "odg";
|
|
73
|
+
odm: "odm";
|
|
74
|
+
odb: "odb";
|
|
75
|
+
odf: "odf";
|
|
76
|
+
markdown: "markdown";
|
|
77
|
+
pdf: "pdf";
|
|
78
|
+
}>;
|
|
79
|
+
xml: z.ZodString;
|
|
80
|
+
}, z.core.$strict>>;
|
|
47
81
|
}, z.core.$strip>>;
|
|
48
82
|
}, z.core.$strip>;
|
|
49
83
|
type PptxDocument = z.infer<typeof PptxDocumentSchema>;
|
|
@@ -439,9 +439,11 @@ function rootEntriesOf(walk) {
|
|
|
439
439
|
return entries;
|
|
440
440
|
}
|
|
441
441
|
function readEmbeddedOoxmlPayload(bytes) {
|
|
442
|
-
if (!(0, archive_codec.isZipArchive)(bytes)) return;
|
|
442
|
+
if (!(0, archive_codec.isZipArchive)(bytes) && !(0, archive_codec.isCompoundFile)(bytes)) return;
|
|
443
443
|
try {
|
|
444
|
-
const
|
|
444
|
+
const zipBytes = zipBytesOfPayload(bytes);
|
|
445
|
+
if (zipBytes === void 0) return;
|
|
446
|
+
const nested = require_package_io_read.packageFromEntries(rootEntriesOf((0, archive_codec.walkArchive)(zipBytes)));
|
|
445
447
|
const objectKind = detectFlavour(nested);
|
|
446
448
|
return objectKind === void 0 ? void 0 : {
|
|
447
449
|
objectKind,
|
|
@@ -451,6 +453,13 @@ function readEmbeddedOoxmlPayload(bytes) {
|
|
|
451
453
|
return;
|
|
452
454
|
}
|
|
453
455
|
}
|
|
456
|
+
function zipBytesOfPayload(bytes) {
|
|
457
|
+
if ((0, archive_codec.isZipArchive)(bytes)) return bytes;
|
|
458
|
+
const packageStream = (0, archive_codec.readCompoundFile)(bytes).find((stream) => stream.path === "Package");
|
|
459
|
+
if (packageStream === void 0) return;
|
|
460
|
+
const fileBytes = (0, archive_codec.readOlePackage)(packageStream.bytes).fileBytes;
|
|
461
|
+
return (0, archive_codec.isZipArchive)(fileBytes) ? fileBytes : void 0;
|
|
462
|
+
}
|
|
454
463
|
const payloadByPart = /* @__PURE__ */ new WeakMap();
|
|
455
464
|
function readEmbeddedPayloadPart(part) {
|
|
456
465
|
const cached = payloadByPart.get(part);
|
|
@@ -34,6 +34,23 @@ declare const DocxDocumentSchema: z.ZodObject<{
|
|
|
34
34
|
leftPt: z.ZodNumber;
|
|
35
35
|
}, z.core.$strip>;
|
|
36
36
|
blocks: z.ZodArray<z.ZodCustom<ContentBlock, ContentBlock>>;
|
|
37
|
+
source: z.ZodOptional<z.ZodObject<{
|
|
38
|
+
format: z.ZodEnum<{
|
|
39
|
+
docx: "docx";
|
|
40
|
+
pptx: "pptx";
|
|
41
|
+
xlsx: "xlsx";
|
|
42
|
+
odt: "odt";
|
|
43
|
+
ods: "ods";
|
|
44
|
+
odp: "odp";
|
|
45
|
+
odg: "odg";
|
|
46
|
+
odm: "odm";
|
|
47
|
+
odb: "odb";
|
|
48
|
+
odf: "odf";
|
|
49
|
+
markdown: "markdown";
|
|
50
|
+
pdf: "pdf";
|
|
51
|
+
}>;
|
|
52
|
+
xml: z.ZodString;
|
|
53
|
+
}, z.core.$strict>>;
|
|
37
54
|
}, z.core.$strip>>;
|
|
38
55
|
comments: z.ZodArray<z.ZodObject<{
|
|
39
56
|
author: z.ZodOptional<z.ZodString>;
|
|
@@ -34,6 +34,23 @@ declare const DocxDocumentSchema: z.ZodObject<{
|
|
|
34
34
|
leftPt: z.ZodNumber;
|
|
35
35
|
}, z.core.$strip>;
|
|
36
36
|
blocks: z.ZodArray<z.ZodCustom<ContentBlock, ContentBlock>>;
|
|
37
|
+
source: z.ZodOptional<z.ZodObject<{
|
|
38
|
+
format: z.ZodEnum<{
|
|
39
|
+
docx: "docx";
|
|
40
|
+
pptx: "pptx";
|
|
41
|
+
xlsx: "xlsx";
|
|
42
|
+
odt: "odt";
|
|
43
|
+
ods: "ods";
|
|
44
|
+
odp: "odp";
|
|
45
|
+
odg: "odg";
|
|
46
|
+
odm: "odm";
|
|
47
|
+
odb: "odb";
|
|
48
|
+
odf: "odf";
|
|
49
|
+
markdown: "markdown";
|
|
50
|
+
pdf: "pdf";
|
|
51
|
+
}>;
|
|
52
|
+
xml: z.ZodString;
|
|
53
|
+
}, z.core.$strict>>;
|
|
37
54
|
}, z.core.$strip>>;
|
|
38
55
|
comments: z.ZodArray<z.ZodObject<{
|
|
39
56
|
author: z.ZodOptional<z.ZodString>;
|
|
@@ -34,6 +34,23 @@ declare const PptxDocumentSchema: z.ZodObject<{
|
|
|
34
34
|
lineSpacingReduction: z.ZodOptional<z.ZodNumber>;
|
|
35
35
|
paintOrder: z.ZodOptional<z.ZodNumber>;
|
|
36
36
|
sourcePath: z.ZodOptional<z.ZodString>;
|
|
37
|
+
source: z.ZodOptional<z.ZodObject<{
|
|
38
|
+
format: z.ZodEnum<{
|
|
39
|
+
docx: "docx";
|
|
40
|
+
pptx: "pptx";
|
|
41
|
+
xlsx: "xlsx";
|
|
42
|
+
odt: "odt";
|
|
43
|
+
ods: "ods";
|
|
44
|
+
odp: "odp";
|
|
45
|
+
odg: "odg";
|
|
46
|
+
odm: "odm";
|
|
47
|
+
odb: "odb";
|
|
48
|
+
odf: "odf";
|
|
49
|
+
markdown: "markdown";
|
|
50
|
+
pdf: "pdf";
|
|
51
|
+
}>;
|
|
52
|
+
xml: z.ZodString;
|
|
53
|
+
}, z.core.$strict>>;
|
|
37
54
|
frames: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
38
55
|
pageIndex: z.ZodNumber;
|
|
39
56
|
xPt: z.ZodNumber;
|
|
@@ -44,6 +61,23 @@ declare const PptxDocumentSchema: z.ZodObject<{
|
|
|
44
61
|
blocks: z.ZodArray<z.ZodCustom<ContentBlock, ContentBlock>>;
|
|
45
62
|
}, z.core.$strip>>;
|
|
46
63
|
notes: z.ZodString;
|
|
64
|
+
source: z.ZodOptional<z.ZodObject<{
|
|
65
|
+
format: z.ZodEnum<{
|
|
66
|
+
docx: "docx";
|
|
67
|
+
pptx: "pptx";
|
|
68
|
+
xlsx: "xlsx";
|
|
69
|
+
odt: "odt";
|
|
70
|
+
ods: "ods";
|
|
71
|
+
odp: "odp";
|
|
72
|
+
odg: "odg";
|
|
73
|
+
odm: "odm";
|
|
74
|
+
odb: "odb";
|
|
75
|
+
odf: "odf";
|
|
76
|
+
markdown: "markdown";
|
|
77
|
+
pdf: "pdf";
|
|
78
|
+
}>;
|
|
79
|
+
xml: z.ZodString;
|
|
80
|
+
}, z.core.$strict>>;
|
|
47
81
|
}, z.core.$strip>>;
|
|
48
82
|
}, z.core.$strip>;
|
|
49
83
|
type PptxDocument = z.infer<typeof PptxDocumentSchema>;
|
|
@@ -15,7 +15,7 @@ import { NumberingDefinitionSchema, readNumberingDefinitions } from "./typed/doc
|
|
|
15
15
|
import { PROVENANCE_CHANGE_BY_TAG, bookmarkAnchorDescriptor, contentBearingChildren, fieldCharType, indexParagraphContent, insertConstructMarkers, isDeletedChange, readContentControlDescriptor, readProvenanceDescriptor, runInstructionText } from "./typed/docx/constructs.js";
|
|
16
16
|
import { z } from "zod";
|
|
17
17
|
import { COLOR_BLACK, ContentSectionSchema, ContentSlideSchema, PAGE_SIZE_LETTER, SLIDE_SIZE_WIDESCREEN, clampHeadingLevel, rgbHexToColor } from "document-schema.js";
|
|
18
|
-
import { isZipArchive, walkArchive } from "archive-codec";
|
|
18
|
+
import { isCompoundFile, isZipArchive, readCompoundFile, readOlePackage, walkArchive } from "archive-codec";
|
|
19
19
|
//#region src/typed/pptx/read.ts
|
|
20
20
|
const PptxDocumentSchema = z.object({
|
|
21
21
|
metadata: DocumentMetadataSchema,
|
|
@@ -439,9 +439,11 @@ function rootEntriesOf(walk) {
|
|
|
439
439
|
return entries;
|
|
440
440
|
}
|
|
441
441
|
function readEmbeddedOoxmlPayload(bytes) {
|
|
442
|
-
if (!isZipArchive(bytes)) return;
|
|
442
|
+
if (!isZipArchive(bytes) && !isCompoundFile(bytes)) return;
|
|
443
443
|
try {
|
|
444
|
-
const
|
|
444
|
+
const zipBytes = zipBytesOfPayload(bytes);
|
|
445
|
+
if (zipBytes === void 0) return;
|
|
446
|
+
const nested = packageFromEntries(rootEntriesOf(walkArchive(zipBytes)));
|
|
445
447
|
const objectKind = detectFlavour(nested);
|
|
446
448
|
return objectKind === void 0 ? void 0 : {
|
|
447
449
|
objectKind,
|
|
@@ -451,6 +453,13 @@ function readEmbeddedOoxmlPayload(bytes) {
|
|
|
451
453
|
return;
|
|
452
454
|
}
|
|
453
455
|
}
|
|
456
|
+
function zipBytesOfPayload(bytes) {
|
|
457
|
+
if (isZipArchive(bytes)) return bytes;
|
|
458
|
+
const packageStream = readCompoundFile(bytes).find((stream) => stream.path === "Package");
|
|
459
|
+
if (packageStream === void 0) return;
|
|
460
|
+
const fileBytes = readOlePackage(packageStream.bytes).fileBytes;
|
|
461
|
+
return isZipArchive(fileBytes) ? fileBytes : void 0;
|
|
462
|
+
}
|
|
454
463
|
const payloadByPart = /* @__PURE__ */ new WeakMap();
|
|
455
464
|
function readEmbeddedPayloadPart(part) {
|
|
456
465
|
const cached = payloadByPart.get(part);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_read = require("../read-
|
|
2
|
+
const require_read = require("../read-C3AaxcT9.cjs");
|
|
3
3
|
const require_typed_xlsx_content = require("./xlsx/content.cjs");
|
|
4
|
-
const require_typed_docx_write = require("./docx/write.cjs");
|
|
5
4
|
const require_typed_xlsx_build = require("./xlsx/build.cjs");
|
|
5
|
+
const require_typed_docx_write = require("./docx/write.cjs");
|
|
6
6
|
let document_schema_js = require("document-schema.js");
|
|
7
7
|
//#region src/typed/document-package.ts
|
|
8
8
|
function readDocx(pkg) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { c as readPptxContent, i as readDocxContent } from "../read-
|
|
1
|
+
import { c as readPptxContent, i as readDocxContent } from "../read-fuJpC4BH.js";
|
|
2
2
|
import { readXlsxContent } from "./xlsx/content.js";
|
|
3
|
-
import { buildDocxPackageFromContent } from "./docx/write.js";
|
|
4
3
|
import { buildXlsxPackageFromContent } from "./xlsx/build.js";
|
|
4
|
+
import { buildDocxPackageFromContent } from "./docx/write.js";
|
|
5
5
|
import { assemblePackage, flattenPackage } from "document-schema.js";
|
|
6
6
|
//#region src/typed/document-package.ts
|
|
7
7
|
function readDocx(pkg) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_xml_build = require("../../xml/build.cjs");
|
|
2
3
|
const require_typed_util = require("../util.cjs");
|
|
3
4
|
//#region src/typed/docx/constructs.ts
|
|
4
5
|
const NON_CONTENT_PARAGRAPH_CHILDREN = /* @__PURE__ */ new Set([
|
|
@@ -105,17 +106,36 @@ const LOCK_BY_VALUE = /* @__PURE__ */ new Map([
|
|
|
105
106
|
]);
|
|
106
107
|
const TABLE_OF_CONTENTS_GALLERY = "Table of Contents";
|
|
107
108
|
function readControlType(sdtPr) {
|
|
108
|
-
if (sdtPr === void 0) return
|
|
109
|
+
if (sdtPr === void 0) return {
|
|
110
|
+
controlType: "richText",
|
|
111
|
+
galleryResidue: void 0
|
|
112
|
+
};
|
|
109
113
|
for (const child of sdtPr.children) {
|
|
110
114
|
if (child.type !== "element") continue;
|
|
111
115
|
const mapped = CONTROL_TYPE_BY_TAG.get(child.tag);
|
|
112
|
-
if (mapped !== void 0) return
|
|
116
|
+
if (mapped !== void 0) return {
|
|
117
|
+
controlType: mapped,
|
|
118
|
+
galleryResidue: void 0
|
|
119
|
+
};
|
|
113
120
|
if (child.tag === "w:docPartObj" || child.tag === "w:docPartList") {
|
|
114
121
|
const gallery = require_typed_util.childrenWithTag(child, "w:docPartGallery")[0];
|
|
115
|
-
|
|
122
|
+
if ((gallery === void 0 ? void 0 : require_typed_util.attr(gallery, "w:val")) === "Table of Contents") return {
|
|
123
|
+
controlType: "index",
|
|
124
|
+
galleryResidue: void 0
|
|
125
|
+
};
|
|
126
|
+
return {
|
|
127
|
+
controlType: "richText",
|
|
128
|
+
galleryResidue: {
|
|
129
|
+
format: "docx",
|
|
130
|
+
xml: require_xml_build.buildXml([child])
|
|
131
|
+
}
|
|
132
|
+
};
|
|
116
133
|
}
|
|
117
134
|
}
|
|
118
|
-
return
|
|
135
|
+
return {
|
|
136
|
+
controlType: "richText",
|
|
137
|
+
galleryResidue: void 0
|
|
138
|
+
};
|
|
119
139
|
}
|
|
120
140
|
function readListItemOptions(sdtPr) {
|
|
121
141
|
const list = require_typed_util.childrenWithTag(sdtPr, "w:dropDownList")[0] ?? require_typed_util.childrenWithTag(sdtPr, "w:comboBox")[0];
|
|
@@ -137,10 +157,12 @@ function readCheckboxState(sdtPr) {
|
|
|
137
157
|
}
|
|
138
158
|
function readContentControlDescriptor(sdt) {
|
|
139
159
|
const sdtPr = require_typed_util.childrenWithTag(sdt, "w:sdtPr")[0];
|
|
160
|
+
const { controlType, galleryResidue } = readControlType(sdtPr);
|
|
140
161
|
const descriptor = {
|
|
141
162
|
kind: "contentControl",
|
|
142
|
-
controlType
|
|
163
|
+
controlType
|
|
143
164
|
};
|
|
165
|
+
if (galleryResidue !== void 0) descriptor.source = galleryResidue;
|
|
144
166
|
if (sdtPr === void 0) return descriptor;
|
|
145
167
|
const tag = require_typed_util.childrenWithTag(sdtPr, "w:tag")[0];
|
|
146
168
|
const tagVal = tag === void 0 ? void 0 : require_typed_util.attr(tag, "w:val");
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { buildXml } from "../../xml/build.js";
|
|
1
2
|
import { attr, childrenWithTag, decodeEntities, textContent } from "../util.js";
|
|
2
3
|
//#region src/typed/docx/constructs.ts
|
|
3
4
|
const NON_CONTENT_PARAGRAPH_CHILDREN = /* @__PURE__ */ new Set([
|
|
@@ -104,17 +105,36 @@ const LOCK_BY_VALUE = /* @__PURE__ */ new Map([
|
|
|
104
105
|
]);
|
|
105
106
|
const TABLE_OF_CONTENTS_GALLERY = "Table of Contents";
|
|
106
107
|
function readControlType(sdtPr) {
|
|
107
|
-
if (sdtPr === void 0) return
|
|
108
|
+
if (sdtPr === void 0) return {
|
|
109
|
+
controlType: "richText",
|
|
110
|
+
galleryResidue: void 0
|
|
111
|
+
};
|
|
108
112
|
for (const child of sdtPr.children) {
|
|
109
113
|
if (child.type !== "element") continue;
|
|
110
114
|
const mapped = CONTROL_TYPE_BY_TAG.get(child.tag);
|
|
111
|
-
if (mapped !== void 0) return
|
|
115
|
+
if (mapped !== void 0) return {
|
|
116
|
+
controlType: mapped,
|
|
117
|
+
galleryResidue: void 0
|
|
118
|
+
};
|
|
112
119
|
if (child.tag === "w:docPartObj" || child.tag === "w:docPartList") {
|
|
113
120
|
const gallery = childrenWithTag(child, "w:docPartGallery")[0];
|
|
114
|
-
|
|
121
|
+
if ((gallery === void 0 ? void 0 : attr(gallery, "w:val")) === "Table of Contents") return {
|
|
122
|
+
controlType: "index",
|
|
123
|
+
galleryResidue: void 0
|
|
124
|
+
};
|
|
125
|
+
return {
|
|
126
|
+
controlType: "richText",
|
|
127
|
+
galleryResidue: {
|
|
128
|
+
format: "docx",
|
|
129
|
+
xml: buildXml([child])
|
|
130
|
+
}
|
|
131
|
+
};
|
|
115
132
|
}
|
|
116
133
|
}
|
|
117
|
-
return
|
|
134
|
+
return {
|
|
135
|
+
controlType: "richText",
|
|
136
|
+
galleryResidue: void 0
|
|
137
|
+
};
|
|
118
138
|
}
|
|
119
139
|
function readListItemOptions(sdtPr) {
|
|
120
140
|
const list = childrenWithTag(sdtPr, "w:dropDownList")[0] ?? childrenWithTag(sdtPr, "w:comboBox")[0];
|
|
@@ -136,10 +156,12 @@ function readCheckboxState(sdtPr) {
|
|
|
136
156
|
}
|
|
137
157
|
function readContentControlDescriptor(sdt) {
|
|
138
158
|
const sdtPr = childrenWithTag(sdt, "w:sdtPr")[0];
|
|
159
|
+
const { controlType, galleryResidue } = readControlType(sdtPr);
|
|
139
160
|
const descriptor = {
|
|
140
161
|
kind: "contentControl",
|
|
141
|
-
controlType
|
|
162
|
+
controlType
|
|
142
163
|
};
|
|
164
|
+
if (galleryResidue !== void 0) descriptor.source = galleryResidue;
|
|
143
165
|
if (sdtPr === void 0) return descriptor;
|
|
144
166
|
const tag = childrenWithTag(sdtPr, "w:tag")[0];
|
|
145
167
|
const tagVal = tag === void 0 ? void 0 : attr(tag, "w:val");
|
package/dist/typed/docx/read.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_read = require("../../read-
|
|
2
|
+
const require_read = require("../../read-C3AaxcT9.cjs");
|
|
3
3
|
exports.CommentSchema = require_read.CommentSchema;
|
|
4
4
|
exports.DocxDocumentSchema = require_read.DocxDocumentSchema;
|
|
5
5
|
exports.FootnoteSchema = require_read.FootnoteSchema;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as Footnote, i as DocxDocumentSchema, n as CommentSchema, o as FootnoteSchema, r as DocxDocument, s as readDocxContent, t as Comment } from "../../read-
|
|
1
|
+
import { a as Footnote, i as DocxDocumentSchema, n as CommentSchema, o as FootnoteSchema, r as DocxDocument, s as readDocxContent, t as Comment } from "../../read-CDX1WbiF.cjs";
|
|
2
2
|
export { Comment, CommentSchema, DocxDocument, DocxDocumentSchema, Footnote, FootnoteSchema, readDocxContent };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as Footnote, i as DocxDocumentSchema, n as CommentSchema, o as FootnoteSchema, r as DocxDocument, s as readDocxContent, t as Comment } from "../../read-
|
|
1
|
+
import { a as Footnote, i as DocxDocumentSchema, n as CommentSchema, o as FootnoteSchema, r as DocxDocument, s as readDocxContent, t as Comment } from "../../read-CxMli3Om.js";
|
|
2
2
|
export { Comment, CommentSchema, DocxDocument, DocxDocumentSchema, Footnote, FootnoteSchema, readDocxContent };
|
package/dist/typed/docx/read.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { i as readDocxContent, n as DocxDocumentSchema, r as FootnoteSchema, t as CommentSchema } from "../../read-
|
|
1
|
+
import { i as readDocxContent, n as DocxDocumentSchema, r as FootnoteSchema, t as CommentSchema } from "../../read-fuJpC4BH.js";
|
|
2
2
|
export { CommentSchema, DocxDocumentSchema, FootnoteSchema, readDocxContent };
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_util_base64 = require("../../util/base64.cjs");
|
|
3
|
+
const require_xml_parse = require("../../xml/parse.cjs");
|
|
4
|
+
const require_codec = require("../../codec.cjs");
|
|
2
5
|
const require_xml_fragment = require("../../xml/fragment.cjs");
|
|
3
6
|
const require_xml_entities = require("../../xml/entities.cjs");
|
|
4
7
|
const require_typed_shared_units = require("../shared/units.cjs");
|
|
5
8
|
const require_typed_docx_constructs = require("./constructs.cjs");
|
|
9
|
+
const require_typed_xlsx_build = require("../xlsx/build.cjs");
|
|
6
10
|
let document_schema_js = require("document-schema.js");
|
|
7
11
|
//#region src/typed/docx/write.ts
|
|
8
12
|
const WML_NS = "http://schemas.openxmlformats.org/wordprocessingml/2006/main";
|
|
@@ -20,14 +24,18 @@ const DRAWING_PIC_NS = "http://schemas.openxmlformats.org/drawingml/2006/picture
|
|
|
20
24
|
const MARKUP_COMPAT_NS = "http://schemas.openxmlformats.org/markup-compatibility/2006";
|
|
21
25
|
const W14_NS = "http://schemas.microsoft.com/office/word/2010/wordml";
|
|
22
26
|
const W15_NS = "http://schemas.microsoft.com/office/word/2012/wordml";
|
|
27
|
+
const VML_OFFICE_NS = "urn:schemas-microsoft-com:office:office";
|
|
23
28
|
const CT_DOCUMENT = "application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml";
|
|
24
29
|
const CT_CORE_PROPS = "application/vnd.openxmlformats-package.core-properties+xml";
|
|
25
30
|
const CT_EXTENDED_PROPS = "application/vnd.openxmlformats-officedocument.extended-properties+xml";
|
|
31
|
+
const CT_EMBEDDED_DOCX = "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
|
|
32
|
+
const CT_EMBEDDED_XLSX = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
|
|
26
33
|
const REL_OFFICE_DOCUMENT = `${REL_NS}/officeDocument`;
|
|
27
34
|
const REL_CORE_PROPS = `${PKG_RELS_NS}/metadata/core-properties`;
|
|
28
35
|
const REL_EXTENDED_PROPS = `${REL_NS}/extended-properties`;
|
|
29
36
|
const REL_HYPERLINK = `${REL_NS}/hyperlink`;
|
|
30
37
|
const REL_IMAGE = `${REL_NS}/image`;
|
|
38
|
+
const REL_OLE_OBJECT = `${REL_NS}/oleObject`;
|
|
31
39
|
const DOCUMENT_PART_PATH = "word/document.xml";
|
|
32
40
|
function newWriteState() {
|
|
33
41
|
return {
|
|
@@ -35,6 +43,8 @@ function newWriteState() {
|
|
|
35
43
|
hyperlinkIds: /* @__PURE__ */ new Map(),
|
|
36
44
|
mediaIds: /* @__PURE__ */ new Map(),
|
|
37
45
|
mediaParts: /* @__PURE__ */ new Map(),
|
|
46
|
+
embeddingIds: /* @__PURE__ */ new Map(),
|
|
47
|
+
embeddingParts: /* @__PURE__ */ new Map(),
|
|
38
48
|
nextDrawingId: 1,
|
|
39
49
|
nextMarkerId: 1
|
|
40
50
|
};
|
|
@@ -297,6 +307,43 @@ function buildDrawing(image, state) {
|
|
|
297
307
|
require_xml_fragment.el("a:graphic", { "xmlns:a": DRAWINGML_NS }, [require_xml_fragment.el("a:graphicData", { uri: DRAWING_PIC_NS }, [picture])])
|
|
298
308
|
])]);
|
|
299
309
|
}
|
|
310
|
+
function embeddedPayloadOf(document) {
|
|
311
|
+
switch (document.kind) {
|
|
312
|
+
case "wordprocessing": return {
|
|
313
|
+
extension: "docx",
|
|
314
|
+
progId: "Word.Document.12",
|
|
315
|
+
base64: require_util_base64.bytesToBase64(require_codec.encodePackage(buildDocxPackageFromContent(document)))
|
|
316
|
+
};
|
|
317
|
+
case "spreadsheet": return {
|
|
318
|
+
extension: "xlsx",
|
|
319
|
+
progId: "Excel.Sheet.12",
|
|
320
|
+
base64: require_util_base64.bytesToBase64(require_codec.encodePackage(require_typed_xlsx_build.buildXlsxPackageFromContent(document)))
|
|
321
|
+
};
|
|
322
|
+
default: throw new Error(`buildDocxPackageFromContent: an embedded object carrying a ${document.kind} document has no OOXML OLE payload this writer can produce (embedded wordprocessing and spreadsheet documents serialise through their own builders; presentation is read-only in this package, and drawing/formula are ODF/MathML spellings)`);
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
function embeddedObjectRelationshipId(state, payload) {
|
|
326
|
+
const existing = state.embeddingIds.get(payload.base64);
|
|
327
|
+
if (existing !== void 0) return existing;
|
|
328
|
+
const name = `oleObject${state.embeddingParts.size + 1}.${payload.extension}`;
|
|
329
|
+
state.embeddingParts.set(name, payload);
|
|
330
|
+
const id = addRelationship(state, REL_OLE_OBJECT, `embeddings/${name}`, false);
|
|
331
|
+
state.embeddingIds.set(payload.base64, id);
|
|
332
|
+
return id;
|
|
333
|
+
}
|
|
334
|
+
function buildObjectElement(block, state) {
|
|
335
|
+
const payload = embeddedPayloadOf(block.document);
|
|
336
|
+
const relId = embeddedObjectRelationshipId(state, payload);
|
|
337
|
+
return require_xml_fragment.el("w:object", {
|
|
338
|
+
"w:dxaOrig": String(require_typed_shared_units.ptToTwips(block.frame.widthPt)),
|
|
339
|
+
"w:dyaOrig": String(require_typed_shared_units.ptToTwips(block.frame.heightPt))
|
|
340
|
+
}, [require_xml_fragment.el("o:OLEObject", {
|
|
341
|
+
Type: "Embed",
|
|
342
|
+
ProgID: payload.progId,
|
|
343
|
+
DrawAspect: "Content",
|
|
344
|
+
"r:id": relId
|
|
345
|
+
})]);
|
|
346
|
+
}
|
|
300
347
|
const TRACKED_CHANGE_TAG_BY_CHANGE = {
|
|
301
348
|
insertion: "w:ins",
|
|
302
349
|
deletion: "w:del",
|
|
@@ -357,10 +404,29 @@ function buildSdtProperties(descriptor) {
|
|
|
357
404
|
children.push(require_xml_fragment.el("w:date", descriptor.value === void 0 ? {} : { "w:fullDate": require_xml_entities.encodeXmlText(descriptor.value) }));
|
|
358
405
|
return require_xml_fragment.el("w:sdtPr", {}, children);
|
|
359
406
|
}
|
|
407
|
+
const restored = restoreGalleryElement(descriptor);
|
|
408
|
+
if (restored !== void 0) {
|
|
409
|
+
children.push(restored);
|
|
410
|
+
return require_xml_fragment.el("w:sdtPr", {}, children);
|
|
411
|
+
}
|
|
360
412
|
const typeTag = SDT_TYPE_ELEMENT[descriptor.controlType];
|
|
361
413
|
children.push(require_xml_fragment.el(typeTag ?? "w:richText"));
|
|
362
414
|
return require_xml_fragment.el("w:sdtPr", {}, children);
|
|
363
415
|
}
|
|
416
|
+
function restoreGalleryElement(descriptor) {
|
|
417
|
+
if (descriptor.controlType !== "richText") return;
|
|
418
|
+
const source = descriptor.source;
|
|
419
|
+
if (source?.format !== "docx") return;
|
|
420
|
+
let nodes;
|
|
421
|
+
try {
|
|
422
|
+
nodes = require_xml_parse.parseXml(source.xml);
|
|
423
|
+
} catch (error) {
|
|
424
|
+
throw new Error(`buildDocxPackageFromContent: a content control carries docx residue that does not parse as XML: ${source.xml}`, { cause: error });
|
|
425
|
+
}
|
|
426
|
+
const first = nodes[0];
|
|
427
|
+
if (nodes.length !== 1 || first?.type !== "element" || first.tag !== "w:docPartObj" && first.tag !== "w:docPartList") return;
|
|
428
|
+
return first;
|
|
429
|
+
}
|
|
364
430
|
function parseFlow(blocks) {
|
|
365
431
|
const imbalance = (0, document_schema_js.findConstructMarkerImbalance)(blocks);
|
|
366
432
|
if (imbalance !== void 0) throw new Error(`buildDocxPackageFromContent: construct markers do not balance (${imbalance.kind} at block ${String(imbalance.index)})`);
|
|
@@ -504,8 +570,25 @@ function buildFlowItems(items, state, deleted, provenance) {
|
|
|
504
570
|
availableImageRuns = [];
|
|
505
571
|
continue;
|
|
506
572
|
}
|
|
507
|
-
|
|
508
|
-
|
|
573
|
+
if (block.kind === "embeddedObject") {
|
|
574
|
+
if (pendingPageBreak) {
|
|
575
|
+
const breakParagraph = require_xml_fragment.el("w:p", {}, [require_xml_fragment.el("w:pPr", {}, [require_xml_fragment.el("w:pageBreakBefore")])]);
|
|
576
|
+
nodes.push(breakParagraph);
|
|
577
|
+
lastParagraph = breakParagraph;
|
|
578
|
+
availableImageRuns = [];
|
|
579
|
+
pendingPageBreak = false;
|
|
580
|
+
}
|
|
581
|
+
const object = buildObjectElement(block, state);
|
|
582
|
+
const reusable = availableImageRuns.shift();
|
|
583
|
+
if (reusable !== void 0) reusable.children.push(object);
|
|
584
|
+
else if (lastParagraph !== void 0) lastParagraph.children.push(require_xml_fragment.el("w:r", {}, [object]));
|
|
585
|
+
else {
|
|
586
|
+
const paragraph = require_xml_fragment.el("w:p", {}, [require_xml_fragment.el("w:r", {}, [object])]);
|
|
587
|
+
lastParagraph = paragraph;
|
|
588
|
+
nodes.push(paragraph);
|
|
589
|
+
}
|
|
590
|
+
continue;
|
|
591
|
+
}
|
|
509
592
|
}
|
|
510
593
|
if (pendingPageBreak) nodes.push(require_xml_fragment.el("w:p", {}, [require_xml_fragment.el("w:pPr", {}, [require_xml_fragment.el("w:pageBreakBefore")])]));
|
|
511
594
|
return nodes;
|
|
@@ -555,12 +638,14 @@ function buildDocumentPart(sections, state) {
|
|
|
555
638
|
"xmlns:wp": DRAWING_WP_NS,
|
|
556
639
|
"xmlns:pic": DRAWING_PIC_NS,
|
|
557
640
|
"xmlns:mc": MARKUP_COMPAT_NS,
|
|
641
|
+
"xmlns:o": VML_OFFICE_NS,
|
|
558
642
|
"xmlns:w14": W14_NS,
|
|
559
643
|
"xmlns:w15": W15_NS,
|
|
560
644
|
"mc:Ignorable": "w14 w15"
|
|
561
645
|
}, [require_xml_fragment.el("w:body", {}, bodyChildren)]));
|
|
562
646
|
}
|
|
563
|
-
function buildContentTypesPart(
|
|
647
|
+
function buildContentTypesPart(state) {
|
|
648
|
+
const mediaFormats = new Set([...state.mediaParts.values()].map((media) => media.format));
|
|
564
649
|
const defaults = [require_xml_fragment.el("Default", {
|
|
565
650
|
Extension: "rels",
|
|
566
651
|
ContentType: "application/vnd.openxmlformats-package.relationships+xml"
|
|
@@ -576,6 +661,10 @@ function buildContentTypesPart(mediaFormats) {
|
|
|
576
661
|
Extension: "jpeg",
|
|
577
662
|
ContentType: "image/jpeg"
|
|
578
663
|
}));
|
|
664
|
+
const embeddingOverrides = [...state.embeddingParts].map(([name, payload]) => require_xml_fragment.el("Override", {
|
|
665
|
+
PartName: `/word/embeddings/${name}`,
|
|
666
|
+
ContentType: payload.extension === "docx" ? CT_EMBEDDED_DOCX : CT_EMBEDDED_XLSX
|
|
667
|
+
}));
|
|
579
668
|
return xmlPart(require_xml_fragment.el("Types", { xmlns: CONTENT_TYPES_NS }, [
|
|
580
669
|
...defaults,
|
|
581
670
|
require_xml_fragment.el("Override", {
|
|
@@ -589,7 +678,8 @@ function buildContentTypesPart(mediaFormats) {
|
|
|
589
678
|
require_xml_fragment.el("Override", {
|
|
590
679
|
PartName: "/docProps/app.xml",
|
|
591
680
|
ContentType: CT_EXTENDED_PROPS
|
|
592
|
-
})
|
|
681
|
+
}),
|
|
682
|
+
...embeddingOverrides
|
|
593
683
|
]));
|
|
594
684
|
}
|
|
595
685
|
function buildPackageRelsPart() {
|
|
@@ -661,7 +751,7 @@ function buildDocxPackageFromContent(content) {
|
|
|
661
751
|
}] : content.sections, state);
|
|
662
752
|
const metadata = content.metadata ?? {};
|
|
663
753
|
const parts = {
|
|
664
|
-
"[Content_Types].xml": buildContentTypesPart(
|
|
754
|
+
"[Content_Types].xml": buildContentTypesPart(state),
|
|
665
755
|
"_rels/.rels": buildPackageRelsPart(),
|
|
666
756
|
[DOCUMENT_PART_PATH]: documentPart,
|
|
667
757
|
"word/_rels/document.xml.rels": buildDocumentRelsPart(state),
|
|
@@ -672,6 +762,10 @@ function buildDocxPackageFromContent(content) {
|
|
|
672
762
|
kind: "binary",
|
|
673
763
|
base64: media.base64
|
|
674
764
|
};
|
|
765
|
+
for (const [name, payload] of state.embeddingParts) parts[`word/embeddings/${name}`] = {
|
|
766
|
+
kind: "binary",
|
|
767
|
+
base64: payload.base64
|
|
768
|
+
};
|
|
675
769
|
return { parts };
|
|
676
770
|
}
|
|
677
771
|
//#endregion
|
package/dist/typed/docx/write.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
|
+
import { bytesToBase64 } from "../../util/base64.js";
|
|
2
|
+
import { parseXml } from "../../xml/parse.js";
|
|
3
|
+
import { encodePackage } from "../../codec.js";
|
|
1
4
|
import { el, txt } from "../../xml/fragment.js";
|
|
2
5
|
import { encodeXmlText } from "../../xml/entities.js";
|
|
3
6
|
import { ptToEighthPoints, ptToEmu, ptToHalfPoints, ptToTwips } from "../shared/units.js";
|
|
4
7
|
import { TABLE_OF_CONTENTS_GALLERY, isDeletedChange } from "./constructs.js";
|
|
8
|
+
import { buildXlsxPackageFromContent } from "../xlsx/build.js";
|
|
5
9
|
import { colorToRgbHex, findConstructMarkerImbalance } from "document-schema.js";
|
|
6
10
|
//#region src/typed/docx/write.ts
|
|
7
11
|
const WML_NS = "http://schemas.openxmlformats.org/wordprocessingml/2006/main";
|
|
@@ -19,14 +23,18 @@ const DRAWING_PIC_NS = "http://schemas.openxmlformats.org/drawingml/2006/picture
|
|
|
19
23
|
const MARKUP_COMPAT_NS = "http://schemas.openxmlformats.org/markup-compatibility/2006";
|
|
20
24
|
const W14_NS = "http://schemas.microsoft.com/office/word/2010/wordml";
|
|
21
25
|
const W15_NS = "http://schemas.microsoft.com/office/word/2012/wordml";
|
|
26
|
+
const VML_OFFICE_NS = "urn:schemas-microsoft-com:office:office";
|
|
22
27
|
const CT_DOCUMENT = "application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml";
|
|
23
28
|
const CT_CORE_PROPS = "application/vnd.openxmlformats-package.core-properties+xml";
|
|
24
29
|
const CT_EXTENDED_PROPS = "application/vnd.openxmlformats-officedocument.extended-properties+xml";
|
|
30
|
+
const CT_EMBEDDED_DOCX = "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
|
|
31
|
+
const CT_EMBEDDED_XLSX = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
|
|
25
32
|
const REL_OFFICE_DOCUMENT = `${REL_NS}/officeDocument`;
|
|
26
33
|
const REL_CORE_PROPS = `${PKG_RELS_NS}/metadata/core-properties`;
|
|
27
34
|
const REL_EXTENDED_PROPS = `${REL_NS}/extended-properties`;
|
|
28
35
|
const REL_HYPERLINK = `${REL_NS}/hyperlink`;
|
|
29
36
|
const REL_IMAGE = `${REL_NS}/image`;
|
|
37
|
+
const REL_OLE_OBJECT = `${REL_NS}/oleObject`;
|
|
30
38
|
const DOCUMENT_PART_PATH = "word/document.xml";
|
|
31
39
|
function newWriteState() {
|
|
32
40
|
return {
|
|
@@ -34,6 +42,8 @@ function newWriteState() {
|
|
|
34
42
|
hyperlinkIds: /* @__PURE__ */ new Map(),
|
|
35
43
|
mediaIds: /* @__PURE__ */ new Map(),
|
|
36
44
|
mediaParts: /* @__PURE__ */ new Map(),
|
|
45
|
+
embeddingIds: /* @__PURE__ */ new Map(),
|
|
46
|
+
embeddingParts: /* @__PURE__ */ new Map(),
|
|
37
47
|
nextDrawingId: 1,
|
|
38
48
|
nextMarkerId: 1
|
|
39
49
|
};
|
|
@@ -296,6 +306,43 @@ function buildDrawing(image, state) {
|
|
|
296
306
|
el("a:graphic", { "xmlns:a": DRAWINGML_NS }, [el("a:graphicData", { uri: DRAWING_PIC_NS }, [picture])])
|
|
297
307
|
])]);
|
|
298
308
|
}
|
|
309
|
+
function embeddedPayloadOf(document) {
|
|
310
|
+
switch (document.kind) {
|
|
311
|
+
case "wordprocessing": return {
|
|
312
|
+
extension: "docx",
|
|
313
|
+
progId: "Word.Document.12",
|
|
314
|
+
base64: bytesToBase64(encodePackage(buildDocxPackageFromContent(document)))
|
|
315
|
+
};
|
|
316
|
+
case "spreadsheet": return {
|
|
317
|
+
extension: "xlsx",
|
|
318
|
+
progId: "Excel.Sheet.12",
|
|
319
|
+
base64: bytesToBase64(encodePackage(buildXlsxPackageFromContent(document)))
|
|
320
|
+
};
|
|
321
|
+
default: throw new Error(`buildDocxPackageFromContent: an embedded object carrying a ${document.kind} document has no OOXML OLE payload this writer can produce (embedded wordprocessing and spreadsheet documents serialise through their own builders; presentation is read-only in this package, and drawing/formula are ODF/MathML spellings)`);
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
function embeddedObjectRelationshipId(state, payload) {
|
|
325
|
+
const existing = state.embeddingIds.get(payload.base64);
|
|
326
|
+
if (existing !== void 0) return existing;
|
|
327
|
+
const name = `oleObject${state.embeddingParts.size + 1}.${payload.extension}`;
|
|
328
|
+
state.embeddingParts.set(name, payload);
|
|
329
|
+
const id = addRelationship(state, REL_OLE_OBJECT, `embeddings/${name}`, false);
|
|
330
|
+
state.embeddingIds.set(payload.base64, id);
|
|
331
|
+
return id;
|
|
332
|
+
}
|
|
333
|
+
function buildObjectElement(block, state) {
|
|
334
|
+
const payload = embeddedPayloadOf(block.document);
|
|
335
|
+
const relId = embeddedObjectRelationshipId(state, payload);
|
|
336
|
+
return el("w:object", {
|
|
337
|
+
"w:dxaOrig": String(ptToTwips(block.frame.widthPt)),
|
|
338
|
+
"w:dyaOrig": String(ptToTwips(block.frame.heightPt))
|
|
339
|
+
}, [el("o:OLEObject", {
|
|
340
|
+
Type: "Embed",
|
|
341
|
+
ProgID: payload.progId,
|
|
342
|
+
DrawAspect: "Content",
|
|
343
|
+
"r:id": relId
|
|
344
|
+
})]);
|
|
345
|
+
}
|
|
299
346
|
const TRACKED_CHANGE_TAG_BY_CHANGE = {
|
|
300
347
|
insertion: "w:ins",
|
|
301
348
|
deletion: "w:del",
|
|
@@ -356,10 +403,29 @@ function buildSdtProperties(descriptor) {
|
|
|
356
403
|
children.push(el("w:date", descriptor.value === void 0 ? {} : { "w:fullDate": encodeXmlText(descriptor.value) }));
|
|
357
404
|
return el("w:sdtPr", {}, children);
|
|
358
405
|
}
|
|
406
|
+
const restored = restoreGalleryElement(descriptor);
|
|
407
|
+
if (restored !== void 0) {
|
|
408
|
+
children.push(restored);
|
|
409
|
+
return el("w:sdtPr", {}, children);
|
|
410
|
+
}
|
|
359
411
|
const typeTag = SDT_TYPE_ELEMENT[descriptor.controlType];
|
|
360
412
|
children.push(el(typeTag ?? "w:richText"));
|
|
361
413
|
return el("w:sdtPr", {}, children);
|
|
362
414
|
}
|
|
415
|
+
function restoreGalleryElement(descriptor) {
|
|
416
|
+
if (descriptor.controlType !== "richText") return;
|
|
417
|
+
const source = descriptor.source;
|
|
418
|
+
if (source?.format !== "docx") return;
|
|
419
|
+
let nodes;
|
|
420
|
+
try {
|
|
421
|
+
nodes = parseXml(source.xml);
|
|
422
|
+
} catch (error) {
|
|
423
|
+
throw new Error(`buildDocxPackageFromContent: a content control carries docx residue that does not parse as XML: ${source.xml}`, { cause: error });
|
|
424
|
+
}
|
|
425
|
+
const first = nodes[0];
|
|
426
|
+
if (nodes.length !== 1 || first?.type !== "element" || first.tag !== "w:docPartObj" && first.tag !== "w:docPartList") return;
|
|
427
|
+
return first;
|
|
428
|
+
}
|
|
363
429
|
function parseFlow(blocks) {
|
|
364
430
|
const imbalance = findConstructMarkerImbalance(blocks);
|
|
365
431
|
if (imbalance !== void 0) throw new Error(`buildDocxPackageFromContent: construct markers do not balance (${imbalance.kind} at block ${String(imbalance.index)})`);
|
|
@@ -503,8 +569,25 @@ function buildFlowItems(items, state, deleted, provenance) {
|
|
|
503
569
|
availableImageRuns = [];
|
|
504
570
|
continue;
|
|
505
571
|
}
|
|
506
|
-
|
|
507
|
-
|
|
572
|
+
if (block.kind === "embeddedObject") {
|
|
573
|
+
if (pendingPageBreak) {
|
|
574
|
+
const breakParagraph = el("w:p", {}, [el("w:pPr", {}, [el("w:pageBreakBefore")])]);
|
|
575
|
+
nodes.push(breakParagraph);
|
|
576
|
+
lastParagraph = breakParagraph;
|
|
577
|
+
availableImageRuns = [];
|
|
578
|
+
pendingPageBreak = false;
|
|
579
|
+
}
|
|
580
|
+
const object = buildObjectElement(block, state);
|
|
581
|
+
const reusable = availableImageRuns.shift();
|
|
582
|
+
if (reusable !== void 0) reusable.children.push(object);
|
|
583
|
+
else if (lastParagraph !== void 0) lastParagraph.children.push(el("w:r", {}, [object]));
|
|
584
|
+
else {
|
|
585
|
+
const paragraph = el("w:p", {}, [el("w:r", {}, [object])]);
|
|
586
|
+
lastParagraph = paragraph;
|
|
587
|
+
nodes.push(paragraph);
|
|
588
|
+
}
|
|
589
|
+
continue;
|
|
590
|
+
}
|
|
508
591
|
}
|
|
509
592
|
if (pendingPageBreak) nodes.push(el("w:p", {}, [el("w:pPr", {}, [el("w:pageBreakBefore")])]));
|
|
510
593
|
return nodes;
|
|
@@ -554,12 +637,14 @@ function buildDocumentPart(sections, state) {
|
|
|
554
637
|
"xmlns:wp": DRAWING_WP_NS,
|
|
555
638
|
"xmlns:pic": DRAWING_PIC_NS,
|
|
556
639
|
"xmlns:mc": MARKUP_COMPAT_NS,
|
|
640
|
+
"xmlns:o": VML_OFFICE_NS,
|
|
557
641
|
"xmlns:w14": W14_NS,
|
|
558
642
|
"xmlns:w15": W15_NS,
|
|
559
643
|
"mc:Ignorable": "w14 w15"
|
|
560
644
|
}, [el("w:body", {}, bodyChildren)]));
|
|
561
645
|
}
|
|
562
|
-
function buildContentTypesPart(
|
|
646
|
+
function buildContentTypesPart(state) {
|
|
647
|
+
const mediaFormats = new Set([...state.mediaParts.values()].map((media) => media.format));
|
|
563
648
|
const defaults = [el("Default", {
|
|
564
649
|
Extension: "rels",
|
|
565
650
|
ContentType: "application/vnd.openxmlformats-package.relationships+xml"
|
|
@@ -575,6 +660,10 @@ function buildContentTypesPart(mediaFormats) {
|
|
|
575
660
|
Extension: "jpeg",
|
|
576
661
|
ContentType: "image/jpeg"
|
|
577
662
|
}));
|
|
663
|
+
const embeddingOverrides = [...state.embeddingParts].map(([name, payload]) => el("Override", {
|
|
664
|
+
PartName: `/word/embeddings/${name}`,
|
|
665
|
+
ContentType: payload.extension === "docx" ? CT_EMBEDDED_DOCX : CT_EMBEDDED_XLSX
|
|
666
|
+
}));
|
|
578
667
|
return xmlPart(el("Types", { xmlns: CONTENT_TYPES_NS }, [
|
|
579
668
|
...defaults,
|
|
580
669
|
el("Override", {
|
|
@@ -588,7 +677,8 @@ function buildContentTypesPart(mediaFormats) {
|
|
|
588
677
|
el("Override", {
|
|
589
678
|
PartName: "/docProps/app.xml",
|
|
590
679
|
ContentType: CT_EXTENDED_PROPS
|
|
591
|
-
})
|
|
680
|
+
}),
|
|
681
|
+
...embeddingOverrides
|
|
592
682
|
]));
|
|
593
683
|
}
|
|
594
684
|
function buildPackageRelsPart() {
|
|
@@ -660,7 +750,7 @@ function buildDocxPackageFromContent(content) {
|
|
|
660
750
|
}] : content.sections, state);
|
|
661
751
|
const metadata = content.metadata ?? {};
|
|
662
752
|
const parts = {
|
|
663
|
-
"[Content_Types].xml": buildContentTypesPart(
|
|
753
|
+
"[Content_Types].xml": buildContentTypesPart(state),
|
|
664
754
|
"_rels/.rels": buildPackageRelsPart(),
|
|
665
755
|
[DOCUMENT_PART_PATH]: documentPart,
|
|
666
756
|
"word/_rels/document.xml.rels": buildDocumentRelsPart(state),
|
|
@@ -671,6 +761,10 @@ function buildDocxPackageFromContent(content) {
|
|
|
671
761
|
kind: "binary",
|
|
672
762
|
base64: media.base64
|
|
673
763
|
};
|
|
764
|
+
for (const [name, payload] of state.embeddingParts) parts[`word/embeddings/${name}`] = {
|
|
765
|
+
kind: "binary",
|
|
766
|
+
base64: payload.base64
|
|
767
|
+
};
|
|
674
768
|
return { parts };
|
|
675
769
|
}
|
|
676
770
|
//#endregion
|
package/dist/typed/embedded.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_read = require("../read-
|
|
2
|
+
const require_read = require("../read-C3AaxcT9.cjs");
|
|
3
3
|
exports.readEmbeddedOoxmlPayload = require_read.readEmbeddedOoxmlPayload;
|
|
4
4
|
exports.readEmbeddedPayloadPart = require_read.readEmbeddedPayloadPart;
|
package/dist/typed/embedded.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as readEmbeddedOoxmlPayload, o as readEmbeddedPayloadPart } from "../read-
|
|
1
|
+
import { a as readEmbeddedOoxmlPayload, o as readEmbeddedPayloadPart } from "../read-fuJpC4BH.js";
|
|
2
2
|
export { readEmbeddedOoxmlPayload, readEmbeddedPayloadPart };
|
package/dist/typed/pptx/read.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_read = require("../../read-
|
|
2
|
+
const require_read = require("../../read-C3AaxcT9.cjs");
|
|
3
3
|
exports.PptxDocumentSchema = require_read.PptxDocumentSchema;
|
|
4
4
|
exports.readPptxContent = require_read.readPptxContent;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as PptxDocumentSchema, r as readPptxContent, t as PptxDocument } from "../../read-
|
|
1
|
+
import { n as PptxDocumentSchema, r as readPptxContent, t as PptxDocument } from "../../read-BoV9SZy4.cjs";
|
|
2
2
|
export { PptxDocument, PptxDocumentSchema, readPptxContent };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as PptxDocumentSchema, r as readPptxContent, t as PptxDocument } from "../../read-
|
|
1
|
+
import { n as PptxDocumentSchema, r as readPptxContent, t as PptxDocument } from "../../read-ZWJPDvG-.js";
|
|
2
2
|
export { PptxDocument, PptxDocumentSchema, readPptxContent };
|
package/dist/typed/pptx/read.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { c as readPptxContent, s as PptxDocumentSchema } from "../../read-
|
|
1
|
+
import { c as readPptxContent, s as PptxDocumentSchema } from "../../read-fuJpC4BH.js";
|
|
2
2
|
export { PptxDocumentSchema, readPptxContent };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ooxml.js",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.2.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": {
|
|
@@ -80,7 +80,7 @@
|
|
|
80
80
|
"license": "MIT",
|
|
81
81
|
"packageManager": "pnpm@11.6.0",
|
|
82
82
|
"dependencies": {
|
|
83
|
-
"archive-codec": "^1.0
|
|
83
|
+
"archive-codec": "^1.1.0",
|
|
84
84
|
"document-schema.js": "^4.3.7",
|
|
85
85
|
"fast-xml-parser": "^5.10.1",
|
|
86
86
|
"fflate": "^0.8.3",
|