@office-open/docx 0.10.9 → 0.10.11
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 +9 -9
- package/dist/{context-CAYk5WLu.mjs → context-nyQP2Fkk.mjs} +21 -5
- package/dist/context-nyQP2Fkk.mjs.map +1 -0
- package/dist/{core-properties-i25gKEDT.d.mts → core-properties-CIG9ZnsW.d.mts} +22 -2
- package/dist/core-properties-CIG9ZnsW.d.mts.map +1 -0
- package/dist/{generate-Di_7M9eJ.mjs → generate-CG1wp4pb.mjs} +41 -37
- package/dist/generate-CG1wp4pb.mjs.map +1 -0
- package/dist/generate.d.mts +1 -1
- package/dist/generate.mjs +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +5 -73
- package/dist/index.mjs.map +1 -1
- package/dist/{parse-DPBWKO12.mjs → parse-IeJ0NXYz.mjs} +4 -7
- package/dist/{parse-DPBWKO12.mjs.map → parse-IeJ0NXYz.mjs.map} +1 -1
- package/dist/parse.d.mts +1 -1
- package/dist/parse.mjs +1 -1
- package/dist/{parts-CATV83XR.mjs → parts-D0KoDfg7.mjs} +355 -110
- package/dist/parts-D0KoDfg7.mjs.map +1 -0
- package/dist/patch/index.d.mts +1 -1
- package/dist/patch/index.mjs +1 -1
- package/package.json +3 -3
- package/dist/context-CAYk5WLu.mjs.map +0 -1
- package/dist/core-properties-i25gKEDT.d.mts.map +0 -1
- package/dist/generate-Di_7M9eJ.mjs.map +0 -1
- package/dist/parts-CATV83XR.mjs.map +0 -1
|
@@ -179,6 +179,32 @@ function breakXml(breakOpt) {
|
|
|
179
179
|
return count === 1 ? one : one.repeat(count);
|
|
180
180
|
}
|
|
181
181
|
/**
|
|
182
|
+
* Empty EG_RunInnerContent elements — self-closing XML with no attributes.
|
|
183
|
+
* Shared by the body run stringifier and the inline (footnote/endnote) run
|
|
184
|
+
* stringifier so both emit them identically. Keyed by the RunOptions child
|
|
185
|
+
* property name (e.g. `{ separator: true }` → `separator`).
|
|
186
|
+
*
|
|
187
|
+
* XSD reference: EG_RunInnerContent group in wml.xsd.
|
|
188
|
+
*/
|
|
189
|
+
const EMPTY_RUN_ELEMENTS = {
|
|
190
|
+
noBreakHyphen: "<w:noBreakHyphen/>",
|
|
191
|
+
softHyphen: "<w:softHyphen/>",
|
|
192
|
+
dayShort: "<w:dayShort/>",
|
|
193
|
+
monthShort: "<w:monthShort/>",
|
|
194
|
+
yearShort: "<w:yearShort/>",
|
|
195
|
+
dayLong: "<w:dayLong/>",
|
|
196
|
+
monthLong: "<w:monthLong/>",
|
|
197
|
+
yearLong: "<w:yearLong/>",
|
|
198
|
+
annotationRef: "<w:annotationRef/>",
|
|
199
|
+
footnoteRef: "<w:footnoteRef/>",
|
|
200
|
+
endnoteRef: "<w:endnoteRef/>",
|
|
201
|
+
separator: "<w:separator/>",
|
|
202
|
+
continuationSeparator: "<w:continuationSeparator/>",
|
|
203
|
+
pgNum: "<w:pgNum/>",
|
|
204
|
+
carriageReturn: "<w:cr/>",
|
|
205
|
+
lastRenderedPageBreak: "<w:lastRenderedPageBreak/>"
|
|
206
|
+
};
|
|
207
|
+
/**
|
|
182
208
|
* Constants for page number field types.
|
|
183
209
|
*
|
|
184
210
|
* These values are used to insert dynamic page number fields into a document.
|
|
@@ -1271,6 +1297,22 @@ const WidthType = {
|
|
|
1271
1297
|
/** Value is in percentage. */
|
|
1272
1298
|
PERCENTAGE: "pct"
|
|
1273
1299
|
};
|
|
1300
|
+
/**
|
|
1301
|
+
* OOXML stores width percentages as fiftieths-of-a-percent integer
|
|
1302
|
+
* (`w:w="5000"`, `w:type="pct"` = 100%). The public API exposes them as plain
|
|
1303
|
+
* percentages (`size: 100` = 100%); these helpers convert at the stringify/parse
|
|
1304
|
+
* boundary so callers never handle the raw 5000 value. A bare number must never
|
|
1305
|
+
* be emitted with a "%" suffix — that is a different XSD branch (`s:ST_Percentage`)
|
|
1306
|
+
* meaning 5000%, which Word treats as `auto` on `tblW`.
|
|
1307
|
+
*/
|
|
1308
|
+
/** Stringify: percentage (`100`, `"50%"`) → OOXML fiftieths integer (`5000`). */
|
|
1309
|
+
const widthPctToFiftieths = (size) => {
|
|
1310
|
+
if (typeof size === "number") return Math.round(size * 50);
|
|
1311
|
+
if (size.endsWith("%")) return Math.round(Number(size.slice(0, -1)) * 50);
|
|
1312
|
+
return size;
|
|
1313
|
+
};
|
|
1314
|
+
/** Parse: OOXML fiftieths (`5000`) → percentage (`100`) when `type` is `"pct"`. */
|
|
1315
|
+
const widthFiftiethsToPct = (size, type) => type === "pct" && typeof size === "number" ? size / 50 : size;
|
|
1274
1316
|
//#endregion
|
|
1275
1317
|
//#region src/parts/object/object-element.ts
|
|
1276
1318
|
/**
|
|
@@ -1415,6 +1457,133 @@ function parseEmbed(el) {
|
|
|
1415
1457
|
return opts;
|
|
1416
1458
|
}
|
|
1417
1459
|
//#endregion
|
|
1460
|
+
//#region src/shared/shading.ts
|
|
1461
|
+
/**
|
|
1462
|
+
* Shading module for WordprocessingML documents.
|
|
1463
|
+
*
|
|
1464
|
+
* Shading is used to apply background colors and patterns to paragraphs,
|
|
1465
|
+
* table cells, and text runs. The shading type is identical in all places.
|
|
1466
|
+
*
|
|
1467
|
+
* Reference: http://officeopenxml.com/WPshading.php
|
|
1468
|
+
*
|
|
1469
|
+
* @see http://officeopenxml.com/WPtableShading.php
|
|
1470
|
+
* @see http://officeopenxml.com/WPtableCellProperties-Shading.php
|
|
1471
|
+
*
|
|
1472
|
+
* ## XSD Schema
|
|
1473
|
+
* ```xml
|
|
1474
|
+
* <xsd:complexType name="CT_Shd">
|
|
1475
|
+
* <xsd:attribute name="val" type="ST_Shd" use="required"/>
|
|
1476
|
+
* <xsd:attribute name="color" type="ST_HexColor" use="optional"/>
|
|
1477
|
+
* <xsd:attribute name="themeColor" type="ST_ThemeColor" use="optional"/>
|
|
1478
|
+
* <xsd:attribute name="themeTint" type="ST_UcharHexNumber" use="optional"/>
|
|
1479
|
+
* <xsd:attribute name="themeShade" type="ST_UcharHexNumber" use="optional"/>
|
|
1480
|
+
* <xsd:attribute name="fill" type="ST_HexColor" use="optional"/>
|
|
1481
|
+
* <xsd:attribute name="themeFill" type="ST_ThemeColor" use="optional"/>
|
|
1482
|
+
* <xsd:attribute name="themeFillTint" type="ST_UcharHexNumber" use="optional"/>
|
|
1483
|
+
* <xsd:attribute name="themeFillShade" type="ST_UcharHexNumber" use="optional"/>
|
|
1484
|
+
* </xsd:complexType>
|
|
1485
|
+
* ```
|
|
1486
|
+
*
|
|
1487
|
+
* @module
|
|
1488
|
+
*/
|
|
1489
|
+
/**
|
|
1490
|
+
* Shading pattern types.
|
|
1491
|
+
*
|
|
1492
|
+
* Specifies the pattern used for shading. The pattern combines the fill
|
|
1493
|
+
* color and the pattern color.
|
|
1494
|
+
*
|
|
1495
|
+
* ## XSD Schema
|
|
1496
|
+
* ```xml
|
|
1497
|
+
* <xsd:simpleType name="ST_Shd">
|
|
1498
|
+
* <xsd:restriction base="xsd:string">
|
|
1499
|
+
* <xsd:enumeration value="nil"/>
|
|
1500
|
+
* <xsd:enumeration value="clear"/>
|
|
1501
|
+
* <xsd:enumeration value="solid"/>
|
|
1502
|
+
* <xsd:enumeration value="horzStripe"/>
|
|
1503
|
+
* <xsd:enumeration value="vertStripe"/>
|
|
1504
|
+
* <xsd:enumeration value="reverseDiagStripe"/>
|
|
1505
|
+
* <xsd:enumeration value="diagStripe"/>
|
|
1506
|
+
* <xsd:enumeration value="horzCross"/>
|
|
1507
|
+
* <xsd:enumeration value="diagCross"/>
|
|
1508
|
+
* <!-- ... percent values ... -->
|
|
1509
|
+
* </xsd:restriction>
|
|
1510
|
+
* </xsd:simpleType>
|
|
1511
|
+
* ```
|
|
1512
|
+
*
|
|
1513
|
+
* @publicApi
|
|
1514
|
+
*/
|
|
1515
|
+
const ShadingType = {
|
|
1516
|
+
/** Clear shading - no pattern, fill color only */
|
|
1517
|
+
CLEAR: "clear",
|
|
1518
|
+
DIAGONAL_CROSS: "diagCross",
|
|
1519
|
+
DIAGONAL_STRIPE: "diagStripe",
|
|
1520
|
+
HORIZONTAL_CROSS: "horzCross",
|
|
1521
|
+
HORIZONTAL_STRIPE: "horzStripe",
|
|
1522
|
+
NIL: "nil",
|
|
1523
|
+
PERCENT_10: "pct10",
|
|
1524
|
+
PERCENT_12: "pct12",
|
|
1525
|
+
PERCENT_15: "pct15",
|
|
1526
|
+
PERCENT_20: "pct20",
|
|
1527
|
+
PERCENT_25: "pct25",
|
|
1528
|
+
PERCENT_30: "pct30",
|
|
1529
|
+
PERCENT_35: "pct35",
|
|
1530
|
+
PERCENT_37: "pct37",
|
|
1531
|
+
PERCENT_40: "pct40",
|
|
1532
|
+
PERCENT_45: "pct45",
|
|
1533
|
+
PERCENT_5: "pct5",
|
|
1534
|
+
PERCENT_50: "pct50",
|
|
1535
|
+
PERCENT_55: "pct55",
|
|
1536
|
+
PERCENT_60: "pct60",
|
|
1537
|
+
PERCENT_62: "pct62",
|
|
1538
|
+
PERCENT_65: "pct65",
|
|
1539
|
+
PERCENT_70: "pct70",
|
|
1540
|
+
PERCENT_75: "pct75",
|
|
1541
|
+
PERCENT_80: "pct80",
|
|
1542
|
+
PERCENT_85: "pct85",
|
|
1543
|
+
PERCENT_87: "pct87",
|
|
1544
|
+
PERCENT_90: "pct90",
|
|
1545
|
+
PERCENT_95: "pct95",
|
|
1546
|
+
REVERSE_DIAGONAL_STRIPE: "reverseDiagStripe",
|
|
1547
|
+
SOLID: "solid",
|
|
1548
|
+
THIN_DIAGONAL_CROSS: "thinDiagCross",
|
|
1549
|
+
THIN_DIAGONAL_STRIPE: "thinDiagStripe",
|
|
1550
|
+
THIN_HORIZONTAL_CROSS: "thinHorzCross",
|
|
1551
|
+
THIN_REVERSE_DIAGONAL_STRIPE: "thinReverseDiagStripe",
|
|
1552
|
+
THIN_VERTICAL_STRIPE: "thinVertStripe",
|
|
1553
|
+
VERTICAL_STRIPE: "vertStripe"
|
|
1554
|
+
};
|
|
1555
|
+
const THEME_COLORS$2 = Object.values(ThemeColor);
|
|
1556
|
+
/**
|
|
1557
|
+
* Parse a w:shd (CT_Shd) element into ShadingAttributesProperties.
|
|
1558
|
+
*
|
|
1559
|
+
* Reads every CT_Shd attribute (fill/color/val plus the theme* family), so the
|
|
1560
|
+
* result round-trips losslessly — paragraph, table-cell, and run shading all
|
|
1561
|
+
* share this single reader. Returns undefined when the element carries no data.
|
|
1562
|
+
*/
|
|
1563
|
+
function parseShading(shd) {
|
|
1564
|
+
const shading = {};
|
|
1565
|
+
const fill = attr(shd, "w:fill");
|
|
1566
|
+
if (fill) shading.fill = fill;
|
|
1567
|
+
const color = attr(shd, "w:color");
|
|
1568
|
+
if (color) shading.color = color;
|
|
1569
|
+
const val = attr(shd, "w:val");
|
|
1570
|
+
if (val) shading.type = val;
|
|
1571
|
+
const themeColor = attr(shd, "w:themeColor");
|
|
1572
|
+
if (themeColor && THEME_COLORS$2.includes(themeColor)) shading.themeColor = themeColor;
|
|
1573
|
+
const themeTint = attr(shd, "w:themeTint");
|
|
1574
|
+
if (themeTint) shading.themeTint = themeTint;
|
|
1575
|
+
const themeShade = attr(shd, "w:themeShade");
|
|
1576
|
+
if (themeShade) shading.themeShade = themeShade;
|
|
1577
|
+
const themeFill = attr(shd, "w:themeFill");
|
|
1578
|
+
if (themeFill && THEME_COLORS$2.includes(themeFill)) shading.themeFill = themeFill;
|
|
1579
|
+
const themeFillTint = attr(shd, "w:themeFillTint");
|
|
1580
|
+
if (themeFillTint) shading.themeFillTint = themeFillTint;
|
|
1581
|
+
const themeFillShade = attr(shd, "w:themeFillShade");
|
|
1582
|
+
if (themeFillShade) shading.themeFillShade = themeFillShade;
|
|
1583
|
+
if (Object.keys(shading).length === 0) return void 0;
|
|
1584
|
+
return shading;
|
|
1585
|
+
}
|
|
1586
|
+
//#endregion
|
|
1418
1587
|
//#region src/util/stringify-element.ts
|
|
1419
1588
|
/**
|
|
1420
1589
|
* Element-to-XML serialization helpers shared across the parse layer.
|
|
@@ -1586,7 +1755,7 @@ function parseRunProperties(el) {
|
|
|
1586
1755
|
}
|
|
1587
1756
|
const kern = findChild(el, "w:kern");
|
|
1588
1757
|
if (kern) {
|
|
1589
|
-
const val =
|
|
1758
|
+
const val = attrMeasure(kern, "w:val");
|
|
1590
1759
|
if (val !== void 0) opts.kern = val;
|
|
1591
1760
|
}
|
|
1592
1761
|
const position = findChild(el, "w:position");
|
|
@@ -1613,7 +1782,7 @@ function parseRunProperties(el) {
|
|
|
1613
1782
|
const bdr = findChild(el, "w:bdr");
|
|
1614
1783
|
if (bdr) opts.border = parseBorder(bdr);
|
|
1615
1784
|
const shd = findChild(el, "w:shd");
|
|
1616
|
-
if (shd) opts.shading = parseShading
|
|
1785
|
+
if (shd) opts.shading = parseShading(shd);
|
|
1617
1786
|
const eastAsianLayout = findChild(el, "w:eastAsianLayout");
|
|
1618
1787
|
if (eastAsianLayout) opts.eastAsianLayout = parseEastAsianLayout(eastAsianLayout);
|
|
1619
1788
|
const contentPart = findChild(el, "w:contentPart");
|
|
@@ -1659,19 +1828,6 @@ function parseBorder(el) {
|
|
|
1659
1828
|
return opts;
|
|
1660
1829
|
}
|
|
1661
1830
|
/**
|
|
1662
|
-
* Parse a w:shd element into ShadingAttributesProperties.
|
|
1663
|
-
*/
|
|
1664
|
-
function parseShading$1(el) {
|
|
1665
|
-
const opts = {};
|
|
1666
|
-
const fill = colorAttr(el, "w:fill");
|
|
1667
|
-
if (fill) opts.fill = fill;
|
|
1668
|
-
const color = colorAttr(el, "w:color");
|
|
1669
|
-
if (color) opts.color = color;
|
|
1670
|
-
const type = attr(el, "w:val");
|
|
1671
|
-
if (type) opts.type = type;
|
|
1672
|
-
return opts;
|
|
1673
|
-
}
|
|
1674
|
-
/**
|
|
1675
1831
|
* Parse a w:eastAsianLayout element into EastAsianLayoutOptions.
|
|
1676
1832
|
*/
|
|
1677
1833
|
function parseEastAsianLayout(el) {
|
|
@@ -2204,7 +2360,7 @@ function stringifyParagraphProperties(options) {
|
|
|
2204
2360
|
if (options.suppressAutoHyphens !== void 0) parts.push(onOff$1("w:suppressAutoHyphens", options.suppressAutoHyphens));
|
|
2205
2361
|
if (options.kinsoku !== void 0) parts.push(onOff$1("w:kinsoku", options.kinsoku));
|
|
2206
2362
|
if (options.wordWrap !== void 0) parts.push(onOff$1("w:wordWrap", options.wordWrap));
|
|
2207
|
-
if (options.overflowPunctuation) parts.push(onOff$1("w:overflowPunct", options.overflowPunctuation));
|
|
2363
|
+
if (options.overflowPunctuation !== void 0) parts.push(onOff$1("w:overflowPunct", options.overflowPunctuation));
|
|
2208
2364
|
if (options.topLinePunct !== void 0) parts.push(onOff$1("w:topLinePunct", options.topLinePunct));
|
|
2209
2365
|
if (options.autoSpaceDE !== void 0) parts.push(onOff$1("w:autoSpaceDE", options.autoSpaceDE));
|
|
2210
2366
|
if (options.autoSpaceEastAsianText !== void 0) parts.push(onOff$1("w:autoSpaceDN", options.autoSpaceEastAsianText));
|
|
@@ -4112,8 +4268,39 @@ function tocInstructionStr(opts) {
|
|
|
4112
4268
|
function stringifyTableOfContents(alias = "Table of Contents", options = {}, entriesXml = "") {
|
|
4113
4269
|
const instr = tocInstructionStr(options);
|
|
4114
4270
|
const aliasAttr = alias ? ` w:val="${escapeXml(alias)}"` : "";
|
|
4115
|
-
const
|
|
4116
|
-
|
|
4271
|
+
const headRuns = `<w:r><w:rPr><w:rFonts w:asciiTheme="majorHAnsi" w:cstheme="majorEastAsia" w:hAnsiTheme="majorHAnsi" w:cs="Times New Roman"/></w:rPr><w:fldChar w:fldCharType="begin"${entriesXml.length > 0 ? "" : " w:dirty=\"1\""}/></w:r><w:r><w:instrText xml:space="preserve"> ${instr} </w:instrText></w:r><w:r><w:fldChar w:fldCharType="separate"/></w:r>`;
|
|
4272
|
+
const endRun = `<w:r><w:fldChar w:fldCharType="end"/></w:r>`;
|
|
4273
|
+
const endParagraph = `<w:p>${endRun}</w:p>`;
|
|
4274
|
+
const body = entriesXml ? injectFieldEnd(injectFieldHead(entriesXml, headRuns), endRun) : `<w:p>${headRuns}</w:p>` + endParagraph;
|
|
4275
|
+
return `<w:sdt>${`<w:sdtPr><w:alias${aliasAttr}/><w:docPartObj><w:docPartGallery w:val="Table of Contents"/></w:docPartObj></w:sdtPr>`}${`<w:sdtContent>${body}</w:sdtContent>`}</w:sdt>`;
|
|
4276
|
+
}
|
|
4277
|
+
/**
|
|
4278
|
+
* Inject the field-head runs into the first `<w:p>` of `entriesXml`, placing
|
|
4279
|
+
* them after the opening tag (and after `<w:pPr>` when present) so the head
|
|
4280
|
+
* shares the first entry's paragraph. Returns `entriesXml` unchanged when no
|
|
4281
|
+
* `<w:p>` is found.
|
|
4282
|
+
*/
|
|
4283
|
+
function injectFieldHead(entriesXml, headRuns) {
|
|
4284
|
+
const pTagStart = entriesXml.search(/<w:p[ >]/);
|
|
4285
|
+
if (pTagStart < 0) return entriesXml;
|
|
4286
|
+
const pTagEnd = entriesXml.indexOf(">", pTagStart) + 1;
|
|
4287
|
+
let injectAt = pTagEnd;
|
|
4288
|
+
if (entriesXml.slice(pTagEnd, pTagEnd + 7) === "<w:pPr>") {
|
|
4289
|
+
const pPrEnd = entriesXml.indexOf("</w:pPr>", pTagEnd);
|
|
4290
|
+
if (pPrEnd >= 0) injectAt = pPrEnd + 8;
|
|
4291
|
+
}
|
|
4292
|
+
return entriesXml.slice(0, injectAt) + headRuns + entriesXml.slice(injectAt);
|
|
4293
|
+
}
|
|
4294
|
+
/**
|
|
4295
|
+
* Inject the field-end run into the last `<w:p>` of `entriesXml` (before its
|
|
4296
|
+
* closing `</w:p>`) so the end shares the last entry's paragraph instead of
|
|
4297
|
+
* occupying a standalone control-only paragraph that renders as a blank line.
|
|
4298
|
+
* Returns `entriesXml` unchanged when no `</w:p>` is found.
|
|
4299
|
+
*/
|
|
4300
|
+
function injectFieldEnd(entriesXml, endRun) {
|
|
4301
|
+
const lastClose = entriesXml.lastIndexOf("</w:p>");
|
|
4302
|
+
if (lastClose < 0) return entriesXml;
|
|
4303
|
+
return entriesXml.slice(0, lastClose) + endRun + entriesXml.slice(lastClose);
|
|
4117
4304
|
}
|
|
4118
4305
|
//#endregion
|
|
4119
4306
|
//#region src/parts/textbox/shape/shape.ts
|
|
@@ -4632,32 +4819,6 @@ function replaceRelsWithPlaceholders(xml, ctx, prefix) {
|
|
|
4632
4819
|
* @module
|
|
4633
4820
|
*/
|
|
4634
4821
|
/**
|
|
4635
|
-
* Mapping from empty child property name to self-closing XML element.
|
|
4636
|
-
*
|
|
4637
|
-
* These are single-key objects like `{ noBreakHyphen: true }` that map to
|
|
4638
|
-
* self-closing XML elements with no attributes.
|
|
4639
|
-
*
|
|
4640
|
-
* XSD reference: EG_RunInnerContent group in wml.xsd.
|
|
4641
|
-
*/
|
|
4642
|
-
const EMPTY_RUN_ELEMENTS = {
|
|
4643
|
-
noBreakHyphen: "<w:noBreakHyphen/>",
|
|
4644
|
-
softHyphen: "<w:softHyphen/>",
|
|
4645
|
-
dayShort: "<w:dayShort/>",
|
|
4646
|
-
monthShort: "<w:monthShort/>",
|
|
4647
|
-
yearShort: "<w:yearShort/>",
|
|
4648
|
-
dayLong: "<w:dayLong/>",
|
|
4649
|
-
monthLong: "<w:monthLong/>",
|
|
4650
|
-
yearLong: "<w:yearLong/>",
|
|
4651
|
-
annotationRef: "<w:annotationRef/>",
|
|
4652
|
-
footnoteRef: "<w:footnoteRef/>",
|
|
4653
|
-
endnoteRef: "<w:endnoteRef/>",
|
|
4654
|
-
separator: "<w:separator/>",
|
|
4655
|
-
continuationSeparator: "<w:continuationSeparator/>",
|
|
4656
|
-
pgNum: "<w:pgNum/>",
|
|
4657
|
-
carriageReturn: "<w:cr/>",
|
|
4658
|
-
lastRenderedPageBreak: "<w:lastRenderedPageBreak/>"
|
|
4659
|
-
};
|
|
4660
|
-
/**
|
|
4661
4822
|
* Stringify a run (w:r) from pure JSON options.
|
|
4662
4823
|
*
|
|
4663
4824
|
* Handles text, children, breaks, and run properties.
|
|
@@ -4989,7 +5150,8 @@ function parseParagraphProperties(el, ctx) {
|
|
|
4989
5150
|
const level = ilvl ? attrNum(ilvl, "w:val") ?? 0 : 0;
|
|
4990
5151
|
const numIdEl = findChild(numPr, "w:numId");
|
|
4991
5152
|
const numId = numIdEl ? attr(numIdEl, "w:val") : void 0;
|
|
4992
|
-
if (numId
|
|
5153
|
+
if (numId === "0") opts.numbering = false;
|
|
5154
|
+
else if (numId !== void 0 && ctx.numberingCache.size > 0) {
|
|
4993
5155
|
const numEl = ctx.docx.numbering;
|
|
4994
5156
|
if (numEl) {
|
|
4995
5157
|
let abstractNumId;
|
|
@@ -5100,14 +5262,8 @@ function parseParagraphProperties(el, ctx) {
|
|
|
5100
5262
|
}
|
|
5101
5263
|
const shd = findChild(el, "w:shd");
|
|
5102
5264
|
if (shd) {
|
|
5103
|
-
const
|
|
5104
|
-
|
|
5105
|
-
if (fill) shdObj.fill = fill;
|
|
5106
|
-
const color = attr(shd, "w:color");
|
|
5107
|
-
if (color) shdObj.color = color;
|
|
5108
|
-
const val = attr(shd, "w:val");
|
|
5109
|
-
if (val) shdObj.type = val;
|
|
5110
|
-
if (Object.keys(shdObj).length > 0) opts.shading = shdObj;
|
|
5265
|
+
const shading = parseShading(shd);
|
|
5266
|
+
if (shading) opts.shading = shading;
|
|
5111
5267
|
}
|
|
5112
5268
|
const textAlignment = findChild(el, "w:textAlignment");
|
|
5113
5269
|
if (textAlignment) {
|
|
@@ -5969,8 +6125,9 @@ function parseImageRun(el, ctx) {
|
|
|
5969
6125
|
if (!mediaPath) return void 0;
|
|
5970
6126
|
const imageData = ctx.docx.doc.getRaw(mediaPath);
|
|
5971
6127
|
if (!imageData) return void 0;
|
|
6128
|
+
const type = imageTypeFromPath(mediaPath);
|
|
5972
6129
|
const imageOpts = {
|
|
5973
|
-
type
|
|
6130
|
+
type,
|
|
5974
6131
|
data: imageData,
|
|
5975
6132
|
transformation: {
|
|
5976
6133
|
...info.width !== void 0 ? { width: info.width } : {},
|
|
@@ -6001,6 +6158,15 @@ function parseImageRun(el, ctx) {
|
|
|
6001
6158
|
if (blipResult.blipEffects) imageOpts.blipEffects = blipResult.blipEffects;
|
|
6002
6159
|
const useLocalDpi = readBlipUseLocalDpi(blip);
|
|
6003
6160
|
if (useLocalDpi !== void 0) imageOpts.useLocalDpi = useLocalDpi;
|
|
6161
|
+
const svg = readBlipSvg(blip, ctx);
|
|
6162
|
+
if (svg) {
|
|
6163
|
+
imageOpts.fallback = {
|
|
6164
|
+
type,
|
|
6165
|
+
data: imageData
|
|
6166
|
+
};
|
|
6167
|
+
imageOpts.type = "svg";
|
|
6168
|
+
imageOpts.data = svg.data;
|
|
6169
|
+
}
|
|
6004
6170
|
return { image: imageOpts };
|
|
6005
6171
|
}
|
|
6006
6172
|
/**
|
|
@@ -6017,6 +6183,33 @@ function readBlipUseLocalDpi(blip) {
|
|
|
6017
6183
|
}
|
|
6018
6184
|
}
|
|
6019
6185
|
/**
|
|
6186
|
+
* Read the `asvg:svgBlip` blip extension. When present, the surrounding
|
|
6187
|
+
* `a:blip` r:embed carries the raster fallback and this extension targets the
|
|
6188
|
+
* vector SVG part. Returns the SVG bytes so the picture round-trips as an
|
|
6189
|
+
* SvgMediaOptions (vector primary + raster fallback); undefined when no SVG
|
|
6190
|
+
* extension exists.
|
|
6191
|
+
*/
|
|
6192
|
+
function readBlipSvg(blip, ctx) {
|
|
6193
|
+
const extLst = findChild(blip, "a:extLst");
|
|
6194
|
+
if (!extLst) return void 0;
|
|
6195
|
+
for (const ext of extLst.elements ?? []) {
|
|
6196
|
+
if (ext.type !== "element" || ext.name !== "a:ext") continue;
|
|
6197
|
+
const svgBlip = findChild(ext, "asvg:svgBlip");
|
|
6198
|
+
if (svgBlip) {
|
|
6199
|
+
const rEmbed = attr(svgBlip, "r:embed");
|
|
6200
|
+
if (!rEmbed) return void 0;
|
|
6201
|
+
const svgPath = ctx.resolveRelationship(rEmbed);
|
|
6202
|
+
if (!svgPath) return void 0;
|
|
6203
|
+
const data = ctx.docx.doc.getRaw(svgPath);
|
|
6204
|
+
if (!data) return void 0;
|
|
6205
|
+
return {
|
|
6206
|
+
data,
|
|
6207
|
+
fileName: svgPath.split("/").pop() ?? svgPath
|
|
6208
|
+
};
|
|
6209
|
+
}
|
|
6210
|
+
}
|
|
6211
|
+
}
|
|
6212
|
+
/**
|
|
6020
6213
|
* Read the blip-fill crop rectangle (`a:srcRect`, l/t/r/b percentage insets)
|
|
6021
6214
|
* from a `pic:blipFill` parent. Returns undefined when there is no crop.
|
|
6022
6215
|
*/
|
|
@@ -6257,6 +6450,19 @@ function parsePicChildMediaData(picEl, ctx) {
|
|
|
6257
6450
|
const ln = findChild(spPr, "a:ln");
|
|
6258
6451
|
if (ln) result.outline = outlineDesc.parse(ln, ctx);
|
|
6259
6452
|
}
|
|
6453
|
+
const svg = readBlipSvg(blip, ctx);
|
|
6454
|
+
if (svg) return {
|
|
6455
|
+
...result,
|
|
6456
|
+
type: "svg",
|
|
6457
|
+
data: svg.data,
|
|
6458
|
+
fileName: svg.fileName,
|
|
6459
|
+
fallback: {
|
|
6460
|
+
type: result.type,
|
|
6461
|
+
fileName: result.fileName,
|
|
6462
|
+
data,
|
|
6463
|
+
transformation: result.transformation
|
|
6464
|
+
}
|
|
6465
|
+
};
|
|
6260
6466
|
return result;
|
|
6261
6467
|
}
|
|
6262
6468
|
/**
|
|
@@ -6393,6 +6599,26 @@ function readPosition(posEl) {
|
|
|
6393
6599
|
}
|
|
6394
6600
|
return Object.keys(result).length > 0 ? result : void 0;
|
|
6395
6601
|
}
|
|
6602
|
+
/** Read wp:wrapPolygon (start + lineTo points) into a WrapPolygon, if present. */
|
|
6603
|
+
function readWrapPolygon(el) {
|
|
6604
|
+
const poly = findChild(el, "wp:wrapPolygon");
|
|
6605
|
+
if (!poly) return void 0;
|
|
6606
|
+
const points = [];
|
|
6607
|
+
const start = findChild(poly, "wp:start");
|
|
6608
|
+
if (start) points.push({
|
|
6609
|
+
x: attrNum(start, "x") ?? 0,
|
|
6610
|
+
y: attrNum(start, "y") ?? 0
|
|
6611
|
+
});
|
|
6612
|
+
for (const child of poly.elements ?? []) if (child.name === "wp:lineTo") points.push({
|
|
6613
|
+
x: attrNum(child, "x") ?? 0,
|
|
6614
|
+
y: attrNum(child, "y") ?? 0
|
|
6615
|
+
});
|
|
6616
|
+
if (points.length === 0) return void 0;
|
|
6617
|
+
return {
|
|
6618
|
+
edited: attrBool(poly, "edited"),
|
|
6619
|
+
points
|
|
6620
|
+
};
|
|
6621
|
+
}
|
|
6396
6622
|
/** Map the wp:anchor wrap child element into a TextWrapping ({ type, side? }). */
|
|
6397
6623
|
function readWrap(anchor) {
|
|
6398
6624
|
const WRAP_TYPE = [
|
|
@@ -6408,6 +6634,10 @@ function readWrap(anchor) {
|
|
|
6408
6634
|
const wrap = { type };
|
|
6409
6635
|
const side = attr(el, "wrapText");
|
|
6410
6636
|
if (side) wrap.side = side;
|
|
6637
|
+
if (name === "wrapTight" || name === "wrapThrough") {
|
|
6638
|
+
const polygon = readWrapPolygon(el);
|
|
6639
|
+
if (polygon) wrap.polygon = polygon;
|
|
6640
|
+
}
|
|
6411
6641
|
return wrap;
|
|
6412
6642
|
}
|
|
6413
6643
|
}
|
|
@@ -6879,11 +7109,17 @@ function stringifyGroupChild(child, ctx) {
|
|
|
6879
7109
|
}
|
|
6880
7110
|
if (child.type === "wpg") return stringifyNestedGroup(child, ctx);
|
|
6881
7111
|
const picData = child;
|
|
7112
|
+
const isSvg = picData.type === "svg";
|
|
7113
|
+
const blipTarget = isSvg && "fallback" in picData ? picData.fallback.fileName : picData.fileName;
|
|
6882
7114
|
const picParts = [];
|
|
6883
7115
|
picParts.push(stringifyNvPicPr({}, picData.nonVisualProperties));
|
|
6884
7116
|
const groupBlipParts = [];
|
|
7117
|
+
const extParts = [];
|
|
6885
7118
|
const useLocalDpiExt = buildUseLocalDpiExt(picData.useLocalDpi);
|
|
6886
|
-
|
|
7119
|
+
if (useLocalDpiExt) extParts.push(useLocalDpiExt);
|
|
7120
|
+
if (isSvg) extParts.push(`<a:ext uri="${SVG_BLIP_EXT_URI}"><asvg:svgBlip xmlns:asvg="http://schemas.microsoft.com/office/drawing/2016/SVG/main" r:embed="{${escapeXml(picData.fileName)}}"/></a:ext>`);
|
|
7121
|
+
const extLst = extParts.length > 0 ? `<a:extLst>${extParts.join("")}</a:extLst>` : "";
|
|
7122
|
+
groupBlipParts.push(extLst ? `<a:blip r:embed="{${escapeXml(blipTarget)}}">${extLst}</a:blip>` : `<a:blip r:embed="{${escapeXml(blipTarget)}}"/>`);
|
|
6887
7123
|
const groupSrcRectXml = buildSrcRectXml(picData.sourceRectangle);
|
|
6888
7124
|
if (groupSrcRectXml) groupBlipParts.push(groupSrcRectXml);
|
|
6889
7125
|
groupBlipParts.push("<a:stretch><a:fillRect/></a:stretch>");
|
|
@@ -6937,7 +7173,12 @@ function stringifyPositionH(opts) {
|
|
|
6937
7173
|
function stringifyPositionV(opts) {
|
|
6938
7174
|
return `<wp:positionV relativeFrom="${opts.relative ?? VerticalPositionRelativeFrom.PAGE}">${opts.align ? `<wp:align>${opts.align}</wp:align>` : opts.offset !== void 0 ? `<wp:posOffset>${convertToEmu(opts.offset)}</wp:posOffset>` : "<wp:align>top</wp:align>"}</wp:positionV>`;
|
|
6939
7175
|
}
|
|
6940
|
-
function wrapPolygonStr(cx, cy) {
|
|
7176
|
+
function wrapPolygonStr(cx, cy, polygon) {
|
|
7177
|
+
if (polygon?.points.length) {
|
|
7178
|
+
const editedAttr = polygon.edited !== void 0 ? ` edited="${polygon.edited ? 1 : 0}"` : "";
|
|
7179
|
+
const [start, ...rest] = polygon.points;
|
|
7180
|
+
return `<wp:wrapPolygon${editedAttr}>${`<wp:start x="${start.x}" y="${start.y}"/>`}${rest.map((p) => `<wp:lineTo x="${p.x}" y="${p.y}"/>`).join("")}</wp:wrapPolygon>`;
|
|
7181
|
+
}
|
|
6941
7182
|
return `<wp:wrapPolygon edited="0"><wp:start x="0" y="0"/><wp:lineTo x="0" y="${-cy}"/><wp:lineTo x="${cx}" y="${-cy}"/><wp:lineTo x="${cx}" y="0"/><wp:lineTo x="0" y="0"/></wp:wrapPolygon>`;
|
|
6942
7183
|
}
|
|
6943
7184
|
function wrapSquareStr(textWrapping, margins) {
|
|
@@ -6955,13 +7196,13 @@ function wrapTightStr(textWrapping, margins, cx, cy) {
|
|
|
6955
7196
|
const a = [`wrapText="${textWrapping.side ?? TextWrappingSide.BOTH_SIDES}"`];
|
|
6956
7197
|
if (margins.left != null) a.push(`distL="${convertToEmu(margins.left)}"`);
|
|
6957
7198
|
if (margins.right != null) a.push(`distR="${convertToEmu(margins.right)}"`);
|
|
6958
|
-
return `<wp:wrapTight ${a.join(" ")}>${wrapPolygonStr(cx, cy)}</wp:wrapTight>`;
|
|
7199
|
+
return `<wp:wrapTight ${a.join(" ")}>${wrapPolygonStr(cx, cy, textWrapping.polygon)}</wp:wrapTight>`;
|
|
6959
7200
|
}
|
|
6960
7201
|
function wrapThroughStr(textWrapping, margins, cx, cy) {
|
|
6961
7202
|
const a = [`wrapText="${textWrapping.side ?? TextWrappingSide.BOTH_SIDES}"`];
|
|
6962
7203
|
if (margins.left != null) a.push(`distL="${convertToEmu(margins.left)}"`);
|
|
6963
7204
|
if (margins.right != null) a.push(`distR="${convertToEmu(margins.right)}"`);
|
|
6964
|
-
return `<wp:wrapThrough ${a.join(" ")}>${wrapPolygonStr(cx, cy)}</wp:wrapThrough>`;
|
|
7205
|
+
return `<wp:wrapThrough ${a.join(" ")}>${wrapPolygonStr(cx, cy, textWrapping.polygon)}</wp:wrapThrough>`;
|
|
6965
7206
|
}
|
|
6966
7207
|
function wrapTopAndBottomStr(margins) {
|
|
6967
7208
|
const m = margins ?? {};
|
|
@@ -7200,14 +7441,36 @@ function stringifyRunInline(opts, ctx) {
|
|
|
7200
7441
|
const rPr = stringifyRunProperties(opts);
|
|
7201
7442
|
if (rPr) parts.push(rPr);
|
|
7202
7443
|
if (opts.break) parts.push(breakXml(opts.break));
|
|
7203
|
-
if (opts.children)
|
|
7204
|
-
|
|
7205
|
-
|
|
7206
|
-
|
|
7207
|
-
|
|
7208
|
-
|
|
7209
|
-
|
|
7210
|
-
|
|
7444
|
+
if (opts.children) {
|
|
7445
|
+
for (const child of opts.children) if (typeof child === "string") parts.push(`<w:t xml:space="preserve">${escapeXml(child)}</w:t>`);
|
|
7446
|
+
else if (typeof child === "object" && child !== null) {
|
|
7447
|
+
if ("tab" in child) {
|
|
7448
|
+
parts.push("<w:tab/>");
|
|
7449
|
+
continue;
|
|
7450
|
+
}
|
|
7451
|
+
if ("pageBreak" in child) {
|
|
7452
|
+
parts.push("<w:br w:type=\"page\"/>");
|
|
7453
|
+
continue;
|
|
7454
|
+
}
|
|
7455
|
+
if ("columnBreak" in child) {
|
|
7456
|
+
parts.push("<w:br w:type=\"column\"/>");
|
|
7457
|
+
continue;
|
|
7458
|
+
}
|
|
7459
|
+
if ("break" in child) {
|
|
7460
|
+
parts.push(breakXml(child.break));
|
|
7461
|
+
continue;
|
|
7462
|
+
}
|
|
7463
|
+
const emptyXml = EMPTY_RUN_ELEMENTS[Object.keys(child)[0]];
|
|
7464
|
+
if (emptyXml) {
|
|
7465
|
+
parts.push(emptyXml);
|
|
7466
|
+
continue;
|
|
7467
|
+
}
|
|
7468
|
+
const jsonResult = stringifyChildDispatch(child, ctx);
|
|
7469
|
+
if (jsonResult !== void 0) if (Array.isArray(jsonResult)) parts.push(...jsonResult);
|
|
7470
|
+
else parts.push(jsonResult);
|
|
7471
|
+
else if ("text" in child || "children" in child || "break" in child) parts.push(stringifyRunInline(child, ctx));
|
|
7472
|
+
}
|
|
7473
|
+
} else if (opts.text !== void 0) parts.push(`<w:t xml:space="preserve">${escapeXml(String(opts.text))}</w:t>`);
|
|
7211
7474
|
const rsidAttrs = [];
|
|
7212
7475
|
if (opts.rsid) rsidAttrs.push(` w:rsidR="${opts.rsid}"`);
|
|
7213
7476
|
if (opts.runPropertiesRsid) rsidAttrs.push(` w:rsidRPr="${opts.runPropertiesRsid}"`);
|
|
@@ -7547,7 +7810,13 @@ function stringifyChildDispatch(child, ctx) {
|
|
|
7547
7810
|
registerMedia(c.children);
|
|
7548
7811
|
continue;
|
|
7549
7812
|
}
|
|
7550
|
-
|
|
7813
|
+
if (c.type === "svg") {
|
|
7814
|
+
const fb = c.fallback;
|
|
7815
|
+
fb.fileName = ctx.file.media.addMedia(fb.data, fb.type, () => fb, fb.fileName).fileName;
|
|
7816
|
+
c.fileName = ctx.file.media.addMedia(c.data, "svg", () => c, c.fileName).fileName;
|
|
7817
|
+
continue;
|
|
7818
|
+
}
|
|
7819
|
+
c.fileName = ctx.file.media.addMedia(c.data, c.type, () => c, c.fileName).fileName;
|
|
7551
7820
|
}
|
|
7552
7821
|
};
|
|
7553
7822
|
registerMedia(opts.children);
|
|
@@ -7808,8 +8077,7 @@ function stringifyParagraphInline(opts, ctx) {
|
|
|
7808
8077
|
*/
|
|
7809
8078
|
function tableWidthStr(name, opts) {
|
|
7810
8079
|
const type = opts.type ?? WidthType.AUTO;
|
|
7811
|
-
|
|
7812
|
-
if (type === WidthType.PERCENTAGE && typeof w === "number") w = `${w}%`;
|
|
8080
|
+
const w = type === WidthType.PERCENTAGE ? widthPctToFiftieths(opts.size) : opts.size;
|
|
7813
8081
|
return `<${name} ${attrParts({
|
|
7814
8082
|
"w:w": w !== void 0 ? measurementOrPercentValue(w) : void 0,
|
|
7815
8083
|
"w:type": type
|
|
@@ -7919,9 +8187,10 @@ function cellMergeStr(opts) {
|
|
|
7919
8187
|
return `<w:cellMerge ${attrParts(attrs)}/>`;
|
|
7920
8188
|
}
|
|
7921
8189
|
function cellSpacingStr(opts) {
|
|
8190
|
+
const w = opts.type === WidthType.PERCENTAGE ? widthPctToFiftieths(opts.size) : opts.size;
|
|
7922
8191
|
return `<w:tblCellSpacing ${attrParts({
|
|
7923
|
-
"w:
|
|
7924
|
-
"w:
|
|
8192
|
+
"w:w": w !== void 0 ? measurementOrPercentValue(w) : void 0,
|
|
8193
|
+
"w:type": opts.type
|
|
7925
8194
|
})}/>`;
|
|
7926
8195
|
}
|
|
7927
8196
|
function stringifyTablePropertiesChangeInner(options) {
|
|
@@ -8241,7 +8510,7 @@ function parseCellMargins(marginEl) {
|
|
|
8241
8510
|
const sideEl = findChild(marginEl, `w:${side}`);
|
|
8242
8511
|
if (sideEl) {
|
|
8243
8512
|
const type = attr(sideEl, "w:type");
|
|
8244
|
-
const size = attrMeasure(sideEl, "w:w", type);
|
|
8513
|
+
const size = widthFiftiethsToPct(attrMeasure(sideEl, "w:w"), type);
|
|
8245
8514
|
if (size !== void 0) margins[side] = type ? {
|
|
8246
8515
|
size,
|
|
8247
8516
|
type
|
|
@@ -8251,30 +8520,6 @@ function parseCellMargins(marginEl) {
|
|
|
8251
8520
|
if (Object.keys(margins).length === 0) return void 0;
|
|
8252
8521
|
return margins;
|
|
8253
8522
|
}
|
|
8254
|
-
/** Parse a w:shd (CT_Shd) element into ShadingAttributesProperties. */
|
|
8255
|
-
function parseShading(shd) {
|
|
8256
|
-
const shading = {};
|
|
8257
|
-
const fill = attr(shd, "w:fill");
|
|
8258
|
-
if (fill) shading.fill = fill;
|
|
8259
|
-
const color = attr(shd, "w:color");
|
|
8260
|
-
if (color) shading.color = color;
|
|
8261
|
-
const val = attr(shd, "w:val");
|
|
8262
|
-
if (val) shading.type = val;
|
|
8263
|
-
const themeColor = attr(shd, "w:themeColor");
|
|
8264
|
-
if (themeColor && THEME_COLORS.includes(themeColor)) shading.themeColor = themeColor;
|
|
8265
|
-
const themeTint = attr(shd, "w:themeTint");
|
|
8266
|
-
if (themeTint) shading.themeTint = themeTint;
|
|
8267
|
-
const themeShade = attr(shd, "w:themeShade");
|
|
8268
|
-
if (themeShade) shading.themeShade = themeShade;
|
|
8269
|
-
const themeFill = attr(shd, "w:themeFill");
|
|
8270
|
-
if (themeFill && THEME_COLORS.includes(themeFill)) shading.themeFill = themeFill;
|
|
8271
|
-
const themeFillTint = attr(shd, "w:themeFillTint");
|
|
8272
|
-
if (themeFillTint) shading.themeFillTint = themeFillTint;
|
|
8273
|
-
const themeFillShade = attr(shd, "w:themeFillShade");
|
|
8274
|
-
if (themeFillShade) shading.themeFillShade = themeFillShade;
|
|
8275
|
-
if (Object.keys(shading).length === 0) return void 0;
|
|
8276
|
-
return shading;
|
|
8277
|
-
}
|
|
8278
8523
|
/** Parse a w:cnfStyle (CT_Cnf) element into CnfStyleOptions. */
|
|
8279
8524
|
function parseCnfStyle(cnfEl) {
|
|
8280
8525
|
const cnf = {};
|
|
@@ -8421,7 +8666,7 @@ function parseTablePropertiesEl(el) {
|
|
|
8421
8666
|
const tblW = findChild(el, "w:tblW");
|
|
8422
8667
|
if (tblW) {
|
|
8423
8668
|
const type = attr(tblW, "w:type");
|
|
8424
|
-
const size = attrMeasure(tblW, "w:w", type);
|
|
8669
|
+
const size = widthFiftiethsToPct(attrMeasure(tblW, "w:w"), type);
|
|
8425
8670
|
if (size !== void 0 || type) opts.width = {
|
|
8426
8671
|
size: size ?? 0,
|
|
8427
8672
|
...type ? { type } : {}
|
|
@@ -8524,7 +8769,7 @@ function parseTablePropertiesEl(el) {
|
|
|
8524
8769
|
const tblInd = findChild(el, "w:tblInd");
|
|
8525
8770
|
if (tblInd) {
|
|
8526
8771
|
const type = attr(tblInd, "w:type");
|
|
8527
|
-
const size = attrMeasure(tblInd, "w:w", type);
|
|
8772
|
+
const size = widthFiftiethsToPct(attrMeasure(tblInd, "w:w"), type);
|
|
8528
8773
|
if (size !== void 0) opts.indent = {
|
|
8529
8774
|
size,
|
|
8530
8775
|
...type ? { type } : {}
|
|
@@ -8550,7 +8795,7 @@ function parseTablePropertiesEl(el) {
|
|
|
8550
8795
|
const tblCellSpacing = findChild(el, "w:tblCellSpacing");
|
|
8551
8796
|
if (tblCellSpacing) {
|
|
8552
8797
|
const type = attr(tblCellSpacing, "w:type");
|
|
8553
|
-
const w = attrMeasure(tblCellSpacing, "w:w", type);
|
|
8798
|
+
const w = widthFiftiethsToPct(attrMeasure(tblCellSpacing, "w:w"), type);
|
|
8554
8799
|
if (w !== void 0) opts.cellSpacing = {
|
|
8555
8800
|
size: w,
|
|
8556
8801
|
...type ? { type } : {}
|
|
@@ -8649,7 +8894,7 @@ function parseTableRowPropertiesEl(el) {
|
|
|
8649
8894
|
const wBefore = findChild(el, "w:wBefore");
|
|
8650
8895
|
if (wBefore) {
|
|
8651
8896
|
const type = attr(wBefore, "w:type");
|
|
8652
|
-
const size = attrMeasure(wBefore, "w:w", type);
|
|
8897
|
+
const size = widthFiftiethsToPct(attrMeasure(wBefore, "w:w"), type);
|
|
8653
8898
|
if (size !== void 0) opts.widthBefore = {
|
|
8654
8899
|
size,
|
|
8655
8900
|
...type ? { type } : {}
|
|
@@ -8658,7 +8903,7 @@ function parseTableRowPropertiesEl(el) {
|
|
|
8658
8903
|
const wAfter = findChild(el, "w:wAfter");
|
|
8659
8904
|
if (wAfter) {
|
|
8660
8905
|
const type = attr(wAfter, "w:type");
|
|
8661
|
-
const size = attrMeasure(wAfter, "w:w", type);
|
|
8906
|
+
const size = widthFiftiethsToPct(attrMeasure(wAfter, "w:w"), type);
|
|
8662
8907
|
if (size !== void 0) opts.widthAfter = {
|
|
8663
8908
|
size,
|
|
8664
8909
|
...type ? { type } : {}
|
|
@@ -8674,7 +8919,7 @@ function parseTableRowPropertiesEl(el) {
|
|
|
8674
8919
|
const tblCellSpacing = findChild(el, "w:tblCellSpacing");
|
|
8675
8920
|
if (tblCellSpacing) {
|
|
8676
8921
|
const type = attr(tblCellSpacing, "w:type");
|
|
8677
|
-
const w = attrMeasure(tblCellSpacing, "w:w", type);
|
|
8922
|
+
const w = widthFiftiethsToPct(attrMeasure(tblCellSpacing, "w:w"), type);
|
|
8678
8923
|
if (w !== void 0) opts.cellSpacing = {
|
|
8679
8924
|
size: w,
|
|
8680
8925
|
...type ? { type } : {}
|
|
@@ -8713,7 +8958,7 @@ function parseTableCellPropertiesEl(el) {
|
|
|
8713
8958
|
const tcW = findChild(el, "w:tcW");
|
|
8714
8959
|
if (tcW) {
|
|
8715
8960
|
const type = attr(tcW, "w:type");
|
|
8716
|
-
const size = attrMeasure(tcW, "w:w", type);
|
|
8961
|
+
const size = widthFiftiethsToPct(attrMeasure(tcW, "w:w"), type);
|
|
8717
8962
|
if (size !== void 0) opts.width = {
|
|
8718
8963
|
size,
|
|
8719
8964
|
...type ? { type } : {}
|
|
@@ -11648,8 +11893,8 @@ const settingsDesc = {
|
|
|
11648
11893
|
}));
|
|
11649
11894
|
p.push(onOff("w:removePersonalInformation", opts.removePersonalInformation));
|
|
11650
11895
|
p.push(onOff("w:removeDateAndTime", opts.removeDateAndTime));
|
|
11651
|
-
p.push(onOff("w:displayBackgroundShape", opts.displayBackgroundShape));
|
|
11652
11896
|
p.push(onOff("w:doNotDisplayPageBoundaries", opts.doNotDisplayPageBoundaries));
|
|
11897
|
+
p.push(onOff("w:displayBackgroundShape", opts.displayBackgroundShape));
|
|
11653
11898
|
p.push(onOff("w:printPostScriptOverText", opts.printPostScriptOverText));
|
|
11654
11899
|
p.push(onOff("w:printFractionalCharacterWidth", opts.printFractionalCharacterWidth));
|
|
11655
11900
|
p.push(onOff("w:printFormsData", opts.printFormsData));
|
|
@@ -11734,12 +11979,12 @@ const settingsDesc = {
|
|
|
11734
11979
|
p.push(numVal("w:drawingGridVerticalSpacing", opts.drawingGridVerticalSpacing));
|
|
11735
11980
|
p.push(numVal("w:displayHorizontalDrawingGridEvery", opts.displayHorizontalDrawingGridEvery));
|
|
11736
11981
|
p.push(numVal("w:displayVerticalDrawingGridEvery", opts.displayVerticalDrawingGridEvery));
|
|
11982
|
+
p.push(onOff("w:doNotUseMarginsForDrawingGridOrigin", opts.doNotUseMarginsForDrawingGridOrigin));
|
|
11737
11983
|
p.push(numVal("w:drawingGridHorizontalOrigin", opts.drawingGridHorizontalOrigin));
|
|
11738
11984
|
p.push(numVal("w:drawingGridVerticalOrigin", opts.drawingGridVerticalOrigin));
|
|
11739
|
-
p.push(onOff("w:doNotUseMarginsForDrawingGridOrigin", opts.doNotUseMarginsForDrawingGridOrigin));
|
|
11740
11985
|
p.push(onOff("w:doNotShadeFormData", opts.doNotShadeFormData));
|
|
11741
|
-
if (opts.characterSpacingControl !== void 0) p.push(strVal("w:characterSpacingControl", opts.characterSpacingControl));
|
|
11742
11986
|
p.push(onOff("w:noPunctuationKerning", opts.noPunctuationKerning));
|
|
11987
|
+
if (opts.characterSpacingControl !== void 0) p.push(strVal("w:characterSpacingControl", opts.characterSpacingControl));
|
|
11743
11988
|
p.push(onOff("w:printTwoOnOne", opts.printTwoOnOne));
|
|
11744
11989
|
p.push(onOff("w:strictFirstAndLastChars", opts.strictFirstAndLastChars));
|
|
11745
11990
|
if (opts.noLineBreaksAfter !== void 0) {
|
|
@@ -11790,7 +12035,6 @@ const settingsDesc = {
|
|
|
11790
12035
|
if (opts.rsids !== void 0) p.push(stringifyRsids(opts.rsids));
|
|
11791
12036
|
if (opts.mathPr !== void 0) p.push(stringifyMathPr(opts.mathPr));
|
|
11792
12037
|
if (opts.attachedSchema !== void 0) for (const schema of opts.attachedSchema) p.push(strVal("w:attachedSchema", schema));
|
|
11793
|
-
if (opts.colorSchemeMapping !== void 0) p.push(stringifyColorSchemeMapping(opts.colorSchemeMapping));
|
|
11794
12038
|
if (opts.themeFontLang !== void 0) {
|
|
11795
12039
|
const a = {};
|
|
11796
12040
|
if (opts.themeFontLang.val !== void 0) a["w:val"] = opts.themeFontLang.val;
|
|
@@ -11798,6 +12042,7 @@ const settingsDesc = {
|
|
|
11798
12042
|
if (opts.themeFontLang.bidi !== void 0) a["w:bidi"] = opts.themeFontLang.bidi;
|
|
11799
12043
|
p.push(attrEl("w:themeFontLang", a));
|
|
11800
12044
|
}
|
|
12045
|
+
if (opts.colorSchemeMapping !== void 0) p.push(stringifyColorSchemeMapping(opts.colorSchemeMapping));
|
|
11801
12046
|
p.push(onOff("w:doNotIncludeSubdocsInStats", opts.doNotIncludeSubdocsInStats));
|
|
11802
12047
|
p.push(onOff("w:doNotAutoCompressPictures", opts.doNotAutoCompressPictures));
|
|
11803
12048
|
if (opts.forceUpgrade !== void 0) p.push("<w:forceUpgrade/>");
|
|
@@ -11811,8 +12056,8 @@ const settingsDesc = {
|
|
|
11811
12056
|
if (st.url !== void 0) attrs["w:url"] = st.url;
|
|
11812
12057
|
p.push(attrEl("w:smartTagType", attrs));
|
|
11813
12058
|
}
|
|
11814
|
-
p.push(onOff("w:doNotEmbedSmartTags", opts.doNotEmbedSmartTags));
|
|
11815
12059
|
if (opts.shapeDefaults !== void 0) p.push(`<w:shapeDefaults>${opts.shapeDefaults}</w:shapeDefaults>`);
|
|
12060
|
+
p.push(onOff("w:doNotEmbedSmartTags", opts.doNotEmbedSmartTags));
|
|
11816
12061
|
p.push(strVal("w:decimalSymbol", opts.decimalSymbol));
|
|
11817
12062
|
p.push(strVal("w:listSeparator", opts.listSeparator));
|
|
11818
12063
|
return `<w:settings ${SETTINGS_NS}>${p.join("")}</w:settings>`;
|
|
@@ -13603,6 +13848,6 @@ const webSettingsDesc = {
|
|
|
13603
13848
|
}
|
|
13604
13849
|
};
|
|
13605
13850
|
//#endregion
|
|
13606
|
-
export { PageBorderZOrder as $, stringifyCustomXmlShell as $t, StyleLevel as A,
|
|
13851
|
+
export { PageBorderZOrder as $, stringifyCustomXmlShell as $t, StyleLevel as A, TextHorzOverflowType as An, sectionPageSizeDefaults as At, stringifyNumberingStyle as B, TextEffect as Bn, NumberFormat as Bt, footnotesDesc as C, RubyAlign as Cn, parseSdtBlock as Ct, selectTocEntryElements as D, EmphasisMarkType as Dn, sectionPropertiesDesc as Dt, parseTocFieldInstruction as E, PositionalTabRelativeTo as En, parseSectionPropertiesEl as Et, extractStyleId as F, parseBodyProperties as Fn, createVerticalPosition as Ft, createHeaderFooterReference as G, TextboxTightWrapType as Gn, TextWrappingSide as Gt, stringifyTableStyle as H, PageNumber as Hn, VerticalPositionAlign as Ht, parseStyleDefinitions as I, createImageData$1 as In, createHorizontalPosition as It, LineNumberRestartFormat as J, AlignmentType as Jn, checkboxSymbolRunInner as Jt, SectionType as K, HeadingLevel as Kn, TextWrappingType as Kt, DefaultStylesFactory as L, Media as Ln, HorizontalPositionRelativeFrom as Lt, Styles as M, TextVerticalType as Mn, PageOrientation as Mt, buildNumberingCache as N, VerticalAnchor as Nn, PageNumberSeparator as Nt, SdtDateMappingType as O, UnderlineType as On, stringifySectionPropertiesXml as Ot, buildStyleCache as P, createBodyProperties as Pn, createPageNumberType as Pt, PageBorderOffsetFrom as Q, setBodyParseChild as Qt, stringifyCharacterStyle as R, createTransformation as Rn, VerticalPositionRelativeFrom as Rt, endnotesDesc as S, parseFormFieldData as Sn, stringifyTableOfContents as St, parseTocFieldFromElements as T, PositionalTabLeader as Tn, FontWrapper as Tt, HeaderFooterReferenceType as U, breakXml as Un, createWrapThrough as Ut, stringifyParagraphStyle as V, EMPTY_RUN_ELEMENTS as Vn, SpaceType as Vt, HeaderFooterType as W, TextAlignmentType as Wn, createWrapTight as Wt, createPageMargin as X, parseCustomXmlProperties as Xt, createLineNumberType as Y, customXmlBlockDesc as Yt, PageBorderDisplay as Z, sdtBlockDesc as Zt, glossaryDesc as _, TextDirection as _n, parseParagraph as _t, appPropertiesDesc as a, parseShading as an, LevelFormat as at, CharacterSet as b, FormFieldTextType as bn, stringifyDocumentXml as bt, relationshipsDesc as c, widthFiftiethsToPct as cn, parseTablePropertiesEl as ct, withAltChunkOverrides as d, BorderStyle as dn, tableDesc as dt, stringifySdtPr as en, DocumentGridType as et, withMediaDefaults as f, TableLayoutType as fn, stringifyChildDispatch as ft, DocPartType as g, TableAnchorType as gn, resetDrawingIdGen as gt, DocPartGallery as h, RelativeVerticalPosition as hn, drawingDesc as ht, webSettingsDesc as i, ShadingType as in, parseNumberingDefinitions as it, settingsDesc as j, TextVertOverflowType as jn, PageTextDirectionType as jt, SdtLock as k, TextBodyWrappingType as kn, sectionMarginDefaults as kt, buildContentTypesFromRegistry as l, widthPctToFiftieths as ln, parseTableRowPropertiesEl as lt, DocPartBehavior as m, RelativeHorizontalPosition as mn, stringifyRunInline as mt, frameXml as n, subDocDesc as nn, DocumentAttributeNamespaces as nt, customPropertiesDesc as o, objectDesc as on, LevelSuffix as ot, commentsDesc as p, OverlapType as pn, stringifyParagraphInline as pt, createSectionType as q, LineRuleType as qn, altChunkDesc as qt, framesetXml as r, stringifyElement as rn, Numbering as rt, corePropertiesDesc as s, WidthType as sn, parseTableCellPropertiesEl as st, TargetScreenSize as t, stringifySdtShell as tn, createDocumentGrid as tt, contentTypesDesc as u, TABLE_BORDERS_NONE as un, setTableParseChild as ut, bibliographyDesc as v, VerticalMergeType as vn, parseParagraphProperties as vt, parseToc as w, PositionalTabAlignment as wn, parseSdtProperties as wt, EditGroupType as x, createFormFieldData as xn, replaceRelsWithPlaceholders as xt, fontTableDesc as y, ProofErrorType as yn, stringifyBodyChild as yt, stringifyConditionalTableStyle as z, HighlightColor as zn, HorizontalPositionAlign as zt };
|
|
13607
13852
|
|
|
13608
|
-
//# sourceMappingURL=parts-
|
|
13853
|
+
//# sourceMappingURL=parts-D0KoDfg7.mjs.map
|