@office-open/docx 0.3.0 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,10 +1,10 @@
1
1
  import { n as __reExport, t as __exportAll } from "./_chunks/chunk-DmsbSTSH.mjs";
2
- import { AppProperties, BaseXmlComponent, BuilderElement, BuilderElement as BuilderElement$1, EMPTY_OBJECT, EmptyElement, Formatter, HpsMeasureElement, IgnoreIfEmptyXmlComponent, ImportedRootElementAttributes, ImportedXmlComponent, InitializableXmlComponent, NextAttributeComponent, NumberValueElement, OnOffElement, Relationships, StringContainer, StringEnumValueElement, StringValueElement, TargetModeType, XmlAttributeComponent, XmlAttributeComponent as XmlAttributeComponent$1, XmlComponent, chartAttr, convertInchesToTwip, convertMillimetersToTwip, convertPixelsToEmu, convertToXmlComponent, getImageType, hashedId, hpsMeasureObj, numberValObj, onOffObj, parseCoreProperties, parseRels, readXmlFromZip, stringEnumValObj, stringValObj, uint8ToBase64, uniqueId, uniqueNumericIdCreator, uniqueNumericIdCreator as uniqueNumericIdCreator$1, uniqueUuid, unzipToMap, wrapEl } from "@office-open/core";
2
+ import { AppProperties, BaseXmlComponent, BuilderElement, BuilderElement as BuilderElement$1, EMPTY_OBJECT, EmptyElement, Formatter, HpsMeasureElement, IgnoreIfEmptyXmlComponent, ImportedRootElementAttributes, ImportedXmlComponent, InitializableXmlComponent, NextAttributeComponent, NumberValueElement, OnOffElement, RawPassthrough, Relationships, StringContainer, StringEnumValueElement, StringValueElement, TargetModeType, XmlAttributeComponent, XmlAttributeComponent as XmlAttributeComponent$1, XmlComponent, chartAttr, convertInchesToTwip, convertMillimetersToTwip, convertPixelsToEmu, convertToXmlComponent, getImageType, hasPlaceholders, hashedId, hpsMeasureObj, isRaw, numberValObj, onOffObj, parseCoreProperties, parseRels, readAllXmlParts, readXmlFromZip, stringEnumValObj, stringValObj, uint8ToBase64, uniqueId, uniqueNumericIdCreator, uniqueNumericIdCreator as uniqueNumericIdCreator$1, uniqueUuid, unzipToMap, wrapEl } from "@office-open/core";
3
3
  import { textToUint8Array, toUint8Array } from "undio";
4
4
  import { PresetGeometry, buildFill, createBlipFill, createCustomGeometry, createEffectDag, createEffectList, createOutline, createScene3D, createShape3D, extractBlipFillMedia } from "@office-open/core/drawingml";
5
5
  import { ChartCollection, ChartTitle, createChartType } from "@office-open/core/chart";
6
6
  import { COLOR_CATEGORIES, COLOR_CATEGORIES as COLOR_CATEGORIES$1, LAYOUT_CATEGORIES, LAYOUT_CATEGORIES as LAYOUT_CATEGORIES$1, STYLE_CATEGORIES, STYLE_CATEGORIES as STYLE_CATEGORIES$1, SmartArtCollection, createDataModel } from "@office-open/core/smartart";
7
- import { attr, attrNum, children, findChild, findDeep, js2xml, textOf, xml, xml2js } from "@office-open/xml";
7
+ import { attr, attrNum, children, colorAttr, findChild, findDeep, js2xml, textOf, xml, xml2js } from "@office-open/xml";
8
8
  import { Readable } from "stream";
9
9
  import { Zip, ZipDeflate, ZipPassThrough, strFromU8, unzipSync, zipSync } from "fflate";
10
10
  export * from "@office-open/core/values";
@@ -2042,8 +2042,9 @@ var RunProperties = class extends IgnoreIfEmptyXmlComponent {
2042
2042
  const szCs = options.sizeComplexScript === void 0 || options.sizeComplexScript === true ? options.size : options.sizeComplexScript;
2043
2043
  if (szCs) this.push(new HpsMeasureElement("w:szCs", szCs));
2044
2044
  if (options.highlight) this.push(new Highlight(options.highlight));
2045
- const highlightCs = options.highlightComplexScript === void 0 || options.highlightComplexScript === true ? options.highlight : options.highlightComplexScript;
2046
- if (highlightCs) this.push(new HighlightComplexScript(highlightCs));
2045
+ if (options.highlightComplexScript === true) {
2046
+ if (options.highlight) this.push(new HighlightComplexScript(options.highlight));
2047
+ } else if (options.highlightComplexScript !== void 0 && options.highlightComplexScript !== false) this.push(new HighlightComplexScript(options.highlightComplexScript));
2047
2048
  if (options.underline) this.push(createUnderline(options.underline.type, options.underline.color));
2048
2049
  if (options.effect) this.push(new StringValueElement("w:effect", options.effect));
2049
2050
  if (options.border) this.push(createBorderElement("w:bdr", options.border));
@@ -2125,8 +2126,9 @@ function buildRunProperties(options) {
2125
2126
  const szCs = options.sizeComplexScript === void 0 || options.sizeComplexScript === true ? options.size : options.sizeComplexScript;
2126
2127
  if (szCs) children.push(hpsMeasureObj("w:szCs", szCs));
2127
2128
  if (options.highlight) children.push(new Highlight(options.highlight).prepForXml(EMPTY_CTX));
2128
- const highlightCs = options.highlightComplexScript === void 0 || options.highlightComplexScript === true ? options.highlight : options.highlightComplexScript;
2129
- if (highlightCs) children.push(new HighlightComplexScript(highlightCs).prepForXml(EMPTY_CTX));
2129
+ if (options.highlightComplexScript === true) {
2130
+ if (options.highlight) children.push(new HighlightComplexScript(options.highlight).prepForXml(EMPTY_CTX));
2131
+ } else if (options.highlightComplexScript !== void 0 && options.highlightComplexScript !== false) children.push(new HighlightComplexScript(options.highlightComplexScript).prepForXml(EMPTY_CTX));
2130
2132
  if (options.underline) children.push(createUnderline(options.underline.type, options.underline.color).prepForXml(EMPTY_CTX));
2131
2133
  if (options.effect) children.push(stringValObj("w:effect", options.effect));
2132
2134
  if (options.border) children.push(createBorderElement("w:bdr", options.border).prepForXml(EMPTY_CTX));
@@ -22719,9 +22721,9 @@ var Compiler = class {
22719
22721
  },
22720
22722
  indent: prettify
22721
22723
  });
22722
- const documentMediaDatas = this.imageReplacer.getMediaData(documentXmlData, file.Media);
22723
- const commentMediaDatas = this.imageReplacer.getMediaData(commentXmlData, file.Media);
22724
- const footnoteMediaDatas = this.imageReplacer.getMediaData(footnoteXmlData, file.Media);
22724
+ const documentMediaDatas = hasPlaceholders(documentXmlData) ? this.imageReplacer.getMediaData(documentXmlData, file.Media) : [];
22725
+ const commentMediaDatas = hasPlaceholders(commentXmlData) ? this.imageReplacer.getMediaData(commentXmlData, file.Media) : [];
22726
+ const footnoteMediaDatas = hasPlaceholders(footnoteXmlData) ? this.imageReplacer.getMediaData(footnoteXmlData, file.Media) : [];
22725
22727
  return {
22726
22728
  AppProperties: {
22727
22729
  data: xml(this.formatter.format(file.AppProperties, {
@@ -22740,7 +22742,7 @@ var Compiler = class {
22740
22742
  },
22741
22743
  Comments: {
22742
22744
  data: (() => {
22743
- const xmlData = this.imageReplacer.replace(commentXmlData, commentMediaDatas, commentRelationshipCount);
22745
+ const xmlData = commentMediaDatas.length > 0 ? this.imageReplacer.replace(commentXmlData, commentMediaDatas, commentRelationshipCount) : commentXmlData;
22744
22746
  return this.numberingReplacer.replace(xmlData, file.Numbering.ConcreteNumbering);
22745
22747
  })(),
22746
22748
  path: "word/comments.xml"
@@ -22806,10 +22808,12 @@ var Compiler = class {
22806
22808
  },
22807
22809
  Document: {
22808
22810
  data: (() => {
22809
- let xmlData = this.imageReplacer.replace(documentXmlData, documentMediaDatas, documentRelationshipCount);
22810
- xmlData = this.chartReplacer.replace(xmlData, file.Charts, documentRelationshipCount);
22811
- const smartArtDataOffset = documentRelationshipCount + documentMediaDatas.length + file.Charts.Array.length;
22812
- xmlData = this.smartArtReplacer.replace(xmlData, file.SmartArts, smartArtDataOffset);
22811
+ let xmlData = documentMediaDatas.length > 0 ? this.imageReplacer.replace(documentXmlData, documentMediaDatas, documentRelationshipCount) : documentXmlData;
22812
+ if (hasPlaceholders(xmlData)) {
22813
+ xmlData = this.chartReplacer.replace(xmlData, file.Charts, documentRelationshipCount);
22814
+ const smartArtDataOffset = documentRelationshipCount + documentMediaDatas.length + file.Charts.Array.length;
22815
+ xmlData = this.smartArtReplacer.replace(xmlData, file.SmartArts, smartArtDataOffset);
22816
+ }
22813
22817
  return this.numberingReplacer.replace(xmlData, file.Numbering.ConcreteNumbering);
22814
22818
  })(),
22815
22819
  path: "word/document.xml"
@@ -22879,7 +22883,7 @@ var Compiler = class {
22879
22883
  },
22880
22884
  FootNotes: {
22881
22885
  data: (() => {
22882
- const xmlData = this.imageReplacer.replace(footnoteXmlData, footnoteMediaDatas, footnoteRelationshipCount);
22886
+ const xmlData = footnoteMediaDatas.length > 0 ? this.imageReplacer.replace(footnoteXmlData, footnoteMediaDatas, footnoteRelationshipCount) : footnoteXmlData;
22883
22887
  return this.numberingReplacer.replace(xmlData, file.Numbering.ConcreteNumbering);
22884
22888
  })(),
22885
22889
  path: "word/footnotes.xml"
@@ -22930,8 +22934,8 @@ var Compiler = class {
22930
22934
  }),
22931
22935
  Footers: file.Footers.map((_footerWrapper, index) => {
22932
22936
  const tempXmlData = footerFormattedViews.get(index);
22933
- const mediaDatas = this.imageReplacer.getMediaData(tempXmlData, file.Media);
22934
- const xmlData = this.imageReplacer.replace(tempXmlData, mediaDatas, 0);
22937
+ const mediaDatas = hasPlaceholders(tempXmlData) ? this.imageReplacer.getMediaData(tempXmlData, file.Media) : [];
22938
+ const xmlData = mediaDatas.length > 0 ? this.imageReplacer.replace(tempXmlData, mediaDatas, 0) : tempXmlData;
22935
22939
  return {
22936
22940
  data: this.numberingReplacer.replace(xmlData, file.Numbering.ConcreteNumbering),
22937
22941
  path: `word/footer${index + 1}.xml`
@@ -22966,8 +22970,8 @@ var Compiler = class {
22966
22970
  }),
22967
22971
  Headers: file.Headers.map((_headerWrapper, index) => {
22968
22972
  const tempXmlData = headerFormattedViews.get(index);
22969
- const mediaDatas = this.imageReplacer.getMediaData(tempXmlData, file.Media);
22970
- const xmlData = this.imageReplacer.replace(tempXmlData, mediaDatas, 0);
22973
+ const mediaDatas = hasPlaceholders(tempXmlData) ? this.imageReplacer.getMediaData(tempXmlData, file.Media) : [];
22974
+ const xmlData = mediaDatas.length > 0 ? this.imageReplacer.replace(tempXmlData, mediaDatas, 0) : tempXmlData;
22971
22975
  return {
22972
22976
  data: this.numberingReplacer.replace(xmlData, file.Numbering.ConcreteNumbering),
22973
22977
  path: `word/header${index + 1}.xml`
@@ -24130,32 +24134,212 @@ function createDocxParseContext(zip) {
24130
24134
  const hyperlinks = /* @__PURE__ */ new Map();
24131
24135
  const media = /* @__PURE__ */ new Map();
24132
24136
  const documentRels = /* @__PURE__ */ new Map();
24137
+ const mediaPaths = /* @__PURE__ */ new Set();
24133
24138
  const rels = parseRels(zip, "word/_rels/document.xml.rels");
24134
24139
  for (const rel of rels) {
24135
24140
  documentRels.set(rel.id, rel);
24136
24141
  if (rel.targetMode === "External" || rel.type.includes("hyperlink")) hyperlinks.set(rel.id, rel.target);
24137
24142
  }
24138
- for (const [path, data] of zip) if (path.startsWith("word/media/")) {
24139
- const fileName = path.split("/").pop() ?? path;
24140
- media.set(path, {
24141
- data: uint8ToBase64(data),
24142
- type: getImageType(fileName)
24143
- });
24144
- }
24143
+ for (const path of zip.keys()) if (path.startsWith("word/media/")) mediaPaths.add(path);
24145
24144
  return {
24146
24145
  zip,
24147
24146
  hyperlinks,
24148
24147
  media,
24149
- documentRels
24148
+ documentRels,
24149
+ mediaPaths
24150
24150
  };
24151
24151
  }
24152
+ function getMediaData(ctx, path) {
24153
+ let entry = ctx.media.get(path);
24154
+ if (entry) return entry;
24155
+ const raw = ctx.zip.get(path);
24156
+ if (!raw || !ctx.mediaPaths.has(path)) return void 0;
24157
+ const fileName = path.split("/").pop() ?? path;
24158
+ entry = {
24159
+ data: uint8ToBase64(raw),
24160
+ type: getImageType(fileName)
24161
+ };
24162
+ ctx.media.set(path, entry);
24163
+ return entry;
24164
+ }
24165
+ //#endregion
24166
+ //#region src/parse/numbering.ts
24167
+ function parseNumbering(zip) {
24168
+ const xml = readXmlFromZip(zip, "word/numbering.xml");
24169
+ if (!xml) return {
24170
+ abstractNums: [],
24171
+ nums: []
24172
+ };
24173
+ const abstractNums = [];
24174
+ const nums = [];
24175
+ for (const child of xml.elements ?? []) if (child.name === "w:abstractNum") {
24176
+ const id = attr(child, "w:abstractNumId");
24177
+ if (id !== void 0) abstractNums.push({
24178
+ id,
24179
+ levels: parseLevels(child)
24180
+ });
24181
+ } else if (child.name === "w:num") {
24182
+ const numId = attr(child, "w:numId");
24183
+ const abstractNumIdEl = findChild(child, "w:abstractNumId");
24184
+ const abstractNumId = abstractNumIdEl ? attr(abstractNumIdEl, "w:val") : void 0;
24185
+ if (numId !== void 0 && abstractNumId !== void 0) nums.push({
24186
+ numId,
24187
+ abstractNumId,
24188
+ levelOverrides: parseLevelOverrides(child)
24189
+ });
24190
+ }
24191
+ return {
24192
+ abstractNums,
24193
+ nums
24194
+ };
24195
+ }
24196
+ function parseLevels(abstractNum) {
24197
+ const levels = [];
24198
+ for (const child of abstractNum.elements ?? []) if (child.name === "w:lvl") {
24199
+ const level = parseLevel(child);
24200
+ if (level) levels.push(level);
24201
+ }
24202
+ return levels;
24203
+ }
24204
+ function parseLevel(lvl) {
24205
+ const result = { level: attrNum(lvl, "w:ilvl") ?? 0 };
24206
+ const numFmt = findChild(lvl, "w:numFmt");
24207
+ if (numFmt) {
24208
+ const val = attr(numFmt, "w:val");
24209
+ if (val) result.format = val;
24210
+ }
24211
+ const lvlText = findChild(lvl, "w:lvlText");
24212
+ if (lvlText) {
24213
+ const val = attr(lvlText, "w:val");
24214
+ if (val) result.text = val;
24215
+ }
24216
+ const lvlJc = findChild(lvl, "w:lvlJc");
24217
+ if (lvlJc) {
24218
+ const val = attr(lvlJc, "w:val");
24219
+ if (val) result.alignment = val;
24220
+ }
24221
+ const start = findChild(lvl, "w:start");
24222
+ if (start) {
24223
+ const val = attrNum(start, "w:val");
24224
+ if (val !== void 0) result.start = val;
24225
+ }
24226
+ const suff = findChild(lvl, "w:suff");
24227
+ if (suff) {
24228
+ const val = attr(suff, "w:val");
24229
+ if (val) result.suffix = val;
24230
+ }
24231
+ const isLgl = findChild(lvl, "w:isLgl");
24232
+ if (isLgl) {
24233
+ const val = attr(isLgl, "w:val");
24234
+ if (val === "1" || val === "true") result.isLegalNumberingStyle = true;
24235
+ }
24236
+ const pPr = findChild(lvl, "w:pPr");
24237
+ if (pPr) {
24238
+ const ind = findChild(pPr, "w:ind");
24239
+ if (ind) {
24240
+ const left = attrNum(ind, "w:left");
24241
+ const hanging = attrNum(ind, "w:hanging");
24242
+ if (left !== void 0 || hanging !== void 0) {
24243
+ if (!result.style) result.style = {};
24244
+ result.style.paragraph = {};
24245
+ if (left !== void 0) result.style.paragraph.indent = {
24246
+ ...result.style.paragraph.indent,
24247
+ left
24248
+ };
24249
+ if (hanging !== void 0) result.style.paragraph.indent = {
24250
+ ...result.style.paragraph.indent,
24251
+ hanging
24252
+ };
24253
+ }
24254
+ }
24255
+ }
24256
+ return result;
24257
+ }
24258
+ function parseLevelOverrides(num) {
24259
+ const overrides = [];
24260
+ for (const child of num.elements ?? []) if (child.name === "w:lvlOverride") {
24261
+ const ilvl = attrNum(child, "w:ilvl");
24262
+ const startOverride = findChild(child, "w:startOverride");
24263
+ const start = startOverride ? attrNum(startOverride, "w:val") : void 0;
24264
+ if (ilvl !== void 0) overrides.push({
24265
+ ilvl,
24266
+ ...start !== void 0 && { startOverride: start }
24267
+ });
24268
+ }
24269
+ return overrides.length > 0 ? overrides : void 0;
24270
+ }
24271
+ /**
24272
+ * Build numbering config from parsed data and remap paragraph references.
24273
+ * Only includes numIds that are actually used by paragraphs.
24274
+ */
24275
+ function buildNumberingConfig(data, sections) {
24276
+ if (data.abstractNums.length === 0) return [];
24277
+ const abstractMap = new Map(data.abstractNums.map((a) => [a.id, a]));
24278
+ const numToAbstract = new Map(data.nums.map((n) => [n.numId, n.abstractNumId]));
24279
+ const usedNumIds = /* @__PURE__ */ new Set();
24280
+ for (const section of sections) collectUsedNumIds(section.children, usedNumIds);
24281
+ if (usedNumIds.size === 0) return [];
24282
+ const config = [];
24283
+ const numIdToReference = /* @__PURE__ */ new Map();
24284
+ for (const numId of usedNumIds) {
24285
+ const abstractId = numToAbstract.get(numId);
24286
+ if (!abstractId) continue;
24287
+ const abstract = abstractMap.get(abstractId);
24288
+ if (!abstract) continue;
24289
+ const reference = `num-${numId}`;
24290
+ numIdToReference.set(numId, reference);
24291
+ const levels = abstract.levels.map((l) => ({
24292
+ ...l,
24293
+ style: l.style ? {
24294
+ ...l.style,
24295
+ paragraph: l.style.paragraph ? {
24296
+ ...l.style.paragraph,
24297
+ indent: { ...l.style.paragraph.indent }
24298
+ } : void 0
24299
+ } : void 0
24300
+ }));
24301
+ const num = data.nums.find((n) => n.numId === numId);
24302
+ if (num?.levelOverrides) for (const override of num.levelOverrides) {
24303
+ const level = levels.find((l) => l.level === override.ilvl);
24304
+ if (level && override.startOverride !== void 0) level.start = override.startOverride;
24305
+ }
24306
+ config.push({
24307
+ reference,
24308
+ levels
24309
+ });
24310
+ }
24311
+ for (const section of sections) remapNumberingReferences(section.children, numIdToReference);
24312
+ return config;
24313
+ }
24314
+ function collectUsedNumIds(children, used) {
24315
+ for (const child of children) {
24316
+ const c = child;
24317
+ if (c.$type === "paragraph" && c.numbering) {
24318
+ const n = c.numbering;
24319
+ if (n.reference) used.add(n.reference);
24320
+ }
24321
+ }
24322
+ }
24323
+ function remapNumberingReferences(children, numIdToReference) {
24324
+ for (const child of children) {
24325
+ const c = child;
24326
+ if (c.$type === "paragraph" && c.numbering) {
24327
+ const n = c.numbering;
24328
+ const newRef = numIdToReference.get(n.reference);
24329
+ if (newRef) n.reference = newRef;
24330
+ }
24331
+ }
24332
+ }
24152
24333
  //#endregion
24153
24334
  //#region src/parse/run.ts
24154
24335
  function parseRun(run, ctx) {
24155
24336
  const rPr = findChild(run, "w:rPr");
24156
24337
  const br = findChild(run, "w:br");
24157
24338
  if (br) {
24158
- if (attr(br, "w:type") === "page") return { $type: "pageBreak" };
24339
+ const brType = attr(br, "w:type");
24340
+ if (brType === "page" || brType === void 0) return { $type: "pageBreak" };
24341
+ if (brType === "column") return { $type: "columnBreak" };
24342
+ if (brType === "line" || brType === "textWrapping") return { $type: "lineBreak" };
24159
24343
  }
24160
24344
  const drawing = findChild(run, "w:drawing") ?? findChild(run, "mc:AlternateContent");
24161
24345
  if (drawing) {
@@ -24168,14 +24352,20 @@ function parseRun(run, ctx) {
24168
24352
  if (image) return image;
24169
24353
  }
24170
24354
  if (findChild(run, "w:tab")) return { $type: "tab" };
24171
- if (findChild(run, "w:footnoteReference")) return;
24355
+ const footnoteRef = findChild(run, "w:footnoteReference");
24356
+ const endnoteRef = findChild(run, "w:endnoteReference");
24357
+ if (footnoteRef || endnoteRef) return {
24358
+ $raw: true,
24359
+ element: footnoteRef ?? endnoteRef
24360
+ };
24172
24361
  const t = findChild(run, "w:t");
24173
24362
  const delText = findChild(run, "w:delText");
24174
24363
  const text = textOf(t ?? delText);
24175
24364
  if (!text && !rPr) return void 0;
24176
24365
  const result = {
24177
24366
  $type: "textRun",
24178
- text
24367
+ text,
24368
+ ...delText && !t && { deletedText: true }
24179
24369
  };
24180
24370
  if (rPr) parseRunProperties(rPr, result);
24181
24371
  return result;
@@ -24191,10 +24381,20 @@ function parseRunProperties(rPr, out) {
24191
24381
  const val = attr(i, "w:val");
24192
24382
  out.italics = val !== "0" && val !== "false";
24193
24383
  }
24384
+ const bCs = findChild(rPr, "w:bCs");
24385
+ if (bCs) {
24386
+ const val = attr(bCs, "w:val");
24387
+ if (val !== "0" && val !== "false") out.boldCs = true;
24388
+ }
24389
+ const iCs = findChild(rPr, "w:iCs");
24390
+ if (iCs) {
24391
+ const val = attr(iCs, "w:val");
24392
+ if (val !== "0" && val !== "false") out.italicCs = true;
24393
+ }
24194
24394
  const u = findChild(rPr, "w:u");
24195
24395
  if (u) {
24196
24396
  const val = attr(u, "w:val");
24197
- const color = attr(u, "w:color");
24397
+ const color = colorAttr(u, "w:color");
24198
24398
  if (val && val !== "none" && val !== "false") {
24199
24399
  out.underline = { type: val };
24200
24400
  if (color) out.underline.color = color;
@@ -24231,15 +24431,31 @@ function parseRunProperties(rPr, out) {
24231
24431
  const val = attrNum(sz, "w:val");
24232
24432
  if (val !== void 0) out.size = val;
24233
24433
  }
24234
- const color = findChild(rPr, "w:color");
24235
- if (color) {
24236
- const val = attr(color, "w:val");
24434
+ const szCs = findChild(rPr, "w:szCs");
24435
+ if (szCs) {
24436
+ const val = attrNum(szCs, "w:val");
24437
+ if (val !== void 0) out.sizeCs = val;
24438
+ }
24439
+ const colorEl = findChild(rPr, "w:color");
24440
+ if (colorEl) {
24441
+ const val = colorAttr(colorEl, "w:val");
24237
24442
  if (val && val !== "auto") out.color = val;
24238
24443
  }
24239
24444
  const rFonts = findChild(rPr, "w:rFonts");
24240
24445
  if (rFonts) {
24241
24446
  const ascii = attr(rFonts, "w:ascii");
24242
- if (ascii) out.font = ascii;
24447
+ const hAnsi = attr(rFonts, "w:hAnsi");
24448
+ const eastAsia = attr(rFonts, "w:eastAsia");
24449
+ const cs = attr(rFonts, "w:cs");
24450
+ const hint = attr(rFonts, "w:hint");
24451
+ if (hAnsi || eastAsia || cs || hint) out.font = {
24452
+ ...ascii && { ascii },
24453
+ ...hAnsi && { hAnsi },
24454
+ ...eastAsia && { eastAsia },
24455
+ ...cs && { cs },
24456
+ ...hint && hint !== "default" && { hint }
24457
+ };
24458
+ else if (ascii) out.font = ascii;
24243
24459
  }
24244
24460
  const highlight = findChild(rPr, "w:highlight");
24245
24461
  if (highlight) {
@@ -24259,7 +24475,11 @@ function parseRunProperties(rPr, out) {
24259
24475
  const shd = findChild(rPr, "w:shd");
24260
24476
  if (shd) {
24261
24477
  const fill = attr(shd, "w:fill");
24262
- if (fill && fill !== "auto") out.shading = { fill };
24478
+ const val = attr(shd, "w:val");
24479
+ if (fill && fill !== "auto") out.shading = {
24480
+ fill,
24481
+ ...val && val !== "clear" && { type: val }
24482
+ };
24263
24483
  }
24264
24484
  const kern = findChild(rPr, "w:kern");
24265
24485
  if (kern) {
@@ -24297,6 +24517,11 @@ function parseRunProperties(rPr, out) {
24297
24517
  if (val !== "0" && val !== "false") out.vanish = true;
24298
24518
  }
24299
24519
  if (findChild(rPr, "w:noProof")) out.noProof = true;
24520
+ const lang = findChild(rPr, "w:lang");
24521
+ if (lang) {
24522
+ const val = attr(lang, "w:val");
24523
+ if (val) out.lang = val;
24524
+ }
24300
24525
  if (findChild(rPr, "w:oMath")) out.math = true;
24301
24526
  }
24302
24527
  function parseDrawingImage(drawing, ctx) {
@@ -24307,8 +24532,7 @@ function parseDrawingImage(drawing, ctx) {
24307
24532
  if (!embedId) return void 0;
24308
24533
  const rel = ctx.documentRels.get(embedId);
24309
24534
  if (!rel) return void 0;
24310
- const mediaPath = rel.target.startsWith("../") ? rel.target.replace("../", "word/") : `word/${rel.target}`;
24311
- const mediaEntry = ctx.media.get(mediaPath);
24535
+ const mediaEntry = getMediaData(ctx, rel.target.startsWith("../") ? rel.target.replace("../", "word/") : `word/${rel.target}`);
24312
24536
  if (!mediaEntry) return void 0;
24313
24537
  const extent = findDeep(drawing, "wp:extent")[0] ?? findDeep(drawing, "wp:inline")[0];
24314
24538
  const cx = extent ? attrNum(extent, "cx") : void 0;
@@ -24331,8 +24555,7 @@ function parsePictImage(pict, ctx) {
24331
24555
  if (!rid) return void 0;
24332
24556
  const rel = ctx.documentRels.get(rid);
24333
24557
  if (!rel) return void 0;
24334
- const mediaPath = rel.target.startsWith("../") ? rel.target.replace("../", "word/") : `word/${rel.target}`;
24335
- const mediaEntry = ctx.media.get(mediaPath);
24558
+ const mediaEntry = getMediaData(ctx, rel.target.startsWith("../") ? rel.target.replace("../", "word/") : `word/${rel.target}`);
24336
24559
  if (!mediaEntry) return void 0;
24337
24560
  return {
24338
24561
  $type: "imageRun",
@@ -24341,27 +24564,341 @@ function parsePictImage(pict, ctx) {
24341
24564
  };
24342
24565
  }
24343
24566
  //#endregion
24567
+ //#region src/parse/table.ts
24568
+ function parseTable(tbl, ctx) {
24569
+ const result = {
24570
+ $type: "table",
24571
+ rows: []
24572
+ };
24573
+ const tblPr = findChild(tbl, "w:tblPr");
24574
+ if (tblPr) parseTableProperties(tblPr, result);
24575
+ const tblGrid = children(tbl, "w:tblGrid")[0];
24576
+ if (tblGrid) {
24577
+ const gridCols = children(tblGrid, "w:gridCol");
24578
+ if (gridCols.length > 0) result.columnWidths = gridCols.map((col) => attrNum(col, "w:w") ?? 0);
24579
+ }
24580
+ const rows = children(tbl, "w:tr");
24581
+ for (const tr of rows) result.rows.push(parseTableRow(tr, ctx));
24582
+ calculateRowSpans(result);
24583
+ return result;
24584
+ }
24585
+ function parseTableProperties(tblPr, out) {
24586
+ const tblW = findChild(tblPr, "w:tblW");
24587
+ if (tblW) {
24588
+ const size = attrNum(tblW, "w:w");
24589
+ const type = attr(tblW, "w:type");
24590
+ if (size !== void 0) out.width = {
24591
+ size,
24592
+ type: type ?? "auto"
24593
+ };
24594
+ }
24595
+ const tblStyle = findChild(tblPr, "w:tblStyle");
24596
+ if (tblStyle) {
24597
+ const val = attr(tblStyle, "w:val");
24598
+ if (val) out.style = val;
24599
+ }
24600
+ const jc = findChild(tblPr, "w:jc");
24601
+ if (jc) {
24602
+ const val = attr(jc, "w:val");
24603
+ if (val) out.alignment = val;
24604
+ }
24605
+ const tblBorders = findChild(tblPr, "w:tblBorders");
24606
+ if (tblBorders) {
24607
+ const borders = {};
24608
+ for (const child of tblBorders.elements ?? []) if (child.name && child.name.startsWith("w:")) {
24609
+ const borderName = child.name.replace("w:", "");
24610
+ const val = String(attr(child, "w:val") ?? "");
24611
+ const sz = attrNum(child, "w:sz");
24612
+ const color = colorAttr(child, "w:color");
24613
+ const space = attrNum(child, "w:space");
24614
+ if (val && val !== "none" && val !== "nil") {
24615
+ const borderDef = { style: val };
24616
+ if (sz !== void 0) borderDef.size = sz;
24617
+ if (color) borderDef.color = color;
24618
+ if (space !== void 0) borderDef.space = space;
24619
+ borders[borderName] = borderDef;
24620
+ }
24621
+ }
24622
+ if (Object.keys(borders).length > 0) out.borders = borders;
24623
+ }
24624
+ const tblCellMar = findChild(tblPr, "w:tblCellMar");
24625
+ if (tblCellMar) {
24626
+ const margins = {};
24627
+ for (const child of tblCellMar.elements ?? []) if (child.name && child.name.startsWith("w:")) {
24628
+ const name = child.name.replace("w:", "");
24629
+ const w = attrNum(child, "w:w");
24630
+ const type = attr(child, "w:type");
24631
+ if (w !== void 0) margins[name] = {
24632
+ w,
24633
+ type: type ?? "dxa"
24634
+ };
24635
+ }
24636
+ if (Object.keys(margins).length > 0) out.cellMargins = margins;
24637
+ }
24638
+ const tblInd = findChild(tblPr, "w:tblInd");
24639
+ if (tblInd) {
24640
+ const w = attrNum(tblInd, "w:w");
24641
+ const type = attr(tblInd, "w:type");
24642
+ if (w !== void 0) out.indentation = {
24643
+ w,
24644
+ type: type ?? "dxa"
24645
+ };
24646
+ }
24647
+ const tblLayout = findChild(tblPr, "w:tblLayout");
24648
+ if (tblLayout) {
24649
+ const val = attr(tblLayout, "w:type");
24650
+ if (val) out.layout = val;
24651
+ }
24652
+ }
24653
+ function parseTableRow(tr, ctx) {
24654
+ const result = { cells: [] };
24655
+ const trPr = findChild(tr, "w:trPr");
24656
+ if (trPr) {
24657
+ const trHeight = findChild(trPr, "w:trHeight");
24658
+ if (trHeight) {
24659
+ const val = attrNum(trHeight, "w:val");
24660
+ const rule = attr(trHeight, "w:hRule");
24661
+ if (val !== void 0) result.height = {
24662
+ value: val,
24663
+ rule: rule ?? void 0
24664
+ };
24665
+ }
24666
+ if (findChild(trPr, "w:tblHeader")) result.isHeader = true;
24667
+ }
24668
+ for (const child of tr.elements ?? []) if (child.name === "w:tc") result.cells.push(parseTableCell(child, ctx));
24669
+ return result;
24670
+ }
24671
+ function parseTableCell(tc, ctx) {
24672
+ const result = { children: [] };
24673
+ const tcPr = findChild(tc, "w:tcPr");
24674
+ if (tcPr) {
24675
+ const gridSpan = findChild(tcPr, "w:gridSpan");
24676
+ if (gridSpan) {
24677
+ const val = attrNum(gridSpan, "w:val");
24678
+ if (val !== void 0 && val > 1) result.columnSpan = val;
24679
+ }
24680
+ const vMerge = findChild(tcPr, "w:vMerge");
24681
+ if (vMerge) if (attr(vMerge, "w:val") === "restart") result.rowSpan = 1;
24682
+ else result.rowSpan = 0;
24683
+ const tcW = findChild(tcPr, "w:tcW");
24684
+ if (tcW) {
24685
+ const size = attrNum(tcW, "w:w");
24686
+ const type = attr(tcW, "w:type");
24687
+ if (size !== void 0) result.width = {
24688
+ size,
24689
+ type: type ?? "auto"
24690
+ };
24691
+ }
24692
+ const shd = findChild(tcPr, "w:shd");
24693
+ if (shd) {
24694
+ const fill = attr(shd, "w:fill");
24695
+ const val = attr(shd, "w:val");
24696
+ if (fill && fill !== "auto") result.shading = {
24697
+ fill,
24698
+ ...val && val !== "clear" && { type: val }
24699
+ };
24700
+ }
24701
+ const vAlign = findChild(tcPr, "w:vAlign");
24702
+ if (vAlign) {
24703
+ const val = attr(vAlign, "w:val");
24704
+ if (val) result.verticalAlign = val;
24705
+ }
24706
+ if (findChild(tcPr, "w:noWrap")) result.noWrap = true;
24707
+ const textDirection = findChild(tcPr, "w:textDirection");
24708
+ if (textDirection) {
24709
+ const val = attr(textDirection, "w:val");
24710
+ if (val) result.textDirection = val;
24711
+ }
24712
+ const tcMar = findChild(tcPr, "w:tcMar");
24713
+ if (tcMar) {
24714
+ const margins = {};
24715
+ for (const child of tcMar.elements ?? []) if (child.name && child.name.startsWith("w:")) {
24716
+ const name = child.name.replace("w:", "");
24717
+ const w = attrNum(child, "w:w");
24718
+ const type = attr(child, "w:type");
24719
+ if (w !== void 0) margins[name] = {
24720
+ w,
24721
+ type: type ?? "dxa"
24722
+ };
24723
+ }
24724
+ if (Object.keys(margins).length > 0) result.margins = margins;
24725
+ }
24726
+ const tcBorders = findChild(tcPr, "w:tcBorders");
24727
+ if (tcBorders) {
24728
+ const borders = {};
24729
+ for (const child of tcBorders.elements ?? []) if (child.name && child.name.startsWith("w:")) {
24730
+ const borderName = child.name.replace("w:", "");
24731
+ const val = String(attr(child, "w:val") ?? "");
24732
+ const sz = attrNum(child, "w:sz");
24733
+ const color = colorAttr(child, "w:color");
24734
+ const space = attrNum(child, "w:space");
24735
+ if (val && val !== "none" && val !== "nil") {
24736
+ const borderDef = { style: val };
24737
+ if (sz !== void 0) borderDef.size = sz;
24738
+ if (color) borderDef.color = color;
24739
+ if (space !== void 0) borderDef.space = space;
24740
+ borders[borderName] = borderDef;
24741
+ }
24742
+ }
24743
+ if (Object.keys(borders).length > 0) result.borders = borders;
24744
+ }
24745
+ }
24746
+ for (const child of tc.elements ?? []) if (child.name === "w:p") result.children.push(parseParagraph(child, ctx));
24747
+ else if (child.name === "w:tcPr") {} else if (child.name === "w:sdt") {
24748
+ const sdt = parseSdtContent(child, ctx);
24749
+ if (sdt) result.children.push(sdt);
24750
+ } else if (child.name === "w:tbl") result.children.push({
24751
+ $raw: true,
24752
+ element: child
24753
+ });
24754
+ else result.children.push({
24755
+ $raw: true,
24756
+ element: child
24757
+ });
24758
+ return result;
24759
+ }
24760
+ /** Post-process: calculate actual rowSpan values from vMerge patterns */
24761
+ function calculateRowSpans(table) {
24762
+ const mergeCounts = [];
24763
+ for (const row of table.rows) {
24764
+ let colIdx = 0;
24765
+ for (const cell of row.cells) {
24766
+ if (cell.rowSpan === 1) mergeCounts[colIdx] = 1;
24767
+ else if (cell.rowSpan === 0 || cell.rowSpan === void 0) {
24768
+ if (mergeCounts[colIdx] !== void 0) mergeCounts[colIdx]++;
24769
+ }
24770
+ const span = cell.columnSpan ?? 1;
24771
+ for (let i = 1; i < span; i++) {
24772
+ colIdx++;
24773
+ mergeCounts[colIdx] = 0;
24774
+ }
24775
+ colIdx++;
24776
+ }
24777
+ }
24778
+ for (const row of table.rows) {
24779
+ let colIdx = 0;
24780
+ for (const cell of row.cells) {
24781
+ if (cell.rowSpan === 1 && mergeCounts[colIdx] !== void 0) cell.rowSpan = mergeCounts[colIdx];
24782
+ else if (cell.rowSpan === 0) cell.rowSpan = void 0;
24783
+ const span = cell.columnSpan ?? 1;
24784
+ colIdx += span;
24785
+ }
24786
+ }
24787
+ }
24788
+ //#endregion
24789
+ //#region src/parse/sdt.ts
24790
+ function parseSdtPr(sdt) {
24791
+ return findChild(sdt, "w:sdtPr");
24792
+ }
24793
+ /** Parse block-level SDT (w:sdt in body or table cell) */
24794
+ function parseSdtContent(sdt, ctx) {
24795
+ const sdtPr = parseSdtPr(sdt);
24796
+ const sdtContent = findChild(sdt, "w:sdtContent");
24797
+ if (!sdtContent) return sdtPr ? {
24798
+ $type: "sdt",
24799
+ sdtPr
24800
+ } : void 0;
24801
+ const content = [];
24802
+ for (const child of sdtContent.elements ?? []) if (child.name === "w:p") content.push(parseParagraph(child, ctx));
24803
+ else if (child.name === "w:tbl") content.push(parseTable(child, ctx));
24804
+ else if (child.name === "w:sdt") {
24805
+ const nested = parseSdtContent(child, ctx);
24806
+ if (nested) content.push(nested);
24807
+ }
24808
+ const result = { $type: "sdt" };
24809
+ if (sdtPr) result.sdtPr = sdtPr;
24810
+ if (content.length > 0) result.content = content;
24811
+ return result;
24812
+ }
24813
+ /** Parse inline-level SDT (w:sdt inside w:p) */
24814
+ function parseSdtRun(sdt, ctx) {
24815
+ const sdtPr = parseSdtPr(sdt);
24816
+ const sdtContent = findChild(sdt, "w:sdtContent");
24817
+ if (!sdtContent) return sdtPr ? {
24818
+ $type: "sdtRun",
24819
+ sdtPr
24820
+ } : void 0;
24821
+ const content = [];
24822
+ for (const child of sdtContent.elements ?? []) if (child.name === "w:r") {
24823
+ const run = parseRun(child, ctx);
24824
+ if (run) content.push(run);
24825
+ } else if (child.name === "w:sdt") {
24826
+ const nested = parseSdtRun(child, ctx);
24827
+ if (nested) content.push(nested);
24828
+ }
24829
+ const result = { $type: "sdtRun" };
24830
+ if (sdtPr) result.sdtPr = sdtPr;
24831
+ if (content.length > 0) result.content = content;
24832
+ return result;
24833
+ }
24834
+ //#endregion
24344
24835
  //#region src/parse/paragraph.ts
24345
24836
  function parseParagraph(p, ctx) {
24346
24837
  const result = { $type: "paragraph" };
24347
24838
  const pPr = findChild(p, "w:pPr");
24348
24839
  if (pPr) parseParagraphProperties(pPr, result);
24349
24840
  const children = [];
24350
- for (const child of p.elements ?? []) if (child.name === "w:r") {
24351
- const run = parseRun(child, ctx);
24352
- if (run) children.push(run);
24353
- } else if (child.name === "w:hyperlink") {
24354
- const hyperlink = parseHyperlink(child, ctx);
24355
- if (hyperlink) children.push(hyperlink);
24356
- } else if (child.name === "w:bookmarkStart") {
24357
- const name = attr(child, "w:name");
24358
- if (name) children.push({
24359
- $type: "bookmark",
24360
- name
24841
+ const elements = p.elements ?? [];
24842
+ let i = 0;
24843
+ while (i < elements.length) {
24844
+ const child = elements[i];
24845
+ if (child.name === "w:r") {
24846
+ const fldChar = findChild(child, "w:fldChar");
24847
+ if (fldChar) {
24848
+ const fldCharType = attr(fldChar, "w:fldCharType");
24849
+ if (fldCharType === "begin") {
24850
+ const field = collectField(elements, i, ctx);
24851
+ if (field) children.push(field);
24852
+ while (i < elements.length) {
24853
+ const next = elements[i];
24854
+ if (next.name === "w:r") {
24855
+ const fc = findChild(next, "w:fldChar");
24856
+ if (fc && attr(fc, "w:fldCharType") === "end") {
24857
+ i++;
24858
+ break;
24859
+ }
24860
+ }
24861
+ i++;
24862
+ }
24863
+ continue;
24864
+ }
24865
+ if (fldCharType === "separate" || fldCharType === "end") {
24866
+ i++;
24867
+ continue;
24868
+ }
24869
+ }
24870
+ const run = parseRun(child, ctx);
24871
+ if (run) children.push(run);
24872
+ } else if (child.name === "w:hyperlink") {
24873
+ const hyperlink = parseHyperlink(child, ctx);
24874
+ if (hyperlink) children.push(hyperlink);
24875
+ } else if (child.name === "w:bookmarkStart") {
24876
+ const name = attr(child, "w:name");
24877
+ if (name) children.push({
24878
+ $type: "bookmark",
24879
+ name
24880
+ });
24881
+ } else if (child.name === "w:bookmarkEnd") {} else if (child.name === "w:sdt") {
24882
+ const sdt = parseSdtRun(child, ctx);
24883
+ if (sdt) children.push(sdt);
24884
+ else children.push({
24885
+ $raw: true,
24886
+ element: child
24887
+ });
24888
+ } else if (child.name === "w:oMath" || child.name === "w:oMathPara") children.push({
24889
+ $type: "math",
24890
+ element: child
24891
+ });
24892
+ else if (child.name === "w:pPr") {} else if (child.name === "w:tab") children.push({ $type: "tab" });
24893
+ else children.push({
24894
+ $raw: true,
24895
+ element: child
24361
24896
  });
24897
+ i++;
24362
24898
  }
24363
- if (children.length === 1 && children[0].$type === "textRun") {
24364
- const textRun = children[0];
24899
+ const first = children[0];
24900
+ if (children.length === 1 && !isRaw(first) && first.$type === "textRun") {
24901
+ const textRun = first;
24365
24902
  if (!Object.keys(textRun).some((k) => k !== "$type" && k !== "text") && textRun.text !== void 0) result.text = textRun.text;
24366
24903
  else result.children = children;
24367
24904
  } else if (children.length > 0) result.children = children;
@@ -24449,16 +24986,115 @@ function parseParagraphProperties(pPr, out) {
24449
24986
  const shd = findChild(pPr, "w:shd");
24450
24987
  if (shd) {
24451
24988
  const fill = attr(shd, "w:fill");
24452
- if (fill && fill !== "auto") out.shading = { fill };
24989
+ const val = attr(shd, "w:val");
24990
+ if (fill && fill !== "auto") out.shading = {
24991
+ fill,
24992
+ ...val && val !== "clear" && { type: val }
24993
+ };
24453
24994
  }
24454
24995
  const pBdr = findChild(pPr, "w:pBdr");
24455
24996
  if (pBdr) {
24456
- const bottom = findChild(pBdr, "w:bottom");
24457
- if (bottom) {
24458
- const val = attr(bottom, "w:val");
24459
- if (val && val !== "none" && val !== "nil") out.thematicBreak = true;
24997
+ const borderSides = [
24998
+ "top",
24999
+ "bottom",
25000
+ "left",
25001
+ "right",
25002
+ "between"
25003
+ ];
25004
+ const borders = {};
25005
+ let hasNonNoneBorder = false;
25006
+ for (const side of borderSides) {
25007
+ const borderEl = findChild(pBdr, `w:${side}`);
25008
+ if (borderEl && borderEl.attributes && Object.keys(borderEl.attributes).length > 0) {
25009
+ const val = String(attr(borderEl, "w:val") ?? "");
25010
+ const sz = attrNum(borderEl, "w:sz");
25011
+ const color = colorAttr(borderEl, "w:color");
25012
+ const space = attrNum(borderEl, "w:space");
25013
+ if (val && val !== "none" && val !== "nil") {
25014
+ hasNonNoneBorder = true;
25015
+ const borderDef = { style: val };
25016
+ if (sz !== void 0) borderDef.size = sz;
25017
+ if (color) borderDef.color = color;
25018
+ if (space !== void 0) borderDef.space = space;
25019
+ borders[side] = borderDef;
25020
+ }
25021
+ }
25022
+ }
25023
+ if (Object.keys(borders).length > 0) out.border = borders;
25024
+ if (hasNonNoneBorder) out.thematicBreak = true;
25025
+ }
25026
+ const tabs = findChild(pPr, "w:tabs");
25027
+ if (tabs) {
25028
+ const tabList = [];
25029
+ for (const tab of tabs.elements ?? []) if (tab.name === "w:tab") {
25030
+ const pos = attrNum(tab, "w:pos");
25031
+ const align = attr(tab, "w:val");
25032
+ const leader = attr(tab, "w:leader");
25033
+ if (pos !== void 0) tabList.push({
25034
+ pos,
25035
+ ...align && align !== "left" && { align },
25036
+ ...leader && leader !== "none" && { leader }
25037
+ });
24460
25038
  }
25039
+ if (tabList.length > 0) out.tabs = tabList;
25040
+ }
25041
+ const suppressLineNumbers = findChild(pPr, "w:suppressLineNumbers");
25042
+ if (suppressLineNumbers) {
25043
+ const val = attr(suppressLineNumbers, "w:val");
25044
+ if (val === void 0 || val !== "0" && val !== "false") out.suppressLineNumbers = true;
25045
+ }
25046
+ const contextualSpacing = findChild(pPr, "w:contextualSpacing");
25047
+ if (contextualSpacing) {
25048
+ const val = attr(contextualSpacing, "w:val");
25049
+ if (val === void 0 || val !== "0" && val !== "false") out.contextualSpacing = true;
24461
25050
  }
25051
+ const mirrorIndents = findChild(pPr, "w:mirrorIndents");
25052
+ if (mirrorIndents) {
25053
+ const val = attr(mirrorIndents, "w:val");
25054
+ if (val === void 0 || val !== "0" && val !== "false") out.mirrorIndents = true;
25055
+ }
25056
+ }
25057
+ /** Collect field code (begin → separate → end) into a FieldJson */
25058
+ function collectField(elements, startIndex, ctx) {
25059
+ let instruction = "";
25060
+ let locked = false;
25061
+ let dirty = false;
25062
+ const fieldChildren = [];
25063
+ let pastSeparate = false;
25064
+ for (let i = startIndex + 1; i < elements.length; i++) {
25065
+ const el = elements[i];
25066
+ if (el.name !== "w:r") continue;
25067
+ const fldChar = findChild(el, "w:fldChar");
25068
+ if (fldChar) {
25069
+ const type = attr(fldChar, "w:fldCharType");
25070
+ if (type === "end") break;
25071
+ if (type === "separate") {
25072
+ pastSeparate = true;
25073
+ continue;
25074
+ }
25075
+ }
25076
+ if (fldChar) {
25077
+ const fldLock = findChild(el, "w:fldChar");
25078
+ if (fldLock) {
25079
+ if (attr(fldLock, "w:fldLock") === "true") locked = true;
25080
+ if (attr(fldLock, "w:dirty") === "true") dirty = true;
25081
+ }
25082
+ continue;
25083
+ }
25084
+ if (!pastSeparate) {
25085
+ const instrText = findChild(el, "w:instrText");
25086
+ if (instrText) instruction += textOf(instrText);
25087
+ } else {
25088
+ const run = parseRun(el, ctx);
25089
+ if (run) fieldChildren.push(run);
25090
+ }
25091
+ }
25092
+ const field = { $type: "field" };
25093
+ if (instruction) field.instruction = instruction;
25094
+ if (locked) field.locked = true;
25095
+ if (dirty) field.dirty = true;
25096
+ if (fieldChildren.length > 0) field.children = fieldChildren;
25097
+ return field;
24462
25098
  }
24463
25099
  function parseHyperlink(hl, ctx) {
24464
25100
  const rid = attr(hl, "r:id");
@@ -24591,9 +25227,9 @@ function parseSectionProperties(sectPr) {
24591
25227
  const borders = {};
24592
25228
  for (const border of pgBorders.elements ?? []) if (border.name?.startsWith("w:")) {
24593
25229
  const borderName = border.name?.replace("w:", "") ?? "";
24594
- const val = attr(border, "w:val");
25230
+ const val = String(attr(border, "w:val") ?? "");
24595
25231
  const sz = attrNum(border, "w:sz");
24596
- const color = attr(border, "w:color");
25232
+ const color = colorAttr(border, "w:color");
24597
25233
  if (val && val !== "none" && val !== "nil") {
24598
25234
  const borderDef = { style: val };
24599
25235
  if (sz !== void 0) borderDef.size = sz;
@@ -24609,92 +25245,116 @@ function parseSectionProperties(sectPr) {
24609
25245
  return Object.keys(props).length > 0 ? props : void 0;
24610
25246
  }
24611
25247
  //#endregion
24612
- //#region src/parse/table.ts
24613
- function parseTable(tbl, ctx) {
24614
- const result = {
24615
- $type: "table",
24616
- rows: []
24617
- };
24618
- const tblPr = findChild(tbl, "w:tblPr");
24619
- if (tblPr) parseTableProperties(tblPr, result);
24620
- const rows = children(tbl, "w:tr");
24621
- for (const tr of rows) result.rows.push(parseTableRow(tr, ctx));
24622
- return result;
24623
- }
24624
- function parseTableProperties(tblPr, out) {
24625
- const tblW = findChild(tblPr, "w:tblW");
24626
- if (tblW) {
24627
- const size = attrNum(tblW, "w:w");
24628
- const type = attr(tblW, "w:type");
24629
- if (size !== void 0) out.width = {
24630
- size,
24631
- type: type ?? "auto"
24632
- };
25248
+ //#region src/parse/structural.ts
25249
+ /**
25250
+ * Parse footnotes.xml into FootnoteEntry[].
25251
+ */
25252
+ function parseFootnotes(zip) {
25253
+ const xml = readXmlFromZip(zip, "word/footnotes.xml");
25254
+ if (!xml) return [];
25255
+ const entries = [];
25256
+ for (const child of xml.elements ?? []) if (child.name === "w:footnote") {
25257
+ const id = attr(child, "w:id");
25258
+ const type = getFootnoteType(child);
25259
+ const children = parseNoteContent(child, zip, "footnote");
25260
+ entries.push({
25261
+ id: id ?? "",
25262
+ ...type && { type },
25263
+ ...children && { children }
25264
+ });
24633
25265
  }
24634
- const tblStyle = findChild(tblPr, "w:tblStyle");
24635
- if (tblStyle) {
24636
- const val = attr(tblStyle, "w:val");
24637
- if (val) out.style = val;
25266
+ return entries;
25267
+ }
25268
+ /**
25269
+ * Parse endnotes.xml into FootnoteEntry[].
25270
+ */
25271
+ function parseEndnotes(zip) {
25272
+ const xml = readXmlFromZip(zip, "word/endnotes.xml");
25273
+ if (!xml) return [];
25274
+ const entries = [];
25275
+ for (const child of xml.elements ?? []) if (child.name === "w:endnote") {
25276
+ const id = attr(child, "w:id");
25277
+ const type = getFootnoteType(child);
25278
+ const children = parseNoteContent(child, zip, "endnote");
25279
+ entries.push({
25280
+ id: id ?? "",
25281
+ ...type && { type },
25282
+ ...children && { children }
25283
+ });
24638
25284
  }
24639
- const jc = findChild(tblPr, "w:jc");
24640
- if (jc) {
24641
- const val = attr(jc, "w:val");
24642
- if (val) out.alignment = val;
25285
+ return entries;
25286
+ }
25287
+ /**
25288
+ * Parse comments.xml into CommentEntry[].
25289
+ */
25290
+ function parseComments(zip) {
25291
+ const xml = readXmlFromZip(zip, "word/comments.xml");
25292
+ if (!xml) return [];
25293
+ const entries = [];
25294
+ for (const child of xml.elements ?? []) if (child.name === "w:comment") {
25295
+ const id = attr(child, "w:id");
25296
+ const author = attr(child, "w:author");
25297
+ const date = attr(child, "w:date");
25298
+ const initials = attr(child, "w:initials");
25299
+ const children = [];
25300
+ for (const p of child.elements ?? []) if (p.name === "w:p") children.push(parseParagraph(p, createNoteContext(zip)));
25301
+ entries.push({
25302
+ id: id ?? "",
25303
+ ...author && { author },
25304
+ ...date && { date },
25305
+ ...initials && { initials },
25306
+ ...children.length > 0 && { children }
25307
+ });
24643
25308
  }
25309
+ return entries;
24644
25310
  }
24645
- function parseTableRow(tr, ctx) {
24646
- const cells = [];
24647
- for (const child of tr.elements ?? []) if (child.name === "w:tc") cells.push(parseTableCell(child, ctx));
24648
- return { cells };
25311
+ function getFootnoteType(note) {
25312
+ const type = attr(note, "w:type");
25313
+ if (type === "separator") return "separator";
25314
+ if (type === "continuationSeparator") return "continuationSeparator";
24649
25315
  }
24650
- function parseTableCell(tc, ctx) {
24651
- const result = { children: [] };
24652
- const tcPr = findChild(tc, "w:tcPr");
24653
- if (tcPr) {
24654
- const gridSpan = findChild(tcPr, "w:gridSpan");
24655
- if (gridSpan) {
24656
- const val = attrNum(gridSpan, "w:val");
24657
- if (val !== void 0 && val > 1) result.columnSpan = val;
24658
- }
24659
- const vMerge = findChild(tcPr, "w:vMerge");
24660
- if (vMerge) {
24661
- if (attr(vMerge, "w:val") === "restart") {}
24662
- }
24663
- const tcW = findChild(tcPr, "w:tcW");
24664
- if (tcW) {
24665
- const size = attrNum(tcW, "w:w");
24666
- const type = attr(tcW, "w:type");
24667
- if (size !== void 0) result.width = {
24668
- size,
24669
- type: type ?? "auto"
24670
- };
24671
- }
24672
- const shd = findChild(tcPr, "w:shd");
24673
- if (shd) {
24674
- const fill = attr(shd, "w:fill");
24675
- if (fill && fill !== "auto") result.shading = { fill };
24676
- }
24677
- const vAlign = findChild(tcPr, "w:vAlign");
24678
- if (vAlign) {
24679
- const val = attr(vAlign, "w:val");
24680
- if (val) result.verticalAlign = val;
24681
- }
24682
- }
24683
- for (const child of tc.elements ?? []) if (child.name === "w:p") result.children.push(parseParagraph(child, ctx));
24684
- return result;
25316
+ function parseNoteContent(note, zip, _partType) {
25317
+ const ctx = createNoteContext(zip);
25318
+ const children = [];
25319
+ for (const child of note.elements ?? []) if (child.name === "w:p") children.push(parseParagraph(child, ctx));
25320
+ return children;
25321
+ }
25322
+ /** Create a minimal parse context for note parsing (no hyperlinks/media) */
25323
+ function createNoteContext(zip) {
25324
+ return {
25325
+ zip,
25326
+ hyperlinks: /* @__PURE__ */ new Map(),
25327
+ media: /* @__PURE__ */ new Map(),
25328
+ documentRels: /* @__PURE__ */ new Map(),
25329
+ mediaPaths: /* @__PURE__ */ new Set()
25330
+ };
24685
25331
  }
24686
25332
  //#endregion
24687
25333
  //#region src/parse/document.ts
24688
- async function parseDocx(data) {
25334
+ async function parseDocx(data, options) {
24689
25335
  const zip = unzipToMap(data);
24690
25336
  const ctx = createDocxParseContext(zip);
25337
+ const includeRawParts = options?.includeRawParts !== false;
24691
25338
  const coreProps = parseCoreProperties(zip);
24692
25339
  const documentXml = readXmlFromZip(zip, "word/document.xml");
24693
25340
  if (!documentXml) throw new Error("Invalid DOCX file: missing word/document.xml");
24694
25341
  const body = findChild(documentXml, "w:body");
24695
25342
  if (!body) throw new Error("Invalid DOCX file: missing w:body element");
25343
+ const sections = parseBodySections(body, ctx);
25344
+ resolveHeadersFooters(sections, ctx);
25345
+ const numberingConfig = buildNumberingConfig(parseNumbering(zip), sections);
25346
+ const footnotes = parseFootnotes(zip);
25347
+ const endnotes = parseEndnotes(zip);
25348
+ const comments = parseComments(zip);
25349
+ let $parts;
25350
+ if (includeRawParts) $parts = readAllXmlParts(zip, { skipPaths: ["word/document.xml"] });
24696
25351
  return {
24697
- sections: parseBodySections(body, ctx),
25352
+ sections,
25353
+ ...$parts && { $parts },
25354
+ ...numberingConfig.length > 0 && { numbering: numberingConfig },
25355
+ ...footnotes.length > 0 && { footnotes },
25356
+ ...endnotes.length > 0 && { endnotes },
25357
+ ...comments.length > 0 && { comments },
24698
25358
  ...coreProps.title && { title: coreProps.title },
24699
25359
  ...coreProps.subject && { subject: coreProps.subject },
24700
25360
  ...coreProps.creator && { creator: coreProps.creator },
@@ -24726,12 +25386,233 @@ function parseBodySections(body, ctx) {
24726
25386
  }
24727
25387
  currentChildren.push(parseParagraph(element, ctx));
24728
25388
  } else if (element.name === "w:tbl") currentChildren.push(parseTable(element, ctx));
25389
+ else if (element.name === "w:sdt") {
25390
+ const sdt = parseSdtContent(element, ctx);
25391
+ if (sdt) currentChildren.push(sdt);
25392
+ else currentChildren.push({
25393
+ $raw: true,
25394
+ element
25395
+ });
25396
+ } else if (element.name === "w:oMath" || element.name === "w:oMathPara") currentChildren.push({
25397
+ $type: "math",
25398
+ element
25399
+ });
25400
+ else currentChildren.push({
25401
+ $raw: true,
25402
+ element
25403
+ });
24729
25404
  sections.push({
24730
25405
  properties: finalSectPr ? parseSectionProperties(finalSectPr) : void 0,
24731
25406
  children: currentChildren
24732
25407
  });
24733
25408
  return sections;
24734
25409
  }
25410
+ /** Resolve header/footer reference IDs to actual paragraph content */
25411
+ function resolveHeadersFooters(sections, ctx) {
25412
+ for (const section of sections) {
25413
+ const props = section.properties;
25414
+ if (!props) continue;
25415
+ const headerRefs = props.headerRefs;
25416
+ const footerRefs = props.footerRefs;
25417
+ if (headerRefs) {
25418
+ section.headers = {};
25419
+ for (const [type, rId] of Object.entries(headerRefs)) {
25420
+ const content = parseHeaderFooterContent(rId, ctx);
25421
+ if (content) section.headers[type] = { children: content };
25422
+ }
25423
+ }
25424
+ if (footerRefs) {
25425
+ section.footers = {};
25426
+ for (const [type, rId] of Object.entries(footerRefs)) {
25427
+ const content = parseHeaderFooterContent(rId, ctx);
25428
+ if (content) section.footers[type] = { children: content };
25429
+ }
25430
+ }
25431
+ }
25432
+ }
25433
+ function parseHeaderFooterContent(rId, ctx) {
25434
+ const rel = ctx.documentRels.get(rId);
25435
+ if (!rel) return void 0;
25436
+ const path = rel.target.startsWith("../") ? rel.target.replace("../", "word/") : `word/${rel.target}`;
25437
+ const xml = readXmlFromZip(ctx.zip, path);
25438
+ if (!xml) return void 0;
25439
+ const children = [];
25440
+ for (const child of xml.elements ?? []) if (child.name === "w:p") children.push(parseParagraph(child, ctx));
25441
+ else if (child.name === "w:tbl") children.push(parseTable(child, ctx));
25442
+ return children.length > 0 ? children : void 0;
25443
+ }
25444
+ //#endregion
25445
+ //#region src/parse/convert.ts
25446
+ /**
25447
+ * Convert parsed section children to constructor-ready FileChild[].
25448
+ */
25449
+ function toSectionChildren(children) {
25450
+ return children.map(convertFileChild);
25451
+ }
25452
+ /**
25453
+ * Convert parsed paragraph children to constructor-ready ParagraphChild[].
25454
+ */
25455
+ function toParagraphChildren(children) {
25456
+ return children.map(convertParagraphChild);
25457
+ }
25458
+ /**
25459
+ * Convert parsed DocxDocumentJson to constructor-ready Document options.
25460
+ * Handles numbering, headers/footers, and all section properties.
25461
+ */
25462
+ function toDocumentOptions(json) {
25463
+ return {
25464
+ ...json.title && { title: json.title },
25465
+ ...json.creator && { creator: json.creator },
25466
+ ...json.subject && { subject: json.subject },
25467
+ ...json.description && { description: json.description },
25468
+ ...json.keywords && { keywords: json.keywords },
25469
+ ...json.lastModifiedBy && { lastModifiedBy: json.lastModifiedBy },
25470
+ ...json.revision && { revision: json.revision },
25471
+ ...json.numbering && json.numbering.length > 0 && { numbering: { config: json.numbering } },
25472
+ sections: json.sections.map(convertSection)
25473
+ };
25474
+ }
25475
+ function convertSection(section) {
25476
+ const props = { ...section.properties };
25477
+ delete props.headerRefs;
25478
+ delete props.footerRefs;
25479
+ const result = {
25480
+ properties: props,
25481
+ children: toSectionChildren(section.children)
25482
+ };
25483
+ if (section.headers) {
25484
+ const headers = {};
25485
+ for (const [type, content] of Object.entries(section.headers)) headers[type] = new Header({ children: toSectionChildren(content.children) });
25486
+ result.headers = headers;
25487
+ }
25488
+ if (section.footers) {
25489
+ const footers = {};
25490
+ for (const [type, content] of Object.entries(section.footers)) footers[type] = new Footer({ children: toSectionChildren(content.children) });
25491
+ result.footers = footers;
25492
+ }
25493
+ return result;
25494
+ }
25495
+ function convertFileChild(child) {
25496
+ if (isRaw(child)) return new RawPassthrough(child.element);
25497
+ switch (child.$type) {
25498
+ case "paragraph": return convertParagraph(child);
25499
+ case "table": return convertTable(child);
25500
+ case "imageRun": return convertImageRun(child);
25501
+ case "externalHyperlink": return convertExternalHyperlink(child);
25502
+ case "pageBreak": return new PageBreak();
25503
+ case "sdt": return convertSdt(child);
25504
+ case "math": return new RawPassthrough(child.element);
25505
+ default: return new RawPassthrough(child.element);
25506
+ }
25507
+ }
25508
+ function convertParagraphChild(child) {
25509
+ if (isRaw(child)) return new RawPassthrough(child.element);
25510
+ switch (child.$type) {
25511
+ case "textRun": return convertRun(child);
25512
+ case "imageRun": return convertImageRun(child);
25513
+ case "externalHyperlink": return convertExternalHyperlink(child);
25514
+ case "pageBreak": return new PageBreak();
25515
+ case "lineBreak": return new ColumnBreak();
25516
+ case "columnBreak": return new ColumnBreak();
25517
+ case "tab": return new Run({ children: [new Tab()] });
25518
+ case "bookmark": return new RawPassthrough(child.element);
25519
+ case "sdtRun": return convertSdtRun(child);
25520
+ case "math": return new RawPassthrough(child.element);
25521
+ case "field": return convertField(child);
25522
+ default: return new RawPassthrough(child.element);
25523
+ }
25524
+ }
25525
+ function convertParagraph(json) {
25526
+ const { children, text, tabs, ...rest } = json;
25527
+ const runs = children ? toParagraphChildren(children) : text ? [new Run({ text })] : void 0;
25528
+ return new Paragraph({
25529
+ ...rest,
25530
+ children: runs,
25531
+ ...tabs ? { tabStops: tabs.map((t) => ({
25532
+ position: t.pos,
25533
+ ...t.align ? { type: t.align } : {},
25534
+ ...t.leader ? { leader: t.leader } : {}
25535
+ })) } : {}
25536
+ });
25537
+ }
25538
+ function convertRun(json) {
25539
+ const { underline, strike, doubleStrike, size, sizeCs, ...rest } = json;
25540
+ return new Run({
25541
+ ...rest,
25542
+ underline: convertUnderline(underline),
25543
+ strike: strike ? true : void 0,
25544
+ doubleStrike: doubleStrike ? true : void 0,
25545
+ size,
25546
+ sizeComplexScript: sizeCs
25547
+ });
25548
+ }
25549
+ const EMU_PER_PIXEL = 9525;
25550
+ function convertImageRun(json) {
25551
+ const { data, type, transformation, altText } = json;
25552
+ const convertedTransform = transformation ? {
25553
+ width: Math.round(transformation.width / EMU_PER_PIXEL),
25554
+ height: Math.round(transformation.height / EMU_PER_PIXEL),
25555
+ ...transformation.flip && { flip: transformation.flip },
25556
+ ...transformation.offset && { offset: transformation.offset }
25557
+ } : {
25558
+ width: 100,
25559
+ height: 100
25560
+ };
25561
+ return new ImageRun({
25562
+ data: typeof data === "string" ? Uint8Array.from(atob(data), (c) => c.charCodeAt(0)) : data,
25563
+ type,
25564
+ transformation: convertedTransform,
25565
+ altText
25566
+ });
25567
+ }
25568
+ function convertExternalHyperlink(json) {
25569
+ const { children, link, tooltip } = json;
25570
+ return new ExternalHyperlink({
25571
+ link,
25572
+ tooltip,
25573
+ children: children ? toParagraphChildren(children) : [new Run({ text: link })]
25574
+ });
25575
+ }
25576
+ function convertSdt(json) {
25577
+ return new RawPassthrough(json.element);
25578
+ }
25579
+ function convertSdtRun(json) {
25580
+ return new RawPassthrough(json.element);
25581
+ }
25582
+ function convertField(json) {
25583
+ const { instruction, children } = json;
25584
+ const cachedText = children?.map((c) => {
25585
+ if (c.$type === "textRun" && c.text) return c.text;
25586
+ }).filter(Boolean).join("") ?? void 0;
25587
+ return new SimpleField(instruction ?? "", cachedText);
25588
+ }
25589
+ function convertTable(json) {
25590
+ const { rows, ...rest } = json;
25591
+ return new Table({
25592
+ ...rest,
25593
+ rows: rows.map(convertTableRow)
25594
+ });
25595
+ }
25596
+ function convertTableRow(row) {
25597
+ const { cells, height, ...rest } = row;
25598
+ return new TableRow({
25599
+ children: cells.map(convertTableCell),
25600
+ ...height && { height },
25601
+ ...rest
25602
+ });
25603
+ }
25604
+ function convertTableCell(cell) {
25605
+ const { children, ...rest } = cell;
25606
+ return new TableCell({
25607
+ ...rest,
25608
+ children: children ? toSectionChildren(children) : [new Paragraph({ text: "" })]
25609
+ });
25610
+ }
25611
+ function convertUnderline(underline) {
25612
+ if (!underline) return void 0;
25613
+ if (typeof underline === "string") return { type: underline };
25614
+ return underline;
25615
+ }
24735
25616
  //#endregion
24736
25617
  //#region src/index.ts
24737
25618
  var src_exports = /* @__PURE__ */ __exportAll({
@@ -25090,11 +25971,15 @@ var src_exports = /* @__PURE__ */ __exportAll({
25090
25971
  getLayoutXml: () => getLayoutXml,
25091
25972
  getStyleXml: () => getStyleXml,
25092
25973
  hashedId: () => hashedId,
25974
+ isRaw: () => isRaw,
25093
25975
  parseDocx: () => parseDocx,
25094
25976
  patchDetector: () => patchDetector,
25095
25977
  patchDocument: () => patchDocument,
25096
25978
  sectionMarginDefaults: () => sectionMarginDefaults,
25097
25979
  sectionPageSizeDefaults: () => sectionPageSizeDefaults,
25980
+ toDocumentOptions: () => toDocumentOptions,
25981
+ toParagraphChildren: () => toParagraphChildren,
25982
+ toSectionChildren: () => toSectionChildren,
25098
25983
  uniqueId: () => uniqueId,
25099
25984
  uniqueNumericIdCreator: () => uniqueNumericIdCreator,
25100
25985
  uniqueUuid: () => uniqueUuid,
@@ -25103,6 +25988,6 @@ var src_exports = /* @__PURE__ */ __exportAll({
25103
25988
  __reExport(src_exports, file_exports);
25104
25989
  __reExport(src_exports, util_exports);
25105
25990
  //#endregion
25106
- export { AbstractNumbering, AlignmentType, AltChunk, AltChunkCollection, AnnotationReference, Attributes, BaseXmlComponent, Bdo, Bibliography, Body, Bookmark, BookmarkEnd, BookmarkStart, Border, BorderStyle, BuilderElement, COLOR_CATEGORIES, CarriageReturn, CellMerge, CellMergeAttributes, CharacterSet, ChartCollection, ChartRun, ChartSpace, CheckBox, CheckBoxSymbolElement, CheckBoxUtil, Column, ColumnBreak, Comment, CommentRangeEnd, CommentRangeStart, CommentReference, Comments, ConcreteHyperlink, ConcreteNumbering, ContinuationSeparator, DEFAULT_DRAWING_XML, DayLong, DayShort, DeletedTableCell, DeletedTableRow, DeletedTextRun, Dir, File as Document, File, DocumentAttributeNamespaces, DocumentBackground, DocumentBackgroundAttributes, DocumentDefaults, DocumentGridType, Drawing, DropCapType, EMPTY_OBJECT, EditGroupType, EmphasisMarkType, EmptyElement, EndnoteIdReference, EndnoteReference, EndnoteReferenceRun, EndnoteReferenceRunAttributes, Endnotes, ExternalHyperlink, FootNoteReferenceRunAttributes, FootNotes, Footer, FooterWrapper, FootnoteReference, FootnoteReferenceElement, FootnoteReferenceRun, FormFieldTextType, FractionType, FrameAnchorType, FrameWrap, GridSpan, Header, HeaderFooterReferenceType, HeaderFooterType, HeaderWrapper, HeadingLevel, HeightRule, HighlightColor, HorizontalPositionAlign, HorizontalPositionRelativeFrom, HpsMeasureElement, HyperlinkType, IgnoreIfEmptyXmlComponent, ImageRun, ImportedRootElementAttributes, ImportedXmlComponent, InitializableXmlComponent, InsertedTableCell, InsertedTableRow, InsertedTextRun, InternalHyperlink, LAYOUT_CATEGORIES, LastRenderedPageBreak, LeaderType, Level, LevelBase, LevelForOverride, LevelFormat, LevelOverride, LevelSuffix, LineNumberRestartFormat, LineRuleType, Math$1 as Math, MathAngledBrackets, MathBorderBox, MathBox, MathCurlyBrackets, MathDegree, MathDenominator, MathEqArr, MathFraction, MathFunction, MathFunctionName, MathGroupChr, MathIntegral, MathLimit, MathLimitLower, MathLimitUpper, MathMatrix, MathNumerator, MathParagraph, MathPhant, MathPreSubSuperScript, MathRadical, MathRadicalProperties, MathRoundBrackets, MathRun, MathSquareBrackets, MathSubScript, MathSubSuperScript, MathSum, MathSuperScript, Media, MonthLong, MonthShort, MoveFromRangeEnd, MoveFromRangeStart, MoveToRangeEnd, MoveToRangeStart, MovedFromTextRun, MovedToTextRun, NextAttributeComponent, NoBreakHyphen, NumberFormat, NumberProperties, NumberValueElement, NumberedItemReference, NumberedItemReferenceFormat, Numbering, OnOffElement, OverlapType, Packer, PageBorderDisplay, PageBorderOffsetFrom, PageBorderZOrder, PageBorders, PageBreak, PageBreakBefore, PageNumber, PageNumberElement, PageNumberSeparator, PageOrientation, PageReference, PageTextDirection, PageTextDirectionType, Paragraph, ParagraphProperties, ParagraphPropertiesChange, ParagraphPropertiesDefaults, ParagraphRunProperties, PatchType, PermEnd, PermStart, PositionalTab, PositionalTabAlignment, PositionalTabLeader, PositionalTabRelativeTo, PrettifyType, RelativeHorizontalPosition, RelativeVerticalPosition, RubyAlign, Run, RunProperties, RunPropertiesChange, RunPropertiesDefaults, STYLE_CATEGORIES, SdtDateMappingType, SdtLock, SectionProperties, SectionPropertiesChange, SectionType, Separator, SequentialIdentifier, ShadingType, SimpleField, SimpleMailMergeField, SmartArtCollection, SmartArtRun, SoftHyphen, SpaceType, StringContainer, StringEnumValueElement, StringValueElement, StructuredDocumentTagBlock, StructuredDocumentTagCell, StructuredDocumentTagContent, StructuredDocumentTagProperties, StructuredDocumentTagRow, StructuredDocumentTagRun, StyleForCharacter, StyleForParagraph, StyleLevel, Styles, SubDoc, SubDocCollection, SymbolRun, TDirection, Tab, TabStopPosition, TabStopType, Table, TableAnchorType, TableBorders, TableCell, TableCellBorders, TableLayoutType, TableOfContents, TableProperties, TablePropertyExceptions, TableRow, TableRowProperties, TableRowPropertiesChange, TextAlignmentType, TextBodyWrappingType, TextDirection, TextEffect, TextHorzOverflowType, TextRun, TextVertOverflowType, TextVerticalType, TextWrappingSide, TextWrappingType, Textbox, TextboxTightWrapType, ThematicBreak, UnderlineType, VerticalAlign, VerticalAlignSection, VerticalAlignTable, VerticalAnchor, VerticalMerge, VerticalMergeRevisionType, VerticalMergeType, VerticalPositionAlign, VerticalPositionRelativeFrom, WORKAROUND2, WORKAROUND4, WidthType, WpgGroupRun, WpsShapeRun, XmlAttributeComponent, XmlComponent, YearLong, YearShort, abstractNumUniqueNumericIdGen, bookmarkUniqueNumericIdGen, buildDocumentAttributes, buildRunProperties, chartAttr, concreteNumUniqueNumericIdGen, convertInchesToTwip, convertMillimetersToTwip, convertToXmlComponent, createAlignment, createBodyProperties, createBorderElement, createBreak, createCnfStyle, createColumns, createDataModel, createDivId, createDocumentGrid, createDotEmphasisMark, createEmphasisMark, createFormFieldData, createFrameProperties, createHeaderFooterReference, createHorizontalPosition, createIndent, createLineNumberType, createMathAccent, createMathAccentCharacter, createMathAccentProperties, createMathBar, createMathBarProperties, createMathBase, createMathBorderBoxProperties, createMathBoxProperties, createMathControlProperties, createMathEqArrProperties, createMathFractionProperties, createMathFunctionProperties, createMathGroupChrProperties, createMathLimitLocation, createMathLimitLowProperties, createMathLimitUpperProperties, createMathMatrixProperties, createMathNAryProperties, createMathPhantProperties, createMathPreSubSuperScriptProperties, createMathProperties, createMathRunProperties, createMathSubScriptElement, createMathSubScriptProperties, createMathSubSuperScriptProperties, createMathSuperScriptElement, createMathSuperScriptProperties, createOutlineLevel, createPageMargin, createPageNumberType, createPageSize, createParagraphStyle, createRuby, createRunFonts, createSectionType, createShading, createSimplePos, createSpacing, createStringElement, createTabStop, createTabStopItem, createTableFloatProperties, createTableLayout, createTableLook, createTableOverlap, createTableRowHeight, createTableWidthElement, createTransformation, createUnderline, createVerticalAlign, createVerticalPosition, createWrapNone, createWrapSquare, createWrapThrough, createWrapTight, createWrapTopAndBottom, docPropertiesUniqueNumericIdGen, getColorXml, getLayoutXml, getStyleXml, hashedId, parseDocx, patchDetector, patchDocument, sectionMarginDefaults, sectionPageSizeDefaults, uniqueId, uniqueNumericIdCreator, uniqueUuid, wrapEl };
25991
+ export { AbstractNumbering, AlignmentType, AltChunk, AltChunkCollection, AnnotationReference, Attributes, BaseXmlComponent, Bdo, Bibliography, Body, Bookmark, BookmarkEnd, BookmarkStart, Border, BorderStyle, BuilderElement, COLOR_CATEGORIES, CarriageReturn, CellMerge, CellMergeAttributes, CharacterSet, ChartCollection, ChartRun, ChartSpace, CheckBox, CheckBoxSymbolElement, CheckBoxUtil, Column, ColumnBreak, Comment, CommentRangeEnd, CommentRangeStart, CommentReference, Comments, ConcreteHyperlink, ConcreteNumbering, ContinuationSeparator, DEFAULT_DRAWING_XML, DayLong, DayShort, DeletedTableCell, DeletedTableRow, DeletedTextRun, Dir, File as Document, File, DocumentAttributeNamespaces, DocumentBackground, DocumentBackgroundAttributes, DocumentDefaults, DocumentGridType, Drawing, DropCapType, EMPTY_OBJECT, EditGroupType, EmphasisMarkType, EmptyElement, EndnoteIdReference, EndnoteReference, EndnoteReferenceRun, EndnoteReferenceRunAttributes, Endnotes, ExternalHyperlink, FootNoteReferenceRunAttributes, FootNotes, Footer, FooterWrapper, FootnoteReference, FootnoteReferenceElement, FootnoteReferenceRun, FormFieldTextType, FractionType, FrameAnchorType, FrameWrap, GridSpan, Header, HeaderFooterReferenceType, HeaderFooterType, HeaderWrapper, HeadingLevel, HeightRule, HighlightColor, HorizontalPositionAlign, HorizontalPositionRelativeFrom, HpsMeasureElement, HyperlinkType, IgnoreIfEmptyXmlComponent, ImageRun, ImportedRootElementAttributes, ImportedXmlComponent, InitializableXmlComponent, InsertedTableCell, InsertedTableRow, InsertedTextRun, InternalHyperlink, LAYOUT_CATEGORIES, LastRenderedPageBreak, LeaderType, Level, LevelBase, LevelForOverride, LevelFormat, LevelOverride, LevelSuffix, LineNumberRestartFormat, LineRuleType, Math$1 as Math, MathAngledBrackets, MathBorderBox, MathBox, MathCurlyBrackets, MathDegree, MathDenominator, MathEqArr, MathFraction, MathFunction, MathFunctionName, MathGroupChr, MathIntegral, MathLimit, MathLimitLower, MathLimitUpper, MathMatrix, MathNumerator, MathParagraph, MathPhant, MathPreSubSuperScript, MathRadical, MathRadicalProperties, MathRoundBrackets, MathRun, MathSquareBrackets, MathSubScript, MathSubSuperScript, MathSum, MathSuperScript, Media, MonthLong, MonthShort, MoveFromRangeEnd, MoveFromRangeStart, MoveToRangeEnd, MoveToRangeStart, MovedFromTextRun, MovedToTextRun, NextAttributeComponent, NoBreakHyphen, NumberFormat, NumberProperties, NumberValueElement, NumberedItemReference, NumberedItemReferenceFormat, Numbering, OnOffElement, OverlapType, Packer, PageBorderDisplay, PageBorderOffsetFrom, PageBorderZOrder, PageBorders, PageBreak, PageBreakBefore, PageNumber, PageNumberElement, PageNumberSeparator, PageOrientation, PageReference, PageTextDirection, PageTextDirectionType, Paragraph, ParagraphProperties, ParagraphPropertiesChange, ParagraphPropertiesDefaults, ParagraphRunProperties, PatchType, PermEnd, PermStart, PositionalTab, PositionalTabAlignment, PositionalTabLeader, PositionalTabRelativeTo, PrettifyType, RelativeHorizontalPosition, RelativeVerticalPosition, RubyAlign, Run, RunProperties, RunPropertiesChange, RunPropertiesDefaults, STYLE_CATEGORIES, SdtDateMappingType, SdtLock, SectionProperties, SectionPropertiesChange, SectionType, Separator, SequentialIdentifier, ShadingType, SimpleField, SimpleMailMergeField, SmartArtCollection, SmartArtRun, SoftHyphen, SpaceType, StringContainer, StringEnumValueElement, StringValueElement, StructuredDocumentTagBlock, StructuredDocumentTagCell, StructuredDocumentTagContent, StructuredDocumentTagProperties, StructuredDocumentTagRow, StructuredDocumentTagRun, StyleForCharacter, StyleForParagraph, StyleLevel, Styles, SubDoc, SubDocCollection, SymbolRun, TDirection, Tab, TabStopPosition, TabStopType, Table, TableAnchorType, TableBorders, TableCell, TableCellBorders, TableLayoutType, TableOfContents, TableProperties, TablePropertyExceptions, TableRow, TableRowProperties, TableRowPropertiesChange, TextAlignmentType, TextBodyWrappingType, TextDirection, TextEffect, TextHorzOverflowType, TextRun, TextVertOverflowType, TextVerticalType, TextWrappingSide, TextWrappingType, Textbox, TextboxTightWrapType, ThematicBreak, UnderlineType, VerticalAlign, VerticalAlignSection, VerticalAlignTable, VerticalAnchor, VerticalMerge, VerticalMergeRevisionType, VerticalMergeType, VerticalPositionAlign, VerticalPositionRelativeFrom, WORKAROUND2, WORKAROUND4, WidthType, WpgGroupRun, WpsShapeRun, XmlAttributeComponent, XmlComponent, YearLong, YearShort, abstractNumUniqueNumericIdGen, bookmarkUniqueNumericIdGen, buildDocumentAttributes, buildRunProperties, chartAttr, concreteNumUniqueNumericIdGen, convertInchesToTwip, convertMillimetersToTwip, convertToXmlComponent, createAlignment, createBodyProperties, createBorderElement, createBreak, createCnfStyle, createColumns, createDataModel, createDivId, createDocumentGrid, createDotEmphasisMark, createEmphasisMark, createFormFieldData, createFrameProperties, createHeaderFooterReference, createHorizontalPosition, createIndent, createLineNumberType, createMathAccent, createMathAccentCharacter, createMathAccentProperties, createMathBar, createMathBarProperties, createMathBase, createMathBorderBoxProperties, createMathBoxProperties, createMathControlProperties, createMathEqArrProperties, createMathFractionProperties, createMathFunctionProperties, createMathGroupChrProperties, createMathLimitLocation, createMathLimitLowProperties, createMathLimitUpperProperties, createMathMatrixProperties, createMathNAryProperties, createMathPhantProperties, createMathPreSubSuperScriptProperties, createMathProperties, createMathRunProperties, createMathSubScriptElement, createMathSubScriptProperties, createMathSubSuperScriptProperties, createMathSuperScriptElement, createMathSuperScriptProperties, createOutlineLevel, createPageMargin, createPageNumberType, createPageSize, createParagraphStyle, createRuby, createRunFonts, createSectionType, createShading, createSimplePos, createSpacing, createStringElement, createTabStop, createTabStopItem, createTableFloatProperties, createTableLayout, createTableLook, createTableOverlap, createTableRowHeight, createTableWidthElement, createTransformation, createUnderline, createVerticalAlign, createVerticalPosition, createWrapNone, createWrapSquare, createWrapThrough, createWrapTight, createWrapTopAndBottom, docPropertiesUniqueNumericIdGen, getColorXml, getLayoutXml, getStyleXml, hashedId, isRaw, parseDocx, patchDetector, patchDocument, sectionMarginDefaults, sectionPageSizeDefaults, toDocumentOptions, toParagraphChildren, toSectionChildren, uniqueId, uniqueNumericIdCreator, uniqueUuid, wrapEl };
25107
25992
 
25108
25993
  //# sourceMappingURL=index.mjs.map