@office-open/docx 0.9.3 → 0.9.4
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/{context-DeKZoZem.mjs → context-CA7wUvmY.mjs} +1217 -604
- package/dist/context-CA7wUvmY.mjs.map +1 -0
- package/dist/{core-properties-D9dBbZtc.d.mts → core-properties-CR-T1Wqh.d.mts} +45 -10
- package/dist/core-properties-CR-T1Wqh.d.mts.map +1 -0
- package/dist/{document-D8HDkCHs.mjs → document-B_uvEH8b.mjs} +367 -79
- package/dist/document-B_uvEH8b.mjs.map +1 -0
- package/dist/{generate-DjkvEWjY.mjs → generate-_AmBlI4o.mjs} +4 -4
- package/dist/generate-_AmBlI4o.mjs.map +1 -0
- package/dist/generate.d.mts +1 -1
- package/dist/generate.mjs +1 -1
- package/dist/index.d.mts +3 -2
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +5 -34
- package/dist/index.mjs.map +1 -1
- package/dist/{parse-CR5VbXbs.mjs → parse-7SJ1sm-D.mjs} +17 -4
- package/dist/parse-7SJ1sm-D.mjs.map +1 -0
- package/dist/parse.d.mts +1 -1
- package/dist/parse.mjs +1 -1
- package/dist/patch/index.d.mts +1 -1
- package/dist/patch/index.mjs +1 -1
- package/package.json +3 -3
- package/dist/context-DeKZoZem.mjs.map +0 -1
- package/dist/core-properties-D9dBbZtc.d.mts.map +0 -1
- package/dist/document-D8HDkCHs.mjs.map +0 -1
- package/dist/generate-DjkvEWjY.mjs.map +0 -1
- package/dist/parse-CR5VbXbs.mjs.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TargetModeType, convertEmuToPixels, convertPixelsToEmu, convertToEmu, convertToTwip, convertUniversalMeasureToEmu, decimalNumber, eighthPointMeasureValue, hexColorValue, hpsMeasureValue, measurementOrPercentValue, pointMeasureValue, signedTwipsMeasureValue, toUint8Array, twipsMeasureValue, uCharHexNumber, uniqueId, uniqueNumericIdCreator, xsdVerticalMergeRev } from "@office-open/core";
|
|
1
|
+
import { TargetModeType, ThemeColor, convertEmuToPixels, convertPixelsToEmu, convertToEmu, convertToTwip, convertUniversalMeasureToEmu, decimalNumber, eighthPointMeasureValue, hexColorValue, hpsMeasureValue, measurementOrPercentValue, pointMeasureValue, signedTwipsMeasureValue, toUint8Array, twipsMeasureValue, uCharHexNumber, uniqueId, uniqueNumericIdCreator, xsdVerticalMergeRev } from "@office-open/core";
|
|
2
2
|
import { attr, attrBool, attrNum, children, element, escapeXml, findChild, findDeep, textOf } from "@office-open/xml";
|
|
3
3
|
import { calculateEffectExtent, createEffectDag, createScene3D, createShape3D, customGeometryDesc, effectListDesc, extractBlipFillMedia, fillDesc, outlineDesc, scene3DDesc, shape3DDesc, transform2DDesc } from "@office-open/core/drawingml";
|
|
4
4
|
import { chartSpaceDesc } from "@office-open/core/chart";
|
|
@@ -1259,40 +1259,76 @@ function parseImageRun(el, ctx) {
|
|
|
1259
1259
|
}
|
|
1260
1260
|
if (anchor && !inline) {
|
|
1261
1261
|
const floating = {};
|
|
1262
|
+
const margins = {};
|
|
1263
|
+
const distT = attrNum(anchor, "distT");
|
|
1264
|
+
if (distT !== void 0) margins.top = distT;
|
|
1265
|
+
const distB = attrNum(anchor, "distB");
|
|
1266
|
+
if (distB !== void 0) margins.bottom = distB;
|
|
1267
|
+
const distL = attrNum(anchor, "distL");
|
|
1268
|
+
if (distL !== void 0) margins.left = distL;
|
|
1269
|
+
const distR = attrNum(anchor, "distR");
|
|
1270
|
+
if (distR !== void 0) margins.right = distR;
|
|
1271
|
+
if (Object.keys(margins).length > 0) floating.margins = margins;
|
|
1262
1272
|
const posH = findChild(anchor, "wp:positionH");
|
|
1263
1273
|
if (posH) {
|
|
1264
|
-
const
|
|
1265
|
-
|
|
1266
|
-
if (align) floating.horizontalPosition = { align: textOf(align) };
|
|
1267
|
-
else if (posOffset) {
|
|
1268
|
-
const val = Number(textOf(posOffset));
|
|
1269
|
-
if (!isNaN(val)) floating.horizontalPosition = { offset: val };
|
|
1270
|
-
}
|
|
1274
|
+
const hp = readPosition(posH);
|
|
1275
|
+
if (hp) floating.horizontalPosition = hp;
|
|
1271
1276
|
}
|
|
1272
1277
|
const posV = findChild(anchor, "wp:positionV");
|
|
1273
1278
|
if (posV) {
|
|
1274
|
-
const
|
|
1275
|
-
|
|
1276
|
-
if (align) floating.verticalPosition = { align: textOf(align) };
|
|
1277
|
-
else if (posOffset) {
|
|
1278
|
-
const val = Number(textOf(posOffset));
|
|
1279
|
-
if (!isNaN(val)) floating.verticalPosition = { offset: val };
|
|
1280
|
-
}
|
|
1279
|
+
const vp = readPosition(posV);
|
|
1280
|
+
if (vp) floating.verticalPosition = vp;
|
|
1281
1281
|
}
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
if (
|
|
1282
|
+
const wrap = readWrap(anchor);
|
|
1283
|
+
if (wrap) floating.wrap = wrap;
|
|
1284
|
+
const allowOverlap = attrBool(anchor, "allowOverlap");
|
|
1285
|
+
if (allowOverlap !== void 0) floating.allowOverlap = allowOverlap;
|
|
1286
|
+
const behindDoc = attrBool(anchor, "behindDoc");
|
|
1287
|
+
if (behindDoc !== void 0) floating.behindDocument = behindDoc;
|
|
1288
|
+
const locked = attrBool(anchor, "locked");
|
|
1289
|
+
if (locked !== void 0) floating.lockAnchor = locked;
|
|
1290
|
+
const layoutInCell = attrBool(anchor, "layoutInCell");
|
|
1291
|
+
if (layoutInCell !== void 0) floating.layoutInCell = layoutInCell;
|
|
1292
|
+
const relativeHeight = attrNum(anchor, "relativeHeight");
|
|
1293
|
+
if (relativeHeight !== void 0) floating.zIndex = relativeHeight;
|
|
1292
1294
|
if (Object.keys(floating).length > 0) imageOpts.floating = floating;
|
|
1293
1295
|
}
|
|
1294
1296
|
return { image: imageOpts };
|
|
1295
1297
|
}
|
|
1298
|
+
/** Map wp:positionH/V children + relativeFrom into a position-options object. */
|
|
1299
|
+
function readPosition(posEl) {
|
|
1300
|
+
const relative = attr(posEl, "relativeFrom");
|
|
1301
|
+
const alignEl = findChild(posEl, "wp:align");
|
|
1302
|
+
const posOffset = findChild(posEl, "wp:posOffset");
|
|
1303
|
+
const result = {};
|
|
1304
|
+
if (relative) result.relative = relative;
|
|
1305
|
+
if (alignEl) {
|
|
1306
|
+
const a = textOf(alignEl);
|
|
1307
|
+
if (a) result.align = a;
|
|
1308
|
+
} else if (posOffset) {
|
|
1309
|
+
const val = Number(textOf(posOffset));
|
|
1310
|
+
if (!isNaN(val)) result.offset = val;
|
|
1311
|
+
}
|
|
1312
|
+
return Object.keys(result).length > 0 ? result : void 0;
|
|
1313
|
+
}
|
|
1314
|
+
/** Map the wp:anchor wrap child element into a TextWrapping ({ type, side? }). */
|
|
1315
|
+
function readWrap(anchor) {
|
|
1316
|
+
const WRAP_TYPE = [
|
|
1317
|
+
["wrapNone", TextWrappingType.NONE],
|
|
1318
|
+
["wrapSquare", TextWrappingType.SQUARE],
|
|
1319
|
+
["wrapTight", TextWrappingType.TIGHT],
|
|
1320
|
+
["wrapTopAndBottom", TextWrappingType.TOP_AND_BOTTOM],
|
|
1321
|
+
["wrapThrough", TextWrappingType.THROUGH]
|
|
1322
|
+
];
|
|
1323
|
+
for (const [name, type] of WRAP_TYPE) {
|
|
1324
|
+
const el = findChild(anchor, `wp:${name}`);
|
|
1325
|
+
if (!el) continue;
|
|
1326
|
+
const wrap = { type };
|
|
1327
|
+
const side = attr(el, "wrapText");
|
|
1328
|
+
if (side) wrap.side = side;
|
|
1329
|
+
return wrap;
|
|
1330
|
+
}
|
|
1331
|
+
}
|
|
1296
1332
|
function getDrawingExtent(el) {
|
|
1297
1333
|
const inline = findDeep(el, "wp:inline")[0];
|
|
1298
1334
|
const anchor = inline ? void 0 : findDeep(el, "wp:anchor")[0];
|
|
@@ -3032,6 +3068,11 @@ function stringifyChildDispatch(child, ctx) {
|
|
|
3032
3068
|
if (sf.cachedValue !== void 0) return `<w:fldSimple w:instr="${escapeXml(sf.instruction)}"><w:r><w:t>${escapeXml(sf.cachedValue)}</w:t></w:r></w:fldSimple>`;
|
|
3033
3069
|
return `<w:fldSimple w:instr="${escapeXml(sf.instruction)}"/>`;
|
|
3034
3070
|
}
|
|
3071
|
+
if ("complexField" in child) {
|
|
3072
|
+
const cf = child.complexField;
|
|
3073
|
+
const resultXml = cf.result !== void 0 ? `<w:r><w:fldChar w:fldCharType="separate"/></w:r><w:r><w:t xml:space="preserve">${escapeXml(cf.result)}</w:t></w:r>` : "";
|
|
3074
|
+
return `<w:r><w:fldChar w:fldCharType="begin"/></w:r><w:r><w:instrText xml:space="preserve">${escapeXml(cf.instruction)}</w:instrText></w:r>` + resultXml + "<w:r><w:fldChar w:fldCharType=\"end\"/></w:r>";
|
|
3075
|
+
}
|
|
3035
3076
|
if ("seqIdentifier" in child) {
|
|
3036
3077
|
const id = child.seqIdentifier;
|
|
3037
3078
|
return `<w:r><w:fldChar w:fldCharType="begin"/><w:instrText xml:space="preserve"> SEQ ${escapeXml(id)} </w:instrText><w:fldChar w:fldCharType="separate"/><w:fldChar w:fldCharType="end"/></w:r>`;
|
|
@@ -3178,20 +3219,15 @@ function cellMarginStr(tag, opts) {
|
|
|
3178
3219
|
const inner = cellMarginChildrenStr(opts);
|
|
3179
3220
|
return inner ? `<${tag}>${inner}</${tag}>` : void 0;
|
|
3180
3221
|
}
|
|
3181
|
-
const DEFAULT_BORDER = {
|
|
3182
|
-
color: "auto",
|
|
3183
|
-
size: 4,
|
|
3184
|
-
style: BorderStyle.SINGLE
|
|
3185
|
-
};
|
|
3186
3222
|
function tableBordersStr(opts) {
|
|
3187
3223
|
const parts = [];
|
|
3188
|
-
parts.push(borderStr("w:top", opts.top
|
|
3189
|
-
parts.push(borderStr("w:left", opts.left
|
|
3190
|
-
parts.push(borderStr("w:bottom", opts.bottom
|
|
3191
|
-
parts.push(borderStr("w:right", opts.right
|
|
3192
|
-
parts.push(borderStr("w:insideH", opts.insideHorizontal
|
|
3193
|
-
parts.push(borderStr("w:insideV", opts.insideVertical
|
|
3194
|
-
return `<w:tblBorders>${parts.join("")}</w:tblBorders
|
|
3224
|
+
if (opts.top) parts.push(borderStr("w:top", opts.top));
|
|
3225
|
+
if (opts.left) parts.push(borderStr("w:left", opts.left));
|
|
3226
|
+
if (opts.bottom) parts.push(borderStr("w:bottom", opts.bottom));
|
|
3227
|
+
if (opts.right) parts.push(borderStr("w:right", opts.right));
|
|
3228
|
+
if (opts.insideHorizontal) parts.push(borderStr("w:insideH", opts.insideHorizontal));
|
|
3229
|
+
if (opts.insideVertical) parts.push(borderStr("w:insideV", opts.insideVertical));
|
|
3230
|
+
return parts.length > 0 ? `<w:tblBorders>${parts.join("")}</w:tblBorders>` : void 0;
|
|
3195
3231
|
}
|
|
3196
3232
|
function cellBordersStr(opts) {
|
|
3197
3233
|
const parts = [];
|
|
@@ -3276,7 +3312,10 @@ function stringifyTablePropertiesInner(options) {
|
|
|
3276
3312
|
if (options.width) parts.push(tableWidthStr("w:tblW", options.width));
|
|
3277
3313
|
if (options.alignment) parts.push(`<w:jc w:val="${options.alignment}"/>`);
|
|
3278
3314
|
if (options.indent) parts.push(tableWidthStr("w:tblInd", options.indent));
|
|
3279
|
-
if (options.borders)
|
|
3315
|
+
if (options.borders) {
|
|
3316
|
+
const bs = tableBordersStr(options.borders);
|
|
3317
|
+
if (bs) parts.push(bs);
|
|
3318
|
+
}
|
|
3280
3319
|
if (options.shading) parts.push(shadingStr(options.shading));
|
|
3281
3320
|
if (options.layout) parts.push(`<w:tblLayout w:type="${options.layout}"/>`);
|
|
3282
3321
|
if (options.cellMargin) {
|
|
@@ -3400,7 +3439,10 @@ function stringifyTablePropertyExceptions(options) {
|
|
|
3400
3439
|
if (options.alignment) parts.push(`<w:jc w:val="${options.alignment}"/>`);
|
|
3401
3440
|
if (options.cellSpacing) parts.push(cellSpacingStr(options.cellSpacing));
|
|
3402
3441
|
if (options.indent) parts.push(tableWidthStr("w:tblInd", options.indent));
|
|
3403
|
-
if (options.borders)
|
|
3442
|
+
if (options.borders) {
|
|
3443
|
+
const bs = tableBordersStr(options.borders);
|
|
3444
|
+
if (bs) parts.push(bs);
|
|
3445
|
+
}
|
|
3404
3446
|
if (options.shading) parts.push(shadingStr(options.shading));
|
|
3405
3447
|
if (options.layout) parts.push(`<w:tblLayout w:type="${options.layout}"/>`);
|
|
3406
3448
|
if (options.cellMargin) {
|
|
@@ -3422,6 +3464,27 @@ function stringifyTablePropertyExceptions(options) {
|
|
|
3422
3464
|
}
|
|
3423
3465
|
//#endregion
|
|
3424
3466
|
//#region src/parts/table/descriptor.ts
|
|
3467
|
+
/**
|
|
3468
|
+
* Table (w:tbl) descriptor for DOCX.
|
|
3469
|
+
*
|
|
3470
|
+
* Stringifies pure JSON TableOptions into XML using direct string
|
|
3471
|
+
* concatenation — zero IXmlableObject, zero xml(), zero BaseXmlComponent.
|
|
3472
|
+
*
|
|
3473
|
+
* @module
|
|
3474
|
+
*/
|
|
3475
|
+
const BORDER_STYLES = Object.values(BorderStyle);
|
|
3476
|
+
const THEME_COLORS = Object.values(ThemeColor);
|
|
3477
|
+
/** Parse track-change attributes (id/author/date) from w:ins/w:del/w:cellIns/w:cellDel. */
|
|
3478
|
+
function parseChangeAttrs(el) {
|
|
3479
|
+
const change = {};
|
|
3480
|
+
const id = attrNum(el, "w:id");
|
|
3481
|
+
if (id !== void 0) change.id = id;
|
|
3482
|
+
const author = attr(el, "w:author");
|
|
3483
|
+
if (author) change.author = author;
|
|
3484
|
+
const date = attr(el, "w:date");
|
|
3485
|
+
if (date) change.date = date;
|
|
3486
|
+
return change;
|
|
3487
|
+
}
|
|
3425
3488
|
function buildTableGridXml(widths, revision) {
|
|
3426
3489
|
const cols = widths.map((w) => `<w:gridCol w:w="${w}"/>`).join("");
|
|
3427
3490
|
if (revision) {
|
|
@@ -3520,9 +3583,9 @@ const tableDesc = {
|
|
|
3520
3583
|
kind: "custom",
|
|
3521
3584
|
stringify(opts, ctx) {
|
|
3522
3585
|
const parts = [];
|
|
3523
|
-
const
|
|
3586
|
+
const tblPrOpts = {
|
|
3524
3587
|
alignment: opts.alignment,
|
|
3525
|
-
borders: opts.borders
|
|
3588
|
+
borders: opts.borders,
|
|
3526
3589
|
caption: opts.caption,
|
|
3527
3590
|
cellMargin: opts.margins,
|
|
3528
3591
|
cellSpacing: opts.cellSpacing,
|
|
@@ -3536,9 +3599,10 @@ const tableDesc = {
|
|
|
3536
3599
|
styleRowBandSize: opts.styleRowBandSize,
|
|
3537
3600
|
tableLook: opts.tableLook,
|
|
3538
3601
|
visuallyRightToLeft: opts.visuallyRightToLeft,
|
|
3539
|
-
width: opts.width
|
|
3540
|
-
|
|
3541
|
-
|
|
3602
|
+
width: opts.width,
|
|
3603
|
+
includeIfEmpty: true
|
|
3604
|
+
};
|
|
3605
|
+
parts.push(stringifyTableProperties(tblPrOpts));
|
|
3542
3606
|
const columnWidths = opts.columnWidths ?? Array(Math.max(...opts.rows.map((r) => r.cells.length))).fill(100);
|
|
3543
3607
|
parts.push(buildTableGridXml(columnWidths, opts.columnWidthsRevision));
|
|
3544
3608
|
const extraCells = computeVerticalMergeCells(opts.rows);
|
|
@@ -3588,28 +3652,38 @@ function parseTablePropertiesEl(el) {
|
|
|
3588
3652
|
}
|
|
3589
3653
|
const tblBorders = findChild(el, "w:tblBorders");
|
|
3590
3654
|
if (tblBorders) {
|
|
3655
|
+
const SIDE_KEYS = [
|
|
3656
|
+
["top", "top"],
|
|
3657
|
+
["left", "left"],
|
|
3658
|
+
["bottom", "bottom"],
|
|
3659
|
+
["right", "right"],
|
|
3660
|
+
["insideH", "insideHorizontal"],
|
|
3661
|
+
["insideV", "insideVertical"]
|
|
3662
|
+
];
|
|
3591
3663
|
const borders = {};
|
|
3592
|
-
for (const
|
|
3593
|
-
|
|
3594
|
-
|
|
3595
|
-
"
|
|
3596
|
-
|
|
3597
|
-
|
|
3598
|
-
"
|
|
3599
|
-
|
|
3600
|
-
const
|
|
3601
|
-
if (
|
|
3602
|
-
|
|
3603
|
-
|
|
3604
|
-
|
|
3605
|
-
|
|
3606
|
-
|
|
3607
|
-
|
|
3608
|
-
|
|
3609
|
-
|
|
3610
|
-
|
|
3611
|
-
|
|
3612
|
-
|
|
3664
|
+
for (const [xmlSide, key] of SIDE_KEYS) {
|
|
3665
|
+
const sideEl = findChild(tblBorders, `w:${xmlSide}`);
|
|
3666
|
+
if (!sideEl) continue;
|
|
3667
|
+
const style = attr(sideEl, "w:val");
|
|
3668
|
+
if (!style || !BORDER_STYLES.includes(style)) continue;
|
|
3669
|
+
const sideOpts = { style };
|
|
3670
|
+
const color = attr(sideEl, "w:color");
|
|
3671
|
+
if (color) sideOpts.color = color;
|
|
3672
|
+
const size = attrNum(sideEl, "w:sz");
|
|
3673
|
+
if (size !== void 0) sideOpts.size = size;
|
|
3674
|
+
const space = attrNum(sideEl, "w:space");
|
|
3675
|
+
if (space !== void 0) sideOpts.space = space;
|
|
3676
|
+
const themeColor = attr(sideEl, "w:themeColor");
|
|
3677
|
+
if (themeColor && THEME_COLORS.includes(themeColor)) sideOpts.themeColor = themeColor;
|
|
3678
|
+
const themeTint = attr(sideEl, "w:themeTint");
|
|
3679
|
+
if (themeTint) sideOpts.themeTint = themeTint;
|
|
3680
|
+
const themeShade = attr(sideEl, "w:themeShade");
|
|
3681
|
+
if (themeShade) sideOpts.themeShade = themeShade;
|
|
3682
|
+
const shadow = attrBool(sideEl, "w:shadow");
|
|
3683
|
+
if (shadow !== void 0) sideOpts.shadow = shadow;
|
|
3684
|
+
const frame = attrBool(sideEl, "w:frame");
|
|
3685
|
+
if (frame !== void 0) sideOpts.frame = frame;
|
|
3686
|
+
borders[key] = sideOpts;
|
|
3613
3687
|
}
|
|
3614
3688
|
if (Object.keys(borders).length > 0) opts.borders = borders;
|
|
3615
3689
|
}
|
|
@@ -3684,6 +3758,45 @@ function parseTablePropertiesEl(el) {
|
|
|
3684
3758
|
...type ? { type } : {}
|
|
3685
3759
|
};
|
|
3686
3760
|
}
|
|
3761
|
+
const bidiVisual = findChild(el, "w:bidiVisual");
|
|
3762
|
+
if (bidiVisual) opts.visuallyRightToLeft = attrBool(bidiVisual, "w:val") ?? true;
|
|
3763
|
+
const tblStyleRowBandSize = findChild(el, "w:tblStyleRowBandSize");
|
|
3764
|
+
if (tblStyleRowBandSize) {
|
|
3765
|
+
const val = attrNum(tblStyleRowBandSize, "w:val");
|
|
3766
|
+
if (val !== void 0) opts.styleRowBandSize = val;
|
|
3767
|
+
}
|
|
3768
|
+
const tblStyleColBandSize = findChild(el, "w:tblStyleColBandSize");
|
|
3769
|
+
if (tblStyleColBandSize) {
|
|
3770
|
+
const val = attrNum(tblStyleColBandSize, "w:val");
|
|
3771
|
+
if (val !== void 0) opts.styleColBandSize = val;
|
|
3772
|
+
}
|
|
3773
|
+
const tblCaption = findChild(el, "w:tblCaption");
|
|
3774
|
+
if (tblCaption) {
|
|
3775
|
+
const val = attr(tblCaption, "w:val");
|
|
3776
|
+
if (val) opts.caption = val;
|
|
3777
|
+
}
|
|
3778
|
+
const tblCellSpacing = findChild(el, "w:tblCellSpacing");
|
|
3779
|
+
if (tblCellSpacing) {
|
|
3780
|
+
const type = attr(tblCellSpacing, "w:type");
|
|
3781
|
+
const w = attrNum(tblCellSpacing, "w:w");
|
|
3782
|
+
if (w !== void 0) opts.cellSpacing = {
|
|
3783
|
+
value: w,
|
|
3784
|
+
...type ? { type } : {}
|
|
3785
|
+
};
|
|
3786
|
+
}
|
|
3787
|
+
const tblPrChange = findChild(el, "w:tblPrChange");
|
|
3788
|
+
if (tblPrChange) {
|
|
3789
|
+
const rev = {};
|
|
3790
|
+
const author = attr(tblPrChange, "w:author");
|
|
3791
|
+
if (author) rev.author = author;
|
|
3792
|
+
const date = attr(tblPrChange, "w:date");
|
|
3793
|
+
if (date) rev.date = date;
|
|
3794
|
+
const id = attrNum(tblPrChange, "w:id");
|
|
3795
|
+
if (id !== void 0) rev.id = id;
|
|
3796
|
+
const innerTblPr = findChild(tblPrChange, "w:tblPr");
|
|
3797
|
+
if (innerTblPr) Object.assign(rev, parseTablePropertiesEl(innerTblPr));
|
|
3798
|
+
if (Object.keys(rev).length > 0) opts.revision = rev;
|
|
3799
|
+
}
|
|
3687
3800
|
return opts;
|
|
3688
3801
|
}
|
|
3689
3802
|
function parseColumnWidthsEl(el) {
|
|
@@ -3707,10 +3820,105 @@ function parseTableRowPropertiesEl(el) {
|
|
|
3707
3820
|
rule: rule ?? "atLeast"
|
|
3708
3821
|
};
|
|
3709
3822
|
}
|
|
3823
|
+
const cnfStyle = findChild(el, "w:cnfStyle");
|
|
3824
|
+
if (cnfStyle) {
|
|
3825
|
+
const val = attr(cnfStyle, "w:val");
|
|
3826
|
+
if (val) {
|
|
3827
|
+
const cnf = { val };
|
|
3828
|
+
const changed = attrBool(cnfStyle, "w:changed");
|
|
3829
|
+
if (changed !== void 0) cnf.changed = changed;
|
|
3830
|
+
opts.cnfStyle = cnf;
|
|
3831
|
+
}
|
|
3832
|
+
}
|
|
3833
|
+
const divId = findChild(el, "w:divId");
|
|
3834
|
+
if (divId) {
|
|
3835
|
+
const val = attrNum(divId, "w:val");
|
|
3836
|
+
if (val !== void 0) opts.divId = val;
|
|
3837
|
+
}
|
|
3838
|
+
const gridBefore = findChild(el, "w:gridBefore");
|
|
3839
|
+
if (gridBefore) {
|
|
3840
|
+
const val = attrNum(gridBefore, "w:val");
|
|
3841
|
+
if (val !== void 0) opts.gridBefore = val;
|
|
3842
|
+
}
|
|
3843
|
+
const gridAfter = findChild(el, "w:gridAfter");
|
|
3844
|
+
if (gridAfter) {
|
|
3845
|
+
const val = attrNum(gridAfter, "w:val");
|
|
3846
|
+
if (val !== void 0) opts.gridAfter = val;
|
|
3847
|
+
}
|
|
3848
|
+
const wBefore = findChild(el, "w:wBefore");
|
|
3849
|
+
if (wBefore) {
|
|
3850
|
+
const rawSize = attr(wBefore, "w:w");
|
|
3851
|
+
const type = attr(wBefore, "w:type");
|
|
3852
|
+
const size = type === "pct" ? rawSize : attrNum(wBefore, "w:w");
|
|
3853
|
+
if (size !== void 0) opts.widthBefore = {
|
|
3854
|
+
size,
|
|
3855
|
+
...type ? { type } : {}
|
|
3856
|
+
};
|
|
3857
|
+
}
|
|
3858
|
+
const wAfter = findChild(el, "w:wAfter");
|
|
3859
|
+
if (wAfter) {
|
|
3860
|
+
const rawSize = attr(wAfter, "w:w");
|
|
3861
|
+
const type = attr(wAfter, "w:type");
|
|
3862
|
+
const size = type === "pct" ? rawSize : attrNum(wAfter, "w:w");
|
|
3863
|
+
if (size !== void 0) opts.widthAfter = {
|
|
3864
|
+
size,
|
|
3865
|
+
...type ? { type } : {}
|
|
3866
|
+
};
|
|
3867
|
+
}
|
|
3868
|
+
const jc = findChild(el, "w:jc");
|
|
3869
|
+
if (jc) {
|
|
3870
|
+
const val = attr(jc, "w:val");
|
|
3871
|
+
if (val) opts.rowAlignment = val;
|
|
3872
|
+
}
|
|
3873
|
+
const hidden = findChild(el, "w:hidden");
|
|
3874
|
+
if (hidden) opts.hidden = attrBool(hidden, "w:val") ?? true;
|
|
3875
|
+
const tblCellSpacing = findChild(el, "w:tblCellSpacing");
|
|
3876
|
+
if (tblCellSpacing) {
|
|
3877
|
+
const type = attr(tblCellSpacing, "w:type");
|
|
3878
|
+
const w = attrNum(tblCellSpacing, "w:w");
|
|
3879
|
+
if (w !== void 0) opts.cellSpacing = {
|
|
3880
|
+
value: w,
|
|
3881
|
+
...type ? { type } : {}
|
|
3882
|
+
};
|
|
3883
|
+
}
|
|
3884
|
+
const ins = findChild(el, "w:ins");
|
|
3885
|
+
if (ins) opts.insertion = parseChangeAttrs(ins);
|
|
3886
|
+
const del = findChild(el, "w:del");
|
|
3887
|
+
if (del) opts.deletion = parseChangeAttrs(del);
|
|
3888
|
+
const trPrChange = findChild(el, "w:trPrChange");
|
|
3889
|
+
if (trPrChange) {
|
|
3890
|
+
const rev = {};
|
|
3891
|
+
const author = attr(trPrChange, "w:author");
|
|
3892
|
+
if (author) rev.author = author;
|
|
3893
|
+
const date = attr(trPrChange, "w:date");
|
|
3894
|
+
if (date) rev.date = date;
|
|
3895
|
+
const id = attrNum(trPrChange, "w:id");
|
|
3896
|
+
if (id !== void 0) rev.id = id;
|
|
3897
|
+
const innerTrPr = findChild(trPrChange, "w:trPr");
|
|
3898
|
+
if (innerTrPr) Object.assign(rev, parseTableRowPropertiesEl(innerTrPr));
|
|
3899
|
+
if (Object.keys(rev).length > 0) opts.revision = rev;
|
|
3900
|
+
}
|
|
3710
3901
|
const tblHeader = findChild(el, "w:tblHeader");
|
|
3711
3902
|
if (tblHeader) opts.tableHeader = attrBool(tblHeader, "w:val") ?? true;
|
|
3712
3903
|
const cantSplit = findChild(el, "w:cantSplit");
|
|
3713
3904
|
if (cantSplit) opts.cantSplit = attrBool(cantSplit, "w:val") ?? true;
|
|
3905
|
+
const tblLook = findChild(el, "w:tblLook");
|
|
3906
|
+
if (tblLook) {
|
|
3907
|
+
const look = {};
|
|
3908
|
+
const firstRow = attrBool(tblLook, "w:firstRow");
|
|
3909
|
+
if (firstRow !== void 0) look.firstRow = firstRow;
|
|
3910
|
+
const lastRow = attrBool(tblLook, "w:lastRow");
|
|
3911
|
+
if (lastRow !== void 0) look.lastRow = lastRow;
|
|
3912
|
+
const firstColumn = attrBool(tblLook, "w:firstColumn");
|
|
3913
|
+
if (firstColumn !== void 0) look.firstColumn = firstColumn;
|
|
3914
|
+
const lastColumn = attrBool(tblLook, "w:lastColumn");
|
|
3915
|
+
if (lastColumn !== void 0) look.lastColumn = lastColumn;
|
|
3916
|
+
const noHBand = attrBool(tblLook, "w:noHBand");
|
|
3917
|
+
if (noHBand !== void 0) look.noHBand = noHBand;
|
|
3918
|
+
const noVBand = attrBool(tblLook, "w:noVBand");
|
|
3919
|
+
if (noVBand !== void 0) look.noVBand = noVBand;
|
|
3920
|
+
if (Object.keys(look).length > 0) opts.tableLook = look;
|
|
3921
|
+
}
|
|
3714
3922
|
return opts;
|
|
3715
3923
|
}
|
|
3716
3924
|
function parseTableCellPropertiesEl(el) {
|
|
@@ -3750,13 +3958,17 @@ function parseTableCellPropertiesEl(el) {
|
|
|
3750
3958
|
const tcBorders = findChild(el, "w:tcBorders");
|
|
3751
3959
|
if (tcBorders) {
|
|
3752
3960
|
const borders = {};
|
|
3753
|
-
for (const
|
|
3754
|
-
"top",
|
|
3755
|
-
"
|
|
3756
|
-
"left",
|
|
3757
|
-
"
|
|
3961
|
+
for (const [xmlSide, key] of [
|
|
3962
|
+
["top", "top"],
|
|
3963
|
+
["start", "start"],
|
|
3964
|
+
["left", "left"],
|
|
3965
|
+
["bottom", "bottom"],
|
|
3966
|
+
["end", "end"],
|
|
3967
|
+
["right", "right"],
|
|
3968
|
+
["tl2br", "topLeftToBottomRight"],
|
|
3969
|
+
["tr2bl", "topRightToBottomLeft"]
|
|
3758
3970
|
]) {
|
|
3759
|
-
const sideEl = findChild(tcBorders, `w:${
|
|
3971
|
+
const sideEl = findChild(tcBorders, `w:${xmlSide}`);
|
|
3760
3972
|
if (sideEl) {
|
|
3761
3973
|
const b = {};
|
|
3762
3974
|
const val = attr(sideEl, "w:val");
|
|
@@ -3765,12 +3977,13 @@ function parseTableCellPropertiesEl(el) {
|
|
|
3765
3977
|
if (color) b.color = color;
|
|
3766
3978
|
const sz = attrNum(sideEl, "w:sz");
|
|
3767
3979
|
if (sz !== void 0) b.size = sz;
|
|
3768
|
-
borders[
|
|
3980
|
+
borders[key] = b;
|
|
3769
3981
|
}
|
|
3770
3982
|
}
|
|
3771
3983
|
if (Object.keys(borders).length > 0) opts.borders = borders;
|
|
3772
3984
|
}
|
|
3773
|
-
|
|
3985
|
+
const noWrap = findChild(el, "w:noWrap");
|
|
3986
|
+
if (noWrap) opts.noWrap = attrBool(noWrap, "w:val") ?? true;
|
|
3774
3987
|
const tcMar = findChild(el, "w:tcMar");
|
|
3775
3988
|
if (tcMar) {
|
|
3776
3989
|
const margins = {};
|
|
@@ -3799,6 +4012,48 @@ function parseTableCellPropertiesEl(el) {
|
|
|
3799
4012
|
const val = attr(textDirection, "w:val");
|
|
3800
4013
|
if (val) opts.textDirection = val;
|
|
3801
4014
|
}
|
|
4015
|
+
const hMerge = findChild(el, "w:hMerge");
|
|
4016
|
+
if (hMerge) opts.horizontalMerge = attr(hMerge, "w:val") === "restart" ? "restart" : "continue";
|
|
4017
|
+
const tcFitText = findChild(el, "w:tcFitText");
|
|
4018
|
+
if (tcFitText) opts.fitText = attrBool(tcFitText, "w:val") ?? true;
|
|
4019
|
+
const hideMark = findChild(el, "w:hideMark");
|
|
4020
|
+
if (hideMark) opts.hideMark = attrBool(hideMark, "w:val") ?? true;
|
|
4021
|
+
const headersEl = findChild(el, "w:headers");
|
|
4022
|
+
if (headersEl) {
|
|
4023
|
+
const headerVals = [];
|
|
4024
|
+
for (const h of headersEl.elements ?? []) {
|
|
4025
|
+
if (h.name !== "w:header") continue;
|
|
4026
|
+
const val = attr(h, "w:val");
|
|
4027
|
+
if (val) headerVals.push(val);
|
|
4028
|
+
}
|
|
4029
|
+
if (headerVals.length > 0) opts.headers = headerVals;
|
|
4030
|
+
}
|
|
4031
|
+
const cellIns = findChild(el, "w:cellIns");
|
|
4032
|
+
if (cellIns) opts.insertion = parseChangeAttrs(cellIns);
|
|
4033
|
+
const cellDel = findChild(el, "w:cellDel");
|
|
4034
|
+
if (cellDel) opts.deletion = parseChangeAttrs(cellDel);
|
|
4035
|
+
const tcPrChange = findChild(el, "w:tcPrChange");
|
|
4036
|
+
if (tcPrChange) {
|
|
4037
|
+
const rev = {};
|
|
4038
|
+
const author = attr(tcPrChange, "w:author");
|
|
4039
|
+
if (author) rev.author = author;
|
|
4040
|
+
const date = attr(tcPrChange, "w:date");
|
|
4041
|
+
if (date) rev.date = date;
|
|
4042
|
+
const id = attrNum(tcPrChange, "w:id");
|
|
4043
|
+
if (id !== void 0) rev.id = id;
|
|
4044
|
+
const innerTcPr = findChild(tcPrChange, "w:tcPr");
|
|
4045
|
+
if (innerTcPr) Object.assign(rev, parseTableCellPropertiesEl(innerTcPr));
|
|
4046
|
+
if (Object.keys(rev).length > 0) opts.revision = rev;
|
|
4047
|
+
}
|
|
4048
|
+
const cellMerge = findChild(el, "w:cellMerge");
|
|
4049
|
+
if (cellMerge) {
|
|
4050
|
+
const cm = parseChangeAttrs(cellMerge);
|
|
4051
|
+
const vMerge = attr(cellMerge, "w:vMerge");
|
|
4052
|
+
if (vMerge) cm.verticalMerge = xsdVerticalMergeRev.from(vMerge);
|
|
4053
|
+
const vMergeOrig = attr(cellMerge, "w:vMergeOrig");
|
|
4054
|
+
if (vMergeOrig) cm.verticalMergeOriginal = xsdVerticalMergeRev.from(vMergeOrig);
|
|
4055
|
+
if (Object.keys(cm).length > 0) opts.cellMerge = cm;
|
|
4056
|
+
}
|
|
3802
4057
|
return opts;
|
|
3803
4058
|
}
|
|
3804
4059
|
function parseTableCellEl(el, ctx) {
|
|
@@ -3821,6 +4076,15 @@ function parseTableRowEl(el, ctx) {
|
|
|
3821
4076
|
const opts = {};
|
|
3822
4077
|
const trPr = findChild(el, "w:trPr");
|
|
3823
4078
|
if (trPr) Object.assign(opts, parseTableRowPropertiesEl(trPr));
|
|
4079
|
+
for (const [attrName, optKey] of [
|
|
4080
|
+
["w:rsidRPr", "rsidRPr"],
|
|
4081
|
+
["w:rsidR", "rsidR"],
|
|
4082
|
+
["w:rsidDel", "rsidDel"],
|
|
4083
|
+
["w:rsidTr", "rsidTr"]
|
|
4084
|
+
]) {
|
|
4085
|
+
const val = attr(el, attrName);
|
|
4086
|
+
if (val) opts[optKey] = val;
|
|
4087
|
+
}
|
|
3824
4088
|
const childCells = [];
|
|
3825
4089
|
for (const child of el.elements ?? []) if (child.name === "w:tc") childCells.push(parseTableCellEl(child, ctx));
|
|
3826
4090
|
opts.cells = childCells;
|
|
@@ -4402,6 +4666,10 @@ const createHeaderFooterReference = (type, options) => `<${type} r:id="rId${opti
|
|
|
4402
4666
|
*
|
|
4403
4667
|
* @module
|
|
4404
4668
|
*/
|
|
4669
|
+
/** Valid page-number @w:fmt values (ST_NumberFormat). */
|
|
4670
|
+
const PAGE_NUMBER_FORMATS = Object.values(NumberFormat);
|
|
4671
|
+
/** Valid page-number @w:chapSep values (ST_ChapterSep). */
|
|
4672
|
+
const PAGE_NUMBER_SEPARATORS = Object.values(PageNumberSeparator);
|
|
4405
4673
|
function stringifyBorderXml(tag, opts) {
|
|
4406
4674
|
const attrs = [];
|
|
4407
4675
|
if (opts.style !== void 0) attrs.push(`w:val="${opts.style}"`);
|
|
@@ -4516,14 +4784,14 @@ function stringifySectionPropertiesInner(opts) {
|
|
|
4516
4784
|
const parts = [];
|
|
4517
4785
|
appendHeaderFooterRefs(parts, "w:headerReference", opts.headerWrapperGroup);
|
|
4518
4786
|
appendHeaderFooterRefs(parts, "w:footerReference", opts.footerWrapperGroup);
|
|
4519
|
-
const { size: { width = sectionPageSizeDefaults.WIDTH, height = sectionPageSizeDefaults.HEIGHT, orientation = sectionPageSizeDefaults.ORIENTATION } = {}, margin: { top = sectionMarginDefaults.TOP, right = sectionMarginDefaults.RIGHT, bottom = sectionMarginDefaults.BOTTOM, left = sectionMarginDefaults.LEFT, header = sectionMarginDefaults.HEADER, footer = sectionMarginDefaults.FOOTER, gutter = sectionMarginDefaults.GUTTER } = {}, pageNumbers = {}, borders, textDirection } = opts.page ?? {};
|
|
4787
|
+
const { size: { width = sectionPageSizeDefaults.WIDTH, height = sectionPageSizeDefaults.HEIGHT, orientation = sectionPageSizeDefaults.ORIENTATION, code } = {}, margin: { top = sectionMarginDefaults.TOP, right = sectionMarginDefaults.RIGHT, bottom = sectionMarginDefaults.BOTTOM, left = sectionMarginDefaults.LEFT, header = sectionMarginDefaults.HEADER, footer = sectionMarginDefaults.FOOTER, gutter = sectionMarginDefaults.GUTTER } = {}, pageNumbers = {}, borders, textDirection } = opts.page ?? {};
|
|
4520
4788
|
const { linePitch = 312, charSpace = 0, type: gridType = "lines" } = opts.grid ?? {};
|
|
4521
4789
|
if (opts.footnotePr) parts.push(footnotePrXml("w:footnotePr", opts.footnotePr));
|
|
4522
4790
|
if (opts.endnotePr) parts.push(footnotePrXml("w:endnotePr", opts.endnotePr));
|
|
4523
4791
|
if (opts.type) parts.push(sectionTypeXml(opts.type));
|
|
4524
4792
|
const pgW = orientation === "landscape" ? convertToTwip(height) : width;
|
|
4525
4793
|
const pgH = orientation === "landscape" ? convertToTwip(width) : height;
|
|
4526
|
-
parts.push(pageSizeXml(pgW, pgH, orientation));
|
|
4794
|
+
parts.push(pageSizeXml(pgW, pgH, orientation, code));
|
|
4527
4795
|
parts.push(pageMarginXml(top, right, bottom, left, header, footer, gutter));
|
|
4528
4796
|
if (borders) parts.push(pageBordersXml(borders));
|
|
4529
4797
|
if (opts.lineNumbers) parts.push(lineNumberXml(opts.lineNumbers));
|
|
@@ -4605,6 +4873,8 @@ function parseSectionPropertiesEl(el) {
|
|
|
4605
4873
|
if (h !== void 0) size.height = h;
|
|
4606
4874
|
}
|
|
4607
4875
|
if (orient) size.orientation = orient;
|
|
4876
|
+
const code = attrNum(pgSz, "w:code");
|
|
4877
|
+
if (code !== void 0) size.code = code;
|
|
4608
4878
|
if (Object.keys(size).length > 0) page.size = size;
|
|
4609
4879
|
const pgMar = findChild(el, "w:pgMar");
|
|
4610
4880
|
if (pgMar) {
|
|
@@ -4629,7 +4899,11 @@ function parseSectionPropertiesEl(el) {
|
|
|
4629
4899
|
const start = attrNum(pgNumType, "w:start");
|
|
4630
4900
|
if (start !== void 0) pageNumbers.start = start;
|
|
4631
4901
|
const fmt = attr(pgNumType, "w:fmt");
|
|
4632
|
-
if (fmt) pageNumbers.formatType = fmt;
|
|
4902
|
+
if (fmt && PAGE_NUMBER_FORMATS.includes(fmt)) pageNumbers.formatType = fmt;
|
|
4903
|
+
const chapSep = attr(pgNumType, "w:chapSep");
|
|
4904
|
+
if (chapSep && PAGE_NUMBER_SEPARATORS.includes(chapSep)) pageNumbers.separator = chapSep;
|
|
4905
|
+
const chapStyle = attrNum(pgNumType, "w:chapStyle");
|
|
4906
|
+
if (chapStyle !== void 0) pageNumbers.chapStyle = chapStyle;
|
|
4633
4907
|
if (Object.keys(pageNumbers).length > 0) page.pageNumbers = pageNumbers;
|
|
4634
4908
|
}
|
|
4635
4909
|
if (Object.keys(page).length > 0) opts.page = page;
|
|
@@ -4641,7 +4915,21 @@ function parseSectionPropertiesEl(el) {
|
|
|
4641
4915
|
if (count !== void 0) column.count = count;
|
|
4642
4916
|
const space = attrNum(cols, "w:space");
|
|
4643
4917
|
if (space !== void 0) column.space = space;
|
|
4644
|
-
|
|
4918
|
+
const separate = attrBool(cols, "w:sep");
|
|
4919
|
+
if (separate !== void 0) column.separate = separate;
|
|
4920
|
+
const equalWidth = attrBool(cols, "w:equalWidth");
|
|
4921
|
+
if (equalWidth !== void 0) column.equalWidth = equalWidth;
|
|
4922
|
+
const colChildren = [];
|
|
4923
|
+
for (const colEl of cols.elements ?? []) {
|
|
4924
|
+
if (colEl.name !== "w:col") continue;
|
|
4925
|
+
const width = attrNum(colEl, "w:w");
|
|
4926
|
+
if (width === void 0) continue;
|
|
4927
|
+
const colAttr = { width };
|
|
4928
|
+
const colSpace = attrNum(colEl, "w:space");
|
|
4929
|
+
if (colSpace !== void 0) colAttr.space = colSpace;
|
|
4930
|
+
colChildren.push(colAttr);
|
|
4931
|
+
}
|
|
4932
|
+
if (colChildren.length > 0) column.children = colChildren;
|
|
4645
4933
|
if (Object.keys(column).length > 0) opts.column = column;
|
|
4646
4934
|
}
|
|
4647
4935
|
const type = findChild(el, "w:type");
|
|
@@ -4793,6 +5081,6 @@ function parseNotePropertiesEl(el) {
|
|
|
4793
5081
|
return opts;
|
|
4794
5082
|
}
|
|
4795
5083
|
//#endregion
|
|
4796
|
-
export {
|
|
5084
|
+
export { FormFieldTextType as $, stringifyParagraphProperties as A, VerticalPositionRelativeFrom as B, createPageSize as C, stringifyChildDispatch as D, tableDesc as E, resetDrawingIdGen as F, createWrapThrough as G, NumberFormat as H, parseDrawingRun as I, TextWrappingType as J, createWrapTight as K, createVerticalPosition as L, stringifyRunPropertiesInner as M, parseMathChildren as N, stringifyParagraphInline as O, drawingDesc as P, VerticalMergeType as Q, createHorizontalPosition as R, PageOrientation as S, setTableParseChild as T, SpaceType as U, HorizontalPositionAlign as V, VerticalPositionAlign as W, BorderStyle as X, WidthType as Y, TextDirection as Z, DocumentGridType as _, HeaderFooterType as a, TextVerticalType as at, sectionPageSizeDefaults as b, createSectionType as c, WORKAROUND2 as ct, createPageMargin as d, createFormFieldData as et, PageBorderDisplay as f, createPageNumberType as g, PageNumberSeparator as h, HeaderFooterReferenceType as i, TextVertOverflowType as it, stringifyRunProperties as j, stringifyRunInline as k, LineNumberRestartFormat as l, Media as lt, PageBorderZOrder as m, sectionPropertiesDesc as n, TextBodyWrappingType as nt, createHeaderFooterReference as o, VerticalAnchor as ot, PageBorderOffsetFrom as p, TextWrappingSide as q, stringifySectionPropertiesXml as r, TextHorzOverflowType as rt, SectionType as s, createBodyProperties as st, parseSectionPropertiesEl as t, parseFormFieldData as tt, createLineNumberType as u, createTransformation as ut, createDocumentGrid as v, DocumentAttributeNamespaces as w, PageTextDirectionType as x, sectionMarginDefaults as y, HorizontalPositionRelativeFrom as z };
|
|
4797
5085
|
|
|
4798
|
-
//# sourceMappingURL=document-
|
|
5086
|
+
//# sourceMappingURL=document-B_uvEH8b.mjs.map
|