@yudaocode/univer-docs 1.6.210 → 1.6.212
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/WORD_TEMPLATE_PROTOCOL.md +209 -0
- package/fixtures/word-template-protocol-v1.json +9135 -0
- package/lib/cjs/index.js +2820 -576
- package/lib/cjs/index.js.map +1 -1
- package/lib/es/index.js +3226 -973
- package/lib/es/index.js.map +1 -1
- package/lib/types/index.d.ts +89 -11
- package/package.json +5 -2
package/lib/cjs/index.js
CHANGED
|
@@ -46,7 +46,9 @@ __export(src_exports, {
|
|
|
46
46
|
DEFAULT_CASCADER_OPTIONS: () => DEFAULT_CASCADER_OPTIONS,
|
|
47
47
|
DEFAULT_ENDNOTE_SETTINGS: () => DEFAULT_ENDNOTE_SETTINGS,
|
|
48
48
|
DEFAULT_FOOTNOTE_SETTINGS: () => DEFAULT_FOOTNOTE_SETTINGS,
|
|
49
|
+
DOC_DRAWING_PLUGIN_RESOURCE: () => DOC_DRAWING_PLUGIN_RESOURCE,
|
|
49
50
|
DOC_HYPERLINK_DEFAULT_COLOR: () => DOC_HYPERLINK_DEFAULT_COLOR,
|
|
51
|
+
DOC_IO_CAPABILITY_FORMATS: () => DOC_IO_CAPABILITY_FORMATS,
|
|
50
52
|
DOC_TRACK_DELETE_STYLE: () => DOC_TRACK_DELETE_STYLE,
|
|
51
53
|
DOC_TRACK_INSERT_STYLE: () => DOC_TRACK_INSERT_STYLE,
|
|
52
54
|
DeleteDocAreaCommand: () => DeleteDocAreaCommand,
|
|
@@ -377,6 +379,7 @@ __export(src_exports, {
|
|
|
377
379
|
listLiveSmartArts: () => listLiveSmartArts,
|
|
378
380
|
matchSdtHighlightRule: () => matchSdtHighlightRule,
|
|
379
381
|
mergeDocTableCellsInSnapshot: () => mergeDocTableCellsInSnapshot,
|
|
382
|
+
normalizeDocDrawingsAndPluginResource: () => normalizeDocDrawingsAndPluginResource,
|
|
380
383
|
normalizeImageDataUriForSdt: () => normalizeImageDataUriForSdt,
|
|
381
384
|
normalizeMacroName: () => normalizeMacroName,
|
|
382
385
|
normalizeSdtListItems: () => normalizeSdtListItems,
|
|
@@ -396,6 +399,7 @@ __export(src_exports, {
|
|
|
396
399
|
recordDocTrackRevisionOnSnapshot: () => recordDocTrackRevisionOnSnapshot,
|
|
397
400
|
refreshTableOfContentsInSnapshot: () => refreshTableOfContentsInSnapshot,
|
|
398
401
|
registerDocMacro: () => registerDocMacro,
|
|
402
|
+
reinitializeDocHeaderFooterModels: () => reinitializeDocHeaderFooterModels,
|
|
399
403
|
removeBookmarkFromSnapshot: () => removeBookmarkFromSnapshot,
|
|
400
404
|
removeCalloutFromSnapshot: () => removeCalloutFromSnapshot,
|
|
401
405
|
removeDocCascadeRule: () => removeDocCascadeRuleFromSnapshot,
|
|
@@ -472,7 +476,9 @@ __export(src_exports, {
|
|
|
472
476
|
spliceDocumentBodySpan: () => spliceDocumentBodySpan,
|
|
473
477
|
spliceMultiParagraphBodySpan: () => spliceMultiParagraphBodySpan,
|
|
474
478
|
splitDocTableCellInSnapshot: () => splitDocTableCellInSnapshot,
|
|
479
|
+
stripDocEditorChromeForView: () => stripDocEditorChromeForView,
|
|
475
480
|
stripSdtAffixes: () => stripSdtAffixes,
|
|
481
|
+
syncDocDrawingsToUniverServices: () => syncDocDrawingsToUniverServices,
|
|
476
482
|
syncSnapshotAuxFields: () => syncSnapshotAuxFields,
|
|
477
483
|
toControlSpecSnapshot: () => toControlSpecSnapshot,
|
|
478
484
|
toggleDocListCheckboxInSnapshot: () => toggleDocListCheckboxInSnapshot,
|
|
@@ -508,6 +514,7 @@ var import_core13 = require("@univerjs/core");
|
|
|
508
514
|
|
|
509
515
|
// src/types/doc-sdt.ts
|
|
510
516
|
var YUDAO_DOCS_TEMPLATE_RESOURCE = "YUDAO_DOCS_TEMPLATE_RESOURCE";
|
|
517
|
+
var DOC_DRAWING_PLUGIN_RESOURCE = "DOC_DRAWING_PLUGIN";
|
|
511
518
|
|
|
512
519
|
// src/utils/doc-medical-and-blocks.ts
|
|
513
520
|
var import_core = require("@univerjs/core");
|
|
@@ -1329,6 +1336,7 @@ function insertInlineDrawingIntoSnapshot(sourceSnapshot, params) {
|
|
|
1329
1336
|
order.push(blockId);
|
|
1330
1337
|
}
|
|
1331
1338
|
nextSnapshot.drawingsOrder = order;
|
|
1339
|
+
normalizeDocDrawingsAndPluginResource(nextSnapshot);
|
|
1332
1340
|
return {
|
|
1333
1341
|
snapshot: nextSnapshot,
|
|
1334
1342
|
blockId,
|
|
@@ -10221,12 +10229,123 @@ function resolveUnderlineCssStyle(ul) {
|
|
|
10221
10229
|
const color = ul?.c !== 0 && ul?.cl?.rgb ? ul.cl.rgb : void 0;
|
|
10222
10230
|
return { style, ...color ? { color } : {} };
|
|
10223
10231
|
}
|
|
10232
|
+
function dxaToPt(dxa) {
|
|
10233
|
+
return Math.round(dxa / 20 * 100) / 100;
|
|
10234
|
+
}
|
|
10235
|
+
function toPoints(nu) {
|
|
10236
|
+
if (!nu || typeof nu.v !== "number" || !Number.isFinite(nu.v)) return 0;
|
|
10237
|
+
return nu.v;
|
|
10238
|
+
}
|
|
10239
|
+
var OOXML_REL_H_TO_CODE = {
|
|
10240
|
+
page: import_core7.ObjectRelativeFromH.PAGE,
|
|
10241
|
+
column: import_core7.ObjectRelativeFromH.COLUMN,
|
|
10242
|
+
character: import_core7.ObjectRelativeFromH.CHARACTER,
|
|
10243
|
+
margin: import_core7.ObjectRelativeFromH.MARGIN,
|
|
10244
|
+
insideMargin: import_core7.ObjectRelativeFromH.INSIDE_MARGIN,
|
|
10245
|
+
outsideMargin: import_core7.ObjectRelativeFromH.OUTSIDE_MARGIN,
|
|
10246
|
+
leftMargin: import_core7.ObjectRelativeFromH.LEFT_MARGIN,
|
|
10247
|
+
rightMargin: import_core7.ObjectRelativeFromH.RIGHT_MARGIN
|
|
10248
|
+
};
|
|
10249
|
+
var CODE_TO_OOXML_REL_H = {
|
|
10250
|
+
[import_core7.ObjectRelativeFromH.PAGE]: "page",
|
|
10251
|
+
[import_core7.ObjectRelativeFromH.COLUMN]: "column",
|
|
10252
|
+
[import_core7.ObjectRelativeFromH.CHARACTER]: "character",
|
|
10253
|
+
[import_core7.ObjectRelativeFromH.MARGIN]: "margin",
|
|
10254
|
+
[import_core7.ObjectRelativeFromH.INSIDE_MARGIN]: "insideMargin",
|
|
10255
|
+
[import_core7.ObjectRelativeFromH.OUTSIDE_MARGIN]: "outsideMargin",
|
|
10256
|
+
[import_core7.ObjectRelativeFromH.LEFT_MARGIN]: "leftMargin",
|
|
10257
|
+
[import_core7.ObjectRelativeFromH.RIGHT_MARGIN]: "rightMargin"
|
|
10258
|
+
};
|
|
10259
|
+
var OOXML_REL_V_TO_CODE = {
|
|
10260
|
+
page: import_core7.ObjectRelativeFromV.PAGE,
|
|
10261
|
+
paragraph: import_core7.ObjectRelativeFromV.PARAGRAPH,
|
|
10262
|
+
line: import_core7.ObjectRelativeFromV.LINE,
|
|
10263
|
+
margin: import_core7.ObjectRelativeFromV.MARGIN,
|
|
10264
|
+
topMargin: import_core7.ObjectRelativeFromV.TOP_MARGIN,
|
|
10265
|
+
bottomMargin: import_core7.ObjectRelativeFromV.BOTTOM_MARGIN,
|
|
10266
|
+
insideMargin: import_core7.ObjectRelativeFromV.INSIDE_MARGIN,
|
|
10267
|
+
outsideMargin: import_core7.ObjectRelativeFromV.OUTSIDE_MARGIN
|
|
10268
|
+
};
|
|
10269
|
+
var CODE_TO_OOXML_REL_V = {
|
|
10270
|
+
[import_core7.ObjectRelativeFromV.PAGE]: "page",
|
|
10271
|
+
[import_core7.ObjectRelativeFromV.PARAGRAPH]: "paragraph",
|
|
10272
|
+
[import_core7.ObjectRelativeFromV.LINE]: "line",
|
|
10273
|
+
[import_core7.ObjectRelativeFromV.MARGIN]: "margin",
|
|
10274
|
+
[import_core7.ObjectRelativeFromV.TOP_MARGIN]: "topMargin",
|
|
10275
|
+
[import_core7.ObjectRelativeFromV.BOTTOM_MARGIN]: "bottomMargin",
|
|
10276
|
+
[import_core7.ObjectRelativeFromV.INSIDE_MARGIN]: "insideMargin",
|
|
10277
|
+
[import_core7.ObjectRelativeFromV.OUTSIDE_MARGIN]: "outsideMargin"
|
|
10278
|
+
};
|
|
10279
|
+
var OOXML_ALIGN_H_TO_CODE = {
|
|
10280
|
+
center: import_core7.AlignTypeH.CENTER,
|
|
10281
|
+
inside: import_core7.AlignTypeH.INSIDE,
|
|
10282
|
+
left: import_core7.AlignTypeH.LEFT,
|
|
10283
|
+
outside: import_core7.AlignTypeH.OUTSIDE,
|
|
10284
|
+
right: import_core7.AlignTypeH.RIGHT
|
|
10285
|
+
};
|
|
10286
|
+
var CODE_TO_OOXML_ALIGN_H = {
|
|
10287
|
+
[import_core7.AlignTypeH.CENTER]: "center",
|
|
10288
|
+
[import_core7.AlignTypeH.INSIDE]: "inside",
|
|
10289
|
+
[import_core7.AlignTypeH.LEFT]: "left",
|
|
10290
|
+
[import_core7.AlignTypeH.OUTSIDE]: "outside",
|
|
10291
|
+
[import_core7.AlignTypeH.RIGHT]: "right"
|
|
10292
|
+
};
|
|
10293
|
+
var OOXML_ALIGN_V_TO_CODE = {
|
|
10294
|
+
bottom: import_core7.AlignTypeV.BOTTOM,
|
|
10295
|
+
center: import_core7.AlignTypeV.CENTER,
|
|
10296
|
+
inside: import_core7.AlignTypeV.INSIDE,
|
|
10297
|
+
outside: import_core7.AlignTypeV.OUTSIDE,
|
|
10298
|
+
top: import_core7.AlignTypeV.TOP
|
|
10299
|
+
};
|
|
10300
|
+
var CODE_TO_OOXML_ALIGN_V = {
|
|
10301
|
+
[import_core7.AlignTypeV.BOTTOM]: "bottom",
|
|
10302
|
+
[import_core7.AlignTypeV.CENTER]: "center",
|
|
10303
|
+
[import_core7.AlignTypeV.INSIDE]: "inside",
|
|
10304
|
+
[import_core7.AlignTypeV.OUTSIDE]: "outside",
|
|
10305
|
+
[import_core7.AlignTypeV.TOP]: "top"
|
|
10306
|
+
};
|
|
10307
|
+
var OOXML_WRAP_TEXT_TO_CODE = {
|
|
10308
|
+
bothSides: import_core7.WrapTextType.BOTH_SIDES,
|
|
10309
|
+
left: import_core7.WrapTextType.LEFT,
|
|
10310
|
+
right: import_core7.WrapTextType.RIGHT,
|
|
10311
|
+
largest: import_core7.WrapTextType.LARGEST
|
|
10312
|
+
};
|
|
10313
|
+
var CODE_TO_OOXML_WRAP_TEXT = {
|
|
10314
|
+
[import_core7.WrapTextType.BOTH_SIDES]: "bothSides",
|
|
10315
|
+
[import_core7.WrapTextType.LEFT]: "left",
|
|
10316
|
+
[import_core7.WrapTextType.RIGHT]: "right",
|
|
10317
|
+
[import_core7.WrapTextType.LARGEST]: "largest"
|
|
10318
|
+
};
|
|
10224
10319
|
function buildRunPrXml(ts) {
|
|
10225
10320
|
if (!ts) return "";
|
|
10226
10321
|
const rPrParts = [];
|
|
10227
|
-
|
|
10228
|
-
|
|
10229
|
-
|
|
10322
|
+
const rFonts = ts.yudaoRFonts;
|
|
10323
|
+
const ea = ts.eastAsiaFontFamily || rFonts?.eastAsia;
|
|
10324
|
+
const latin = rFonts ? ts.ff && ts.ff !== rFonts.eastAsia ? ts.ff : rFonts.ascii || rFonts.hAnsi : ts.ff;
|
|
10325
|
+
const cs = rFonts?.cs || (!rFonts ? latin || ea : void 0);
|
|
10326
|
+
const hint = ts.fontHint || rFonts?.hint;
|
|
10327
|
+
if (latin || ea || cs || hint) {
|
|
10328
|
+
const fontAttrs = [];
|
|
10329
|
+
if (latin) {
|
|
10330
|
+
fontAttrs.push(`w:ascii="${escapeXml(latin)}"`);
|
|
10331
|
+
const hAnsi = rFonts?.hAnsi && (!ts.ff || ts.ff === rFonts.ascii) ? rFonts.hAnsi : latin;
|
|
10332
|
+
fontAttrs.push(`w:hAnsi="${escapeXml(hAnsi)}"`);
|
|
10333
|
+
} else if (rFonts?.hAnsi) {
|
|
10334
|
+
fontAttrs.push(`w:hAnsi="${escapeXml(rFonts.hAnsi)}"`);
|
|
10335
|
+
}
|
|
10336
|
+
const effEa = ea || (!rFonts ? latin : void 0);
|
|
10337
|
+
if (effEa) {
|
|
10338
|
+
fontAttrs.push(`w:eastAsia="${escapeXml(effEa)}"`);
|
|
10339
|
+
}
|
|
10340
|
+
if (cs) {
|
|
10341
|
+
fontAttrs.push(`w:cs="${escapeXml(cs)}"`);
|
|
10342
|
+
}
|
|
10343
|
+
if (hint) {
|
|
10344
|
+
fontAttrs.push(`w:hint="${escapeXml(hint)}"`);
|
|
10345
|
+
}
|
|
10346
|
+
if (fontAttrs.length > 0) {
|
|
10347
|
+
rPrParts.push(`<w:rFonts ${fontAttrs.join(" ")}/>`);
|
|
10348
|
+
}
|
|
10230
10349
|
}
|
|
10231
10350
|
if (ts.bl === 1) rPrParts.push("<w:b/>");
|
|
10232
10351
|
if (ts.it === 1) rPrParts.push("<w:i/>");
|
|
@@ -10290,37 +10409,68 @@ function toOoxmlCropPct1000(val) {
|
|
|
10290
10409
|
}
|
|
10291
10410
|
return Math.max(0, Math.min(95e3, Math.round(val * 1e3)));
|
|
10292
10411
|
}
|
|
10293
|
-
function buildInlineImageDrawingXml(relId, docPrId, widthPt, heightPt, blockId, transform) {
|
|
10412
|
+
function buildInlineImageDrawingXml(relId, docPrId, widthPt, heightPt, blockId, transform, drawingObj) {
|
|
10294
10413
|
const cx = Math.max(91440, Math.round(widthPt * 12700));
|
|
10295
10414
|
const cy = Math.max(91440, Math.round(heightPt * 12700));
|
|
10296
10415
|
const picName = escapeXml(blockId || `Picture_${docPrId}`);
|
|
10297
10416
|
const crop = transform?.crop;
|
|
10298
10417
|
const srcRectXml = crop && (crop.left || crop.top || crop.right || crop.bottom) ? `<a:srcRect l="${toOoxmlCropPct1000(crop.left)}" t="${toOoxmlCropPct1000(crop.top)}" r="${toOoxmlCropPct1000(crop.right)}" b="${toOoxmlCropPct1000(crop.bottom)}"/>` : "";
|
|
10299
|
-
const
|
|
10418
|
+
const effRotDeg = typeof transform?.rotationDeg === "number" ? transform.rotationDeg : typeof drawingObj?.docTransform?.angle === "number" ? drawingObj.docTransform.angle : 0;
|
|
10419
|
+
const rotAttr = effRotDeg !== 0 ? ` rot="${Math.round(effRotDeg * 6e4)}"` : "";
|
|
10300
10420
|
const graphicXml = `<a:graphic xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main"><a:graphicData uri="http://schemas.openxmlformats.org/drawingml/2006/picture"><pic:pic xmlns:pic="http://schemas.openxmlformats.org/drawingml/2006/picture"><pic:nvPicPr><pic:cNvPr id="${docPrId}" name="${picName}"/><pic:cNvPicPr/></pic:nvPicPr><pic:blipFill><a:blip r:embed="${relId}" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"/>${srcRectXml}<a:stretch><a:fillRect/></a:stretch></pic:blipFill><pic:spPr><a:xfrm${rotAttr}><a:off x="0" y="0"/><a:ext cx="${cx}" cy="${cy}"/></a:xfrm><a:prstGeom prst="rect"><a:avLst/></a:prstGeom></pic:spPr></pic:pic></a:graphicData></a:graphic>`;
|
|
10301
|
-
|
|
10302
|
-
|
|
10303
|
-
|
|
10304
|
-
|
|
10305
|
-
|
|
10306
|
-
|
|
10421
|
+
let layoutCode = typeof drawingObj?.layoutType === "number" ? drawingObj.layoutType : import_core7.PositionedObjectLayoutType.INLINE;
|
|
10422
|
+
if (transform?.wrapType) {
|
|
10423
|
+
if (transform.wrapType === "inline") layoutCode = import_core7.PositionedObjectLayoutType.INLINE;
|
|
10424
|
+
else if (transform.wrapType === "square") layoutCode = import_core7.PositionedObjectLayoutType.WRAP_SQUARE;
|
|
10425
|
+
else if (transform.wrapType === "tight") layoutCode = import_core7.PositionedObjectLayoutType.WRAP_TIGHT;
|
|
10426
|
+
else if (transform.wrapType === "through") layoutCode = import_core7.PositionedObjectLayoutType.WRAP_THROUGH;
|
|
10427
|
+
else if (transform.wrapType === "polygon") layoutCode = import_core7.PositionedObjectLayoutType.WRAP_POLYGON;
|
|
10428
|
+
else if (transform.wrapType === "topAndBottom") layoutCode = import_core7.PositionedObjectLayoutType.WRAP_TOP_AND_BOTTOM;
|
|
10429
|
+
else layoutCode = import_core7.PositionedObjectLayoutType.WRAP_NONE;
|
|
10430
|
+
}
|
|
10431
|
+
const isInline = layoutCode === import_core7.PositionedObjectLayoutType.INLINE;
|
|
10432
|
+
const distTEmu = Math.max(0, Math.round((transform?.distT ?? drawingObj?.distT ?? 0) * 12700));
|
|
10433
|
+
const distBEmu = Math.max(0, Math.round((transform?.distB ?? drawingObj?.distB ?? 0) * 12700));
|
|
10434
|
+
const distLEmu = Math.max(
|
|
10435
|
+
0,
|
|
10436
|
+
Math.round((transform?.distL ?? drawingObj?.distL ?? (isInline ? 0 : 9)) * 12700)
|
|
10437
|
+
);
|
|
10438
|
+
const distREmu = Math.max(
|
|
10439
|
+
0,
|
|
10440
|
+
Math.round((transform?.distR ?? drawingObj?.distR ?? (isInline ? 0 : 9)) * 12700)
|
|
10441
|
+
);
|
|
10442
|
+
if (isInline) {
|
|
10307
10443
|
return `<w:r><w:drawing><wp:inline distT="${distTEmu}" distB="${distBEmu}" distL="${distLEmu}" distR="${distREmu}" xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing"><wp:extent cx="${cx}" cy="${cy}"/><wp:docPr id="${docPrId}" name="${picName}"/>${graphicXml}</wp:inline></w:drawing></w:r>`;
|
|
10308
10444
|
}
|
|
10309
|
-
const behindDoc = transform?.behindDoc !== void 0 ? transform.behindDoc ? "1" : "0" : wrapType === "behindText" ? "1" : "0";
|
|
10310
|
-
const
|
|
10445
|
+
const behindDoc = transform?.behindDoc !== void 0 ? transform.behindDoc ? "1" : "0" : transform?.wrapType === "behindText" ? "1" : transform?.wrapType === "inFrontOfText" ? "0" : drawingObj?.behindDoc === import_core7.BooleanNumber.TRUE ? "1" : "0";
|
|
10446
|
+
const resolvedWrapText = transform?.wrapText || (typeof drawingObj?.wrapText === "number" ? CODE_TO_OOXML_WRAP_TEXT[drawingObj.wrapText] : typeof drawingObj?.wrapText === "string" ? drawingObj.wrapText : void 0) || "bothSides";
|
|
10447
|
+
const wrapTextAttr = escapeXml(resolvedWrapText);
|
|
10311
10448
|
let wrapNodeXml = "<wp:wrapNone/>";
|
|
10312
|
-
if (
|
|
10449
|
+
if (layoutCode === import_core7.PositionedObjectLayoutType.WRAP_SQUARE) {
|
|
10313
10450
|
wrapNodeXml = `<wp:wrapSquare wrapText="${wrapTextAttr}"/>`;
|
|
10314
|
-
} else if (
|
|
10451
|
+
} else if (layoutCode === import_core7.PositionedObjectLayoutType.WRAP_TOP_AND_BOTTOM) {
|
|
10315
10452
|
wrapNodeXml = "<wp:wrapTopAndBottom/>";
|
|
10316
|
-
} else if (
|
|
10453
|
+
} else if (layoutCode === import_core7.PositionedObjectLayoutType.WRAP_THROUGH) {
|
|
10454
|
+
wrapNodeXml = `<wp:wrapThrough wrapText="${wrapTextAttr}"><wp:wrapPolygon edited="0"><wp:start x="0" y="0"/><wp:lineTo x="0" y="21600"/><wp:lineTo x="21600" y="21600"/><wp:lineTo x="21600" y="0"/><wp:lineTo x="0" y="0"/></wp:wrapPolygon></wp:wrapThrough>`;
|
|
10455
|
+
} else if (layoutCode === import_core7.PositionedObjectLayoutType.WRAP_TIGHT || layoutCode === import_core7.PositionedObjectLayoutType.WRAP_POLYGON) {
|
|
10317
10456
|
wrapNodeXml = `<wp:wrapTight wrapText="${wrapTextAttr}"><wp:wrapPolygon edited="0"><wp:start x="0" y="0"/><wp:lineTo x="0" y="21600"/><wp:lineTo x="21600" y="21600"/><wp:lineTo x="21600" y="0"/><wp:lineTo x="0" y="0"/></wp:wrapPolygon></wp:wrapTight>`;
|
|
10318
10457
|
}
|
|
10319
|
-
const
|
|
10320
|
-
const
|
|
10321
|
-
const
|
|
10322
|
-
|
|
10323
|
-
|
|
10458
|
+
const modelPosH = drawingObj?.docTransform?.positionH;
|
|
10459
|
+
const modelPosV = drawingObj?.docTransform?.positionV;
|
|
10460
|
+
const relH = escapeXml(
|
|
10461
|
+
transform?.relativeFromH || (typeof modelPosH?.relativeFrom === "number" ? CODE_TO_OOXML_REL_H[modelPosH.relativeFrom] : void 0) || "column"
|
|
10462
|
+
);
|
|
10463
|
+
const relV = escapeXml(
|
|
10464
|
+
transform?.relativeFromV || (typeof modelPosV?.relativeFrom === "number" ? CODE_TO_OOXML_REL_V[modelPosV.relativeFrom] : void 0) || "paragraph"
|
|
10465
|
+
);
|
|
10466
|
+
const alignH = transform?.alignH || (typeof modelPosH?.align === "number" ? CODE_TO_OOXML_ALIGN_H[modelPosH.align] : void 0);
|
|
10467
|
+
const alignV = transform?.alignV || (typeof modelPosV?.align === "number" ? CODE_TO_OOXML_ALIGN_V[modelPosV.align] : void 0);
|
|
10468
|
+
const posHInnerXml = alignH && transform?.posOffsetH === void 0 && modelPosH?.posOffset === void 0 ? `<wp:align>${escapeXml(alignH)}</wp:align>` : `<wp:posOffset>${Math.round((transform?.posOffsetH ?? modelPosH?.posOffset ?? 0) * 12700)}</wp:posOffset>`;
|
|
10469
|
+
const posVInnerXml = alignV && transform?.posOffsetV === void 0 && modelPosV?.posOffset === void 0 ? `<wp:align>${escapeXml(alignV)}</wp:align>` : `<wp:posOffset>${Math.round((transform?.posOffsetV ?? modelPosV?.posOffset ?? 0) * 12700)}</wp:posOffset>`;
|
|
10470
|
+
const relHeight = typeof drawingObj?.relativeHeight === "number" ? drawingObj.relativeHeight : 251658240;
|
|
10471
|
+
const layoutInCell = drawingObj?.layoutInCell !== void 0 ? drawingObj.layoutInCell ? "1" : "0" : "1";
|
|
10472
|
+
const allowOverlap = drawingObj?.allowOverlap !== void 0 ? drawingObj.allowOverlap ? "1" : "0" : "1";
|
|
10473
|
+
return `<w:r><w:drawing><wp:anchor distT="${distTEmu}" distB="${distBEmu}" distL="${distLEmu}" distR="${distREmu}" simplePos="0" relativeHeight="${relHeight}" behindDoc="${behindDoc}" locked="0" layoutInCell="${layoutInCell}" allowOverlap="${allowOverlap}" xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing"><wp:simplePos x="0" y="0"/><wp:positionH relativeFrom="${relH}">${posHInnerXml}</wp:positionH><wp:positionV relativeFrom="${relV}">${posVInnerXml}</wp:positionV><wp:extent cx="${cx}" cy="${cy}"/>${wrapNodeXml}<wp:docPr id="${docPrId}" name="${picName}"/>${graphicXml}</wp:anchor></w:drawing></w:r>`;
|
|
10324
10474
|
}
|
|
10325
10475
|
function decodeDataUriImage(dataUri) {
|
|
10326
10476
|
const utf8SvgMatch = dataUri.match(/^data:(image\/svg\+xml)(?:;charset=utf-8|;utf8)?,([\s\S]+)$/i);
|
|
@@ -10470,9 +10620,17 @@ function serializeSpanToRunsAndSdtXml(body, spanStart, spanEndExclusive, exportC
|
|
|
10470
10620
|
const instrText = String(fldObj?.instrText || fldObj?.fieldType || "PAGE").trim();
|
|
10471
10621
|
const fldValText = stream.slice(fieldAtCursor.startIndex, fieldAtCursor.endIndex + 1).replace(/[\r\n\u0000-\u001F]/g, "");
|
|
10472
10622
|
const fldStyle = findStyleAtBody(body, fieldAtCursor.startIndex);
|
|
10473
|
-
|
|
10474
|
-
|
|
10475
|
-
|
|
10623
|
+
if (fldObj?.sourceKind === "complex") {
|
|
10624
|
+
const rPr = buildRunPrXml(fldStyle);
|
|
10625
|
+
const valRuns = buildRunXmlWithBreaks(fldValText, fldStyle);
|
|
10626
|
+
innerXml.push(
|
|
10627
|
+
`<w:r>${rPr}<w:fldChar w:fldCharType="begin"/></w:r><w:r>${rPr}<w:instrText xml:space="preserve"> ${escapeXml(instrText)} </w:instrText></w:r><w:r>${rPr}<w:fldChar w:fldCharType="separate"/></w:r>` + (valRuns || `<w:r>${rPr}<w:t xml:space="preserve">${escapeXml(fldValText)}</w:t></w:r>`) + `<w:r>${rPr}<w:fldChar w:fldCharType="end"/></w:r>`
|
|
10628
|
+
);
|
|
10629
|
+
} else {
|
|
10630
|
+
innerXml.push(
|
|
10631
|
+
`<w:fldSimple w:instr=" ${escapeXml(instrText)} ">${buildRunXmlWithBreaks(fldValText, fldStyle)}</w:fldSimple>`
|
|
10632
|
+
);
|
|
10633
|
+
}
|
|
10476
10634
|
cursor = fieldAtCursor.endIndex + 1;
|
|
10477
10635
|
continue;
|
|
10478
10636
|
}
|
|
@@ -10484,17 +10642,19 @@ function serializeSpanToRunsAndSdtXml(body, spanStart, spanEndExclusive, exportC
|
|
|
10484
10642
|
const sdtSliceRaw = stream.slice(sdtAtCursor.startIndex, sdtAtCursor.endIndex + 1);
|
|
10485
10643
|
const rawTs = findStyleAtBody(body, sdtAtCursor.startIndex);
|
|
10486
10644
|
let sdtRunStyle = rawTs;
|
|
10487
|
-
if (resolved && !resolved.matchedHighlight) {
|
|
10645
|
+
if (resolved && !resolved.matchedHighlight && !resolved.invalidHighlight) {
|
|
10488
10646
|
if (resolved.visualChrome === "underline") {
|
|
10489
10647
|
sdtRunStyle = {
|
|
10490
10648
|
...rawTs ?? {},
|
|
10491
10649
|
bg: void 0,
|
|
10492
10650
|
ul: rawTs?.ul?.s ? rawTs.ul : { s: 1 }
|
|
10493
10651
|
};
|
|
10494
|
-
} else if (resolved.visualChrome === "brackets" || resolved.visualChrome === "clean") {
|
|
10652
|
+
} else if (resolved.visualChrome === "brackets" || resolved.visualChrome === "clean" || !resolved.showingPlaceholder && resolved.visualChrome !== "highlight") {
|
|
10653
|
+
const rawBgLower = rawTs?.bg?.rgb?.trim().toLowerCase();
|
|
10654
|
+
const isEditorChromeBg = rawBgLower === "#f3f5ff" || rawBgLower === "#eeeff1" || rawBgLower === "#eff6ff";
|
|
10495
10655
|
sdtRunStyle = {
|
|
10496
10656
|
...rawTs ?? {},
|
|
10497
|
-
bg: void 0,
|
|
10657
|
+
bg: resolved.visualChrome === "brackets" || resolved.visualChrome === "clean" || isEditorChromeBg ? void 0 : rawTs?.bg,
|
|
10498
10658
|
ul: resolved.visualChrome === "clean" ? void 0 : rawTs?.ul
|
|
10499
10659
|
};
|
|
10500
10660
|
}
|
|
@@ -10620,8 +10780,14 @@ function buildTableBordersOoxml(preset) {
|
|
|
10620
10780
|
}
|
|
10621
10781
|
return '<w:tblBorders><w:top w:val="dashed" w:sz="4" w:space="0" w:color="CBD5E1"/><w:left w:val="dashed" w:sz="4" w:space="0" w:color="CBD5E1"/><w:bottom w:val="dashed" w:sz="4" w:space="0" w:color="CBD5E1"/><w:right w:val="dashed" w:sz="4" w:space="0" w:color="CBD5E1"/><w:insideH w:val="dashed" w:sz="4" w:space="0" w:color="CBD5E1"/><w:insideV w:val="dashed" w:sz="4" w:space="0" w:color="CBD5E1"/></w:tblBorders>';
|
|
10622
10782
|
}
|
|
10623
|
-
function buildTcBordersOoxml(preset, rIdx, cIdx, rowCount, colCount, slashType, cellBorders) {
|
|
10783
|
+
function buildTcBordersOoxml(preset, rIdx, cIdx, rowCount, colCount, slashType, cellBorders, cellDef) {
|
|
10624
10784
|
const edgeVal = preset === "dash" ? "dashed" : "single";
|
|
10785
|
+
const defEdgeMap = {
|
|
10786
|
+
top: "borderTop",
|
|
10787
|
+
left: "borderLeft",
|
|
10788
|
+
bottom: "borderBottom",
|
|
10789
|
+
right: "borderRight"
|
|
10790
|
+
};
|
|
10625
10791
|
const mk = (active, tag) => {
|
|
10626
10792
|
const customEdge = cellBorders?.[tag];
|
|
10627
10793
|
if (customEdge) {
|
|
@@ -10633,6 +10799,18 @@ function buildTcBordersOoxml(preset, rIdx, cIdx, rowCount, colCount, slashType,
|
|
|
10633
10799
|
const wCol = normalizeHex6(customEdge.color) || "CBD5E1";
|
|
10634
10800
|
return `<w:${tag} w:val="${wVal}" w:sz="${wSz}" w:space="0" w:color="${wCol}"/>`;
|
|
10635
10801
|
}
|
|
10802
|
+
if (!preset && cellDef) {
|
|
10803
|
+
const defBorder = cellDef[defEdgeMap[tag]];
|
|
10804
|
+
const defWidthPt = defBorder?.width?.v;
|
|
10805
|
+
if (typeof defWidthPt === "number") {
|
|
10806
|
+
if (defWidthPt <= 0) {
|
|
10807
|
+
return `<w:${tag} w:val="none" w:sz="0" w:space="0" w:color="auto"/>`;
|
|
10808
|
+
}
|
|
10809
|
+
const wSz = Math.max(2, Math.round(defWidthPt * 8));
|
|
10810
|
+
const wCol = normalizeHex6(defBorder?.color?.rgb) || "CBD5E1";
|
|
10811
|
+
return `<w:${tag} w:val="${edgeVal}" w:sz="${wSz}" w:space="0" w:color="${wCol}"/>`;
|
|
10812
|
+
}
|
|
10813
|
+
}
|
|
10636
10814
|
return active ? `<w:${tag} w:val="${edgeVal}" w:sz="4" w:space="0" w:color="CBD5E1"/>` : `<w:${tag} w:val="none" w:sz="0" w:space="0" w:color="auto"/>`;
|
|
10637
10815
|
};
|
|
10638
10816
|
const isTop = rIdx === 0;
|
|
@@ -10668,18 +10846,32 @@ function buildTcBordersOoxml(preset, rIdx, cIdx, rowCount, colCount, slashType,
|
|
|
10668
10846
|
function buildParagraphOpenPrXml(para, opts) {
|
|
10669
10847
|
const pStyle = para?.paragraphStyle;
|
|
10670
10848
|
const pPrParts = [];
|
|
10671
|
-
if (
|
|
10849
|
+
if (para?.styleId) {
|
|
10850
|
+
pPrParts.push(`<w:pStyle w:val="${escapeXml(String(para.styleId))}"/>`);
|
|
10851
|
+
} else if (pStyle?.namedStyleType >= 1 && pStyle?.namedStyleType <= 6) {
|
|
10672
10852
|
pPrParts.push(`<w:pStyle w:val="Heading${Number(pStyle.namedStyleType)}"/>`);
|
|
10673
10853
|
}
|
|
10854
|
+
const pag = pStyle?.yudaoPagination;
|
|
10855
|
+
if (pag?.keepNext || pStyle?.keepNext) {
|
|
10856
|
+
pPrParts.push("<w:keepNext/>");
|
|
10857
|
+
}
|
|
10858
|
+
if (pag?.keepLines || pStyle?.keepLines) {
|
|
10859
|
+
pPrParts.push("<w:keepLines/>");
|
|
10860
|
+
}
|
|
10861
|
+
if (pag?.pageBreakBefore || pStyle?.pageBreakBefore) {
|
|
10862
|
+
pPrParts.push("<w:pageBreakBefore/>");
|
|
10863
|
+
}
|
|
10864
|
+
if (pag?.widowControl !== void 0) {
|
|
10865
|
+
pPrParts.push(pag.widowControl ? "<w:widowControl/>" : '<w:widowControl w:val="0"/>');
|
|
10866
|
+
} else if (pStyle?.widowControl !== void 0) {
|
|
10867
|
+
pPrParts.push(pStyle.widowControl ? "<w:widowControl/>" : '<w:widowControl w:val="0"/>');
|
|
10868
|
+
}
|
|
10674
10869
|
if (para?.bullet?.listId) {
|
|
10675
10870
|
const ilvl = Math.max(0, Number(para.bullet.nestingLevel ?? 0));
|
|
10676
10871
|
const mappedNumId = opts?.listNumIdMap?.get(String(para.bullet.listId));
|
|
10677
10872
|
const numId = mappedNumId ?? (String(para.bullet.listId).toLowerCase().includes("order") ? 2 : 1);
|
|
10678
10873
|
pPrParts.push(`<w:numPr><w:ilvl w:val="${ilvl}"/><w:numId w:val="${numId}"/></w:numPr>`);
|
|
10679
10874
|
}
|
|
10680
|
-
if (opts?.isRtl || pStyle?.yudaoTextDirection === "rtl" || pStyle?.textDirection === 2) {
|
|
10681
|
-
pPrParts.push("<w:bidi/>");
|
|
10682
|
-
}
|
|
10683
10875
|
if (opts?.callout) {
|
|
10684
10876
|
const bdrHex = normalizeHex6(opts.callout.borderColor) || "2C53F1";
|
|
10685
10877
|
const bgHex = normalizeHex6(opts.callout.backgroundColor) || "F3F5FF";
|
|
@@ -10692,7 +10884,6 @@ function buildParagraphOpenPrXml(para, opts) {
|
|
|
10692
10884
|
pPrParts.push(
|
|
10693
10885
|
`<w:pBdr><w:left w:val="single" w:sz="24" w:space="8" w:color="${lineHex}"/></w:pBdr>`
|
|
10694
10886
|
);
|
|
10695
|
-
pPrParts.push('<w:ind w:left="480"/>');
|
|
10696
10887
|
} else if (opts?.isCodeBlockPara) {
|
|
10697
10888
|
pPrParts.push(
|
|
10698
10889
|
'<w:pBdr><w:top w:val="single" w:sz="4" w:space="2" w:color="CBD5E1"/><w:left w:val="single" w:sz="12" w:space="6" w:color="3B82F6"/><w:bottom w:val="single" w:sz="4" w:space="2" w:color="CBD5E1"/><w:right w:val="single" w:sz="4" w:space="4" w:color="CBD5E1"/></w:pBdr>'
|
|
@@ -10744,21 +10935,6 @@ function buildParagraphOpenPrXml(para, opts) {
|
|
|
10744
10935
|
pPrParts.push(`<w:shd w:val="clear" w:color="auto" w:fill="${shdHex}"/>`);
|
|
10745
10936
|
}
|
|
10746
10937
|
}
|
|
10747
|
-
const pag = pStyle?.yudaoPagination;
|
|
10748
|
-
if (pag?.keepNext || pStyle?.keepNext) {
|
|
10749
|
-
pPrParts.push("<w:keepNext/>");
|
|
10750
|
-
}
|
|
10751
|
-
if (pag?.keepLines || pStyle?.keepLines) {
|
|
10752
|
-
pPrParts.push("<w:keepLines/>");
|
|
10753
|
-
}
|
|
10754
|
-
if (pag?.pageBreakBefore || pStyle?.pageBreakBefore) {
|
|
10755
|
-
pPrParts.push("<w:pageBreakBefore/>");
|
|
10756
|
-
}
|
|
10757
|
-
if (pag?.widowControl !== void 0) {
|
|
10758
|
-
pPrParts.push(pag.widowControl ? "<w:widowControl/>" : '<w:widowControl w:val="0"/>');
|
|
10759
|
-
} else if (pStyle?.widowControl) {
|
|
10760
|
-
pPrParts.push("<w:widowControl/>");
|
|
10761
|
-
}
|
|
10762
10938
|
const tabStops = pStyle?.yudaoTabStops;
|
|
10763
10939
|
if (Array.isArray(tabStops) && tabStops.length > 0) {
|
|
10764
10940
|
const tabTags = tabStops.map((t) => {
|
|
@@ -10769,6 +10945,72 @@ function buildParagraphOpenPrXml(para, opts) {
|
|
|
10769
10945
|
}).join("");
|
|
10770
10946
|
pPrParts.push(`<w:tabs>${tabTags}</w:tabs>`);
|
|
10771
10947
|
}
|
|
10948
|
+
if (pStyle?.snapToGrid !== void 0) {
|
|
10949
|
+
pPrParts.push(pStyle.snapToGrid ? "<w:snapToGrid/>" : '<w:snapToGrid w:val="0"/>');
|
|
10950
|
+
}
|
|
10951
|
+
if (opts?.isRtl || pStyle?.yudaoTextDirection === "rtl" || pStyle?.textDirection === 2) {
|
|
10952
|
+
pPrParts.push("<w:bidi/>");
|
|
10953
|
+
}
|
|
10954
|
+
const spacingAttrs = [];
|
|
10955
|
+
if (typeof pStyle?.spaceAbove?.v === "number") {
|
|
10956
|
+
spacingAttrs.push(`w:before="${Math.max(0, Math.round(pStyle.spaceAbove.v * 20))}"`);
|
|
10957
|
+
}
|
|
10958
|
+
if (pStyle?.beforeAutoSpacing !== void 0) {
|
|
10959
|
+
spacingAttrs.push(`w:beforeAutospacing="${pStyle.beforeAutoSpacing ? "1" : "0"}"`);
|
|
10960
|
+
}
|
|
10961
|
+
if (typeof pStyle?.spaceBelow?.v === "number") {
|
|
10962
|
+
spacingAttrs.push(`w:after="${Math.max(0, Math.round(pStyle.spaceBelow.v * 20))}"`);
|
|
10963
|
+
}
|
|
10964
|
+
if (pStyle?.afterAutoSpacing !== void 0) {
|
|
10965
|
+
spacingAttrs.push(`w:afterAutospacing="${pStyle.afterAutoSpacing ? "1" : "0"}"`);
|
|
10966
|
+
}
|
|
10967
|
+
if (typeof pStyle?.lineSpacing === "number" && pStyle.lineSpacing > 0) {
|
|
10968
|
+
if (pStyle.spacingRule === import_core7.SpacingRule.EXACT) {
|
|
10969
|
+
spacingAttrs.push(`w:line="${Math.max(1, Math.round(pStyle.lineSpacing * 20))}"`);
|
|
10970
|
+
spacingAttrs.push('w:lineRule="exact"');
|
|
10971
|
+
} else if (pStyle.spacingRule === import_core7.SpacingRule.AT_LEAST) {
|
|
10972
|
+
spacingAttrs.push(`w:line="${Math.max(1, Math.round(pStyle.lineSpacing * 20))}"`);
|
|
10973
|
+
spacingAttrs.push('w:lineRule="atLeast"');
|
|
10974
|
+
} else {
|
|
10975
|
+
spacingAttrs.push(`w:line="${Math.max(1, Math.round(pStyle.lineSpacing * 240))}"`);
|
|
10976
|
+
spacingAttrs.push('w:lineRule="auto"');
|
|
10977
|
+
}
|
|
10978
|
+
}
|
|
10979
|
+
if (spacingAttrs.length > 0) {
|
|
10980
|
+
pPrParts.push(`<w:spacing ${spacingAttrs.join(" ")}/>`);
|
|
10981
|
+
}
|
|
10982
|
+
if (opts?.quote) {
|
|
10983
|
+
pPrParts.push('<w:ind w:left="480"/>');
|
|
10984
|
+
} else {
|
|
10985
|
+
const indAttrs = [];
|
|
10986
|
+
if (typeof pStyle?.indentStart?.v === "number") {
|
|
10987
|
+
indAttrs.push(`w:left="${Math.max(0, Math.round(pStyle.indentStart.v * 20))}"`);
|
|
10988
|
+
}
|
|
10989
|
+
if (typeof pStyle?.indentEnd?.v === "number") {
|
|
10990
|
+
indAttrs.push(`w:right="${Math.max(0, Math.round(pStyle.indentEnd.v * 20))}"`);
|
|
10991
|
+
}
|
|
10992
|
+
if (typeof pStyle?.hanging?.v === "number" && pStyle.hanging.v > 0) {
|
|
10993
|
+
indAttrs.push(`w:hanging="${Math.max(0, Math.round(pStyle.hanging.v * 20))}"`);
|
|
10994
|
+
} else if (typeof pStyle?.indentFirstLine?.v === "number") {
|
|
10995
|
+
if (pStyle.indentFirstLine.u === import_core7.NumberUnitType.CHARACTER) {
|
|
10996
|
+
indAttrs.push(
|
|
10997
|
+
`w:firstLineChars="${Math.max(0, Math.round(pStyle.indentFirstLine.v * 100))}"`
|
|
10998
|
+
);
|
|
10999
|
+
} else if (pStyle.indentFirstLine.v > 0) {
|
|
11000
|
+
indAttrs.push(`w:firstLine="${Math.max(0, Math.round(pStyle.indentFirstLine.v * 20))}"`);
|
|
11001
|
+
} else if (indAttrs.length === 0) {
|
|
11002
|
+
indAttrs.push('w:left="0"');
|
|
11003
|
+
}
|
|
11004
|
+
}
|
|
11005
|
+
if (indAttrs.length > 0) {
|
|
11006
|
+
pPrParts.push(`<w:ind ${indAttrs.join(" ")}/>`);
|
|
11007
|
+
}
|
|
11008
|
+
}
|
|
11009
|
+
if (pStyle?.contextualSpacing !== void 0) {
|
|
11010
|
+
pPrParts.push(
|
|
11011
|
+
pStyle.contextualSpacing ? "<w:contextualSpacing/>" : '<w:contextualSpacing w:val="0"/>'
|
|
11012
|
+
);
|
|
11013
|
+
}
|
|
10772
11014
|
if (pStyle?.horizontalAlign === 2) {
|
|
10773
11015
|
pPrParts.push('<w:jc w:val="center"/>');
|
|
10774
11016
|
} else if (pStyle?.horizontalAlign === 3) {
|
|
@@ -10776,24 +11018,6 @@ function buildParagraphOpenPrXml(para, opts) {
|
|
|
10776
11018
|
} else if (pStyle?.horizontalAlign === 4) {
|
|
10777
11019
|
pPrParts.push('<w:jc w:val="both"/>');
|
|
10778
11020
|
}
|
|
10779
|
-
const spaceAbove = pStyle?.spaceAbove?.v;
|
|
10780
|
-
const spaceBelow = pStyle?.spaceBelow?.v;
|
|
10781
|
-
if (typeof spaceAbove === "number" || typeof spaceBelow === "number") {
|
|
10782
|
-
const before = Math.max(0, Math.round((spaceAbove ?? 0) * 20));
|
|
10783
|
-
const after = Math.max(0, Math.round((spaceBelow ?? 0) * 20));
|
|
10784
|
-
pPrParts.push(`<w:spacing w:before="${before}" w:after="${after}"/>`);
|
|
10785
|
-
}
|
|
10786
|
-
if (!opts?.quote) {
|
|
10787
|
-
const indentFirst = pStyle?.indentFirstLine?.v;
|
|
10788
|
-
const indentStart = pStyle?.indentStart?.v;
|
|
10789
|
-
if (typeof indentFirst === "number" || typeof indentStart === "number") {
|
|
10790
|
-
const left = Math.max(0, Math.round((indentStart ?? 0) * 20));
|
|
10791
|
-
const firstLine = Math.max(0, Math.round((indentFirst ?? 0) * 20));
|
|
10792
|
-
pPrParts.push(
|
|
10793
|
-
firstLine > 0 ? `<w:ind w:left="${left}" w:firstLine="${firstLine}"/>` : `<w:ind w:left="${left}"/>`
|
|
10794
|
-
);
|
|
10795
|
-
}
|
|
10796
|
-
}
|
|
10797
11021
|
if (pStyle?.yudaoSectionBreakType) {
|
|
10798
11022
|
const orient = opts?.sectionOrientation ?? pStyle?.yudaoSectionOrientation;
|
|
10799
11023
|
let sectPgSzXml = "";
|
|
@@ -10891,25 +11115,65 @@ function serializeStoryBodyXml(snapshot, body, exportCtx) {
|
|
|
10891
11115
|
pCursor++;
|
|
10892
11116
|
}
|
|
10893
11117
|
const parsedRows = parseTableRowsInStream(stream, nextTbl.startIndex, nextTbl.endIndex);
|
|
10894
|
-
const tblDef = snapshot.tableSource?.[nextTbl.tableId];
|
|
11118
|
+
const tblDef = exportCtx?.storyTableSource?.[nextTbl.tableId] ?? snapshot.tableSource?.[nextTbl.tableId];
|
|
10895
11119
|
const hdrRowCount = resolveTableHeaderRowCount(snapshot, nextTbl.tableId);
|
|
10896
11120
|
const tblDir = getDocTableDirection(snapshot, nextTbl.tableId);
|
|
10897
11121
|
const tblBorderPreset = templateMeta.tableBorderPresets?.[nextTbl.tableId];
|
|
10898
11122
|
const tblAutoFitWindow = tblDef?.yudaoAutoFitMode === "window";
|
|
10899
11123
|
const colCount = tblDef?.tableColumns?.length || Math.max(1, ...parsedRows.map((r) => r.cells.length));
|
|
10900
11124
|
const gridColsXml = Array.from({ length: colCount }, (_, cIdx) => {
|
|
10901
|
-
const
|
|
10902
|
-
|
|
11125
|
+
const colW = toPoints(tblDef?.tableColumns?.[cIdx]?.size?.width);
|
|
11126
|
+
const wPt = colW > 0 ? colW : Math.floor(460 / colCount);
|
|
11127
|
+
return `<w:gridCol w:w="${Math.max(20, Math.round(wPt * 20))}"/>`;
|
|
10903
11128
|
}).join("");
|
|
11129
|
+
const buildTcWXml = (targetCellDef, cIdx, spanCols) => {
|
|
11130
|
+
const tcWType = targetCellDef?.tcWidthType;
|
|
11131
|
+
if (tcWType === "pct") {
|
|
11132
|
+
const pctVal = typeof targetCellDef?.yudaoTcWidthPct === "number" ? Math.max(1, Math.round(targetCellDef.yudaoTcWidthPct)) : Math.max(1, Math.round(toPoints(targetCellDef?.size?.width) * 50));
|
|
11133
|
+
return `<w:tcW w:w="${pctVal}" w:type="pct"/>`;
|
|
11134
|
+
}
|
|
11135
|
+
if (tcWType === "auto") {
|
|
11136
|
+
return '<w:tcW w:w="0" w:type="auto"/>';
|
|
11137
|
+
}
|
|
11138
|
+
if (tcWType === "nil") {
|
|
11139
|
+
return '<w:tcW w:w="0" w:type="nil"/>';
|
|
11140
|
+
}
|
|
11141
|
+
if (tcWType === "dxa" || targetCellDef?.size?.type === import_core7.TableSizeType.SPECIFIED) {
|
|
11142
|
+
const wPt = toPoints(targetCellDef?.size?.width);
|
|
11143
|
+
if (wPt > 0) {
|
|
11144
|
+
return `<w:tcW w:w="${Math.max(20, Math.round(wPt * 20))}" w:type="dxa"/>`;
|
|
11145
|
+
}
|
|
11146
|
+
}
|
|
11147
|
+
if (tblDef?.layout === import_core7.TableLayoutType.FIXED && tblDef.tableColumns?.length) {
|
|
11148
|
+
let sumPt = 0;
|
|
11149
|
+
for (let k = 0; k < spanCols; k++) {
|
|
11150
|
+
sumPt += toPoints(tblDef.tableColumns[cIdx + k]?.size?.width);
|
|
11151
|
+
}
|
|
11152
|
+
if (sumPt > 0) {
|
|
11153
|
+
return `<w:tcW w:w="${Math.max(20, Math.round(sumPt * 20))}" w:type="dxa"/>`;
|
|
11154
|
+
}
|
|
11155
|
+
}
|
|
11156
|
+
return "";
|
|
11157
|
+
};
|
|
10904
11158
|
const trXmlList = parsedRows.map((rSpan, rIdx) => {
|
|
10905
11159
|
const rowDef = tblDef?.tableRows?.[rIdx];
|
|
10906
11160
|
const trPrParts = [];
|
|
11161
|
+
if (rowDef?.cantSplit === import_core7.BooleanNumber.TRUE) {
|
|
11162
|
+
trPrParts.push("<w:cantSplit/>");
|
|
11163
|
+
} else if (rowDef?.cantSplit === import_core7.BooleanNumber.FALSE) {
|
|
11164
|
+
trPrParts.push('<w:cantSplit w:val="0"/>');
|
|
11165
|
+
}
|
|
11166
|
+
const hValPt = toPoints(rowDef?.trHeight?.val);
|
|
11167
|
+
const hRule = rowDef?.trHeight?.hRule;
|
|
11168
|
+
if (hValPt > 0 && hRule !== import_core7.TableRowHeightRule.AUTO) {
|
|
11169
|
+
const wRule = hRule === import_core7.TableRowHeightRule.EXACT ? "exact" : "atLeast";
|
|
11170
|
+
trPrParts.push(
|
|
11171
|
+
`<w:trHeight w:val="${Math.max(1, Math.round(hValPt * 20))}" w:hRule="${wRule}"/>`
|
|
11172
|
+
);
|
|
11173
|
+
}
|
|
10907
11174
|
if (rowDef?.repeatHeaderRow === import_core7.BooleanNumber.TRUE || rIdx < hdrRowCount) {
|
|
10908
11175
|
trPrParts.push("<w:tblHeader/>");
|
|
10909
11176
|
}
|
|
10910
|
-
if (rowDef?.trHeight?.val?.v) {
|
|
10911
|
-
trPrParts.push(`<w:trHeight w:val="${Math.round(rowDef.trHeight.val.v * 20)}"/>`);
|
|
10912
|
-
}
|
|
10913
11177
|
const trPrXml = trPrParts.length ? `<w:trPr>${trPrParts.join("")}</w:trPr>` : "";
|
|
10914
11178
|
const tcXmlList = [];
|
|
10915
11179
|
rSpan.cells.forEach((cSpan, cIdx) => {
|
|
@@ -10926,6 +11190,11 @@ function serializeStoryBodyXml(snapshot, body, exportCtx) {
|
|
|
10926
11190
|
}
|
|
10927
11191
|
if (master && rIdx > master.row && cIdx === master.col) {
|
|
10928
11192
|
const contPr = [];
|
|
11193
|
+
const contCellDef = cellDef ?? tblDef?.tableRows?.[master.row]?.tableCells?.[master.col];
|
|
11194
|
+
const contTcW = buildTcWXml(contCellDef, cIdx, master.colSpan);
|
|
11195
|
+
if (contTcW) {
|
|
11196
|
+
contPr.push(contTcW);
|
|
11197
|
+
}
|
|
10929
11198
|
if (master.colSpan > 1) {
|
|
10930
11199
|
contPr.push(`<w:gridSpan w:val="${master.colSpan}"/>`);
|
|
10931
11200
|
}
|
|
@@ -10939,6 +11208,10 @@ function serializeStoryBodyXml(snapshot, body, exportCtx) {
|
|
|
10939
11208
|
const tcPrParts = [];
|
|
10940
11209
|
const colSpan = cellDef?.columnSpan ?? 1;
|
|
10941
11210
|
const rowSpan = cellDef?.rowSpan ?? 1;
|
|
11211
|
+
const tcWXml = buildTcWXml(cellDef, cIdx, colSpan);
|
|
11212
|
+
if (tcWXml) {
|
|
11213
|
+
tcPrParts.push(tcWXml);
|
|
11214
|
+
}
|
|
10942
11215
|
if (colSpan > 1) {
|
|
10943
11216
|
tcPrParts.push(`<w:gridSpan w:val="${colSpan}"/>`);
|
|
10944
11217
|
}
|
|
@@ -10960,7 +11233,8 @@ function serializeStoryBodyXml(snapshot, body, exportCtx) {
|
|
|
10960
11233
|
parsedRows.length,
|
|
10961
11234
|
colCount,
|
|
10962
11235
|
cellProps?.slashType,
|
|
10963
|
-
cellProps?.borders
|
|
11236
|
+
cellProps?.borders,
|
|
11237
|
+
cellDef
|
|
10964
11238
|
)
|
|
10965
11239
|
);
|
|
10966
11240
|
const cellParas = paragraphs.filter(
|
|
@@ -11004,11 +11278,25 @@ function serializeStoryBodyXml(snapshot, body, exportCtx) {
|
|
|
11004
11278
|
});
|
|
11005
11279
|
return `<w:tr>${trPrXml}${tcXmlList.join("")}</w:tr>`;
|
|
11006
11280
|
});
|
|
11281
|
+
const yudaoTblWType = tblDef?.yudaoTblWidthType;
|
|
11282
|
+
let tblWXml;
|
|
11283
|
+
if (tblAutoFitWindow || yudaoTblWType === "pct") {
|
|
11284
|
+
const pctVal = Math.max(1, Math.round(Number(tblDef?.yudaoTblWidthPct ?? 5e3)));
|
|
11285
|
+
tblWXml = `<w:tblW w:w="${pctVal}" w:type="pct"/>`;
|
|
11286
|
+
} else if (yudaoTblWType === "nil") {
|
|
11287
|
+
tblWXml = '<w:tblW w:w="0" w:type="nil"/>';
|
|
11288
|
+
} else if (yudaoTblWType === "dxa" || tblDef?.size?.type === import_core7.TableSizeType.SPECIFIED) {
|
|
11289
|
+
const rawDxa = typeof tblDef?.yudaoTblWidthDxa === "number" ? Math.max(20, Math.round(tblDef.yudaoTblWidthDxa)) : Math.max(20, Math.round(toPoints(tblDef?.size?.width) * 20));
|
|
11290
|
+
tblWXml = `<w:tblW w:w="${rawDxa}" w:type="dxa"/>`;
|
|
11291
|
+
} else {
|
|
11292
|
+
tblWXml = '<w:tblW w:w="0" w:type="auto"/>';
|
|
11293
|
+
}
|
|
11294
|
+
const tblLayoutXml = tblDef?.layout === import_core7.TableLayoutType.FIXED ? '<w:tblLayout w:type="fixed"/>' : tblDef?.layout === import_core7.TableLayoutType.AUTO_FIT ? '<w:tblLayout w:type="autofit"/>' : "";
|
|
11007
11295
|
const tblPrExtra = [
|
|
11008
11296
|
tblDir === "rtl" ? "<w:bidiVisual/>" : "",
|
|
11009
|
-
buildTableBordersOoxml(tblBorderPreset)
|
|
11297
|
+
buildTableBordersOoxml(tblBorderPreset),
|
|
11298
|
+
tblLayoutXml
|
|
11010
11299
|
].join("");
|
|
11011
|
-
const tblWXml = tblAutoFitWindow ? '<w:tblW w:w="5000" w:type="pct"/>' : '<w:tblW w:w="0" w:type="auto"/>';
|
|
11012
11300
|
blocksXml.push(
|
|
11013
11301
|
`<w:tbl><w:tblPr><w:tblStyle w:val="TableGrid"/>${tblWXml}${tblPrExtra}</w:tblPr><w:tblGrid>${gridColsXml}</w:tblGrid>${trXmlList.join("")}</w:tbl>`
|
|
11014
11302
|
);
|
|
@@ -11028,9 +11316,13 @@ function serializeStoryBodyXml(snapshot, body, exportCtx) {
|
|
|
11028
11316
|
return blocksXml.join("\n ");
|
|
11029
11317
|
}
|
|
11030
11318
|
function exportDocxBytes(rawSnapshot, data, exportOptions) {
|
|
11031
|
-
const
|
|
11319
|
+
const evaluatedSnapshot = evaluateDocTableFormulas(
|
|
11032
11320
|
data ? fillDatasetIntoDocSnapshot(rawSnapshot, data) : rawSnapshot
|
|
11033
11321
|
);
|
|
11322
|
+
const snapshot = Object.keys(evaluatedSnapshot.drawings ?? {}).length === 0 && (evaluatedSnapshot.resources ?? []).some((r) => r.name === "DOC_DRAWING_PLUGIN") ? normalizeDocDrawingsAndPluginResource({
|
|
11323
|
+
...evaluatedSnapshot,
|
|
11324
|
+
resources: evaluatedSnapshot.resources ? [...evaluatedSnapshot.resources] : void 0
|
|
11325
|
+
}) : evaluatedSnapshot;
|
|
11034
11326
|
const body = snapshot.body ?? {
|
|
11035
11327
|
dataStream: "\r\n",
|
|
11036
11328
|
paragraphs: [{ startIndex: 0, paragraphId: "p0" }]
|
|
@@ -11123,7 +11415,8 @@ function exportDocxBytes(rawSnapshot, data, exportOptions) {
|
|
|
11123
11415
|
wPt,
|
|
11124
11416
|
hPt,
|
|
11125
11417
|
block.blockId,
|
|
11126
|
-
drwTransform
|
|
11418
|
+
drwTransform,
|
|
11419
|
+
drawing
|
|
11127
11420
|
);
|
|
11128
11421
|
const embedSpec = exportMeta.embedBlocks?.[block.blockId];
|
|
11129
11422
|
if (embedSpec?.url) {
|
|
@@ -11212,6 +11505,7 @@ function exportDocxBytes(rawSnapshot, data, exportOptions) {
|
|
|
11212
11505
|
const mediaName = `media/image${imgSeq}.${dec.ext}`;
|
|
11213
11506
|
const wPt = drw?.docTransform?.size?.width ?? 90;
|
|
11214
11507
|
const hPt = drw?.docTransform?.size?.height ?? 36;
|
|
11508
|
+
const hfDrwTransform = exportMeta.imageTransforms?.[blk.blockId] ?? drw?.yudaoTransform;
|
|
11215
11509
|
extraZipFiles.push({ name: `word/${mediaName}`, content: dec.bytes });
|
|
11216
11510
|
imageExts.set(dec.ext, dec.mime);
|
|
11217
11511
|
hfRels.push(
|
|
@@ -11219,7 +11513,7 @@ function exportDocxBytes(rawSnapshot, data, exportOptions) {
|
|
|
11219
11513
|
);
|
|
11220
11514
|
hfDrawingMap.set(
|
|
11221
11515
|
blk.startIndex,
|
|
11222
|
-
buildInlineImageDrawingXml(rId, imgSeq, wPt, hPt, blk.blockId)
|
|
11516
|
+
buildInlineImageDrawingXml(rId, imgSeq, wPt, hPt, blk.blockId, hfDrwTransform, drw)
|
|
11223
11517
|
);
|
|
11224
11518
|
imgSeq++;
|
|
11225
11519
|
}
|
|
@@ -11247,7 +11541,8 @@ function exportDocxBytes(rawSnapshot, data, exportOptions) {
|
|
|
11247
11541
|
<Override PartName="/word/${target}" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.header+xml"/>`;
|
|
11248
11542
|
const hfDrw = collectHfDrawings(entry.body, target);
|
|
11249
11543
|
const hdrBodyXml = serializeStoryBodyXml(snapshot, entry.body, {
|
|
11250
|
-
drawingXmlByOffset: hfDrw
|
|
11544
|
+
drawingXmlByOffset: hfDrw,
|
|
11545
|
+
storyTableSource: entry.tableSource
|
|
11251
11546
|
});
|
|
11252
11547
|
extraZipFiles.push({
|
|
11253
11548
|
name: `word/${target}`,
|
|
@@ -11269,7 +11564,8 @@ function exportDocxBytes(rawSnapshot, data, exportOptions) {
|
|
|
11269
11564
|
<Override PartName="/word/${target}" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.footer+xml"/>`;
|
|
11270
11565
|
const hfDrw = collectHfDrawings(entry.body, target);
|
|
11271
11566
|
const ftrBodyXml = serializeStoryBodyXml(snapshot, entry.body, {
|
|
11272
|
-
drawingXmlByOffset: hfDrw
|
|
11567
|
+
drawingXmlByOffset: hfDrw,
|
|
11568
|
+
storyTableSource: entry.tableSource
|
|
11273
11569
|
});
|
|
11274
11570
|
extraZipFiles.push({
|
|
11275
11571
|
name: `word/${target}`,
|
|
@@ -11365,14 +11661,21 @@ function exportDocxBytes(rawSnapshot, data, exportOptions) {
|
|
|
11365
11661
|
<w:hdr xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"><w:p>${wmDrawingXml}</w:p></w:hdr>`
|
|
11366
11662
|
});
|
|
11367
11663
|
}
|
|
11368
|
-
const
|
|
11369
|
-
const
|
|
11664
|
+
const explicitUseFirstHf = docStyle?.useFirstPageHeaderFooter ?? firstSectionBreak?.useFirstPageHeaderFooter;
|
|
11665
|
+
const hasFirstPageHf = explicitUseFirstHf === import_core7.BooleanNumber.TRUE || explicitUseFirstHf === void 0 && (resolvedHeaders.some((h) => h.slot === "first") || resolvedFooters.some((f) => f.slot === "first"));
|
|
11666
|
+
const explicitEvenOdd = docStyle?.evenAndOddHeaders ?? firstSectionBreak?.evenAndOddHeaders;
|
|
11667
|
+
const hasEvenPageHf = explicitEvenOdd === import_core7.BooleanNumber.TRUE || explicitEvenOdd === void 0 && (resolvedHeaders.some((h) => h.slot === "even") || resolvedFooters.some((f) => f.slot === "even"));
|
|
11668
|
+
const liveDocFields = listDocFields(snapshot);
|
|
11669
|
+
const hasTocField = Boolean(
|
|
11670
|
+
(body.customRanges ?? []).some((r) => r.properties?.yudaoBlockKind === "toc")
|
|
11671
|
+
);
|
|
11672
|
+
const wantUpdateFields = liveDocFields.length > 0 || hasTocField;
|
|
11370
11673
|
const wantAutoHyphenation = Boolean(exportMeta.printConfig?.autoHyphenation);
|
|
11371
11674
|
const wantGutterAtTop = exportMeta.printConfig?.gutterPosition === "top";
|
|
11372
11675
|
const fnSettings = exportMeta.noteSettings?.footnote;
|
|
11373
11676
|
const enSettings = exportMeta.noteSettings?.endnote;
|
|
11374
11677
|
const mapNoteFmtOoxml = (fmt3) => fmt3 === "lowerRoman" ? "lowerRoman" : fmt3 === "circled" ? "chicago" : "decimal";
|
|
11375
|
-
if (hasEvenPageHf || wantAutoHyphenation || wantGutterAtTop || fnSettings || enSettings) {
|
|
11678
|
+
if (hasEvenPageHf || wantAutoHyphenation || wantGutterAtTop || fnSettings || enSettings || wantUpdateFields) {
|
|
11376
11679
|
relEntries.push({
|
|
11377
11680
|
id: "rIdSettings",
|
|
11378
11681
|
type: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings",
|
|
@@ -11386,6 +11689,7 @@ function exportDocxBytes(rawSnapshot, data, exportOptions) {
|
|
|
11386
11689
|
hasEvenPageHf ? " <w:evenAndOddHeaders/>" : "",
|
|
11387
11690
|
wantAutoHyphenation ? " <w:autoHyphenation/>" : "",
|
|
11388
11691
|
wantGutterAtTop ? " <w:gutterAtTop/>" : "",
|
|
11692
|
+
wantUpdateFields ? ' <w:updateFields w:val="true"/>' : "",
|
|
11389
11693
|
fnPrXml,
|
|
11390
11694
|
enPrXml
|
|
11391
11695
|
].filter(Boolean).join("\n");
|
|
@@ -11484,7 +11788,6 @@ ${commentsItemsXml}
|
|
|
11484
11788
|
const liveShapesArr = listLiveDocShapes(snapshot);
|
|
11485
11789
|
const liveInlineFormulas = listDocInlineFormulas(snapshot);
|
|
11486
11790
|
const liveSmartArtsArr = listLiveSmartArts(snapshot);
|
|
11487
|
-
const liveDocFields = listDocFields(snapshot);
|
|
11488
11791
|
const liveCaptions = listDocCaptions(snapshot);
|
|
11489
11792
|
const liveCitations = listDocCitations(snapshot);
|
|
11490
11793
|
const serializedLatexMap = liveLatexArr.length > 0 ? Object.fromEntries(liveLatexArr.map((f) => [f.id, f])) : templateMeta.latexFormulas;
|
|
@@ -11504,7 +11807,7 @@ ${commentsItemsXml}
|
|
|
11504
11807
|
const liveSdtControls = listDocSdtControls(snapshot);
|
|
11505
11808
|
const serializedSdtExtendedSpecs = {};
|
|
11506
11809
|
for (const ctrl of liveSdtControls) {
|
|
11507
|
-
if (ctrl.kind === "cascader" || ctrl.kind === "checkbox" || ctrl.kind === "radio" || ctrl.kind === "multiSelect" || ctrl.kind === "number" || ctrl.kind === "dateRange" || ctrl.kind === "picture" || ctrl.kind === "group" || ctrl.kind === "signature" || ctrl.segmentId || ctrl.conceptId || ctrl.deletable !== void 0 || ctrl.cascaderOptions?.length || ctrl.cascaderSeparator !== void 0 || ctrl.preText !== void 0 || ctrl.postText !== void 0 || ctrl.minWidthPt !== void 0 || ctrl.underlineBlank !== void 0 || ctrl.pasteDisabled !== void 0 || ctrl.hint !== void 0 || ctrl.calculatorEnabled !== void 0 || ctrl.checkboxMarkType !== void 0 || ctrl.layoutDirection !== void 0 || ctrl.options?.length) {
|
|
11810
|
+
if (ctrl.kind === "cascader" || ctrl.kind === "checkbox" || ctrl.kind === "radio" || ctrl.kind === "multiSelect" || ctrl.kind === "number" || ctrl.kind === "dateRange" || ctrl.kind === "picture" || ctrl.kind === "group" || ctrl.kind === "signature" || ctrl.segmentId || ctrl.conceptId || ctrl.deletable !== void 0 || ctrl.cascaderOptions?.length || ctrl.cascaderSeparator !== void 0 || ctrl.visualChrome !== void 0 || ctrl.prefix !== void 0 || ctrl.postfix !== void 0 || ctrl.preText !== void 0 || ctrl.postText !== void 0 || ctrl.minWidthPt !== void 0 || ctrl.underlineBlank !== void 0 || ctrl.pasteDisabled !== void 0 || ctrl.hint !== void 0 || ctrl.calculatorEnabled !== void 0 || ctrl.checkboxMarkType !== void 0 || ctrl.layoutDirection !== void 0 || ctrl.options?.length) {
|
|
11508
11811
|
serializedSdtExtendedSpecs[ctrl.id] = {
|
|
11509
11812
|
id: ctrl.id,
|
|
11510
11813
|
tag: ctrl.tag,
|
|
@@ -11517,6 +11820,9 @@ ${commentsItemsXml}
|
|
|
11517
11820
|
...ctrl.options?.length ? { options: ctrl.options } : {},
|
|
11518
11821
|
...ctrl.checkboxMarkType ? { checkboxMarkType: ctrl.checkboxMarkType } : {},
|
|
11519
11822
|
...ctrl.layoutDirection ? { layoutDirection: ctrl.layoutDirection } : {},
|
|
11823
|
+
...ctrl.visualChrome ? { visualChrome: ctrl.visualChrome } : {},
|
|
11824
|
+
...ctrl.prefix !== void 0 ? { prefix: ctrl.prefix } : {},
|
|
11825
|
+
...ctrl.postfix !== void 0 ? { postfix: ctrl.postfix } : {},
|
|
11520
11826
|
...ctrl.preText !== void 0 ? { preText: ctrl.preText } : {},
|
|
11521
11827
|
...ctrl.postText !== void 0 ? { postText: ctrl.postText } : {},
|
|
11522
11828
|
...ctrl.minWidthPt !== void 0 ? { minWidthPt: ctrl.minWidthPt } : {},
|
|
@@ -11551,7 +11857,7 @@ ${commentsItemsXml}
|
|
|
11551
11857
|
levels: def?.levels
|
|
11552
11858
|
});
|
|
11553
11859
|
}
|
|
11554
|
-
if (templateMeta.medicalFormulas && Object.keys(templateMeta.medicalFormulas).length > 0 || templateMeta.barcodeBlocks && Object.keys(templateMeta.barcodeBlocks).length > 0 || Boolean(templateMeta.codeBlocks?.length) || Boolean(templateMeta.activeRole) || liveCallouts.length > 0 || liveQuotes.length > 0 || liveBookmarks.length > 0 || Boolean(serializedLatexMap && Object.keys(serializedLatexMap).length > 0) || Boolean(serializedChartMap && Object.keys(serializedChartMap).length > 0) || Boolean(serializedShapeMap && Object.keys(serializedShapeMap).length > 0) || Boolean(serializedSmartArtMap && Object.keys(serializedSmartArtMap).length > 0) || Boolean(serializedInlineFmlMap && Object.keys(serializedInlineFmlMap).length > 0) || Boolean(serializedFieldsMap && Object.keys(serializedFieldsMap).length > 0) || Boolean(templateMeta.tableRepeatHeaders && Object.keys(templateMeta.tableRepeatHeaders).length > 0) || Boolean(templateMeta.repeatingSections && Object.keys(templateMeta.repeatingSections).length > 0) || Boolean(templateMeta.tocConfig) || Boolean(templateMeta.imageTransforms && Object.keys(templateMeta.imageTransforms).length > 0) || Boolean(templateMeta.printConfig && Object.keys(templateMeta.printConfig).length > 0) || Boolean(templateMeta.columnGroupConfig) || liveCaptions.length > 0 || liveCitations.length > 0 || Boolean(templateMeta.buildingBlocks?.length) || liveAreas.length > 0 || Boolean(liveMainBadge) || Boolean(serializedLabelBadgesMap && Object.keys(serializedLabelBadgesMap).length > 0) || Boolean(templateMeta.cascadeRules?.length) || Boolean(templateMeta.cascadeBaselines && Object.keys(templateMeta.cascadeBaselines).length > 0) || Boolean(serializedStyledSepsMap && Object.keys(serializedStyledSepsMap).length > 0) || Boolean(serializedEmbedBlocksMap && Object.keys(serializedEmbedBlocksMap).length > 0) || Boolean(templateMeta.macros && Object.keys(templateMeta.macros).length > 0) || Boolean(templateMeta.graffitiStrokes?.length) || Boolean(templateMeta.noteSettings) || Boolean(templateMeta.company) || Boolean(templateMeta.customProperties && Object.keys(templateMeta.customProperties).length > 0) || Boolean(templateMeta.copyPastePolicy) || Boolean(templateMeta.sectionOrientations && Object.keys(templateMeta.sectionOrientations).length > 0) || Boolean(templateMeta.paragraphDirections && Object.keys(templateMeta.paragraphDirections).length > 0) || Boolean(templateMeta.tableDirections && Object.keys(templateMeta.tableDirections).length > 0) || Boolean(templateMeta.tableBorderPresets && Object.keys(templateMeta.tableBorderPresets).length > 0) || Boolean(templateMeta.tableCellProperties && Object.keys(templateMeta.tableCellProperties).length > 0) || Boolean(templateMeta.listDefinitions && Object.keys(templateMeta.listDefinitions).length > 0) || Boolean(templateMeta.listParagraphChecks && Object.keys(templateMeta.listParagraphChecks).length > 0) || liveComments.length > 0 || Boolean(templateMeta.titleProperties && Object.keys(templateMeta.titleProperties).length > 0) || Object.keys(serializedSdtExtendedSpecs).length > 0) {
|
|
11860
|
+
if (templateMeta.medicalFormulas && Object.keys(templateMeta.medicalFormulas).length > 0 || templateMeta.barcodeBlocks && Object.keys(templateMeta.barcodeBlocks).length > 0 || Boolean(templateMeta.codeBlocks?.length) || Boolean(templateMeta.activeRole) || liveCallouts.length > 0 || liveQuotes.length > 0 || liveBookmarks.length > 0 || Boolean(serializedLatexMap && Object.keys(serializedLatexMap).length > 0) || Boolean(serializedChartMap && Object.keys(serializedChartMap).length > 0) || Boolean(serializedShapeMap && Object.keys(serializedShapeMap).length > 0) || Boolean(serializedSmartArtMap && Object.keys(serializedSmartArtMap).length > 0) || Boolean(serializedInlineFmlMap && Object.keys(serializedInlineFmlMap).length > 0) || Boolean(serializedFieldsMap && Object.keys(serializedFieldsMap).length > 0) || Boolean(templateMeta.tableRowLoops && Object.keys(templateMeta.tableRowLoops).length > 0) || Boolean(templateMeta.tableRepeatHeaders && Object.keys(templateMeta.tableRepeatHeaders).length > 0) || Boolean(templateMeta.repeatingSections && Object.keys(templateMeta.repeatingSections).length > 0) || Boolean(templateMeta.tocConfig) || Boolean(templateMeta.imageTransforms && Object.keys(templateMeta.imageTransforms).length > 0) || Boolean(templateMeta.printConfig && Object.keys(templateMeta.printConfig).length > 0) || Boolean(templateMeta.columnGroupConfig) || liveCaptions.length > 0 || liveCitations.length > 0 || Boolean(templateMeta.buildingBlocks?.length) || liveAreas.length > 0 || Boolean(liveMainBadge) || Boolean(serializedLabelBadgesMap && Object.keys(serializedLabelBadgesMap).length > 0) || Boolean(templateMeta.cascadeRules?.length) || Boolean(templateMeta.cascadeBaselines && Object.keys(templateMeta.cascadeBaselines).length > 0) || Boolean(serializedStyledSepsMap && Object.keys(serializedStyledSepsMap).length > 0) || Boolean(serializedEmbedBlocksMap && Object.keys(serializedEmbedBlocksMap).length > 0) || Boolean(templateMeta.macros && Object.keys(templateMeta.macros).length > 0) || Boolean(templateMeta.graffitiStrokes?.length) || Boolean(templateMeta.noteSettings) || Boolean(templateMeta.company) || Boolean(templateMeta.customProperties && Object.keys(templateMeta.customProperties).length > 0) || Boolean(templateMeta.copyPastePolicy) || Boolean(templateMeta.sectionOrientations && Object.keys(templateMeta.sectionOrientations).length > 0) || Boolean(templateMeta.paragraphDirections && Object.keys(templateMeta.paragraphDirections).length > 0) || Boolean(templateMeta.tableDirections && Object.keys(templateMeta.tableDirections).length > 0) || Boolean(templateMeta.tableBorderPresets && Object.keys(templateMeta.tableBorderPresets).length > 0) || Boolean(templateMeta.tableCellProperties && Object.keys(templateMeta.tableCellProperties).length > 0) || Boolean(templateMeta.listDefinitions && Object.keys(templateMeta.listDefinitions).length > 0) || Boolean(templateMeta.listParagraphChecks && Object.keys(templateMeta.listParagraphChecks).length > 0) || liveComments.length > 0 || Boolean(templateMeta.titleProperties && Object.keys(templateMeta.titleProperties).length > 0) || Object.keys(serializedSdtExtendedSpecs).length > 0) {
|
|
11555
11861
|
extraZipFiles.push({
|
|
11556
11862
|
name: "docProps/yudao-meta.json",
|
|
11557
11863
|
content: JSON.stringify({
|
|
@@ -11577,6 +11883,7 @@ ${commentsItemsXml}
|
|
|
11577
11883
|
imageTransforms: templateMeta.imageTransforms,
|
|
11578
11884
|
printConfig: templateMeta.printConfig,
|
|
11579
11885
|
columnGroupConfig: templateMeta.columnGroupConfig,
|
|
11886
|
+
tableRowLoops: templateMeta.tableRowLoops,
|
|
11580
11887
|
tableRepeatHeaders: templateMeta.tableRepeatHeaders,
|
|
11581
11888
|
repeatingSections: templateMeta.repeatingSections,
|
|
11582
11889
|
tocConfig: templateMeta.tocConfig,
|
|
@@ -11681,10 +11988,18 @@ ${commentsItemsXml}
|
|
|
11681
11988
|
const pageW = trailingOrient === "landscape" ? Math.max(basePageWTw, basePageHTw) : trailingOrient === "portrait" ? Math.min(basePageWTw, basePageHTw) : basePageWTw;
|
|
11682
11989
|
const pageH = trailingOrient === "landscape" ? Math.min(basePageWTw, basePageHTw) : trailingOrient === "portrait" ? Math.max(basePageWTw, basePageHTw) : basePageHTw;
|
|
11683
11990
|
const orientAttr = pageW > pageH ? ' w:orient="landscape"' : "";
|
|
11684
|
-
const marTop = Math.round((docStyle?.marginTop ?? 56) * 20);
|
|
11685
|
-
const marBottom = Math.round(
|
|
11686
|
-
|
|
11687
|
-
|
|
11991
|
+
const marTop = Math.round((docStyle?.marginTop ?? firstSectionBreak?.marginTop ?? 56) * 20);
|
|
11992
|
+
const marBottom = Math.round(
|
|
11993
|
+
(docStyle?.marginBottom ?? firstSectionBreak?.marginBottom ?? 56) * 20
|
|
11994
|
+
);
|
|
11995
|
+
const marLeft = Math.round((docStyle?.marginLeft ?? firstSectionBreak?.marginLeft ?? 64) * 20);
|
|
11996
|
+
const marRight = Math.round((docStyle?.marginRight ?? firstSectionBreak?.marginRight ?? 64) * 20);
|
|
11997
|
+
const marHeader = Math.round(
|
|
11998
|
+
(docStyle?.marginHeader ?? firstSectionBreak?.marginHeader ?? 36) * 20
|
|
11999
|
+
);
|
|
12000
|
+
const marFooter = Math.round(
|
|
12001
|
+
(docStyle?.marginFooter ?? firstSectionBreak?.marginFooter ?? 36) * 20
|
|
12002
|
+
);
|
|
11688
12003
|
const gutterTwips = Math.max(0, Math.round((templateMeta.printConfig?.gutterPt ?? 0) * 20));
|
|
11689
12004
|
const gutterAttr = gutterTwips > 0 ? ` w:gutter="${gutterTwips}"` : "";
|
|
11690
12005
|
let pgBordersXml = "";
|
|
@@ -11736,6 +12051,24 @@ ${commentsItemsXml}
|
|
|
11736
12051
|
}
|
|
11737
12052
|
}
|
|
11738
12053
|
const titlePgXml = hasFirstPageHf ? "\n <w:titlePg/>" : "";
|
|
12054
|
+
let docGridXml = "";
|
|
12055
|
+
const savedGrid = docStyle?.yudaoDocGrid;
|
|
12056
|
+
const effGridType = firstSectionBreak?.gridType ?? docStyle?.gridType;
|
|
12057
|
+
const effLinePitch = firstSectionBreak?.linePitch ?? docStyle?.linePitch;
|
|
12058
|
+
const effCharSpace = firstSectionBreak?.charSpace ?? docStyle?.charSpace;
|
|
12059
|
+
if (savedGrid || effGridType !== void 0 || typeof effLinePitch === "number" || typeof effCharSpace === "number") {
|
|
12060
|
+
const gAttrs = [];
|
|
12061
|
+
const gTypeStr = savedGrid?.type ?? (effGridType === import_core7.GridType.LINES ? "lines" : effGridType === import_core7.GridType.LINES_AND_CHARS ? "linesAndChars" : effGridType === import_core7.GridType.SNAP_TO_CHARS ? "snapToChars" : effGridType === import_core7.GridType.DEFAULT ? "default" : void 0);
|
|
12062
|
+
if (gTypeStr) gAttrs.push(`w:type="${escapeXml(gTypeStr)}"`);
|
|
12063
|
+
const lpTwips = typeof savedGrid?.linePitch === "number" ? Math.round(savedGrid.linePitch) : typeof effLinePitch === "number" && effLinePitch > 0 ? Math.round(effLinePitch * 20) : void 0;
|
|
12064
|
+
if (lpTwips !== void 0) gAttrs.push(`w:linePitch="${lpTwips}"`);
|
|
12065
|
+
const csVal = typeof savedGrid?.charSpace === "number" ? Math.round(savedGrid.charSpace) : typeof effCharSpace === "number" && effCharSpace !== 0 ? Math.round(effCharSpace) : void 0;
|
|
12066
|
+
if (csVal !== void 0) gAttrs.push(`w:charSpace="${csVal}"`);
|
|
12067
|
+
if (gAttrs.length > 0) {
|
|
12068
|
+
docGridXml = `
|
|
12069
|
+
<w:docGrid ${gAttrs.join(" ")}/>`;
|
|
12070
|
+
}
|
|
12071
|
+
}
|
|
11739
12072
|
const documentXml = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
11740
12073
|
<w:document xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/wordprocessingml" xmlns:w06="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:w15="http://schemas.microsoft.com/office/word/2012/wordml">`.replace(
|
|
11741
12074
|
'xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/wordprocessingml" xmlns:w06=',
|
|
@@ -11746,28 +12079,103 @@ ${commentsItemsXml}
|
|
|
11746
12079
|
<w:sectPr>
|
|
11747
12080
|
${sectHeaderFooterRefs}${titlePgXml}
|
|
11748
12081
|
<w:pgSz w:w="${pageW}" w:h="${pageH}"${orientAttr}/>
|
|
11749
|
-
<w:pgMar w:top="${marTop}" w:right="${marRight}" w:bottom="${marBottom}" w:left="${marLeft}" w:header="
|
|
12082
|
+
<w:pgMar w:top="${marTop}" w:right="${marRight}" w:bottom="${marBottom}" w:left="${marLeft}" w:header="${marHeader}" w:footer="${marFooter}"${gutterAttr}/>${pgBordersXml}${lnNumXml}${colsXml}${docGridXml}
|
|
11750
12083
|
</w:sectPr>
|
|
11751
12084
|
</w:body>
|
|
11752
12085
|
</w:document>`;
|
|
11753
|
-
const
|
|
11754
|
-
|
|
11755
|
-
).
|
|
12086
|
+
const defTs = docStyle?.textStyle;
|
|
12087
|
+
const defRFonts = defTs?.yudaoRFonts;
|
|
12088
|
+
const defLatin = defTs?.ff && (!defRFonts?.eastAsia || defTs.ff !== defRFonts.eastAsia || defRFonts.ascii || defRFonts.hAnsi) ? defTs.ff : defRFonts?.ascii || defRFonts?.hAnsi || "Calibri";
|
|
12089
|
+
const defHAnsi = defRFonts?.hAnsi || defLatin;
|
|
12090
|
+
const defEa = defTs?.eastAsiaFontFamily || defRFonts?.eastAsia || "Microsoft YaHei";
|
|
12091
|
+
const defCs = defRFonts?.cs || (defTs?.ff ? defLatin : "Times New Roman");
|
|
12092
|
+
const defHintAttr = defTs?.fontHint || defRFonts?.hint ? ` w:hint="${escapeXml(String(defTs?.fontHint || defRFonts?.hint))}"` : "";
|
|
12093
|
+
const defSzHalfPt = Math.max(2, Math.round((defTs?.fs ?? 11) * 2));
|
|
12094
|
+
const defExtraRPr = defTs ? buildRunPrXml({
|
|
12095
|
+
...defTs,
|
|
12096
|
+
ff: void 0,
|
|
12097
|
+
eastAsiaFontFamily: void 0,
|
|
12098
|
+
fontHint: void 0,
|
|
12099
|
+
fs: void 0,
|
|
12100
|
+
...{ yudaoRFonts: void 0 }
|
|
12101
|
+
}).replace(/^<w:rPr>|<\/w:rPr>$/g, "") : "";
|
|
12102
|
+
const pPrDefaultInner = docStyle?.defaultParagraphStyle ? buildParagraphOpenPrXml({ paragraphStyle: docStyle.defaultParagraphStyle }) : "";
|
|
12103
|
+
const pPrDefaultXml = pPrDefaultInner ? `
|
|
12104
|
+
<w:pPrDefault>
|
|
12105
|
+
${pPrDefaultInner}
|
|
12106
|
+
</w:pPrDefault>` : "";
|
|
12107
|
+
const defaultParaStyleId = docStyle?.defaultParagraphStyleId || "Normal";
|
|
12108
|
+
const snapshotStyles = snapshot.styles ?? {};
|
|
12109
|
+
const serializeNamedStyleXml = (styleId, st, isDefault = false, outlineLvl) => {
|
|
12110
|
+
const wType = st.type === import_core7.DocStyleType.character ? "character" : st.type === import_core7.DocStyleType.table ? "table" : st.type === import_core7.DocStyleType.numbering ? "numbering" : "paragraph";
|
|
12111
|
+
const defAttr = isDefault ? ' w:default="1"' : "";
|
|
12112
|
+
const customAttr = st.customStyle ? ' w:customStyle="1"' : "";
|
|
12113
|
+
const nameXml = `<w:name w:val="${escapeXml(st.name || styleId)}"/>`;
|
|
12114
|
+
const basedOnXml = st.basedOn ? `<w:basedOn w:val="${escapeXml(st.basedOn)}"/>` : "";
|
|
12115
|
+
const linkXml = st.link ? `<w:link w:val="${escapeXml(st.link)}"/>` : "";
|
|
12116
|
+
let pPrXml = st.paragraphStyle ? buildParagraphOpenPrXml({ paragraphStyle: st.paragraphStyle }) : "";
|
|
12117
|
+
if (typeof outlineLvl === "number") {
|
|
12118
|
+
const outlineTag = `<w:outlineLvl w:val="${outlineLvl}"/>`;
|
|
12119
|
+
if (pPrXml) {
|
|
12120
|
+
pPrXml = pPrXml.replace(/^<w:pPr>/, `<w:pPr>${outlineTag}`);
|
|
12121
|
+
} else {
|
|
12122
|
+
pPrXml = `<w:pPr>${outlineTag}</w:pPr>`;
|
|
12123
|
+
}
|
|
12124
|
+
}
|
|
12125
|
+
const rPrXml = st.textStyle ? buildRunPrXml(st.textStyle) : "";
|
|
12126
|
+
return ` <w:style w:type="${wType}"${defAttr}${customAttr} w:styleId="${escapeXml(styleId)}">${nameXml}${basedOnXml}${linkXml}${pPrXml}${rPrXml}</w:style>`;
|
|
12127
|
+
};
|
|
12128
|
+
const styleBlocksXml = [];
|
|
12129
|
+
const emittedStyleIds = /* @__PURE__ */ new Set();
|
|
12130
|
+
if (snapshotStyles[defaultParaStyleId]) {
|
|
12131
|
+
styleBlocksXml.push(
|
|
12132
|
+
serializeNamedStyleXml(defaultParaStyleId, snapshotStyles[defaultParaStyleId], true)
|
|
12133
|
+
);
|
|
12134
|
+
emittedStyleIds.add(defaultParaStyleId);
|
|
12135
|
+
} else {
|
|
12136
|
+
styleBlocksXml.push(
|
|
12137
|
+
` <w:style w:type="paragraph" w:default="1" w:styleId="${escapeXml(defaultParaStyleId)}"><w:name w:val="Normal"/></w:style>`
|
|
12138
|
+
);
|
|
12139
|
+
emittedStyleIds.add(defaultParaStyleId);
|
|
12140
|
+
}
|
|
12141
|
+
if (!emittedStyleIds.has("Normal")) {
|
|
12142
|
+
if (snapshotStyles.Normal) {
|
|
12143
|
+
styleBlocksXml.push(serializeNamedStyleXml("Normal", snapshotStyles.Normal, false));
|
|
12144
|
+
} else {
|
|
12145
|
+
styleBlocksXml.push(
|
|
12146
|
+
' <w:style w:type="paragraph" w:styleId="Normal"><w:name w:val="Normal"/></w:style>'
|
|
12147
|
+
);
|
|
12148
|
+
}
|
|
12149
|
+
emittedStyleIds.add("Normal");
|
|
12150
|
+
}
|
|
12151
|
+
for (let lvl = 1; lvl <= 6; lvl++) {
|
|
12152
|
+
const hId = `Heading${lvl}`;
|
|
12153
|
+
if (snapshotStyles[hId]) {
|
|
12154
|
+
styleBlocksXml.push(serializeNamedStyleXml(hId, snapshotStyles[hId], false, lvl - 1));
|
|
12155
|
+
} else {
|
|
12156
|
+
styleBlocksXml.push(
|
|
12157
|
+
` <w:style w:type="paragraph" w:styleId="${hId}"><w:name w:val="heading ${lvl}"/><w:pPr><w:outlineLvl w:val="${lvl - 1}"/></w:pPr></w:style>`
|
|
12158
|
+
);
|
|
12159
|
+
}
|
|
12160
|
+
emittedStyleIds.add(hId);
|
|
12161
|
+
}
|
|
12162
|
+
for (const [sId, st] of Object.entries(snapshotStyles)) {
|
|
12163
|
+
if (emittedStyleIds.has(sId) || sId === "TableGrid" || !st) continue;
|
|
12164
|
+
styleBlocksXml.push(serializeNamedStyleXml(sId, st, false));
|
|
12165
|
+
emittedStyleIds.add(sId);
|
|
12166
|
+
}
|
|
11756
12167
|
const stylesXml = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
11757
12168
|
<w:styles xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main">
|
|
11758
12169
|
<w:docDefaults>
|
|
11759
12170
|
<w:rPrDefault>
|
|
11760
12171
|
<w:rPr>
|
|
11761
|
-
<w:rFonts w:ascii="
|
|
11762
|
-
<w:sz w:val="
|
|
11763
|
-
<w:szCs w:val="
|
|
12172
|
+
<w:rFonts w:ascii="${escapeXml(defLatin)}" w:hAnsi="${escapeXml(defHAnsi)}" w:eastAsia="${escapeXml(defEa)}" w:cs="${escapeXml(defCs)}"${defHintAttr}/>${defExtraRPr}
|
|
12173
|
+
<w:sz w:val="${defSzHalfPt}"/>
|
|
12174
|
+
<w:szCs w:val="${defSzHalfPt}"/>
|
|
11764
12175
|
</w:rPr>
|
|
11765
|
-
</w:rPrDefault
|
|
12176
|
+
</w:rPrDefault>${pPrDefaultXml}
|
|
11766
12177
|
</w:docDefaults>
|
|
11767
|
-
|
|
11768
|
-
<w:name w:val="Normal"/>
|
|
11769
|
-
</w:style>
|
|
11770
|
-
${headingStylesXml}
|
|
12178
|
+
${styleBlocksXml.join("\n")}
|
|
11771
12179
|
<w:style w:type="table" w:styleId="TableGrid">
|
|
11772
12180
|
<w:name w:val="Table Grid"/>
|
|
11773
12181
|
<w:tblPr>
|
|
@@ -12743,8 +13151,62 @@ async function extractAllDocxZipEntries(bytes) {
|
|
|
12743
13151
|
}
|
|
12744
13152
|
return out;
|
|
12745
13153
|
}
|
|
12746
|
-
function
|
|
12747
|
-
const
|
|
13154
|
+
function parseThemeFontsFromXml(themeXml) {
|
|
13155
|
+
const extractSlot = (tag) => {
|
|
13156
|
+
const block = themeXml.match(new RegExp(`<a:${tag}[\\s>][\\s\\S]*?<\\/a:${tag}>`))?.[0] || "";
|
|
13157
|
+
if (!block) return {};
|
|
13158
|
+
const latin = block.match(/<a:latin\b[^>]*\btypeface="([^"]*)"/)?.[1]?.trim() || void 0;
|
|
13159
|
+
const eaDirect = block.match(/<a:ea\b[^>]*\btypeface="([^"]*)"/)?.[1]?.trim() || void 0;
|
|
13160
|
+
const hans = block.match(/<a:font\b[^>]*\bscript="Hans"[^>]*\btypeface="([^"]+)"/)?.[1]?.trim() || block.match(/<a:font\b[^>]*\btypeface="([^"]+)"[^>]*\bscript="Hans"/)?.[1]?.trim() || void 0;
|
|
13161
|
+
return {
|
|
13162
|
+
latin: latin ? unescapeXml(latin) : void 0,
|
|
13163
|
+
eastAsia: eaDirect ? unescapeXml(eaDirect) : hans ? unescapeXml(hans) : void 0
|
|
13164
|
+
};
|
|
13165
|
+
};
|
|
13166
|
+
const major = extractSlot("majorFont");
|
|
13167
|
+
const minor = extractSlot("minorFont");
|
|
13168
|
+
return {
|
|
13169
|
+
...major.latin ? { majorLatin: major.latin } : {},
|
|
13170
|
+
...minor.latin ? { minorLatin: minor.latin } : {},
|
|
13171
|
+
...major.eastAsia ? { majorEastAsia: major.eastAsia } : {},
|
|
13172
|
+
...minor.eastAsia ? { minorEastAsia: minor.eastAsia } : {}
|
|
13173
|
+
};
|
|
13174
|
+
}
|
|
13175
|
+
function resolveThemeFontToken(token, theme) {
|
|
13176
|
+
if (!token || !theme) return void 0;
|
|
13177
|
+
const lower = token.toLowerCase();
|
|
13178
|
+
if (lower === "majoreastasia") return theme.majorEastAsia || theme.majorLatin;
|
|
13179
|
+
if (lower === "minoreastasia") return theme.minorEastAsia || theme.minorLatin;
|
|
13180
|
+
if (lower.startsWith("major")) return theme.majorLatin;
|
|
13181
|
+
if (lower.startsWith("minor")) return theme.minorLatin;
|
|
13182
|
+
return void 0;
|
|
13183
|
+
}
|
|
13184
|
+
function mergeDocTextStyles(base, override) {
|
|
13185
|
+
if (!base && !override) return void 0;
|
|
13186
|
+
if (!base) return override ? { ...override } : void 0;
|
|
13187
|
+
if (!override) return { ...base };
|
|
13188
|
+
const baseRF = base.yudaoRFonts;
|
|
13189
|
+
const overRF = override.yudaoRFonts;
|
|
13190
|
+
const mergedRF = baseRF || overRF ? {
|
|
13191
|
+
...baseRF ?? {},
|
|
13192
|
+
...overRF ?? {}
|
|
13193
|
+
} : void 0;
|
|
13194
|
+
const merged = {
|
|
13195
|
+
...base,
|
|
13196
|
+
...override
|
|
13197
|
+
};
|
|
13198
|
+
if (mergedRF) {
|
|
13199
|
+
merged.yudaoRFonts = mergedRF;
|
|
13200
|
+
const latin = mergedRF.ascii || mergedRF.hAnsi || mergedRF.cs;
|
|
13201
|
+
const ea = override.eastAsiaFontFamily || base.eastAsiaFontFamily || mergedRF.eastAsia;
|
|
13202
|
+
if (ea) merged.eastAsiaFontFamily = ea;
|
|
13203
|
+
if (latin) merged.ff = latin;
|
|
13204
|
+
else if (ea) merged.ff = ea;
|
|
13205
|
+
}
|
|
13206
|
+
return merged;
|
|
13207
|
+
}
|
|
13208
|
+
function parseRunStyleFromXml(rXml, themeFonts) {
|
|
13209
|
+
const rPrMatch = rXml.startsWith("<w:rPr") ? [rXml] : rXml.match(/<w:rPr[\s>][\s\S]*?<\/w:rPr>/);
|
|
12748
13210
|
if (!rPrMatch) return void 0;
|
|
12749
13211
|
const rPr = rPrMatch[0];
|
|
12750
13212
|
const style = {};
|
|
@@ -12799,15 +13261,49 @@ function parseRunStyleFromXml(rXml) {
|
|
|
12799
13261
|
hasAny = true;
|
|
12800
13262
|
}
|
|
12801
13263
|
}
|
|
12802
|
-
const szMatch = rPr.match(/<w:sz\
|
|
13264
|
+
const szMatch = rPr.match(/<w:sz\b[^>]*w:val="(\d+)"/) || rPr.match(/<w:szCs\b[^>]*w:val="(\d+)"/);
|
|
12803
13265
|
if (szMatch) {
|
|
12804
|
-
style.fs = Math.max(6, Math.round(Number(szMatch[1]) / 2 *
|
|
13266
|
+
style.fs = Math.max(6, Math.round(Number(szMatch[1]) / 2 * 100) / 100);
|
|
12805
13267
|
hasAny = true;
|
|
12806
13268
|
}
|
|
12807
|
-
const
|
|
12808
|
-
if (
|
|
12809
|
-
|
|
12810
|
-
|
|
13269
|
+
const rFontsMatch = rPr.match(/<w:rFonts\b([^>]*)\/?>/);
|
|
13270
|
+
if (rFontsMatch) {
|
|
13271
|
+
const rfAttrs = rFontsMatch[1] || "";
|
|
13272
|
+
const rawAscii = rfAttrs.match(/\bw:ascii="([^"]+)"/)?.[1];
|
|
13273
|
+
const rawHAnsi = rfAttrs.match(/\bw:hAnsi="([^"]+)"/)?.[1];
|
|
13274
|
+
const rawEa = rfAttrs.match(/\bw:eastAsia="([^"]+)"/)?.[1];
|
|
13275
|
+
const rawCs = rfAttrs.match(/\bw:cs="([^"]+)"/)?.[1];
|
|
13276
|
+
const rawHint = rfAttrs.match(/\bw:hint="([^"]+)"/)?.[1];
|
|
13277
|
+
const ascii = (rawAscii ? unescapeXml(rawAscii) : void 0) ?? resolveThemeFontToken(rfAttrs.match(/\bw:asciiTheme="([^"]+)"/)?.[1], themeFonts);
|
|
13278
|
+
const hAnsi = (rawHAnsi ? unescapeXml(rawHAnsi) : void 0) ?? resolveThemeFontToken(rfAttrs.match(/\bw:hAnsiTheme="([^"]+)"/)?.[1], themeFonts);
|
|
13279
|
+
const eastAsia = (rawEa ? unescapeXml(rawEa) : void 0) ?? resolveThemeFontToken(rfAttrs.match(/\bw:eastAsiaTheme="([^"]+)"/)?.[1], themeFonts);
|
|
13280
|
+
const cs = (rawCs ? unescapeXml(rawCs) : void 0) ?? resolveThemeFontToken(rfAttrs.match(/\bw:csTheme="([^"]+)"/)?.[1], themeFonts);
|
|
13281
|
+
const hint = rawHint ? unescapeXml(rawHint) : void 0;
|
|
13282
|
+
const latin = ascii || hAnsi || cs;
|
|
13283
|
+
if (eastAsia) {
|
|
13284
|
+
style.eastAsiaFontFamily = eastAsia;
|
|
13285
|
+
hasAny = true;
|
|
13286
|
+
}
|
|
13287
|
+
if (latin) {
|
|
13288
|
+
style.ff = latin;
|
|
13289
|
+
hasAny = true;
|
|
13290
|
+
} else if (eastAsia) {
|
|
13291
|
+
style.ff = eastAsia;
|
|
13292
|
+
hasAny = true;
|
|
13293
|
+
}
|
|
13294
|
+
if (hint === "default" || hint === "eastAsia" || hint === "cs") {
|
|
13295
|
+
style.fontHint = hint;
|
|
13296
|
+
hasAny = true;
|
|
13297
|
+
}
|
|
13298
|
+
const yudaoRFonts = {};
|
|
13299
|
+
if (ascii) yudaoRFonts.ascii = ascii;
|
|
13300
|
+
if (hAnsi) yudaoRFonts.hAnsi = hAnsi;
|
|
13301
|
+
if (eastAsia) yudaoRFonts.eastAsia = eastAsia;
|
|
13302
|
+
if (cs) yudaoRFonts.cs = cs;
|
|
13303
|
+
if (hint) yudaoRFonts.hint = hint;
|
|
13304
|
+
if (Object.keys(yudaoRFonts).length > 0) {
|
|
13305
|
+
style.yudaoRFonts = yudaoRFonts;
|
|
13306
|
+
}
|
|
12811
13307
|
}
|
|
12812
13308
|
const colorMatch = rPr.match(/<w:color\s[^>]*w:val="([0-9a-fA-F]{6})"/);
|
|
12813
13309
|
if (colorMatch) {
|
|
@@ -12882,7 +13378,10 @@ function extractDrawingFromXmlChunk(chunk, relsMap, entries, collectedDrawings,
|
|
|
12882
13378
|
const ext = (zipKey.split(".").pop() || "png").toLowerCase();
|
|
12883
13379
|
const mime = ext === "jpg" || ext === "jpeg" ? "image/jpeg" : ext === "svg" ? "image/svg+xml" : `image/${ext}`;
|
|
12884
13380
|
const docPrName = chunk.match(/<wp:docPr\s[^>]*name="([^"]+)"/)?.[1];
|
|
12885
|
-
|
|
13381
|
+
let blockId = docPrName && !docPrName.startsWith("Picture_") && !docPrName.startsWith("Picture ") ? unescapeXml(docPrName) : `img_${(0, import_core7.generateRandomId)(6)}`;
|
|
13382
|
+
if (collectedDrawings[blockId]) {
|
|
13383
|
+
blockId = `${blockId}_${(0, import_core7.generateRandomId)(4)}`;
|
|
13384
|
+
}
|
|
12886
13385
|
const extMatch = chunk.match(/<wp:extent\s[^>]*cx="(\d+)"[^>]*cy="(\d+)"/);
|
|
12887
13386
|
const wPt = extMatch ? Math.round(Number(extMatch[1]) / 12700 * 100) / 100 : 140;
|
|
12888
13387
|
const hPt = extMatch ? Math.round(Number(extMatch[2]) / 12700 * 100) / 100 : 90;
|
|
@@ -12914,29 +13413,41 @@ function extractDrawingFromXmlChunk(chunk, relsMap, entries, collectedDrawings,
|
|
|
12914
13413
|
let posOffsetVPt = 0;
|
|
12915
13414
|
let relFromHStr = "column";
|
|
12916
13415
|
let relFromVStr = "paragraph";
|
|
13416
|
+
let alignHCode;
|
|
13417
|
+
let alignVCode;
|
|
12917
13418
|
let behindDocBool = false;
|
|
12918
13419
|
let wrapTextStr = "bothSides";
|
|
12919
|
-
let layoutType =
|
|
13420
|
+
let layoutType = import_core7.PositionedObjectLayoutType.INLINE;
|
|
12920
13421
|
if (isAnchor) {
|
|
12921
13422
|
behindDocBool = /\bbehindDoc="(?:1|true)"/.test(containerTag);
|
|
12922
13423
|
parsedTransform.behindDoc = behindDocBool;
|
|
12923
|
-
const posHMatch = chunk.match(
|
|
12924
|
-
/<wp:positionH\b([^>]*)>[\s\S]*?(?:<wp:posOffset>(-?\d+)<\/wp:posOffset>)?[\s\S]*?<\/wp:positionH>/
|
|
12925
|
-
);
|
|
13424
|
+
const posHMatch = chunk.match(/<wp:positionH\b([^>]*)>([\s\S]*?)<\/wp:positionH>/);
|
|
12926
13425
|
if (posHMatch) {
|
|
12927
13426
|
relFromHStr = posHMatch[1]?.match(/\brelativeFrom="([^"]+)"/)?.[1] || "column";
|
|
12928
|
-
posOffsetHPt = posHMatch[2] ? Math.round(Number(posHMatch[2]) / 12700 * 100) / 100 : 0;
|
|
12929
13427
|
parsedTransform.relativeFromH = relFromHStr;
|
|
12930
|
-
|
|
13428
|
+
const alignHRaw = posHMatch[2]?.match(/<wp:align>\s*([^<\s]+)\s*<\/wp:align>/)?.[1];
|
|
13429
|
+
const offsetHEmu = posHMatch[2]?.match(/<wp:posOffset>\s*(-?\d+)\s*<\/wp:posOffset>/)?.[1];
|
|
13430
|
+
if (alignHRaw && OOXML_ALIGN_H_TO_CODE[alignHRaw] !== void 0) {
|
|
13431
|
+
alignHCode = OOXML_ALIGN_H_TO_CODE[alignHRaw];
|
|
13432
|
+
parsedTransform.alignH = alignHRaw;
|
|
13433
|
+
} else {
|
|
13434
|
+
posOffsetHPt = offsetHEmu ? Math.round(Number(offsetHEmu) / 12700 * 100) / 100 : 0;
|
|
13435
|
+
parsedTransform.posOffsetH = posOffsetHPt;
|
|
13436
|
+
}
|
|
12931
13437
|
}
|
|
12932
|
-
const posVMatch = chunk.match(
|
|
12933
|
-
/<wp:positionV\b([^>]*)>[\s\S]*?(?:<wp:posOffset>(-?\d+)<\/wp:posOffset>)?[\s\S]*?<\/wp:positionV>/
|
|
12934
|
-
);
|
|
13438
|
+
const posVMatch = chunk.match(/<wp:positionV\b([^>]*)>([\s\S]*?)<\/wp:positionV>/);
|
|
12935
13439
|
if (posVMatch) {
|
|
12936
13440
|
relFromVStr = posVMatch[1]?.match(/\brelativeFrom="([^"]+)"/)?.[1] || "paragraph";
|
|
12937
|
-
posOffsetVPt = posVMatch[2] ? Math.round(Number(posVMatch[2]) / 12700 * 100) / 100 : 0;
|
|
12938
13441
|
parsedTransform.relativeFromV = relFromVStr;
|
|
12939
|
-
|
|
13442
|
+
const alignVRaw = posVMatch[2]?.match(/<wp:align>\s*([^<\s]+)\s*<\/wp:align>/)?.[1];
|
|
13443
|
+
const offsetVEmu = posVMatch[2]?.match(/<wp:posOffset>\s*(-?\d+)\s*<\/wp:posOffset>/)?.[1];
|
|
13444
|
+
if (alignVRaw && OOXML_ALIGN_V_TO_CODE[alignVRaw] !== void 0) {
|
|
13445
|
+
alignVCode = OOXML_ALIGN_V_TO_CODE[alignVRaw];
|
|
13446
|
+
parsedTransform.alignV = alignVRaw;
|
|
13447
|
+
} else {
|
|
13448
|
+
posOffsetVPt = offsetVEmu ? Math.round(Number(offsetVEmu) / 12700 * 100) / 100 : 0;
|
|
13449
|
+
parsedTransform.posOffsetV = posOffsetVPt;
|
|
13450
|
+
}
|
|
12940
13451
|
}
|
|
12941
13452
|
const wrapTextAttr = chunk.match(/\bwrapText="([^"]+)"/)?.[1];
|
|
12942
13453
|
if (wrapTextAttr === "bothSides" || wrapTextAttr === "left" || wrapTextAttr === "right" || wrapTextAttr === "largest") {
|
|
@@ -12945,25 +13456,37 @@ function extractDrawingFromXmlChunk(chunk, relsMap, entries, collectedDrawings,
|
|
|
12945
13456
|
}
|
|
12946
13457
|
if (/<wp:wrapSquare[\s/>]/.test(chunk)) {
|
|
12947
13458
|
parsedTransform.wrapType = "square";
|
|
12948
|
-
layoutType =
|
|
13459
|
+
layoutType = import_core7.PositionedObjectLayoutType.WRAP_SQUARE;
|
|
12949
13460
|
} else if (/<wp:wrapTopAndBottom[\s/>]/.test(chunk)) {
|
|
12950
13461
|
parsedTransform.wrapType = "topAndBottom";
|
|
12951
|
-
layoutType =
|
|
13462
|
+
layoutType = import_core7.PositionedObjectLayoutType.WRAP_TOP_AND_BOTTOM;
|
|
12952
13463
|
} else if (/<wp:wrapTight[\s/>]/.test(chunk)) {
|
|
12953
13464
|
parsedTransform.wrapType = "tight";
|
|
12954
|
-
layoutType =
|
|
13465
|
+
layoutType = import_core7.PositionedObjectLayoutType.WRAP_TIGHT;
|
|
13466
|
+
} else if (/<wp:wrapThrough[\s/>]/.test(chunk)) {
|
|
13467
|
+
parsedTransform.wrapType = "through";
|
|
13468
|
+
layoutType = import_core7.PositionedObjectLayoutType.WRAP_THROUGH;
|
|
13469
|
+
} else if (/<wp:wrapPolygon[\s/>]/.test(chunk)) {
|
|
13470
|
+
parsedTransform.wrapType = "polygon";
|
|
13471
|
+
layoutType = import_core7.PositionedObjectLayoutType.WRAP_POLYGON;
|
|
13472
|
+
} else if (/<wp:wrapNone[\s/>]/.test(chunk)) {
|
|
13473
|
+
parsedTransform.wrapType = behindDocBool ? "behindText" : "inFrontOfText";
|
|
13474
|
+
layoutType = import_core7.PositionedObjectLayoutType.WRAP_NONE;
|
|
12955
13475
|
} else if (behindDocBool) {
|
|
12956
13476
|
parsedTransform.wrapType = "behindText";
|
|
12957
|
-
layoutType =
|
|
13477
|
+
layoutType = import_core7.PositionedObjectLayoutType.WRAP_NONE;
|
|
12958
13478
|
} else {
|
|
12959
13479
|
parsedTransform.wrapType = "inFrontOfText";
|
|
12960
|
-
layoutType =
|
|
13480
|
+
layoutType = import_core7.PositionedObjectLayoutType.WRAP_NONE;
|
|
12961
13481
|
}
|
|
12962
13482
|
} else if (Object.keys(parsedTransform).length > 0) {
|
|
12963
13483
|
parsedTransform.wrapType = "inline";
|
|
12964
13484
|
}
|
|
12965
|
-
const relHCode = relFromHStr
|
|
12966
|
-
const relVCode = relFromVStr
|
|
13485
|
+
const relHCode = OOXML_REL_H_TO_CODE[relFromHStr] ?? import_core7.ObjectRelativeFromH.COLUMN;
|
|
13486
|
+
const relVCode = OOXML_REL_V_TO_CODE[relFromVStr] ?? import_core7.ObjectRelativeFromV.PARAGRAPH;
|
|
13487
|
+
const wrapTextCode = OOXML_WRAP_TEXT_TO_CODE[wrapTextStr] ?? import_core7.WrapTextType.BOTH_SIDES;
|
|
13488
|
+
const positionH = alignHCode !== void 0 ? { relativeFrom: relHCode, align: alignHCode } : { relativeFrom: relHCode, posOffset: posOffsetHPt };
|
|
13489
|
+
const positionV = alignVCode !== void 0 ? { relativeFrom: relVCode, align: alignVCode } : { relativeFrom: relVCode, posOffset: posOffsetVPt };
|
|
12967
13490
|
const dataUri = `data:${mime};base64,${uint8ToBase64(imgBytes)}`;
|
|
12968
13491
|
collectedDrawings[blockId] = {
|
|
12969
13492
|
unitId: docUnitId,
|
|
@@ -12975,8 +13498,8 @@ function extractDrawingFromXmlChunk(chunk, relsMap, entries, collectedDrawings,
|
|
|
12975
13498
|
title: "",
|
|
12976
13499
|
description: "",
|
|
12977
13500
|
layoutType,
|
|
12978
|
-
behindDoc: behindDocBool ?
|
|
12979
|
-
wrapText:
|
|
13501
|
+
behindDoc: behindDocBool ? import_core7.BooleanNumber.TRUE : import_core7.BooleanNumber.FALSE,
|
|
13502
|
+
wrapText: wrapTextCode,
|
|
12980
13503
|
distT: distTPt,
|
|
12981
13504
|
distB: distBPt,
|
|
12982
13505
|
distL: distLPt,
|
|
@@ -12994,17 +13517,246 @@ function extractDrawingFromXmlChunk(chunk, relsMap, entries, collectedDrawings,
|
|
|
12994
13517
|
},
|
|
12995
13518
|
docTransform: {
|
|
12996
13519
|
size: { width: wPt, height: hPt },
|
|
12997
|
-
positionH
|
|
12998
|
-
positionV
|
|
12999
|
-
angle: rotDeg
|
|
13520
|
+
positionH,
|
|
13521
|
+
positionV,
|
|
13522
|
+
angle: rotDeg,
|
|
13523
|
+
wrapText: wrapTextCode
|
|
13000
13524
|
},
|
|
13001
13525
|
...Object.keys(parsedTransform).length > 0 ? { yudaoTransform: parsedTransform } : {}
|
|
13002
13526
|
};
|
|
13003
13527
|
inlineBlocksQueue.push({ blockId });
|
|
13004
13528
|
return { blockId, dataUri };
|
|
13005
13529
|
}
|
|
13530
|
+
function applyParagraphSpacingAndIndentFromPrXml(pPrXml, pStyle, includeIndentation = true) {
|
|
13531
|
+
if (!pPrXml) return;
|
|
13532
|
+
const spacingMatch = pPrXml.match(/<w:spacing\b([^>]*)\/?>/);
|
|
13533
|
+
if (spacingMatch) {
|
|
13534
|
+
const spAttrs = spacingMatch[1] || "";
|
|
13535
|
+
const beforeVal = spAttrs.match(/\bw:before="(-?\d+)"/)?.[1];
|
|
13536
|
+
if (beforeVal !== void 0) {
|
|
13537
|
+
pStyle.spaceAbove = {
|
|
13538
|
+
v: dxaToPt(Math.max(0, Number(beforeVal))),
|
|
13539
|
+
u: import_core7.NumberUnitType.POINT
|
|
13540
|
+
};
|
|
13541
|
+
}
|
|
13542
|
+
const beforeAutoVal = spAttrs.match(/\bw:beforeAutospacing="([^"]+)"/)?.[1];
|
|
13543
|
+
if (beforeAutoVal !== void 0) {
|
|
13544
|
+
const autoOn = /^(?:1|true|on)$/i.test(beforeAutoVal);
|
|
13545
|
+
pStyle.beforeAutoSpacing = autoOn ? import_core7.BooleanNumber.TRUE : import_core7.BooleanNumber.FALSE;
|
|
13546
|
+
}
|
|
13547
|
+
const afterVal = spAttrs.match(/\bw:after="(-?\d+)"/)?.[1];
|
|
13548
|
+
if (afterVal !== void 0) {
|
|
13549
|
+
pStyle.spaceBelow = {
|
|
13550
|
+
v: dxaToPt(Math.max(0, Number(afterVal))),
|
|
13551
|
+
u: import_core7.NumberUnitType.POINT
|
|
13552
|
+
};
|
|
13553
|
+
}
|
|
13554
|
+
const afterAutoVal = spAttrs.match(/\bw:afterAutospacing="([^"]+)"/)?.[1];
|
|
13555
|
+
if (afterAutoVal !== void 0) {
|
|
13556
|
+
const autoOn = /^(?:1|true|on)$/i.test(afterAutoVal);
|
|
13557
|
+
pStyle.afterAutoSpacing = autoOn ? import_core7.BooleanNumber.TRUE : import_core7.BooleanNumber.FALSE;
|
|
13558
|
+
}
|
|
13559
|
+
const lineVal = spAttrs.match(/\bw:line="(-?\d+)"/)?.[1];
|
|
13560
|
+
if (lineVal !== void 0) {
|
|
13561
|
+
const rawLine = Number(lineVal);
|
|
13562
|
+
const rawRule = (spAttrs.match(/\bw:lineRule="([^"]+)"/)?.[1] || "").toLowerCase();
|
|
13563
|
+
if (rawRule === "exact" || rawLine < 0) {
|
|
13564
|
+
pStyle.lineSpacing = dxaToPt(Math.abs(rawLine));
|
|
13565
|
+
pStyle.spacingRule = import_core7.SpacingRule.EXACT;
|
|
13566
|
+
} else if (rawRule === "atleast") {
|
|
13567
|
+
pStyle.lineSpacing = dxaToPt(Math.abs(rawLine));
|
|
13568
|
+
pStyle.spacingRule = import_core7.SpacingRule.AT_LEAST;
|
|
13569
|
+
} else if (rawLine > 0) {
|
|
13570
|
+
pStyle.lineSpacing = Math.round(rawLine / 240 * 1e4) / 1e4;
|
|
13571
|
+
pStyle.spacingRule = import_core7.SpacingRule.AUTO;
|
|
13572
|
+
}
|
|
13573
|
+
}
|
|
13574
|
+
}
|
|
13575
|
+
const ctxSpMatch = pPrXml.match(/<w:contextualSpacing\b([^>]*)\/?>/);
|
|
13576
|
+
if (ctxSpMatch) {
|
|
13577
|
+
const off = /\bw:val="(?:0|false|off)"/i.test(ctxSpMatch[1] || "");
|
|
13578
|
+
pStyle.contextualSpacing = off ? import_core7.BooleanNumber.FALSE : import_core7.BooleanNumber.TRUE;
|
|
13579
|
+
}
|
|
13580
|
+
const snapMatch = pPrXml.match(/<w:snapToGrid\b([^>]*)\/?>/);
|
|
13581
|
+
if (snapMatch) {
|
|
13582
|
+
const off = /\bw:val="(?:0|false|off)"/i.test(snapMatch[1] || "");
|
|
13583
|
+
pStyle.snapToGrid = off ? import_core7.BooleanNumber.FALSE : import_core7.BooleanNumber.TRUE;
|
|
13584
|
+
}
|
|
13585
|
+
if (includeIndentation) {
|
|
13586
|
+
const indMatch = pPrXml.match(/<w:ind\b([^>]*)\/?>/);
|
|
13587
|
+
if (indMatch) {
|
|
13588
|
+
const indAttrs = indMatch[1] || "";
|
|
13589
|
+
const leftRaw = indAttrs.match(/\bw:left="(-?\d+)"/)?.[1] ?? indAttrs.match(/\bw:start="(-?\d+)"/)?.[1];
|
|
13590
|
+
const rightRaw = indAttrs.match(/\bw:right="(-?\d+)"/)?.[1] ?? indAttrs.match(/\bw:end="(-?\d+)"/)?.[1];
|
|
13591
|
+
const hangingRaw = indAttrs.match(/\bw:hanging="(\d+)"/)?.[1];
|
|
13592
|
+
const firstCharsRaw = indAttrs.match(/\bw:firstLineChars="(\d+)"/)?.[1];
|
|
13593
|
+
const firstLineRaw = indAttrs.match(/\bw:firstLine="(\d+)"/)?.[1];
|
|
13594
|
+
if (leftRaw !== void 0) {
|
|
13595
|
+
pStyle.indentStart = {
|
|
13596
|
+
v: dxaToPt(Math.max(0, Number(leftRaw))),
|
|
13597
|
+
u: import_core7.NumberUnitType.POINT
|
|
13598
|
+
};
|
|
13599
|
+
}
|
|
13600
|
+
if (rightRaw !== void 0) {
|
|
13601
|
+
pStyle.indentEnd = {
|
|
13602
|
+
v: dxaToPt(Math.max(0, Number(rightRaw))),
|
|
13603
|
+
u: import_core7.NumberUnitType.POINT
|
|
13604
|
+
};
|
|
13605
|
+
}
|
|
13606
|
+
if (hangingRaw !== void 0 && Number(hangingRaw) > 0) {
|
|
13607
|
+
pStyle.hanging = {
|
|
13608
|
+
v: dxaToPt(Number(hangingRaw)),
|
|
13609
|
+
u: import_core7.NumberUnitType.POINT
|
|
13610
|
+
};
|
|
13611
|
+
} else if (firstCharsRaw !== void 0 && Number(firstCharsRaw) > 0) {
|
|
13612
|
+
pStyle.indentFirstLine = {
|
|
13613
|
+
v: Math.round(Number(firstCharsRaw) / 100 * 100) / 100,
|
|
13614
|
+
u: import_core7.NumberUnitType.CHARACTER
|
|
13615
|
+
};
|
|
13616
|
+
} else if (firstLineRaw !== void 0) {
|
|
13617
|
+
pStyle.indentFirstLine = {
|
|
13618
|
+
v: dxaToPt(Number(firstLineRaw)),
|
|
13619
|
+
u: import_core7.NumberUnitType.POINT
|
|
13620
|
+
};
|
|
13621
|
+
}
|
|
13622
|
+
}
|
|
13623
|
+
}
|
|
13624
|
+
}
|
|
13625
|
+
function parseStyleParagraphPropsFromPrXml(pPrXml) {
|
|
13626
|
+
if (!pPrXml) return void 0;
|
|
13627
|
+
const pStyle = {};
|
|
13628
|
+
const jcMatch = pPrXml.match(/<w:jc\s[^>]*w:val="([^"]+)"/);
|
|
13629
|
+
if (jcMatch) {
|
|
13630
|
+
if (jcMatch[1] === "center") pStyle.horizontalAlign = 2;
|
|
13631
|
+
else if (jcMatch[1] === "right") pStyle.horizontalAlign = 3;
|
|
13632
|
+
else if (jcMatch[1] === "both" || jcMatch[1] === "distribute") pStyle.horizontalAlign = 4;
|
|
13633
|
+
}
|
|
13634
|
+
const outLvl = pPrXml.match(/<w:outlineLvl\s[^>]*w:val="([0-5])"/)?.[1];
|
|
13635
|
+
if (outLvl !== void 0) {
|
|
13636
|
+
pStyle.namedStyleType = Number(outLvl) + 1;
|
|
13637
|
+
}
|
|
13638
|
+
if (/<w:keepLines(?:\s|\/|>)/.test(pPrXml) && !/<w:keepLines\s[^>]*w:val="(?:0|false)"/.test(pPrXml)) {
|
|
13639
|
+
pStyle.keepLines = 1;
|
|
13640
|
+
}
|
|
13641
|
+
if (/<w:keepNext(?:\s|\/|>)/.test(pPrXml) && !/<w:keepNext\s[^>]*w:val="(?:0|false)"/.test(pPrXml)) {
|
|
13642
|
+
pStyle.keepNext = 1;
|
|
13643
|
+
}
|
|
13644
|
+
if (/<w:pageBreakBefore(?:\s|\/|>)/.test(pPrXml) && !/<w:pageBreakBefore\s[^>]*w:val="(?:0|false)"/.test(pPrXml)) {
|
|
13645
|
+
pStyle.pageBreakBefore = 1;
|
|
13646
|
+
}
|
|
13647
|
+
if (/<w:widowControl(?:\s|\/|>)/.test(pPrXml)) {
|
|
13648
|
+
const wcOff = /<w:widowControl\s[^>]*w:val="(?:0|false)"/.test(pPrXml);
|
|
13649
|
+
pStyle.widowControl = wcOff ? 0 : 1;
|
|
13650
|
+
}
|
|
13651
|
+
applyParagraphSpacingAndIndentFromPrXml(pPrXml, pStyle, true);
|
|
13652
|
+
return Object.keys(pStyle).length > 0 ? pStyle : void 0;
|
|
13653
|
+
}
|
|
13654
|
+
function parseStylesXmlIntoDoc(stylesXml, themeFonts, docData) {
|
|
13655
|
+
const docDefaultsXml = stylesXml.match(/<w:docDefaults[\s>][\s\S]*?<\/w:docDefaults>/)?.[0] || "";
|
|
13656
|
+
const rPrDefXml = docDefaultsXml.match(/<w:rPrDefault[\s>][\s\S]*?<\/w:rPrDefault>/)?.[0] || "";
|
|
13657
|
+
const pPrDefXml = docDefaultsXml.match(/<w:pPrDefault[\s>][\s\S]*?<\/w:pPrDefault>/)?.[0] || "";
|
|
13658
|
+
const docDefaultTextStyle = rPrDefXml ? parseRunStyleFromXml(rPrDefXml, themeFonts) : void 0;
|
|
13659
|
+
const docDefaultParaPPr = pPrDefXml.match(/<w:pPr[\s>][\s\S]*?<\/w:pPr>/)?.[0] || "";
|
|
13660
|
+
const docDefaultParaStyle = parseStyleParagraphPropsFromPrXml(docDefaultParaPPr);
|
|
13661
|
+
const rawStyles = /* @__PURE__ */ new Map();
|
|
13662
|
+
let defaultParaStyleId;
|
|
13663
|
+
for (const sm of stylesXml.matchAll(/<w:style\b([^>]*)>([\s\S]*?)<\/w:style>/g)) {
|
|
13664
|
+
const attrs = sm[1] || "";
|
|
13665
|
+
const inner = sm[2] || "";
|
|
13666
|
+
const styleId = unescapeXml(attrs.match(/\bw:styleId="([^"]+)"/)?.[1] || "");
|
|
13667
|
+
if (!styleId) continue;
|
|
13668
|
+
const wType = (attrs.match(/\bw:type="([^"]+)"/)?.[1] || "paragraph").toLowerCase();
|
|
13669
|
+
const type = wType === "character" ? import_core7.DocStyleType.character : wType === "table" ? import_core7.DocStyleType.table : wType === "numbering" ? import_core7.DocStyleType.numbering : import_core7.DocStyleType.paragraph;
|
|
13670
|
+
const isDefault = /\bw:default="(?:1|true|on)"/i.test(attrs);
|
|
13671
|
+
const customStyle = /\bw:customStyle="(?:1|true|on)"/i.test(attrs);
|
|
13672
|
+
const name = unescapeXml(inner.match(/<w:name\b[^>]*\bw:val="([^"]+)"/)?.[1] || styleId);
|
|
13673
|
+
const basedOnRaw = inner.match(/<w:basedOn\b[^>]*\bw:val="([^"]+)"/)?.[1];
|
|
13674
|
+
const basedOn = basedOnRaw ? unescapeXml(basedOnRaw) : void 0;
|
|
13675
|
+
const linkRaw = inner.match(/<w:link\b[^>]*\bw:val="([^"]+)"/)?.[1];
|
|
13676
|
+
const link = linkRaw ? unescapeXml(linkRaw) : void 0;
|
|
13677
|
+
const strippedTblStylePr = inner.replace(/<w:tblStylePr[\s>][\s\S]*?<\/w:tblStylePr>/g, "");
|
|
13678
|
+
const stylePPrXml = strippedTblStylePr.match(/<w:pPr[\s>][\s\S]*?<\/w:pPr>/)?.[0] || "";
|
|
13679
|
+
const withoutPPr = stylePPrXml ? strippedTblStylePr.replace(stylePPrXml, "") : strippedTblStylePr;
|
|
13680
|
+
const styleRPrXml = withoutPPr.match(/<w:rPr[\s>][\s\S]*?<\/w:rPr>/)?.[0] || "";
|
|
13681
|
+
const paragraphStyle = parseStyleParagraphPropsFromPrXml(stylePPrXml);
|
|
13682
|
+
const textStyle = styleRPrXml ? parseRunStyleFromXml(styleRPrXml, themeFonts) : void 0;
|
|
13683
|
+
if (wType === "paragraph" && isDefault && !defaultParaStyleId) {
|
|
13684
|
+
defaultParaStyleId = styleId;
|
|
13685
|
+
}
|
|
13686
|
+
rawStyles.set(styleId, {
|
|
13687
|
+
styleId,
|
|
13688
|
+
name,
|
|
13689
|
+
type,
|
|
13690
|
+
wType,
|
|
13691
|
+
isDefault,
|
|
13692
|
+
...customStyle ? { customStyle: true } : {},
|
|
13693
|
+
...basedOn ? { basedOn } : {},
|
|
13694
|
+
...link ? { link } : {},
|
|
13695
|
+
...paragraphStyle ? { paragraphStyle } : {},
|
|
13696
|
+
...textStyle ? { textStyle } : {}
|
|
13697
|
+
});
|
|
13698
|
+
}
|
|
13699
|
+
if (!defaultParaStyleId) {
|
|
13700
|
+
if (rawStyles.has("Normal")) {
|
|
13701
|
+
defaultParaStyleId = "Normal";
|
|
13702
|
+
} else {
|
|
13703
|
+
for (const [sId, st] of rawStyles.entries()) {
|
|
13704
|
+
if (st.wType === "paragraph" && st.name.toLowerCase() === "normal") {
|
|
13705
|
+
defaultParaStyleId = sId;
|
|
13706
|
+
break;
|
|
13707
|
+
}
|
|
13708
|
+
}
|
|
13709
|
+
}
|
|
13710
|
+
}
|
|
13711
|
+
const resolvedCache = /* @__PURE__ */ new Map();
|
|
13712
|
+
const resolveStyleChain = (sId, visited = /* @__PURE__ */ new Set()) => {
|
|
13713
|
+
if (resolvedCache.has(sId)) return resolvedCache.get(sId);
|
|
13714
|
+
const item = rawStyles.get(sId);
|
|
13715
|
+
if (!item || visited.has(sId)) return {};
|
|
13716
|
+
visited.add(sId);
|
|
13717
|
+
const parent = item.basedOn && item.basedOn !== sId ? resolveStyleChain(item.basedOn, visited) : {};
|
|
13718
|
+
const mergedP = parent.paragraphStyle || item.paragraphStyle ? { ...parent.paragraphStyle ?? {}, ...item.paragraphStyle ?? {} } : void 0;
|
|
13719
|
+
const mergedT = mergeDocTextStyles(parent.textStyle, item.textStyle);
|
|
13720
|
+
const out = {
|
|
13721
|
+
...mergedP ? { paragraphStyle: mergedP } : {},
|
|
13722
|
+
...mergedT ? { textStyle: mergedT } : {}
|
|
13723
|
+
};
|
|
13724
|
+
resolvedCache.set(sId, out);
|
|
13725
|
+
return out;
|
|
13726
|
+
};
|
|
13727
|
+
const docStylesOut = {};
|
|
13728
|
+
for (const [sId, item] of rawStyles.entries()) {
|
|
13729
|
+
if (item.wType === "table" && !item.paragraphStyle && !item.textStyle) continue;
|
|
13730
|
+
const resolved = resolveStyleChain(sId);
|
|
13731
|
+
docStylesOut[sId] = {
|
|
13732
|
+
name: item.name,
|
|
13733
|
+
type: item.type,
|
|
13734
|
+
...item.customStyle ? { customStyle: true } : {},
|
|
13735
|
+
...item.basedOn ? { basedOn: item.basedOn } : {},
|
|
13736
|
+
...item.link ? { link: item.link } : {},
|
|
13737
|
+
...resolved.paragraphStyle ? { paragraphStyle: resolved.paragraphStyle } : {},
|
|
13738
|
+
...resolved.textStyle ? { textStyle: resolved.textStyle } : {}
|
|
13739
|
+
};
|
|
13740
|
+
}
|
|
13741
|
+
if (Object.keys(docStylesOut).length > 0) {
|
|
13742
|
+
docData.styles = docStylesOut;
|
|
13743
|
+
}
|
|
13744
|
+
const normalResolved = defaultParaStyleId ? resolveStyleChain(defaultParaStyleId) : {};
|
|
13745
|
+
const effectiveDocTextStyle = mergeDocTextStyles(docDefaultTextStyle, normalResolved.textStyle);
|
|
13746
|
+
if (effectiveDocTextStyle && docData.documentStyle) {
|
|
13747
|
+
docData.documentStyle.textStyle = effectiveDocTextStyle;
|
|
13748
|
+
}
|
|
13749
|
+
const effectiveDocParaStyle = docDefaultParaStyle || normalResolved.paragraphStyle ? { ...docDefaultParaStyle ?? {}, ...normalResolved.paragraphStyle ?? {} } : void 0;
|
|
13750
|
+
if (effectiveDocParaStyle && Object.keys(effectiveDocParaStyle).length > 0 && docData.documentStyle) {
|
|
13751
|
+
docData.documentStyle.defaultParagraphStyle = effectiveDocParaStyle;
|
|
13752
|
+
}
|
|
13753
|
+
if (defaultParaStyleId && docData.documentStyle) {
|
|
13754
|
+
docData.documentStyle.defaultParagraphStyleId = defaultParaStyleId;
|
|
13755
|
+
}
|
|
13756
|
+
}
|
|
13006
13757
|
function parseParagraphXmlToBuilder(pXml, relsMap, entries, collectedDrawings, inlineBlocksQueue, warningsCounter, numCtx) {
|
|
13007
13758
|
const docUnitId = numCtx?.docUnitId || "doc-imported";
|
|
13759
|
+
const themeFonts = numCtx?.themeFonts;
|
|
13008
13760
|
const pStyle = {};
|
|
13009
13761
|
let parsedBullet;
|
|
13010
13762
|
const pPrXml = pXml.match(/<w:pPr[\s>][\s\S]*?<\/w:pPr>/)?.[0] || "";
|
|
@@ -13013,9 +13765,10 @@ function parseParagraphXmlToBuilder(pXml, relsMap, entries, collectedDrawings, i
|
|
|
13013
13765
|
if (jcMatch) {
|
|
13014
13766
|
if (jcMatch[1] === "center") pStyle.horizontalAlign = 2;
|
|
13015
13767
|
else if (jcMatch[1] === "right") pStyle.horizontalAlign = 3;
|
|
13016
|
-
else if (jcMatch[1] === "both") pStyle.horizontalAlign = 4;
|
|
13768
|
+
else if (jcMatch[1] === "both" || jcMatch[1] === "distribute") pStyle.horizontalAlign = 4;
|
|
13017
13769
|
}
|
|
13018
|
-
const
|
|
13770
|
+
const rawPStyleVal = pPrXml.match(/<w:pStyle\s[^>]*w:val="([^"]+)"/)?.[1] || "";
|
|
13771
|
+
const pStyleVal = rawPStyleVal ? unescapeXml(rawPStyleVal) : "";
|
|
13019
13772
|
const hMatch = pStyleVal.match(/^(?:Heading|heading\s*)([1-6])$/i);
|
|
13020
13773
|
if (hMatch) {
|
|
13021
13774
|
pStyle.namedStyleType = Number(hMatch[1]);
|
|
@@ -13067,6 +13820,7 @@ function parseParagraphXmlToBuilder(pXml, relsMap, entries, collectedDrawings, i
|
|
|
13067
13820
|
if (Object.keys(parsedPag).length > 0) {
|
|
13068
13821
|
pStyle.yudaoPagination = parsedPag;
|
|
13069
13822
|
}
|
|
13823
|
+
applyParagraphSpacingAndIndentFromPrXml(pPrXml, pStyle, false);
|
|
13070
13824
|
const tabsXml = pPrXml.match(/<w:tabs[\s>][\s\S]*?<\/w:tabs>/)?.[0] || "";
|
|
13071
13825
|
if (tabsXml) {
|
|
13072
13826
|
const parsedTabs = [];
|
|
@@ -13113,7 +13867,131 @@ function parseParagraphXmlToBuilder(pXml, relsMap, entries, collectedDrawings, i
|
|
|
13113
13867
|
const parseInlineSegments = (srcXml) => {
|
|
13114
13868
|
const outSegs = [];
|
|
13115
13869
|
const chunks = tokenizeParagraphInlineChunks(srcXml);
|
|
13870
|
+
let fieldDepth = 0;
|
|
13871
|
+
let fldInstrParts = [];
|
|
13872
|
+
let fldResultParts = [];
|
|
13873
|
+
let fldBeginStyle;
|
|
13874
|
+
let fldResultStyle;
|
|
13875
|
+
let fldHasSeparate = false;
|
|
13876
|
+
const finalizeComplexField = () => {
|
|
13877
|
+
const instrRaw = fldInstrParts.join("").trim();
|
|
13878
|
+
const resultText = fldResultParts.join("");
|
|
13879
|
+
const effStyle = fldResultStyle ?? fldBeginStyle;
|
|
13880
|
+
if (!instrRaw) {
|
|
13881
|
+
if (resultText) {
|
|
13882
|
+
outSegs.push(effStyle ? { text: resultText, style: effStyle } : resultText);
|
|
13883
|
+
}
|
|
13884
|
+
return;
|
|
13885
|
+
}
|
|
13886
|
+
const upperFirstTok = (instrRaw.split(/\s+/)[0] || "").toUpperCase();
|
|
13887
|
+
const isDynamicPageField = upperFirstTok === "PAGE" || upperFirstTok === "NUMPAGES" || upperFirstTok === "SECTIONPAGES";
|
|
13888
|
+
const supportedStaticComplex = /* @__PURE__ */ new Set([
|
|
13889
|
+
"DATE",
|
|
13890
|
+
"TIME",
|
|
13891
|
+
"AUTHOR",
|
|
13892
|
+
"FILENAME",
|
|
13893
|
+
"TITLE",
|
|
13894
|
+
"COMPANY",
|
|
13895
|
+
"DOCPROPERTY"
|
|
13896
|
+
]);
|
|
13897
|
+
const isPassthroughComplex = upperFirstTok === "TOC" || upperFirstTok === "HYPERLINK";
|
|
13898
|
+
if (isDynamicPageField || !supportedStaticComplex.has(upperFirstTok) && !isPassthroughComplex) {
|
|
13899
|
+
warningsCounter.dynamicFields = (warningsCounter.dynamicFields ?? 0) + 1;
|
|
13900
|
+
}
|
|
13901
|
+
if (isPassthroughComplex) {
|
|
13902
|
+
if (resultText) {
|
|
13903
|
+
outSegs.push(effStyle ? { text: resultText, style: effStyle } : resultText);
|
|
13904
|
+
}
|
|
13905
|
+
return;
|
|
13906
|
+
}
|
|
13907
|
+
const parsedInstr = parseFieldInstrString(instrRaw);
|
|
13908
|
+
const fallbackVal = resultText || (isDynamicPageField ? "1" : `{${upperFirstTok}}`);
|
|
13909
|
+
outSegs.push({
|
|
13910
|
+
docField: {
|
|
13911
|
+
fieldType: parsedInstr.fieldType,
|
|
13912
|
+
instructionArgs: parsedInstr.instructionArgs,
|
|
13913
|
+
instrText: instrRaw,
|
|
13914
|
+
value: fallbackVal,
|
|
13915
|
+
sourceKind: "complex",
|
|
13916
|
+
preserveStyle: true,
|
|
13917
|
+
...effStyle ? { style: effStyle } : {}
|
|
13918
|
+
}
|
|
13919
|
+
});
|
|
13920
|
+
};
|
|
13116
13921
|
for (const chunk of chunks) {
|
|
13922
|
+
if (chunk.startsWith("<w:r") && (fieldDepth > 0 || /<w:fldChar\b/.test(chunk))) {
|
|
13923
|
+
const runStyle = parseRunStyleFromXml(chunk, themeFonts);
|
|
13924
|
+
const tokenRe = /<w:fldChar\b([^>]*)\/?>|<w:instrText(?=[\s>])[^>]*>([\s\S]*?)<\/w:instrText>|<w:t(?=[\s>])[^>]*>([\s\S]*?)<\/w:t>|<w:tab(?:\s|\/|>)|<w:br\s[^>]*w:type="page"/g;
|
|
13925
|
+
let tm;
|
|
13926
|
+
while ((tm = tokenRe.exec(chunk)) !== null) {
|
|
13927
|
+
const fullTok = tm[0];
|
|
13928
|
+
if (fullTok.startsWith("<w:fldChar")) {
|
|
13929
|
+
const fcType = (tm[1]?.match(/\bw:fldCharType="([^"]+)"/)?.[1] || "").toLowerCase();
|
|
13930
|
+
if (fcType === "begin") {
|
|
13931
|
+
fieldDepth++;
|
|
13932
|
+
if (fieldDepth === 1) {
|
|
13933
|
+
fldInstrParts = [];
|
|
13934
|
+
fldResultParts = [];
|
|
13935
|
+
fldBeginStyle = runStyle;
|
|
13936
|
+
fldResultStyle = void 0;
|
|
13937
|
+
fldHasSeparate = false;
|
|
13938
|
+
}
|
|
13939
|
+
} else if (fcType === "separate") {
|
|
13940
|
+
if (fieldDepth === 1) {
|
|
13941
|
+
fldHasSeparate = true;
|
|
13942
|
+
}
|
|
13943
|
+
} else if (fcType === "end") {
|
|
13944
|
+
if (fieldDepth > 0) {
|
|
13945
|
+
fieldDepth--;
|
|
13946
|
+
if (fieldDepth === 0) {
|
|
13947
|
+
finalizeComplexField();
|
|
13948
|
+
}
|
|
13949
|
+
}
|
|
13950
|
+
}
|
|
13951
|
+
} else if (fullTok.startsWith("<w:instrText")) {
|
|
13952
|
+
if (fieldDepth === 1 && !fldHasSeparate) {
|
|
13953
|
+
fldInstrParts.push(unescapeXml(tm[2] || ""));
|
|
13954
|
+
}
|
|
13955
|
+
} else if (fullTok.startsWith("<w:t")) {
|
|
13956
|
+
const txt = unescapeXml(tm[3] || "");
|
|
13957
|
+
if (fieldDepth > 0) {
|
|
13958
|
+
if (fldHasSeparate) {
|
|
13959
|
+
const isTocInstr = fldInstrParts.join("").trim().toUpperCase().startsWith("TOC");
|
|
13960
|
+
if (isTocInstr) {
|
|
13961
|
+
if (txt) outSegs.push(runStyle ? { text: txt, style: runStyle } : txt);
|
|
13962
|
+
} else if (txt) {
|
|
13963
|
+
fldResultParts.push(txt);
|
|
13964
|
+
if (!fldResultStyle && runStyle) {
|
|
13965
|
+
fldResultStyle = runStyle;
|
|
13966
|
+
}
|
|
13967
|
+
}
|
|
13968
|
+
}
|
|
13969
|
+
} else if (txt) {
|
|
13970
|
+
outSegs.push(runStyle ? { text: txt, style: runStyle } : txt);
|
|
13971
|
+
}
|
|
13972
|
+
} else if (fullTok.startsWith("<w:tab")) {
|
|
13973
|
+
if (fieldDepth === 0 || fldHasSeparate && fldInstrParts.join("").trim().toUpperCase().startsWith("TOC")) {
|
|
13974
|
+
outSegs.push({ tab: true });
|
|
13975
|
+
}
|
|
13976
|
+
} else if (fullTok.startsWith("<w:br")) {
|
|
13977
|
+
if (fieldDepth === 0) {
|
|
13978
|
+
outSegs.push({ pageBreak: true });
|
|
13979
|
+
}
|
|
13980
|
+
}
|
|
13981
|
+
}
|
|
13982
|
+
continue;
|
|
13983
|
+
}
|
|
13984
|
+
if (fieldDepth > 0 && !fldInstrParts.join("").trim().toUpperCase().startsWith("TOC")) {
|
|
13985
|
+
if (fldHasSeparate) {
|
|
13986
|
+
const innerTexts = Array.from(
|
|
13987
|
+
chunk.matchAll(/<w:t(?=[\s>])[^>]*>([\s\S]*?)<\/w:t>/g)
|
|
13988
|
+
).map((m) => unescapeXml(m[1]));
|
|
13989
|
+
if (innerTexts.length > 0) {
|
|
13990
|
+
fldResultParts.push(innerTexts.join(""));
|
|
13991
|
+
}
|
|
13992
|
+
}
|
|
13993
|
+
continue;
|
|
13994
|
+
}
|
|
13117
13995
|
if (chunk.startsWith("<w:bookmarkStart")) {
|
|
13118
13996
|
const bmId = chunk.match(/w:id="([^"]*)"/)?.[1] || "";
|
|
13119
13997
|
const bmName = unescapeXml(chunk.match(/w:name="([^"]*)"/)?.[1] || "");
|
|
@@ -13193,16 +14071,24 @@ function parseParagraphXmlToBuilder(pXml, relsMap, entries, collectedDrawings, i
|
|
|
13193
14071
|
}
|
|
13194
14072
|
if (chunk.startsWith("<w:fldSimple")) {
|
|
13195
14073
|
const instrRaw = unescapeXml(chunk.match(/w:instr="([^"]*)"/)?.[1] || "PAGE").trim();
|
|
14074
|
+
const upperFirst = (instrRaw.split(/\s+/)[0] || "").toUpperCase();
|
|
14075
|
+
if (upperFirst === "PAGE" || upperFirst === "NUMPAGES" || upperFirst === "SECTIONPAGES") {
|
|
14076
|
+
warningsCounter.dynamicFields = (warningsCounter.dynamicFields ?? 0) + 1;
|
|
14077
|
+
}
|
|
13196
14078
|
const parsedInstr = parseFieldInstrString(instrRaw);
|
|
13197
14079
|
const fldTexts = Array.from(chunk.matchAll(/<w:t(?=[\s>])[^>]*>([\s\S]*?)<\/w:t>/g)).map(
|
|
13198
14080
|
(m) => unescapeXml(m[1])
|
|
13199
14081
|
);
|
|
14082
|
+
const firstFldRun = chunk.match(/<w:r[\s>][\s\S]*?<\/w:r>/)?.[0];
|
|
14083
|
+
const fldStyle = firstFldRun ? parseRunStyleFromXml(firstFldRun, themeFonts) : void 0;
|
|
13200
14084
|
outSegs.push({
|
|
13201
14085
|
docField: {
|
|
13202
14086
|
fieldType: parsedInstr.fieldType,
|
|
13203
14087
|
instructionArgs: parsedInstr.instructionArgs,
|
|
13204
14088
|
instrText: instrRaw,
|
|
13205
|
-
value: fldTexts.join("") || "1"
|
|
14089
|
+
value: fldTexts.join("") || "1",
|
|
14090
|
+
sourceKind: "simple",
|
|
14091
|
+
...fldStyle ? { preserveStyle: true, style: fldStyle } : {}
|
|
13206
14092
|
}
|
|
13207
14093
|
});
|
|
13208
14094
|
continue;
|
|
@@ -13212,7 +14098,7 @@ function parseParagraphXmlToBuilder(pXml, relsMap, entries, collectedDrawings, i
|
|
|
13212
14098
|
const cStartMatch = chunk.match(/<w:sdtContent(?=[\s>])[^>]*>/);
|
|
13213
14099
|
const cEndIdx = chunk.lastIndexOf("</w:sdtContent>");
|
|
13214
14100
|
const sdtContentXml = cStartMatch && cEndIdx > (cStartMatch.index ?? 0) ? chunk.slice((cStartMatch.index ?? 0) + cStartMatch[0].length, cEndIdx) : "";
|
|
13215
|
-
const sdtPrStyle = parseRunStyleFromXml(sdtPrXml);
|
|
14101
|
+
const sdtPrStyle = parseRunStyleFromXml(sdtPrXml, themeFonts);
|
|
13216
14102
|
const aliasMatch = sdtPrXml.match(/<w:alias[^>]*w:val="([^"]*)"/);
|
|
13217
14103
|
const tagMatch = sdtPrXml.match(/<w:tag[^>]*w:val="([^"]*)"/);
|
|
13218
14104
|
const lockMatch = sdtPrXml.match(/<w:lock[^>]*w:val="([^"]*)"/);
|
|
@@ -13399,10 +14285,14 @@ function parseParagraphXmlToBuilder(pXml, relsMap, entries, collectedDrawings, i
|
|
|
13399
14285
|
);
|
|
13400
14286
|
const plain = textMatches.join("");
|
|
13401
14287
|
if (plain) {
|
|
13402
|
-
const style = parseRunStyleFromXml(chunk);
|
|
14288
|
+
const style = parseRunStyleFromXml(chunk, themeFonts);
|
|
13403
14289
|
outSegs.push(style ? { text: plain, style } : plain);
|
|
13404
14290
|
}
|
|
13405
14291
|
}
|
|
14292
|
+
if (fieldDepth > 0) {
|
|
14293
|
+
fieldDepth = 0;
|
|
14294
|
+
finalizeComplexField();
|
|
14295
|
+
}
|
|
13406
14296
|
return outSegs;
|
|
13407
14297
|
};
|
|
13408
14298
|
const pBodyOnly = pPrXml ? pXml.replace(pPrXml, "") : pXml;
|
|
@@ -13444,6 +14334,9 @@ function parseParagraphXmlToBuilder(pXml, relsMap, entries, collectedDrawings, i
|
|
|
13444
14334
|
};
|
|
13445
14335
|
}
|
|
13446
14336
|
}
|
|
14337
|
+
if (!detectedQuote) {
|
|
14338
|
+
applyParagraphSpacingAndIndentFromPrXml(pPrXml, pStyle, true);
|
|
14339
|
+
}
|
|
13447
14340
|
if (!detectedCallout && !detectedQuote) {
|
|
13448
14341
|
const shdFillOnly = pPrXml.match(/<w:shd\b[^>]*w:fill="([0-9a-fA-F]{6})"/);
|
|
13449
14342
|
if (pBdrXml || shdFillOnly) {
|
|
@@ -13486,6 +14379,7 @@ function parseParagraphXmlToBuilder(pXml, relsMap, entries, collectedDrawings, i
|
|
|
13486
14379
|
return {
|
|
13487
14380
|
kind: "paragraph",
|
|
13488
14381
|
segments: segments.length > 0 ? segments : [""],
|
|
14382
|
+
...pStyleVal ? { styleId: pStyleVal } : {},
|
|
13489
14383
|
...Object.keys(pStyle).length > 0 ? { paragraphStyle: pStyle } : {},
|
|
13490
14384
|
...parsedBullet ? { bullet: parsedBullet } : {},
|
|
13491
14385
|
...detectedCallout ? { callout: detectedCallout } : {},
|
|
@@ -13541,7 +14435,53 @@ function tokenizeBodyTopLevelBlocks(bodyXml) {
|
|
|
13541
14435
|
}
|
|
13542
14436
|
return blocks;
|
|
13543
14437
|
}
|
|
13544
|
-
function
|
|
14438
|
+
function tokenizeNestedTagBlocks(xml, tagName) {
|
|
14439
|
+
const out = [];
|
|
14440
|
+
const tagRe = new RegExp(`<\\/?w:${tagName}(?=[\\s/>])[^>]*>`, "g");
|
|
14441
|
+
let depth = 0;
|
|
14442
|
+
let startIdx = -1;
|
|
14443
|
+
let m;
|
|
14444
|
+
while ((m = tagRe.exec(xml)) !== null) {
|
|
14445
|
+
const full = m[0];
|
|
14446
|
+
const isClose = full.startsWith("</");
|
|
14447
|
+
const isSelfClose = full.endsWith("/>");
|
|
14448
|
+
if (depth === 0) {
|
|
14449
|
+
if (!isClose) {
|
|
14450
|
+
if (isSelfClose) {
|
|
14451
|
+
out.push(full);
|
|
14452
|
+
} else {
|
|
14453
|
+
depth = 1;
|
|
14454
|
+
startIdx = m.index;
|
|
14455
|
+
}
|
|
14456
|
+
}
|
|
14457
|
+
continue;
|
|
14458
|
+
}
|
|
14459
|
+
if (isSelfClose) continue;
|
|
14460
|
+
depth += isClose ? -1 : 1;
|
|
14461
|
+
if (depth === 0 && startIdx >= 0) {
|
|
14462
|
+
out.push(xml.slice(startIdx, m.index + full.length));
|
|
14463
|
+
startIdx = -1;
|
|
14464
|
+
}
|
|
14465
|
+
}
|
|
14466
|
+
return out;
|
|
14467
|
+
}
|
|
14468
|
+
function unwrapCellParagraphBlocks(xml) {
|
|
14469
|
+
const out = [];
|
|
14470
|
+
for (const blk of tokenizeBodyTopLevelBlocks(xml)) {
|
|
14471
|
+
if (blk.tag === "p") {
|
|
14472
|
+
out.push(blk.xml);
|
|
14473
|
+
} else if (blk.tag === "sdt") {
|
|
14474
|
+
const cStart = blk.xml.match(/<w:sdtContent(?=[\s>])[^>]*>/);
|
|
14475
|
+
const cEnd = blk.xml.lastIndexOf("</w:sdtContent>");
|
|
14476
|
+
const inner = cStart && cEnd > (cStart.index ?? 0) ? blk.xml.slice((cStart.index ?? 0) + cStart[0].length, cEnd) : "";
|
|
14477
|
+
if (inner) {
|
|
14478
|
+
out.push(...unwrapCellParagraphBlocks(inner));
|
|
14479
|
+
}
|
|
14480
|
+
}
|
|
14481
|
+
}
|
|
14482
|
+
return out;
|
|
14483
|
+
}
|
|
14484
|
+
function scanUnsupportedDocxFeatures(xml, floatingImages, dynamicFields = 0) {
|
|
13545
14485
|
const warnings = [];
|
|
13546
14486
|
const check = (re, code, label) => {
|
|
13547
14487
|
const matches = xml.match(re);
|
|
@@ -13572,6 +14512,13 @@ function scanUnsupportedDocxFeatures(xml, floatingImages) {
|
|
|
13572
14512
|
message: `${floatingImages} \u5F20\u6D6E\u52A8\u951A\u5B9A\u56FE\u7247\u5DF2\u81EA\u52A8\u964D\u7EA7\u4E3A\u884C\u5185\u5D4C\u5165\u56FE\u7247`
|
|
13573
14513
|
});
|
|
13574
14514
|
}
|
|
14515
|
+
if (dynamicFields > 0) {
|
|
14516
|
+
warnings.push({
|
|
14517
|
+
code: "UNSUPPORTED_FIELD",
|
|
14518
|
+
count: dynamicFields,
|
|
14519
|
+
message: "\u68C0\u6D4B\u5230\u52A8\u6001\u9875\u7801/\u6587\u6863\u57DF\uFF08\u5982 PAGE / NUMPAGES\uFF09\uFF0C\u6D4F\u89C8\u5668\u753B\u5E03\u9884\u89C8\u5C06\u663E\u793A\u7F13\u5B58\u9759\u6001\u6587\u672C\uFF0C\u5BFC\u51FA DOCX \u65F6\u4FDD\u7559\u52A8\u6001\u57DF\u6307\u4EE4"
|
|
14520
|
+
});
|
|
14521
|
+
}
|
|
13575
14522
|
return warnings;
|
|
13576
14523
|
}
|
|
13577
14524
|
async function parseDocxBytesWithReport(bytes, title = "Imported Word Document") {
|
|
@@ -13700,25 +14647,25 @@ async function parseDocxBytesWithReport(bytes, title = "Imported Word Document")
|
|
|
13700
14647
|
});
|
|
13701
14648
|
}
|
|
13702
14649
|
}
|
|
14650
|
+
const themeBytes = entries.get("word/theme/theme1.xml");
|
|
14651
|
+
const themeFonts = themeBytes ? parseThemeFontsFromXml(decoder.decode(themeBytes)) : void 0;
|
|
13703
14652
|
const numCtx = {
|
|
13704
14653
|
numIdToInfo,
|
|
13705
14654
|
docUnitId,
|
|
13706
14655
|
commentsMap,
|
|
13707
|
-
openedCommentIds: /* @__PURE__ */ new Set()
|
|
14656
|
+
openedCommentIds: /* @__PURE__ */ new Set(),
|
|
14657
|
+
themeFonts
|
|
13708
14658
|
};
|
|
13709
14659
|
const bodyInnerMatch = xml.match(/<w:body[\s>]([\s\S]*?)<\/w:body>/);
|
|
13710
14660
|
const bodyXml = bodyInnerMatch ? bodyInnerMatch[1] : xml;
|
|
13711
|
-
const rawBlocks = tokenizeBodyTopLevelBlocks(bodyXml);
|
|
13712
14661
|
const collectedDrawings = {};
|
|
13713
14662
|
const inlineBlocksQueue = [];
|
|
13714
|
-
const warningsCounter = { floatingImages: 0 };
|
|
13715
|
-
const builderBlocks = [];
|
|
14663
|
+
const warningsCounter = { floatingImages: 0, dynamicFields: 0 };
|
|
13716
14664
|
const xmlTableDirections = {};
|
|
13717
14665
|
const xmlTableBorderPresets = {};
|
|
13718
14666
|
const xmlTableCellProperties = {};
|
|
13719
14667
|
const xmlTableAutoFitWindow = /* @__PURE__ */ new Set();
|
|
13720
14668
|
let detectedTocSpan = null;
|
|
13721
|
-
let topLevelParaCounter = 0;
|
|
13722
14669
|
const parseTblBordersPreset = (tblPrXml) => {
|
|
13723
14670
|
const bXml = tblPrXml.match(/<w:tblBorders[\s>][\s\S]*?<\/w:tblBorders>/)?.[0];
|
|
13724
14671
|
if (!bXml) return void 0;
|
|
@@ -13737,231 +14684,441 @@ async function parseDocxBytesWithReport(bytes, title = "Imported Word Document")
|
|
|
13737
14684
|
if (!ext && inn) return "internal";
|
|
13738
14685
|
return "all";
|
|
13739
14686
|
};
|
|
13740
|
-
|
|
13741
|
-
|
|
13742
|
-
|
|
13743
|
-
|
|
13744
|
-
|
|
13745
|
-
|
|
13746
|
-
|
|
13747
|
-
|
|
13748
|
-
|
|
13749
|
-
|
|
13750
|
-
|
|
13751
|
-
|
|
13752
|
-
|
|
13753
|
-
|
|
13754
|
-
|
|
13755
|
-
|
|
13756
|
-
const
|
|
13757
|
-
|
|
13758
|
-
const
|
|
13759
|
-
const
|
|
13760
|
-
if (
|
|
13761
|
-
|
|
13762
|
-
|
|
13763
|
-
|
|
13764
|
-
|
|
13765
|
-
|
|
13766
|
-
|
|
13767
|
-
|
|
13768
|
-
|
|
14687
|
+
const parseTableXmlToBuilder = (tblXml, storyRelsMap, storyInlineQueue) => {
|
|
14688
|
+
const tableId = `tbl_${(0, import_core7.generateRandomId)(6)}`;
|
|
14689
|
+
const firstTrMatch = tblXml.match(/<w:tr(?=[\s>])/);
|
|
14690
|
+
const tblHeadXml = firstTrMatch && typeof firstTrMatch.index === "number" ? tblXml.slice(0, firstTrMatch.index) : tblXml;
|
|
14691
|
+
const tblPrXml = tblHeadXml.match(/<w:tblPr[\s>][\s\S]*?<\/w:tblPr>/)?.[0] || "";
|
|
14692
|
+
const tblGridXml = tblHeadXml.match(/<w:tblGrid[\s>][\s\S]*?<\/w:tblGrid>/)?.[0] || "";
|
|
14693
|
+
if (/<w:bidiVisual(?:\s|\/|>)/.test(tblPrXml) && !/<w:bidiVisual\s[^>]*w:val="(?:0|false)"/.test(tblPrXml)) {
|
|
14694
|
+
xmlTableDirections[tableId] = "rtl";
|
|
14695
|
+
}
|
|
14696
|
+
const detectedPreset = parseTblBordersPreset(tblPrXml);
|
|
14697
|
+
if (detectedPreset) {
|
|
14698
|
+
xmlTableBorderPresets[tableId] = detectedPreset;
|
|
14699
|
+
}
|
|
14700
|
+
const tblBordersBlockXml = tblPrXml.match(/<w:tblBorders[\s>][\s\S]*?<\/w:tblBorders>/)?.[0] || "";
|
|
14701
|
+
const parseOoxmlBorderTag = (containerXml, edgeTag) => {
|
|
14702
|
+
if (!containerXml) return void 0;
|
|
14703
|
+
const em = containerXml.match(new RegExp(`<w:${edgeTag}\\b([^>]*)\\/?>`));
|
|
14704
|
+
if (!em) return void 0;
|
|
14705
|
+
const eAttrs = em[1] || "";
|
|
14706
|
+
const rawVal = (eAttrs.match(/w:val="([^"]+)"/)?.[1] || "single").toLowerCase();
|
|
14707
|
+
if (rawVal === "none" || rawVal === "nil") {
|
|
14708
|
+
return { style: "none", widthPt: 0 };
|
|
14709
|
+
}
|
|
14710
|
+
const szEighths = Number(eAttrs.match(/w:sz="(\d+)"/)?.[1] ?? 4);
|
|
14711
|
+
const widthPt = Math.max(0.25, Math.round(szEighths / 8 * 100) / 100);
|
|
14712
|
+
const rawColor = (eAttrs.match(/w:color="([0-9a-fA-F]{6})"/)?.[1] || "CBD5E1").toUpperCase();
|
|
14713
|
+
const style = rawVal === "double" ? "double" : rawVal.includes("dash") ? "dashed" : rawVal.includes("dot") ? "dotted" : "single";
|
|
14714
|
+
return { style, widthPt, color: `#${rawColor}` };
|
|
14715
|
+
};
|
|
14716
|
+
const defaultGridEdge = {
|
|
14717
|
+
style: "single",
|
|
14718
|
+
widthPt: 0.5,
|
|
14719
|
+
color: "#CBD5E1"
|
|
14720
|
+
};
|
|
14721
|
+
const noneGridEdge = { style: "none", widthPt: 0 };
|
|
14722
|
+
const tblLevelBorders = tblBordersBlockXml ? {
|
|
14723
|
+
top: parseOoxmlBorderTag(tblBordersBlockXml, "top") ?? noneGridEdge,
|
|
14724
|
+
bottom: parseOoxmlBorderTag(tblBordersBlockXml, "bottom") ?? noneGridEdge,
|
|
14725
|
+
left: parseOoxmlBorderTag(tblBordersBlockXml, "left") ?? noneGridEdge,
|
|
14726
|
+
right: parseOoxmlBorderTag(tblBordersBlockXml, "right") ?? noneGridEdge,
|
|
14727
|
+
insideH: parseOoxmlBorderTag(tblBordersBlockXml, "insideH") ?? noneGridEdge,
|
|
14728
|
+
insideV: parseOoxmlBorderTag(tblBordersBlockXml, "insideV") ?? noneGridEdge
|
|
14729
|
+
} : {
|
|
14730
|
+
top: defaultGridEdge,
|
|
14731
|
+
bottom: defaultGridEdge,
|
|
14732
|
+
left: defaultGridEdge,
|
|
14733
|
+
right: defaultGridEdge,
|
|
14734
|
+
insideH: defaultGridEdge,
|
|
14735
|
+
insideV: defaultGridEdge
|
|
14736
|
+
};
|
|
14737
|
+
let yudaoTblWidthType;
|
|
14738
|
+
let yudaoTblWidthDxa;
|
|
14739
|
+
let yudaoTblWidthPct;
|
|
14740
|
+
let tableSize;
|
|
14741
|
+
const tblWMatch = tblPrXml.match(/<w:tblW\b([^>]*)\/?>/);
|
|
14742
|
+
if (tblWMatch) {
|
|
14743
|
+
const tblWAttrs = tblWMatch[1] || "";
|
|
14744
|
+
const rawWVal = Number(tblWAttrs.match(/\bw:w="(-?\d+)"/)?.[1] ?? 0);
|
|
14745
|
+
const rawWType = (tblWAttrs.match(/\bw:type="([^"]+)"/)?.[1] || (rawWVal > 0 ? "dxa" : "auto")).toLowerCase();
|
|
14746
|
+
if (rawWType === "pct") {
|
|
14747
|
+
yudaoTblWidthType = "pct";
|
|
14748
|
+
yudaoTblWidthPct = rawWVal > 0 ? rawWVal : 5e3;
|
|
14749
|
+
xmlTableAutoFitWindow.add(tableId);
|
|
14750
|
+
tableSize = {
|
|
14751
|
+
type: import_core7.TableSizeType.UNSPECIFIED,
|
|
14752
|
+
width: { v: 0, u: import_core7.NumberUnitType.POINT }
|
|
14753
|
+
};
|
|
14754
|
+
} else if (rawWType === "nil") {
|
|
14755
|
+
yudaoTblWidthType = "nil";
|
|
14756
|
+
tableSize = {
|
|
14757
|
+
type: import_core7.TableSizeType.SPECIFIED,
|
|
14758
|
+
width: { v: 0, u: import_core7.NumberUnitType.POINT }
|
|
14759
|
+
};
|
|
14760
|
+
} else if (rawWType === "auto") {
|
|
14761
|
+
yudaoTblWidthType = "auto";
|
|
14762
|
+
tableSize = {
|
|
14763
|
+
type: import_core7.TableSizeType.UNSPECIFIED,
|
|
14764
|
+
width: { v: 0, u: import_core7.NumberUnitType.POINT }
|
|
14765
|
+
};
|
|
14766
|
+
} else {
|
|
14767
|
+
yudaoTblWidthType = "dxa";
|
|
14768
|
+
yudaoTblWidthDxa = Math.max(20, Math.round(rawWVal));
|
|
14769
|
+
tableSize = {
|
|
14770
|
+
type: import_core7.TableSizeType.SPECIFIED,
|
|
14771
|
+
width: { v: Math.max(1, dxaToPt(rawWVal)), u: import_core7.NumberUnitType.POINT }
|
|
14772
|
+
};
|
|
14773
|
+
}
|
|
14774
|
+
}
|
|
14775
|
+
let tableLayout;
|
|
14776
|
+
const tblLayoutMatch = tblPrXml.match(/<w:tblLayout\b[^>]*\bw:type="(fixed|autofit)"/i);
|
|
14777
|
+
if (tblLayoutMatch) {
|
|
14778
|
+
tableLayout = tblLayoutMatch[1].toLowerCase() === "fixed" ? import_core7.TableLayoutType.FIXED : import_core7.TableLayoutType.AUTO_FIT;
|
|
14779
|
+
}
|
|
14780
|
+
let colWidthsPt = Array.from(tblGridXml.matchAll(/<w:gridCol\b[^>]*\bw:w="(\d+)"/g)).map(
|
|
14781
|
+
(m) => Math.max(1, dxaToPt(Number(m[1])))
|
|
14782
|
+
);
|
|
14783
|
+
const trMatches = tokenizeNestedTagBlocks(tblXml, "tr");
|
|
14784
|
+
const trHeadList = trMatches.map((trXml) => {
|
|
14785
|
+
const firstTc = trXml.match(/<w:tc(?=[\s>])/);
|
|
14786
|
+
const head = firstTc && typeof firstTc.index === "number" ? trXml.slice(0, firstTc.index) : trXml;
|
|
14787
|
+
return head.match(/<w:trPr[\s>][\s\S]*?<\/w:trPr>/)?.[0] || "";
|
|
14788
|
+
});
|
|
14789
|
+
let headerRowCount = 0;
|
|
14790
|
+
while (headerRowCount < trHeadList.length && /<w:tblHeader(?:\s|\/|>)/.test(trHeadList[headerRowCount]) && !/<w:tblHeader\s[^>]*w:val="(?:0|false|off)"/i.test(trHeadList[headerRowCount])) {
|
|
14791
|
+
headerRowCount++;
|
|
14792
|
+
}
|
|
14793
|
+
const repeatHeaderRow = headerRowCount > 0;
|
|
14794
|
+
const rows = [];
|
|
14795
|
+
const rowMeta = [];
|
|
14796
|
+
const activeVMerges = /* @__PURE__ */ new Map();
|
|
14797
|
+
trMatches.forEach((trXml, trIdx) => {
|
|
14798
|
+
const trPrXml = trHeadList[trIdx] || "";
|
|
14799
|
+
let rowCantSplit;
|
|
14800
|
+
const cantSplitMatch = trPrXml.match(/<w:cantSplit\b([^>]*)\/?>/);
|
|
14801
|
+
if (cantSplitMatch) {
|
|
14802
|
+
const csOff = /\bw:val="(?:0|false|off)"/i.test(cantSplitMatch[1] || "");
|
|
14803
|
+
rowCantSplit = csOff ? import_core7.BooleanNumber.FALSE : import_core7.BooleanNumber.TRUE;
|
|
14804
|
+
}
|
|
14805
|
+
let rowTrHeight;
|
|
14806
|
+
const trHeightMatch = trPrXml.match(/<w:trHeight\b([^>]*)\/?>/);
|
|
14807
|
+
if (trHeightMatch) {
|
|
14808
|
+
const hAttrs = trHeightMatch[1] || "";
|
|
14809
|
+
const hDxa = Number(hAttrs.match(/\bw:val="(\d+)"/)?.[1] ?? 0);
|
|
14810
|
+
const rawHRule = (hAttrs.match(/\bw:hRule="([^"]+)"/)?.[1] || "").toLowerCase();
|
|
14811
|
+
if (rawHRule === "auto") {
|
|
14812
|
+
rowTrHeight = {
|
|
14813
|
+
val: { v: 0, u: import_core7.NumberUnitType.POINT },
|
|
14814
|
+
hRule: import_core7.TableRowHeightRule.AUTO
|
|
14815
|
+
};
|
|
14816
|
+
} else if (rawHRule === "exact") {
|
|
14817
|
+
rowTrHeight = {
|
|
14818
|
+
val: { v: dxaToPt(hDxa), u: import_core7.NumberUnitType.POINT },
|
|
14819
|
+
hRule: import_core7.TableRowHeightRule.EXACT
|
|
14820
|
+
};
|
|
14821
|
+
} else {
|
|
14822
|
+
rowTrHeight = {
|
|
14823
|
+
val: { v: dxaToPt(hDxa), u: import_core7.NumberUnitType.POINT },
|
|
14824
|
+
hRule: import_core7.TableRowHeightRule.AT_LEAST
|
|
14825
|
+
};
|
|
14826
|
+
}
|
|
14827
|
+
} else {
|
|
14828
|
+
rowTrHeight = {
|
|
14829
|
+
val: { v: 0, u: import_core7.NumberUnitType.POINT },
|
|
14830
|
+
hRule: import_core7.TableRowHeightRule.AUTO
|
|
14831
|
+
};
|
|
14832
|
+
}
|
|
14833
|
+
const tcMatches = tokenizeNestedTagBlocks(trXml, "tc");
|
|
14834
|
+
const rowIdx = rows.length;
|
|
14835
|
+
const rowCells = [];
|
|
14836
|
+
let gridCol = 0;
|
|
14837
|
+
for (const tcXml of tcMatches) {
|
|
14838
|
+
const firstTcBodyMatch = tcXml.match(/<w:(?:p|tbl|sdt)(?=[\s/>])/);
|
|
14839
|
+
const tcHeadXml = firstTcBodyMatch && typeof firstTcBodyMatch.index === "number" ? tcXml.slice(0, firstTcBodyMatch.index) : tcXml;
|
|
14840
|
+
const tcPrXml = tcHeadXml.match(/<w:tcPr[\s>][\s\S]*?<\/w:tcPr>/)?.[0] || "";
|
|
14841
|
+
const spanMatch = tcPrXml.match(/<w:gridSpan\s[^>]*w:val="(\d+)"/);
|
|
14842
|
+
const colSpan = spanMatch ? Math.max(1, Number(spanMatch[1])) : 1;
|
|
14843
|
+
const vMergeTag = tcPrXml.match(/<w:vMerge\b([^>]*)\/?>/);
|
|
14844
|
+
const isVMergeRestart = Boolean(vMergeTag && /w:val="restart"/.test(vMergeTag[1] || ""));
|
|
14845
|
+
const isVMergeContinue = Boolean(vMergeTag && !isVMergeRestart);
|
|
14846
|
+
let tcWidthType;
|
|
14847
|
+
let cellSize;
|
|
14848
|
+
let yudaoTcWidthPct;
|
|
14849
|
+
const tcWMatch = tcPrXml.match(/<w:tcW\b([^>]*)\/?>/);
|
|
14850
|
+
if (tcWMatch) {
|
|
14851
|
+
const tcWAttrs = tcWMatch[1] || "";
|
|
14852
|
+
const rawTcWVal = Number(tcWAttrs.match(/\bw:w="(-?\d+)"/)?.[1] ?? 0);
|
|
14853
|
+
const rawTcWType = (tcWAttrs.match(/\bw:type="([^"]+)"/)?.[1] || (rawTcWVal > 0 ? "dxa" : "auto")).toLowerCase();
|
|
14854
|
+
if (rawTcWType === "pct") {
|
|
14855
|
+
tcWidthType = "pct";
|
|
14856
|
+
yudaoTcWidthPct = rawTcWVal > 0 ? rawTcWVal : void 0;
|
|
14857
|
+
cellSize = {
|
|
14858
|
+
type: import_core7.TableSizeType.UNSPECIFIED,
|
|
14859
|
+
width: { v: 0, u: import_core7.NumberUnitType.POINT }
|
|
14860
|
+
};
|
|
14861
|
+
} else if (rawTcWType === "nil") {
|
|
14862
|
+
tcWidthType = "nil";
|
|
14863
|
+
cellSize = {
|
|
14864
|
+
type: import_core7.TableSizeType.SPECIFIED,
|
|
14865
|
+
width: { v: 0, u: import_core7.NumberUnitType.POINT }
|
|
14866
|
+
};
|
|
14867
|
+
} else if (rawTcWType === "auto") {
|
|
14868
|
+
tcWidthType = "auto";
|
|
14869
|
+
cellSize = {
|
|
14870
|
+
type: import_core7.TableSizeType.UNSPECIFIED,
|
|
14871
|
+
width: { v: 0, u: import_core7.NumberUnitType.POINT }
|
|
14872
|
+
};
|
|
14873
|
+
} else {
|
|
14874
|
+
tcWidthType = "dxa";
|
|
14875
|
+
cellSize = {
|
|
14876
|
+
type: import_core7.TableSizeType.SPECIFIED,
|
|
14877
|
+
width: { v: Math.max(1, dxaToPt(rawTcWVal)), u: import_core7.NumberUnitType.POINT }
|
|
14878
|
+
};
|
|
13769
14879
|
}
|
|
13770
|
-
|
|
13771
|
-
|
|
13772
|
-
|
|
13773
|
-
|
|
14880
|
+
}
|
|
14881
|
+
const shdMatch = tcPrXml.match(/<w:shd\s[^>]*w:fill="([0-9a-fA-F]{6})"/);
|
|
14882
|
+
const vAlignMatch = tcPrXml.match(/<w:vAlign\s[^>]*w:val="([^"]+)"/)?.[1];
|
|
14883
|
+
const tcBordersXml = tcPrXml.match(/<w:tcBorders[\s>][\s\S]*?<\/w:tcBorders>/)?.[0] || "";
|
|
14884
|
+
const parseTcBorderEdge = (edgeTag) => {
|
|
14885
|
+
const em = tcBordersXml.match(new RegExp(`<w:${edgeTag}\\b([^>]*)\\/?>`));
|
|
14886
|
+
if (!em) return void 0;
|
|
14887
|
+
const eAttrs = em[1] || "";
|
|
14888
|
+
const rawVal = (eAttrs.match(/w:val="([^"]+)"/)?.[1] || "single").toLowerCase();
|
|
14889
|
+
if (rawVal === "none" || rawVal === "nil") {
|
|
14890
|
+
return { style: "none", widthPt: 0 };
|
|
14891
|
+
}
|
|
14892
|
+
const szEighths = Number(eAttrs.match(/w:sz="(\d+)"/)?.[1] ?? 4);
|
|
14893
|
+
const widthPt = Math.max(0.25, Math.round(szEighths / 8 * 100) / 100);
|
|
14894
|
+
const rawColor = (eAttrs.match(/w:color="([0-9a-fA-F]{6})"/)?.[1] || "CBD5E1").toUpperCase();
|
|
14895
|
+
const style = rawVal === "double" ? "double" : rawVal.includes("dash") ? "dashed" : rawVal.includes("dot") ? "dotted" : "single";
|
|
14896
|
+
return { style, widthPt, color: `#${rawColor}` };
|
|
14897
|
+
};
|
|
14898
|
+
const parsedCellBorders = {};
|
|
14899
|
+
const effectiveColCount = Math.max(colWidthsPt.length, tcMatches.length, gridCol + colSpan);
|
|
14900
|
+
const inhTop = trIdx === 0 ? tblLevelBorders.top : tblLevelBorders.insideH;
|
|
14901
|
+
const inhBot = trIdx === trMatches.length - 1 ? tblLevelBorders.bottom : tblLevelBorders.insideH;
|
|
14902
|
+
const inhLeft = gridCol === 0 ? tblLevelBorders.left : tblLevelBorders.insideV;
|
|
14903
|
+
const inhRight = gridCol + colSpan >= effectiveColCount ? tblLevelBorders.right : tblLevelBorders.insideV;
|
|
14904
|
+
const bTop = tcBordersXml ? parseTcBorderEdge("top") : void 0;
|
|
14905
|
+
const bBot = tcBordersXml ? parseTcBorderEdge("bottom") : void 0;
|
|
14906
|
+
const bLeft = tcBordersXml ? parseTcBorderEdge("left") : void 0;
|
|
14907
|
+
const bRight = tcBordersXml ? parseTcBorderEdge("right") : void 0;
|
|
14908
|
+
parsedCellBorders.top = bTop ?? inhTop;
|
|
14909
|
+
parsedCellBorders.bottom = bBot ?? inhBot;
|
|
14910
|
+
parsedCellBorders.left = bLeft ?? inhLeft;
|
|
14911
|
+
parsedCellBorders.right = bRight ?? inhRight;
|
|
14912
|
+
const hasExplicitCellBorders = Boolean(bTop || bBot || bLeft || bRight);
|
|
14913
|
+
const hasTl2Br = /<w:tl2br\b/.test(tcBordersXml) && !/<w:tl2br\b[^>]*w:val="(?:none|nil)"/.test(tcBordersXml);
|
|
14914
|
+
const hasTr2Bl = /<w:tr2bl\b/.test(tcBordersXml) && !/<w:tr2bl\b[^>]*w:val="(?:none|nil)"/.test(tcBordersXml);
|
|
14915
|
+
const cellProps = {};
|
|
14916
|
+
if (hasTl2Br && hasTr2Bl) cellProps.slashType = "both";
|
|
14917
|
+
else if (hasTl2Br) cellProps.slashType = "back";
|
|
14918
|
+
else if (hasTr2Bl) cellProps.slashType = "forward";
|
|
14919
|
+
if (vAlignMatch === "top" || vAlignMatch === "center" || vAlignMatch === "bottom") {
|
|
14920
|
+
cellProps.verticalAlign = vAlignMatch;
|
|
14921
|
+
}
|
|
14922
|
+
if (shdMatch) {
|
|
14923
|
+
cellProps.backgroundColor = `#${shdMatch[1].toUpperCase()}`;
|
|
14924
|
+
}
|
|
14925
|
+
if (hasExplicitCellBorders) {
|
|
14926
|
+
cellProps.borders = {
|
|
14927
|
+
...bTop ? { top: bTop } : {},
|
|
14928
|
+
...bBot ? { bottom: bBot } : {},
|
|
14929
|
+
...bLeft ? { left: bLeft } : {},
|
|
14930
|
+
...bRight ? { right: bRight } : {}
|
|
14931
|
+
};
|
|
14932
|
+
}
|
|
14933
|
+
if (Object.keys(cellProps).length > 0) {
|
|
14934
|
+
xmlTableCellProperties[`${tableId}:${rowIdx}:${gridCol}`] = cellProps;
|
|
14935
|
+
}
|
|
14936
|
+
if (isVMergeContinue && activeVMerges.has(gridCol)) {
|
|
14937
|
+
const masterInfo = activeVMerges.get(gridCol);
|
|
14938
|
+
const masterCell = rows[masterInfo.startRow]?.[gridCol];
|
|
14939
|
+
if (masterCell) {
|
|
14940
|
+
masterCell.rowSpan = (masterCell.rowSpan ?? 1) + 1;
|
|
14941
|
+
}
|
|
14942
|
+
rowCells.push({
|
|
14943
|
+
text: "",
|
|
14944
|
+
colSpan,
|
|
14945
|
+
rowSpan: 0,
|
|
14946
|
+
borders: parsedCellBorders,
|
|
14947
|
+
...tcWidthType ? { tcWidthType } : {},
|
|
14948
|
+
...cellSize ? { cellSize } : {},
|
|
14949
|
+
...yudaoTcWidthPct !== void 0 ? { yudaoTcWidthPct } : {}
|
|
14950
|
+
});
|
|
14951
|
+
for (let k = 1; k < colSpan; k++) {
|
|
14952
|
+
rowCells.push({ text: "", colSpan: 0, rowSpan: 0 });
|
|
14953
|
+
}
|
|
14954
|
+
} else {
|
|
14955
|
+
if (isVMergeRestart) {
|
|
14956
|
+
activeVMerges.set(gridCol, { startRow: rowIdx, colSpan });
|
|
14957
|
+
} else {
|
|
14958
|
+
activeVMerges.delete(gridCol);
|
|
14959
|
+
}
|
|
14960
|
+
const tcBodyOnly = tcPrXml ? tcXml.replace(tcPrXml, "") : tcXml;
|
|
14961
|
+
const tcInnerMatch = tcBodyOnly.match(/^<w:tc(?=[\s>])[^>]*>([\s\S]*)<\/w:tc>$/);
|
|
14962
|
+
const tcInnerXml = tcInnerMatch ? tcInnerMatch[1] : tcBodyOnly;
|
|
14963
|
+
const tcPXmlList = unwrapCellParagraphBlocks(tcInnerXml);
|
|
14964
|
+
const tcParas = tcPXmlList.length > 0 ? tcPXmlList.map(
|
|
14965
|
+
(pXmlItem) => parseParagraphXmlToBuilder(
|
|
14966
|
+
pXmlItem,
|
|
14967
|
+
storyRelsMap,
|
|
13774
14968
|
entries,
|
|
13775
14969
|
collectedDrawings,
|
|
13776
|
-
|
|
14970
|
+
storyInlineQueue,
|
|
13777
14971
|
warningsCounter,
|
|
13778
14972
|
numCtx
|
|
13779
14973
|
)
|
|
13780
|
-
);
|
|
13781
|
-
|
|
13782
|
-
|
|
13783
|
-
|
|
13784
|
-
|
|
13785
|
-
|
|
13786
|
-
|
|
13787
|
-
|
|
13788
|
-
|
|
13789
|
-
|
|
13790
|
-
|
|
13791
|
-
|
|
13792
|
-
|
|
13793
|
-
|
|
13794
|
-
|
|
13795
|
-
|
|
13796
|
-
|
|
13797
|
-
|
|
13798
|
-
|
|
13799
|
-
collectedDrawings,
|
|
13800
|
-
inlineBlocksQueue,
|
|
13801
|
-
warningsCounter,
|
|
13802
|
-
numCtx
|
|
13803
|
-
)
|
|
13804
|
-
);
|
|
13805
|
-
topLevelParaCounter++;
|
|
14974
|
+
) : void 0;
|
|
14975
|
+
const cellTexts = Array.from(
|
|
14976
|
+
tcXml.matchAll(/<w:t(?=[\s>])[^>]*>([\s\S]*?)<\/w:t>/g)
|
|
14977
|
+
).map((m) => unescapeXml(m[1]));
|
|
14978
|
+
const firstRunMatch = tcXml.match(/<w:r[\s>][\s\S]*?<\/w:r>/);
|
|
14979
|
+
rowCells.push({
|
|
14980
|
+
text: cellTexts.join("\n"),
|
|
14981
|
+
style: firstRunMatch ? parseRunStyleFromXml(firstRunMatch[0], themeFonts) : void 0,
|
|
14982
|
+
colSpan,
|
|
14983
|
+
rowSpan: 1,
|
|
14984
|
+
backgroundRgb: shdMatch ? `#${shdMatch[1]}` : void 0,
|
|
14985
|
+
borders: parsedCellBorders,
|
|
14986
|
+
...tcWidthType ? { tcWidthType } : {},
|
|
14987
|
+
...cellSize ? { cellSize } : {},
|
|
14988
|
+
...yudaoTcWidthPct !== void 0 ? { yudaoTcWidthPct } : {},
|
|
14989
|
+
...tcParas ? { paragraphs: tcParas } : {}
|
|
14990
|
+
});
|
|
14991
|
+
for (let k = 1; k < colSpan; k++) {
|
|
14992
|
+
rowCells.push({ text: "", colSpan: 0, rowSpan: 1 });
|
|
13806
14993
|
}
|
|
13807
14994
|
}
|
|
14995
|
+
gridCol += colSpan;
|
|
13808
14996
|
}
|
|
13809
|
-
|
|
13810
|
-
|
|
13811
|
-
|
|
13812
|
-
|
|
13813
|
-
|
|
13814
|
-
|
|
13815
|
-
if (/<w:tblW\b[^>]*w:type="pct"/.test(tblPrXml)) {
|
|
13816
|
-
xmlTableAutoFitWindow.add(tableId);
|
|
14997
|
+
if (rowCells.length > 0) {
|
|
14998
|
+
rows.push(rowCells);
|
|
14999
|
+
rowMeta.push({
|
|
15000
|
+
...rowCantSplit !== void 0 ? { cantSplit: rowCantSplit } : {},
|
|
15001
|
+
trHeight: rowTrHeight
|
|
15002
|
+
});
|
|
13817
15003
|
}
|
|
13818
|
-
|
|
13819
|
-
|
|
13820
|
-
|
|
15004
|
+
});
|
|
15005
|
+
if (colWidthsPt.length === 0 && rows[0]?.length) {
|
|
15006
|
+
const derivedCols = [];
|
|
15007
|
+
let cCursor = 0;
|
|
15008
|
+
while (cCursor < rows[0].length) {
|
|
15009
|
+
const cell = rows[0][cCursor];
|
|
15010
|
+
const span = Math.max(1, cell.colSpan ?? 1);
|
|
15011
|
+
const wPt = cell.cellSize?.width?.v;
|
|
15012
|
+
if (typeof wPt === "number" && wPt > 0) {
|
|
15013
|
+
const each = Math.max(1, Math.round(wPt / span * 100) / 100);
|
|
15014
|
+
for (let k = 0; k < span; k++) derivedCols.push(each);
|
|
15015
|
+
} else {
|
|
15016
|
+
derivedCols.length = 0;
|
|
15017
|
+
break;
|
|
15018
|
+
}
|
|
15019
|
+
cCursor += span;
|
|
13821
15020
|
}
|
|
13822
|
-
|
|
13823
|
-
|
|
13824
|
-
);
|
|
13825
|
-
const trMatches = item.xml.match(/<w:tr[\s>][\s\S]*?<\/w:tr>/g) ?? [];
|
|
13826
|
-
let headerRowCount = 0;
|
|
13827
|
-
while (headerRowCount < trMatches.length && /<w:tblHeader(?:\s|\/|>)/.test(trMatches[headerRowCount])) {
|
|
13828
|
-
headerRowCount++;
|
|
15021
|
+
if (derivedCols.length > 0) {
|
|
15022
|
+
colWidthsPt = derivedCols;
|
|
13829
15023
|
}
|
|
13830
|
-
|
|
13831
|
-
|
|
13832
|
-
|
|
13833
|
-
|
|
13834
|
-
|
|
13835
|
-
|
|
13836
|
-
|
|
13837
|
-
|
|
13838
|
-
|
|
13839
|
-
|
|
13840
|
-
|
|
13841
|
-
|
|
13842
|
-
|
|
13843
|
-
|
|
13844
|
-
|
|
13845
|
-
|
|
13846
|
-
|
|
13847
|
-
|
|
13848
|
-
|
|
13849
|
-
|
|
13850
|
-
|
|
13851
|
-
|
|
13852
|
-
|
|
13853
|
-
|
|
13854
|
-
|
|
13855
|
-
|
|
13856
|
-
|
|
13857
|
-
|
|
13858
|
-
|
|
13859
|
-
|
|
13860
|
-
|
|
13861
|
-
|
|
13862
|
-
|
|
13863
|
-
|
|
13864
|
-
|
|
13865
|
-
|
|
13866
|
-
|
|
13867
|
-
|
|
13868
|
-
|
|
13869
|
-
|
|
13870
|
-
|
|
13871
|
-
|
|
13872
|
-
|
|
13873
|
-
|
|
13874
|
-
|
|
13875
|
-
|
|
13876
|
-
|
|
13877
|
-
|
|
13878
|
-
|
|
13879
|
-
|
|
13880
|
-
|
|
13881
|
-
|
|
13882
|
-
|
|
13883
|
-
|
|
13884
|
-
|
|
13885
|
-
|
|
13886
|
-
|
|
13887
|
-
|
|
13888
|
-
|
|
13889
|
-
|
|
13890
|
-
|
|
13891
|
-
|
|
13892
|
-
|
|
13893
|
-
|
|
13894
|
-
const masterCell = rows[masterInfo.startRow]?.[gridCol];
|
|
13895
|
-
if (masterCell) {
|
|
13896
|
-
masterCell.rowSpan = (masterCell.rowSpan ?? 1) + 1;
|
|
15024
|
+
}
|
|
15025
|
+
if (rows.length === 0) return null;
|
|
15026
|
+
return {
|
|
15027
|
+
kind: "table",
|
|
15028
|
+
tableId,
|
|
15029
|
+
columnWidthsPt: colWidthsPt.length > 0 ? colWidthsPt : void 0,
|
|
15030
|
+
repeatHeaderRow,
|
|
15031
|
+
headerRowCount,
|
|
15032
|
+
rows,
|
|
15033
|
+
rowMeta,
|
|
15034
|
+
...tableSize ? { tableSize } : {},
|
|
15035
|
+
...tableLayout !== void 0 ? { tableLayout } : {},
|
|
15036
|
+
...yudaoTblWidthType ? { yudaoTblWidthType } : {},
|
|
15037
|
+
...yudaoTblWidthDxa !== void 0 ? { yudaoTblWidthDxa } : {},
|
|
15038
|
+
...yudaoTblWidthPct !== void 0 ? { yudaoTblWidthPct } : {}
|
|
15039
|
+
};
|
|
15040
|
+
};
|
|
15041
|
+
const parseStoryBlocksFromXml = (storyXml, storyRelsMap, storyInlineQueue, allowTocDetection) => {
|
|
15042
|
+
const storyBlocks = [];
|
|
15043
|
+
let topLevelParaCounter = 0;
|
|
15044
|
+
const appendBlocksFromXml = (containerXml) => {
|
|
15045
|
+
const items = tokenizeBodyTopLevelBlocks(containerXml);
|
|
15046
|
+
for (const item of items) {
|
|
15047
|
+
if (item.tag === "p") {
|
|
15048
|
+
storyBlocks.push(
|
|
15049
|
+
parseParagraphXmlToBuilder(
|
|
15050
|
+
item.xml,
|
|
15051
|
+
storyRelsMap,
|
|
15052
|
+
entries,
|
|
15053
|
+
collectedDrawings,
|
|
15054
|
+
storyInlineQueue,
|
|
15055
|
+
warningsCounter,
|
|
15056
|
+
numCtx
|
|
15057
|
+
)
|
|
15058
|
+
);
|
|
15059
|
+
topLevelParaCounter++;
|
|
15060
|
+
} else if (item.tag === "sdt") {
|
|
15061
|
+
const isTocSdt = allowTocDetection && (/<w:docPartGallery\s[^>]*w:val="Table of Contents"/i.test(item.xml) || /\bTOC\s+\\o\b/.test(item.xml));
|
|
15062
|
+
const cStart = item.xml.match(/<w:sdtContent(?=[\s>])[^>]*>/);
|
|
15063
|
+
const cEnd = item.xml.lastIndexOf("</w:sdtContent>");
|
|
15064
|
+
const innerContent = cStart && cEnd > (cStart.index ?? 0) ? item.xml.slice((cStart.index ?? 0) + cStart[0].length, cEnd) : item.xml;
|
|
15065
|
+
if (isTocSdt) {
|
|
15066
|
+
const innerBlocks = tokenizeBodyTopLevelBlocks(innerContent);
|
|
15067
|
+
const instrMatch = item.xml.match(/TOC\s+\\o\s+(?:"|")1-(\d+)(?:"|")/);
|
|
15068
|
+
const maxLvl = instrMatch ? Math.max(1, Math.min(6, Number(instrMatch[1]))) : 3;
|
|
15069
|
+
const hidePg = /\s\\n\b/.test(item.xml);
|
|
15070
|
+
const startIdx = topLevelParaCounter;
|
|
15071
|
+
for (const ib of innerBlocks) {
|
|
15072
|
+
if (ib.tag !== "p") continue;
|
|
15073
|
+
if (/<w:fldChar\b/.test(ib.xml) && !/<w:t(?=[\s>])/.test(ib.xml)) {
|
|
15074
|
+
continue;
|
|
15075
|
+
}
|
|
15076
|
+
storyBlocks.push(
|
|
15077
|
+
parseParagraphXmlToBuilder(
|
|
15078
|
+
ib.xml,
|
|
15079
|
+
storyRelsMap,
|
|
15080
|
+
entries,
|
|
15081
|
+
collectedDrawings,
|
|
15082
|
+
storyInlineQueue,
|
|
15083
|
+
warningsCounter,
|
|
15084
|
+
numCtx
|
|
15085
|
+
)
|
|
15086
|
+
);
|
|
15087
|
+
topLevelParaCounter++;
|
|
13897
15088
|
}
|
|
13898
|
-
|
|
13899
|
-
|
|
13900
|
-
|
|
13901
|
-
|
|
13902
|
-
|
|
13903
|
-
|
|
13904
|
-
|
|
15089
|
+
if (topLevelParaCounter > startIdx) {
|
|
15090
|
+
detectedTocSpan = {
|
|
15091
|
+
startTopParaIdx: startIdx,
|
|
15092
|
+
endTopParaIdx: topLevelParaCounter - 1,
|
|
15093
|
+
maxLevel: maxLvl,
|
|
15094
|
+
showPageNumbers: !hidePg
|
|
15095
|
+
};
|
|
13905
15096
|
}
|
|
13906
15097
|
} else {
|
|
13907
|
-
|
|
13908
|
-
|
|
13909
|
-
|
|
13910
|
-
|
|
13911
|
-
|
|
13912
|
-
|
|
13913
|
-
const tcInnerMatch = tcBodyOnly.match(/^<w:tc(?=[\s>])[^>]*>([\s\S]*)<\/w:tc>$/);
|
|
13914
|
-
const tcInnerXml = tcInnerMatch ? tcInnerMatch[1] : tcBodyOnly;
|
|
13915
|
-
const tcPBlocks = tokenizeBodyTopLevelBlocks(tcInnerXml).filter((b) => b.tag === "p");
|
|
13916
|
-
const tcParas = tcPBlocks.length > 0 ? tcPBlocks.map(
|
|
13917
|
-
(pb) => parseParagraphXmlToBuilder(
|
|
13918
|
-
pb.xml,
|
|
13919
|
-
relsMap,
|
|
13920
|
-
entries,
|
|
13921
|
-
collectedDrawings,
|
|
13922
|
-
inlineBlocksQueue,
|
|
13923
|
-
warningsCounter,
|
|
13924
|
-
numCtx
|
|
13925
|
-
)
|
|
13926
|
-
) : void 0;
|
|
13927
|
-
const cellTexts = Array.from(
|
|
13928
|
-
tcXml.matchAll(/<w:t(?=[\s>])[^>]*>([\s\S]*?)<\/w:t>/g)
|
|
13929
|
-
).map((m) => unescapeXml(m[1]));
|
|
13930
|
-
const firstRunMatch = tcXml.match(/<w:r[\s>][\s\S]*?<\/w:r>/);
|
|
13931
|
-
rowCells.push({
|
|
13932
|
-
text: cellTexts.join("\n"),
|
|
13933
|
-
style: firstRunMatch ? parseRunStyleFromXml(firstRunMatch[0]) : void 0,
|
|
13934
|
-
colSpan,
|
|
13935
|
-
rowSpan: 1,
|
|
13936
|
-
backgroundRgb: shdMatch ? `#${shdMatch[1]}` : void 0,
|
|
13937
|
-
...hasCellBorders ? { borders: parsedCellBorders } : {},
|
|
13938
|
-
...tcParas ? { paragraphs: tcParas } : {}
|
|
13939
|
-
});
|
|
13940
|
-
for (let k = 1; k < colSpan; k++) {
|
|
13941
|
-
rowCells.push({ text: "", colSpan: 0, rowSpan: 1 });
|
|
13942
|
-
}
|
|
15098
|
+
appendBlocksFromXml(innerContent);
|
|
15099
|
+
}
|
|
15100
|
+
} else if (item.tag === "tbl") {
|
|
15101
|
+
const builtTbl = parseTableXmlToBuilder(item.xml, storyRelsMap, storyInlineQueue);
|
|
15102
|
+
if (builtTbl) {
|
|
15103
|
+
storyBlocks.push(builtTbl);
|
|
13943
15104
|
}
|
|
13944
|
-
gridCol += colSpan;
|
|
13945
|
-
}
|
|
13946
|
-
if (rowCells.length > 0) {
|
|
13947
|
-
rows.push(rowCells);
|
|
13948
15105
|
}
|
|
13949
|
-
});
|
|
13950
|
-
if (rows.length > 0) {
|
|
13951
|
-
builderBlocks.push({
|
|
13952
|
-
kind: "table",
|
|
13953
|
-
tableId,
|
|
13954
|
-
columnWidthsPt: colWidthsPt.length > 0 ? colWidthsPt : void 0,
|
|
13955
|
-
repeatHeaderRow,
|
|
13956
|
-
headerRowCount,
|
|
13957
|
-
rows
|
|
13958
|
-
});
|
|
13959
15106
|
}
|
|
13960
|
-
}
|
|
13961
|
-
|
|
13962
|
-
|
|
13963
|
-
|
|
13964
|
-
const
|
|
15107
|
+
};
|
|
15108
|
+
appendBlocksFromXml(storyXml);
|
|
15109
|
+
return storyBlocks;
|
|
15110
|
+
};
|
|
15111
|
+
const builderBlocks = parseStoryBlocksFromXml(bodyXml, relsMap, inlineBlocksQueue, true);
|
|
15112
|
+
const trailingSectMatch = bodyXml.match(
|
|
15113
|
+
/<w:sectPr(?=[\s>])(?![\s\S]*<w:sectPr)([\s\S]*?)<\/w:sectPr>/
|
|
15114
|
+
);
|
|
15115
|
+
const sectPrXml = trailingSectMatch ? trailingSectMatch[0] : xml;
|
|
15116
|
+
const pgSzTag = sectPrXml.match(/<w:pgSz\b([^>]*)\/?>/) ?? xml.match(/<w:pgSz\b([^>]*)\/?>/);
|
|
15117
|
+
const pgSzAttrs = pgSzTag?.[1] || "";
|
|
15118
|
+
const pgSzW = pgSzAttrs.match(/\bw:w="(\d+)"/)?.[1];
|
|
15119
|
+
const pgSzH = pgSzAttrs.match(/\bw:h="(\d+)"/)?.[1];
|
|
15120
|
+
const pageWidthPt = pgSzW ? dxaToPt(Number(pgSzW)) : 595.28;
|
|
15121
|
+
const pageHeightPt = pgSzH ? dxaToPt(Number(pgSzH)) : 841.89;
|
|
13965
15122
|
const docData = buildStructuredDocData({
|
|
13966
15123
|
id: docUnitId,
|
|
13967
15124
|
title,
|
|
@@ -13969,19 +15126,79 @@ async function parseDocxBytesWithReport(bytes, title = "Imported Word Document")
|
|
|
13969
15126
|
pageWidthPt,
|
|
13970
15127
|
pageHeightPt
|
|
13971
15128
|
});
|
|
15129
|
+
if (themeFonts && docData.documentStyle) {
|
|
15130
|
+
if (themeFonts.majorLatin || themeFonts.minorLatin) {
|
|
15131
|
+
docData.documentStyle.latinFontScheme = {
|
|
15132
|
+
...themeFonts.majorLatin ? { major: themeFonts.majorLatin } : {},
|
|
15133
|
+
...themeFonts.minorLatin ? { minor: themeFonts.minorLatin } : {}
|
|
15134
|
+
};
|
|
15135
|
+
}
|
|
15136
|
+
if (themeFonts.majorEastAsia || themeFonts.minorEastAsia) {
|
|
15137
|
+
docData.documentStyle.eastAsiaFontScheme = {
|
|
15138
|
+
major: { ...themeFonts.majorEastAsia ? { fontFamily: themeFonts.majorEastAsia } : {} },
|
|
15139
|
+
minor: { ...themeFonts.minorEastAsia ? { fontFamily: themeFonts.minorEastAsia } : {} }
|
|
15140
|
+
};
|
|
15141
|
+
}
|
|
15142
|
+
}
|
|
15143
|
+
const stylesBytes = entries.get("word/styles.xml");
|
|
15144
|
+
if (stylesBytes) {
|
|
15145
|
+
parseStylesXmlIntoDoc(decoder.decode(stylesBytes), themeFonts, docData);
|
|
15146
|
+
}
|
|
13972
15147
|
for (const autoTblId of xmlTableAutoFitWindow) {
|
|
13973
15148
|
if (docData.tableSource?.[autoTblId]) {
|
|
13974
15149
|
docData.tableSource[autoTblId].yudaoAutoFitMode = "window";
|
|
13975
15150
|
}
|
|
13976
15151
|
}
|
|
13977
|
-
const
|
|
13978
|
-
|
|
13979
|
-
|
|
13980
|
-
|
|
13981
|
-
|
|
13982
|
-
|
|
13983
|
-
|
|
13984
|
-
|
|
15152
|
+
const pgMarTag = sectPrXml.match(/<w:pgMar\b([^>]*)\/?>/) ?? xml.match(/<w:pgMar\b([^>]*)\/?>/);
|
|
15153
|
+
if (pgMarTag && docData.documentStyle) {
|
|
15154
|
+
const pmAttrs = pgMarTag[1] || "";
|
|
15155
|
+
const pmTop = pmAttrs.match(/\bw:top="(-?\d+)"/)?.[1];
|
|
15156
|
+
const pmRight = pmAttrs.match(/\bw:right="(-?\d+)"/)?.[1];
|
|
15157
|
+
const pmBottom = pmAttrs.match(/\bw:bottom="(-?\d+)"/)?.[1];
|
|
15158
|
+
const pmLeft = pmAttrs.match(/\bw:left="(-?\d+)"/)?.[1];
|
|
15159
|
+
const pmHeader = pmAttrs.match(/\bw:header="(-?\d+)"/)?.[1];
|
|
15160
|
+
const pmFooter = pmAttrs.match(/\bw:footer="(-?\d+)"/)?.[1];
|
|
15161
|
+
if (pmTop !== void 0) docData.documentStyle.marginTop = dxaToPt(Math.max(0, Number(pmTop)));
|
|
15162
|
+
if (pmRight !== void 0) {
|
|
15163
|
+
docData.documentStyle.marginRight = dxaToPt(Math.max(0, Number(pmRight)));
|
|
15164
|
+
}
|
|
15165
|
+
if (pmBottom !== void 0) {
|
|
15166
|
+
docData.documentStyle.marginBottom = dxaToPt(Math.max(0, Number(pmBottom)));
|
|
15167
|
+
}
|
|
15168
|
+
if (pmLeft !== void 0) docData.documentStyle.marginLeft = dxaToPt(Math.max(0, Number(pmLeft)));
|
|
15169
|
+
if (pmHeader !== void 0) {
|
|
15170
|
+
docData.documentStyle.marginHeader = dxaToPt(Math.max(0, Number(pmHeader)));
|
|
15171
|
+
}
|
|
15172
|
+
if (pmFooter !== void 0) {
|
|
15173
|
+
docData.documentStyle.marginFooter = dxaToPt(Math.max(0, Number(pmFooter)));
|
|
15174
|
+
}
|
|
15175
|
+
}
|
|
15176
|
+
if (docData.documentStyle) {
|
|
15177
|
+
docData.documentStyle.documentFlavor = 1;
|
|
15178
|
+
}
|
|
15179
|
+
const docGridTag = sectPrXml.match(/<w:docGrid\b([^>]*)\/?>/) ?? xml.match(/<w:docGrid\b([^>]*)\/?>/);
|
|
15180
|
+
if (docGridTag && docData.documentStyle) {
|
|
15181
|
+
const dgAttrs = docGridTag[1] || "";
|
|
15182
|
+
const dgTypeRaw = dgAttrs.match(/\bw:type="([^"]+)"/)?.[1];
|
|
15183
|
+
const dgLinePitchRaw = dgAttrs.match(/\bw:linePitch="(-?\d+)"/)?.[1];
|
|
15184
|
+
const dgCharSpaceRaw = dgAttrs.match(/\bw:charSpace="(-?\d+)"/)?.[1];
|
|
15185
|
+
const savedGrid = {};
|
|
15186
|
+
if (dgTypeRaw) {
|
|
15187
|
+
savedGrid.type = dgTypeRaw;
|
|
15188
|
+
const lowerDg = dgTypeRaw.toLowerCase();
|
|
15189
|
+
docData.documentStyle.gridType = lowerDg === "lines" ? import_core7.GridType.LINES : lowerDg === "linesandchars" ? import_core7.GridType.LINES_AND_CHARS : lowerDg === "snaptochars" ? import_core7.GridType.SNAP_TO_CHARS : import_core7.GridType.DEFAULT;
|
|
15190
|
+
}
|
|
15191
|
+
if (dgLinePitchRaw !== void 0) {
|
|
15192
|
+
savedGrid.linePitch = Number(dgLinePitchRaw);
|
|
15193
|
+
docData.documentStyle.linePitch = dxaToPt(Math.max(0, Number(dgLinePitchRaw)));
|
|
15194
|
+
}
|
|
15195
|
+
if (dgCharSpaceRaw !== void 0) {
|
|
15196
|
+
savedGrid.charSpace = Number(dgCharSpaceRaw);
|
|
15197
|
+
docData.documentStyle.charSpace = Number(dgCharSpaceRaw);
|
|
15198
|
+
}
|
|
15199
|
+
if (Object.keys(savedGrid).length > 0) {
|
|
15200
|
+
docData.documentStyle.yudaoDocGrid = savedGrid;
|
|
15201
|
+
}
|
|
13985
15202
|
}
|
|
13986
15203
|
const colsTagMatch = xml.match(/<w:cols\b([^>]*)(?:\/>|>([\s\S]*?)<\/w:cols>)/);
|
|
13987
15204
|
if (colsTagMatch && docData.body) {
|
|
@@ -14150,6 +15367,8 @@ async function parseDocxBytesWithReport(bytes, title = "Imported Word Document")
|
|
|
14150
15367
|
const hfBytes = entries.get(key);
|
|
14151
15368
|
if (!hfBytes) return null;
|
|
14152
15369
|
const hfXml = decoder.decode(hfBytes);
|
|
15370
|
+
const hfInnerMatch = hfXml.match(/<w:(?:hdr|ftr)[\s>]([\s\S]*?)<\/w:(?:hdr|ftr)>/);
|
|
15371
|
+
const hfBodyXml = hfInnerMatch ? hfInnerMatch[1] : hfXml;
|
|
14153
15372
|
const hfFileName = key.split("/").pop() || "header1.xml";
|
|
14154
15373
|
const hfRelsBytes = entries.get(`word/_rels/${hfFileName}.rels`);
|
|
14155
15374
|
const hfRelsMap = new Map(relsMap);
|
|
@@ -14160,43 +15379,59 @@ async function parseDocxBytesWithReport(bytes, title = "Imported Word Document")
|
|
|
14160
15379
|
}
|
|
14161
15380
|
}
|
|
14162
15381
|
const hfQueue = [];
|
|
14163
|
-
const
|
|
14164
|
-
const
|
|
14165
|
-
|
|
14166
|
-
|
|
14167
|
-
|
|
14168
|
-
|
|
14169
|
-
|
|
14170
|
-
|
|
14171
|
-
|
|
14172
|
-
|
|
14173
|
-
|
|
14174
|
-
|
|
14175
|
-
|
|
14176
|
-
|
|
14177
|
-
|
|
14178
|
-
|
|
15382
|
+
const hfBlocks = parseStoryBlocksFromXml(hfBodyXml, hfRelsMap, hfQueue, false);
|
|
15383
|
+
const hfDoc = buildStructuredDocData({
|
|
15384
|
+
id: docUnitId,
|
|
15385
|
+
title: key,
|
|
15386
|
+
blocks: hfBlocks.length > 0 ? hfBlocks : [
|
|
15387
|
+
{
|
|
15388
|
+
segments: [
|
|
15389
|
+
Array.from(hfBodyXml.matchAll(/<w:t(?=[\s>])[^>]*>([\s\S]*?)<\/w:t>/g)).map((m) => unescapeXml(m[1])).join("")
|
|
15390
|
+
]
|
|
15391
|
+
}
|
|
15392
|
+
],
|
|
15393
|
+
pageWidthPt,
|
|
15394
|
+
pageHeightPt
|
|
15395
|
+
});
|
|
15396
|
+
if (hfDoc.tableSource && Object.keys(hfDoc.tableSource).length > 0) {
|
|
15397
|
+
for (const autoTblId of xmlTableAutoFitWindow) {
|
|
15398
|
+
if (hfDoc.tableSource[autoTblId]) {
|
|
15399
|
+
hfDoc.tableSource[autoTblId].yudaoAutoFitMode = "window";
|
|
15400
|
+
}
|
|
14179
15401
|
}
|
|
14180
|
-
|
|
14181
|
-
|
|
15402
|
+
docData.tableSource = {
|
|
15403
|
+
...docData.tableSource ?? {},
|
|
15404
|
+
...hfDoc.tableSource
|
|
15405
|
+
};
|
|
15406
|
+
}
|
|
14182
15407
|
if (hfDoc.body && hfQueue.length > 0) {
|
|
14183
15408
|
const hfStream = hfDoc.body.dataStream;
|
|
14184
15409
|
const hfCustomBlocks = [];
|
|
14185
15410
|
let hq = 0;
|
|
14186
15411
|
for (let i = 0; i < hfStream.length && hq < hfQueue.length; i++) {
|
|
14187
15412
|
if (hfStream[i] === import_core7.DataStreamTreeTokenType.CUSTOM_BLOCK) {
|
|
15413
|
+
const blkId = hfQueue[hq++].blockId;
|
|
14188
15414
|
hfCustomBlocks.push({
|
|
14189
15415
|
startIndex: i,
|
|
14190
|
-
blockId:
|
|
15416
|
+
blockId: blkId,
|
|
14191
15417
|
blockType: 0
|
|
14192
15418
|
});
|
|
15419
|
+
const drw = collectedDrawings[blkId];
|
|
15420
|
+
if (drw) {
|
|
15421
|
+
drw.isMultiTransform = import_core7.BooleanNumber.TRUE;
|
|
15422
|
+
drw.transforms = Array.isArray(drw.transforms) && drw.transforms.length > 0 ? drw.transforms : drw.transform ? [import_core7.Tools.deepClone(drw.transform)] : [];
|
|
15423
|
+
}
|
|
14193
15424
|
}
|
|
14194
15425
|
}
|
|
14195
15426
|
hfDoc.body.customBlocks = hfCustomBlocks;
|
|
14196
15427
|
docData.drawings = collectedDrawings;
|
|
14197
15428
|
docData.drawingsOrder = Object.keys(collectedDrawings);
|
|
14198
15429
|
}
|
|
14199
|
-
|
|
15430
|
+
if (!hfDoc.body) return null;
|
|
15431
|
+
return {
|
|
15432
|
+
body: hfDoc.body,
|
|
15433
|
+
...hfDoc.tableSource && Object.keys(hfDoc.tableSource).length > 0 ? { tableSource: hfDoc.tableSource } : {}
|
|
15434
|
+
};
|
|
14200
15435
|
};
|
|
14201
15436
|
const parsedHeaders = {};
|
|
14202
15437
|
for (const hm of xml.matchAll(/<w:headerReference\b([^>]*)\/?>/g)) {
|
|
@@ -14205,16 +15440,28 @@ async function parseDocxBytesWithReport(bytes, title = "Imported Word Document")
|
|
|
14205
15440
|
if (!rId) continue;
|
|
14206
15441
|
if (relsMap.get(rId)?.endsWith("header_wm.xml")) continue;
|
|
14207
15442
|
const rawType = (attrs.match(/w:type="([^"]+)"/)?.[1] || "default").toLowerCase();
|
|
14208
|
-
const
|
|
14209
|
-
if (!
|
|
15443
|
+
const headerRes = parseHfBodyFromZip(rId, "word/header1.xml");
|
|
15444
|
+
if (!headerRes) continue;
|
|
14210
15445
|
if (rawType === "first") {
|
|
14211
|
-
parsedHeaders.firstPageHeader = {
|
|
15446
|
+
parsedHeaders.firstPageHeader = {
|
|
15447
|
+
headerId: "firstPageHeader",
|
|
15448
|
+
body: headerRes.body,
|
|
15449
|
+
...headerRes.tableSource ? { tableSource: headerRes.tableSource } : {}
|
|
15450
|
+
};
|
|
14212
15451
|
docData.documentStyle.firstPageHeaderId = "firstPageHeader";
|
|
14213
15452
|
} else if (rawType === "even") {
|
|
14214
|
-
parsedHeaders.evenPageHeader = {
|
|
15453
|
+
parsedHeaders.evenPageHeader = {
|
|
15454
|
+
headerId: "evenPageHeader",
|
|
15455
|
+
body: headerRes.body,
|
|
15456
|
+
...headerRes.tableSource ? { tableSource: headerRes.tableSource } : {}
|
|
15457
|
+
};
|
|
14215
15458
|
docData.documentStyle.evenPageHeaderId = "evenPageHeader";
|
|
14216
15459
|
} else {
|
|
14217
|
-
parsedHeaders.defaultHeader = {
|
|
15460
|
+
parsedHeaders.defaultHeader = {
|
|
15461
|
+
headerId: "defaultHeader",
|
|
15462
|
+
body: headerRes.body,
|
|
15463
|
+
...headerRes.tableSource ? { tableSource: headerRes.tableSource } : {}
|
|
15464
|
+
};
|
|
14218
15465
|
docData.documentStyle.defaultHeaderId = "defaultHeader";
|
|
14219
15466
|
}
|
|
14220
15467
|
}
|
|
@@ -14227,30 +15474,78 @@ async function parseDocxBytesWithReport(bytes, title = "Imported Word Document")
|
|
|
14227
15474
|
const rId = attrs.match(/r:id="([^"]+)"/)?.[1];
|
|
14228
15475
|
if (!rId) continue;
|
|
14229
15476
|
const rawType = (attrs.match(/w:type="([^"]+)"/)?.[1] || "default").toLowerCase();
|
|
14230
|
-
const
|
|
14231
|
-
if (!
|
|
15477
|
+
const footerRes = parseHfBodyFromZip(rId, "word/footer1.xml");
|
|
15478
|
+
if (!footerRes) continue;
|
|
14232
15479
|
if (rawType === "first") {
|
|
14233
|
-
parsedFooters.firstPageFooter = {
|
|
15480
|
+
parsedFooters.firstPageFooter = {
|
|
15481
|
+
footerId: "firstPageFooter",
|
|
15482
|
+
body: footerRes.body,
|
|
15483
|
+
...footerRes.tableSource ? { tableSource: footerRes.tableSource } : {}
|
|
15484
|
+
};
|
|
14234
15485
|
docData.documentStyle.firstPageFooterId = "firstPageFooter";
|
|
14235
15486
|
} else if (rawType === "even") {
|
|
14236
|
-
parsedFooters.evenPageFooter = {
|
|
15487
|
+
parsedFooters.evenPageFooter = {
|
|
15488
|
+
footerId: "evenPageFooter",
|
|
15489
|
+
body: footerRes.body,
|
|
15490
|
+
...footerRes.tableSource ? { tableSource: footerRes.tableSource } : {}
|
|
15491
|
+
};
|
|
14237
15492
|
docData.documentStyle.evenPageFooterId = "evenPageFooter";
|
|
14238
15493
|
} else {
|
|
14239
|
-
parsedFooters.defaultFooter = {
|
|
15494
|
+
parsedFooters.defaultFooter = {
|
|
15495
|
+
footerId: "defaultFooter",
|
|
15496
|
+
body: footerRes.body,
|
|
15497
|
+
...footerRes.tableSource ? { tableSource: footerRes.tableSource } : {}
|
|
15498
|
+
};
|
|
14240
15499
|
docData.documentStyle.defaultFooterId = "defaultFooter";
|
|
14241
15500
|
}
|
|
14242
15501
|
}
|
|
14243
15502
|
if (Object.keys(parsedFooters).length > 0) {
|
|
14244
15503
|
docData.footers = parsedFooters;
|
|
14245
15504
|
}
|
|
14246
|
-
|
|
15505
|
+
const titlePgTag = sectPrXml.match(/<w:titlePg\b([^>]*)\/?>/) ?? xml.match(/<w:titlePg\b([^>]*)\/?>/);
|
|
15506
|
+
const hasActiveTitlePg = Boolean(
|
|
15507
|
+
titlePgTag && !/\bw:val="(?:0|false|off)"/i.test(titlePgTag[1] || "")
|
|
15508
|
+
);
|
|
15509
|
+
if (hasActiveTitlePg) {
|
|
14247
15510
|
docData.documentStyle.useFirstPageHeaderFooter = import_core7.BooleanNumber.TRUE;
|
|
15511
|
+
} else if (titlePgTag || docData.documentStyle.firstPageHeaderId || docData.documentStyle.firstPageFooterId) {
|
|
15512
|
+
docData.documentStyle.useFirstPageHeaderFooter = import_core7.BooleanNumber.FALSE;
|
|
14248
15513
|
}
|
|
14249
15514
|
const settingsBytes = entries.get("word/settings.xml");
|
|
14250
15515
|
const settingsXml = settingsBytes ? decoder.decode(settingsBytes) : "";
|
|
14251
|
-
|
|
15516
|
+
const evenOddTag = settingsXml.match(/<w:evenAndOddHeaders\b([^>]*)\/?>/) ?? xml.match(/<w:evenAndOddHeaders\b([^>]*)\/?>/);
|
|
15517
|
+
const hasActiveEvenOdd = Boolean(
|
|
15518
|
+
evenOddTag && !/\bw:val="(?:0|false|off)"/i.test(evenOddTag[1] || "")
|
|
15519
|
+
);
|
|
15520
|
+
if (hasActiveEvenOdd || !evenOddTag && (docData.documentStyle.evenPageHeaderId || docData.documentStyle.evenPageFooterId)) {
|
|
14252
15521
|
docData.documentStyle.evenAndOddHeaders = import_core7.BooleanNumber.TRUE;
|
|
14253
15522
|
}
|
|
15523
|
+
if (docData.body?.sectionBreaks?.length && docData.documentStyle) {
|
|
15524
|
+
const ds = docData.documentStyle;
|
|
15525
|
+
for (const sb of docData.body.sectionBreaks) {
|
|
15526
|
+
if (ds.useFirstPageHeaderFooter !== void 0) {
|
|
15527
|
+
sb.useFirstPageHeaderFooter = ds.useFirstPageHeaderFooter;
|
|
15528
|
+
}
|
|
15529
|
+
if (ds.evenAndOddHeaders !== void 0) {
|
|
15530
|
+
sb.evenAndOddHeaders = ds.evenAndOddHeaders;
|
|
15531
|
+
}
|
|
15532
|
+
if (ds.defaultHeaderId !== void 0) sb.defaultHeaderId = ds.defaultHeaderId;
|
|
15533
|
+
if (ds.defaultFooterId !== void 0) sb.defaultFooterId = ds.defaultFooterId;
|
|
15534
|
+
if (ds.firstPageHeaderId !== void 0) sb.firstPageHeaderId = ds.firstPageHeaderId;
|
|
15535
|
+
if (ds.firstPageFooterId !== void 0) sb.firstPageFooterId = ds.firstPageFooterId;
|
|
15536
|
+
if (ds.evenPageHeaderId !== void 0) sb.evenPageHeaderId = ds.evenPageHeaderId;
|
|
15537
|
+
if (ds.evenPageFooterId !== void 0) sb.evenPageFooterId = ds.evenPageFooterId;
|
|
15538
|
+
if (ds.marginTop !== void 0) sb.marginTop = ds.marginTop;
|
|
15539
|
+
if (ds.marginBottom !== void 0) sb.marginBottom = ds.marginBottom;
|
|
15540
|
+
if (ds.marginLeft !== void 0) sb.marginLeft = ds.marginLeft;
|
|
15541
|
+
if (ds.marginRight !== void 0) sb.marginRight = ds.marginRight;
|
|
15542
|
+
if (ds.marginHeader !== void 0) sb.marginHeader = ds.marginHeader;
|
|
15543
|
+
if (ds.marginFooter !== void 0) sb.marginFooter = ds.marginFooter;
|
|
15544
|
+
if (ds.gridType !== void 0) sb.gridType = ds.gridType;
|
|
15545
|
+
if (ds.linePitch !== void 0) sb.linePitch = ds.linePitch;
|
|
15546
|
+
if (ds.charSpace !== void 0) sb.charSpace = ds.charSpace;
|
|
15547
|
+
}
|
|
15548
|
+
}
|
|
14254
15549
|
const parsedPrintCfg = {};
|
|
14255
15550
|
const headerWmBytes = entries.get("word/header_wm.xml");
|
|
14256
15551
|
if (headerWmBytes) {
|
|
@@ -14356,7 +15651,6 @@ async function parseDocxBytesWithReport(bytes, title = "Imported Word Document")
|
|
|
14356
15651
|
const xmlParaPagination = {};
|
|
14357
15652
|
const xmlParaDirections = {};
|
|
14358
15653
|
const xmlSectionOrientations = {};
|
|
14359
|
-
const trailingSectMatch = bodyXml.match(/<w:sectPr(?=[\s>])(?![\s\S]*<w:sectPr)([\s\S]*?)<\/w:sectPr>/);
|
|
14360
15654
|
if (trailingSectMatch) {
|
|
14361
15655
|
const tPgSz = trailingSectMatch[1].match(/<w:pgSz\b([^>]*)\/?>/);
|
|
14362
15656
|
if (tPgSz && /\bw:orient="landscape"/.test(tPgSz[1] || "")) {
|
|
@@ -14563,6 +15857,9 @@ async function parseDocxBytesWithReport(bytes, title = "Imported Word Document")
|
|
|
14563
15857
|
...hit.options ? { options: hit.options } : {},
|
|
14564
15858
|
...hit.checkboxMarkType ? { checkboxMarkType: hit.checkboxMarkType } : {},
|
|
14565
15859
|
...hit.layoutDirection ? { layoutDirection: hit.layoutDirection } : {},
|
|
15860
|
+
...hit.visualChrome ? { visualChrome: hit.visualChrome } : {},
|
|
15861
|
+
...hit.prefix !== void 0 ? { prefix: hit.prefix } : {},
|
|
15862
|
+
...hit.postfix !== void 0 ? { postfix: hit.postfix } : {},
|
|
14566
15863
|
...hit.preText !== void 0 ? { preText: hit.preText } : {},
|
|
14567
15864
|
...hit.postText !== void 0 ? { postText: hit.postText } : {},
|
|
14568
15865
|
...hit.minWidthPt !== void 0 ? { minWidthPt: hit.minWidthPt } : {},
|
|
@@ -14621,6 +15918,44 @@ async function parseDocxBytesWithReport(bytes, title = "Imported Word Document")
|
|
|
14621
15918
|
oldToNewTblId.set(oldId, liveTables[idx].tableId);
|
|
14622
15919
|
}
|
|
14623
15920
|
});
|
|
15921
|
+
const remappedRowLoops = {
|
|
15922
|
+
...curMeta.tableRowLoops ?? {}
|
|
15923
|
+
};
|
|
15924
|
+
if (extraMeta.tableRowLoops && typeof extraMeta.tableRowLoops === "object") {
|
|
15925
|
+
for (const [k, cfg] of Object.entries(
|
|
15926
|
+
extraMeta.tableRowLoops
|
|
15927
|
+
)) {
|
|
15928
|
+
if (!cfg || typeof cfg !== "object") continue;
|
|
15929
|
+
const colonIdx = k.lastIndexOf(":");
|
|
15930
|
+
const rawTblId = cfg.tableId || (colonIdx > 0 ? k.slice(0, colonIdx) : k);
|
|
15931
|
+
const rawRowIdx = typeof cfg.rowIndex === "number" ? cfg.rowIndex : colonIdx > 0 ? Number(k.slice(colonIdx + 1)) : 0;
|
|
15932
|
+
const mappedTblId = oldToNewTblId.get(rawTblId) ?? (liveTables.length === 1 ? liveTables[0].tableId : rawTblId);
|
|
15933
|
+
const mappedKey = `${mappedTblId}:${rawRowIdx}`;
|
|
15934
|
+
remappedRowLoops[mappedKey] = {
|
|
15935
|
+
...cfg,
|
|
15936
|
+
tableId: mappedTblId,
|
|
15937
|
+
rowIndex: rawRowIdx
|
|
15938
|
+
};
|
|
15939
|
+
}
|
|
15940
|
+
}
|
|
15941
|
+
const remappedRepeatHeaders = {
|
|
15942
|
+
...curMeta.tableRepeatHeaders ?? {}
|
|
15943
|
+
};
|
|
15944
|
+
if (extraMeta.tableRepeatHeaders && typeof extraMeta.tableRepeatHeaders === "object") {
|
|
15945
|
+
for (const [oldTblId, hdrCount] of Object.entries(
|
|
15946
|
+
extraMeta.tableRepeatHeaders
|
|
15947
|
+
)) {
|
|
15948
|
+
if (typeof hdrCount !== "number") continue;
|
|
15949
|
+
const mappedTblId = oldToNewTblId.get(oldTblId) ?? (liveTables.length === 1 ? liveTables[0].tableId : oldTblId);
|
|
15950
|
+
remappedRepeatHeaders[mappedTblId] = hdrCount;
|
|
15951
|
+
const rows = docData.tableSource?.[mappedTblId]?.tableRows;
|
|
15952
|
+
if (rows) {
|
|
15953
|
+
rows.forEach((r, idx) => {
|
|
15954
|
+
r.repeatHeaderRow = idx < hdrCount ? import_core7.BooleanNumber.TRUE : import_core7.BooleanNumber.FALSE;
|
|
15955
|
+
});
|
|
15956
|
+
}
|
|
15957
|
+
}
|
|
15958
|
+
}
|
|
14624
15959
|
const remappedCellProps = {
|
|
14625
15960
|
...curMeta.tableCellProperties ?? {}
|
|
14626
15961
|
};
|
|
@@ -14705,6 +16040,8 @@ async function parseDocxBytesWithReport(bytes, title = "Imported Word Document")
|
|
|
14705
16040
|
...extraMeta.imageTransforms ? { imageTransforms: { ...curMeta.imageTransforms ?? {}, ...extraMeta.imageTransforms } } : {},
|
|
14706
16041
|
...extraMeta.printConfig ? { printConfig: { ...curMeta.printConfig ?? {}, ...extraMeta.printConfig } } : {},
|
|
14707
16042
|
...extraMeta.columnGroupConfig ? { columnGroupConfig: extraMeta.columnGroupConfig } : {},
|
|
16043
|
+
...Object.keys(remappedRowLoops).length > 0 ? { tableRowLoops: remappedRowLoops } : {},
|
|
16044
|
+
...Object.keys(remappedRepeatHeaders).length > 0 ? { tableRepeatHeaders: remappedRepeatHeaders } : {},
|
|
14708
16045
|
...extraMeta.repeatingSections ? { repeatingSections: extraMeta.repeatingSections } : {},
|
|
14709
16046
|
...extraMeta.tocConfig ? { tocConfig: extraMeta.tocConfig } : {},
|
|
14710
16047
|
...Array.isArray(extraMeta.docAreas) ? { docAreas: extraMeta.docAreas } : {},
|
|
@@ -14739,7 +16076,12 @@ async function parseDocxBytesWithReport(bytes, title = "Imported Word Document")
|
|
|
14739
16076
|
}
|
|
14740
16077
|
}
|
|
14741
16078
|
renumberDocNotesInPlace(docData);
|
|
14742
|
-
|
|
16079
|
+
normalizeDocDrawingsAndPluginResource(docData);
|
|
16080
|
+
const warnings = scanUnsupportedDocxFeatures(
|
|
16081
|
+
xml,
|
|
16082
|
+
warningsCounter.floatingImages,
|
|
16083
|
+
warningsCounter.dynamicFields ?? 0
|
|
16084
|
+
);
|
|
14743
16085
|
return {
|
|
14744
16086
|
documentData: docData,
|
|
14745
16087
|
warnings
|
|
@@ -14807,6 +16149,7 @@ function updateDocImageTransformInSnapshot(sourceSnapshot, drawingId, spec) {
|
|
|
14807
16149
|
[drawingId]: mergedTransform
|
|
14808
16150
|
}
|
|
14809
16151
|
});
|
|
16152
|
+
normalizeDocDrawingsAndPluginResource(nextSnapshot);
|
|
14810
16153
|
return nextSnapshot;
|
|
14811
16154
|
}
|
|
14812
16155
|
function getDocImageTransformFromSnapshot(snapshot, drawingId) {
|
|
@@ -15577,6 +16920,7 @@ function parseFieldInstrString(rawInstr) {
|
|
|
15577
16920
|
const allowed = [
|
|
15578
16921
|
"PAGE",
|
|
15579
16922
|
"NUMPAGES",
|
|
16923
|
+
"SECTIONPAGES",
|
|
15580
16924
|
"DATE",
|
|
15581
16925
|
"TIME",
|
|
15582
16926
|
"AUTHOR",
|
|
@@ -15598,7 +16942,8 @@ function evaluateSingleFieldValue(snapshot, fieldType, instructionArgs, seqCount
|
|
|
15598
16942
|
switch (fieldType) {
|
|
15599
16943
|
case "PAGE":
|
|
15600
16944
|
return String(context?.page ?? 1);
|
|
15601
|
-
case "NUMPAGES":
|
|
16945
|
+
case "NUMPAGES":
|
|
16946
|
+
case "SECTIONPAGES": {
|
|
15602
16947
|
if (typeof context?.numPages === "number") return String(context.numPages);
|
|
15603
16948
|
const stream = snapshot.body?.dataStream ?? "";
|
|
15604
16949
|
let breaks = 1;
|
|
@@ -15756,24 +17101,37 @@ function getDocCustomPropertiesFromSnapshot(snapshot) {
|
|
|
15756
17101
|
};
|
|
15757
17102
|
}
|
|
15758
17103
|
function listDocFields(snapshot) {
|
|
15759
|
-
const body = snapshot?.body;
|
|
15760
|
-
const stream = body?.dataStream ?? "";
|
|
15761
17104
|
const out = [];
|
|
15762
|
-
|
|
15763
|
-
|
|
15764
|
-
|
|
15765
|
-
|
|
15766
|
-
|
|
15767
|
-
|
|
15768
|
-
|
|
15769
|
-
|
|
15770
|
-
|
|
15771
|
-
|
|
15772
|
-
|
|
15773
|
-
|
|
17105
|
+
const scanStoryBody = (storyBody, segmentId) => {
|
|
17106
|
+
if (!storyBody) return;
|
|
17107
|
+
const stream = storyBody.dataStream ?? "";
|
|
17108
|
+
const items = [];
|
|
17109
|
+
for (const r of storyBody.customRanges ?? []) {
|
|
17110
|
+
const props = r.properties;
|
|
17111
|
+
if (props?.yudaoBlockKind === "docField" && props.field) {
|
|
17112
|
+
const f = props.field;
|
|
17113
|
+
const liveVal = stream.slice(r.startIndex, r.endIndex + 1).replace(/[\r\n\u0000-\u001F]/g, "");
|
|
17114
|
+
items.push({
|
|
17115
|
+
...import_core8.Tools.deepClone(f),
|
|
17116
|
+
id: r.rangeId,
|
|
17117
|
+
value: liveVal || f.value,
|
|
17118
|
+
...segmentId ? { segmentId } : {},
|
|
17119
|
+
startIndex: r.startIndex,
|
|
17120
|
+
endIndex: r.endIndex
|
|
17121
|
+
});
|
|
17122
|
+
}
|
|
15774
17123
|
}
|
|
17124
|
+
items.sort((a, b) => (a.startIndex ?? 0) - (b.startIndex ?? 0));
|
|
17125
|
+
out.push(...items);
|
|
17126
|
+
};
|
|
17127
|
+
scanStoryBody(snapshot?.body, void 0);
|
|
17128
|
+
for (const [hdrId, hdr] of Object.entries(snapshot?.headers ?? {})) {
|
|
17129
|
+
scanStoryBody(hdr?.body, hdrId);
|
|
15775
17130
|
}
|
|
15776
|
-
|
|
17131
|
+
for (const [ftrId, ftr] of Object.entries(snapshot?.footers ?? {})) {
|
|
17132
|
+
scanStoryBody(ftr?.body, ftrId);
|
|
17133
|
+
}
|
|
17134
|
+
return out;
|
|
15777
17135
|
}
|
|
15778
17136
|
function updateAllDocFieldsInSnapshot(snapshot, context) {
|
|
15779
17137
|
if (!snapshot.body) return false;
|
|
@@ -15783,7 +17141,8 @@ function updateAllDocFieldsInSnapshot(snapshot, context) {
|
|
|
15783
17141
|
const seqCounters = /* @__PURE__ */ new Map();
|
|
15784
17142
|
for (const fld of initialFields) {
|
|
15785
17143
|
if (fld.fieldType === "REF") continue;
|
|
15786
|
-
const liveBody = snapshot.
|
|
17144
|
+
const liveBody = resolveSegmentBodyInSnapshot(snapshot, fld.segmentId);
|
|
17145
|
+
if (!liveBody) continue;
|
|
15787
17146
|
const range = (liveBody.customRanges ?? []).find(
|
|
15788
17147
|
(r) => r.rangeId === fld.id && r.properties?.yudaoBlockKind === "docField"
|
|
15789
17148
|
);
|
|
@@ -15803,7 +17162,7 @@ function updateAllDocFieldsInSnapshot(snapshot, context) {
|
|
|
15803
17162
|
endIndex: range.startIndex + Math.max(0, nextVal.length - 1)
|
|
15804
17163
|
};
|
|
15805
17164
|
if (curVal !== nextVal) {
|
|
15806
|
-
|
|
17165
|
+
const nextBody = spliceDocumentBodySpan(
|
|
15807
17166
|
liveBody,
|
|
15808
17167
|
range.startIndex,
|
|
15809
17168
|
range.endIndex,
|
|
@@ -15814,9 +17173,10 @@ function updateAllDocFieldsInSnapshot(snapshot, context) {
|
|
|
15814
17173
|
yudaoBlockKind: "docField",
|
|
15815
17174
|
field: import_core8.Tools.deepClone(updatedEntry)
|
|
15816
17175
|
},
|
|
15817
|
-
textStyle: { cl: { rgb: "#2C53F1" }, bg: { rgb: "#F3F5FF" } }
|
|
17176
|
+
textStyle: fld.preserveStyle ? void 0 : { cl: { rgb: "#2C53F1" }, bg: { rgb: "#F3F5FF" } }
|
|
15818
17177
|
}
|
|
15819
17178
|
);
|
|
17179
|
+
writeSegmentBodyInSnapshot(snapshot, nextBody, fld.segmentId);
|
|
15820
17180
|
changed = true;
|
|
15821
17181
|
}
|
|
15822
17182
|
}
|
|
@@ -15830,7 +17190,8 @@ function updateAllDocFieldsInSnapshot(snapshot, context) {
|
|
|
15830
17190
|
}
|
|
15831
17191
|
for (const fld of listDocFields(snapshot)) {
|
|
15832
17192
|
if (fld.fieldType !== "REF") continue;
|
|
15833
|
-
const liveBody = snapshot.
|
|
17193
|
+
const liveBody = resolveSegmentBodyInSnapshot(snapshot, fld.segmentId);
|
|
17194
|
+
if (!liveBody) continue;
|
|
15834
17195
|
const range = (liveBody.customRanges ?? []).find(
|
|
15835
17196
|
(r) => r.rangeId === fld.id && r.properties?.yudaoBlockKind === "docField"
|
|
15836
17197
|
);
|
|
@@ -15850,7 +17211,7 @@ function updateAllDocFieldsInSnapshot(snapshot, context) {
|
|
|
15850
17211
|
endIndex: range.startIndex + Math.max(0, nextVal.length - 1)
|
|
15851
17212
|
};
|
|
15852
17213
|
if (curVal !== nextVal) {
|
|
15853
|
-
|
|
17214
|
+
const nextBody = spliceDocumentBodySpan(
|
|
15854
17215
|
liveBody,
|
|
15855
17216
|
range.startIndex,
|
|
15856
17217
|
range.endIndex,
|
|
@@ -15861,9 +17222,10 @@ function updateAllDocFieldsInSnapshot(snapshot, context) {
|
|
|
15861
17222
|
yudaoBlockKind: "docField",
|
|
15862
17223
|
field: import_core8.Tools.deepClone(updatedEntry)
|
|
15863
17224
|
},
|
|
15864
|
-
textStyle: { cl: { rgb: "#2C53F1" }, bg: { rgb: "#F3F5FF" } }
|
|
17225
|
+
textStyle: fld.preserveStyle ? void 0 : { cl: { rgb: "#2C53F1" }, bg: { rgb: "#F3F5FF" } }
|
|
15865
17226
|
}
|
|
15866
17227
|
);
|
|
17228
|
+
writeSegmentBodyInSnapshot(snapshot, nextBody, fld.segmentId);
|
|
15867
17229
|
changed = true;
|
|
15868
17230
|
}
|
|
15869
17231
|
}
|
|
@@ -21459,7 +22821,8 @@ var YUDAO_SDT_STORE_ID = "yudao-dataset-store";
|
|
|
21459
22821
|
var IDENT_PART = "[\\p{L}\\p{N}_-]+";
|
|
21460
22822
|
var PATH_PART = "[\\p{L}\\p{N}_.\\[\\]-]+";
|
|
21461
22823
|
var EXPLICIT_LIST_TOKEN_RE = new RegExp(`(?:\\$|#)\\{#(${IDENT_PART})\\.(${PATH_PART})\\}`, "gu");
|
|
21462
|
-
var
|
|
22824
|
+
var EXPLICIT_NESTED_LIST_TOKEN_RE = new RegExp(`(?:\\$|#)\\{#(${PATH_PART})\\}`, "gu");
|
|
22825
|
+
var ANY_CELL_TOKEN_RE = new RegExp(`(?:\\$|#)\\{(#?)(${PATH_PART})\\}`, "gu");
|
|
21463
22826
|
var INLINE_VALUE_TOKEN_RE = new RegExp(`(?:\\$|#)\\{(${PATH_PART})\\}`, "gu");
|
|
21464
22827
|
function resolvePathValue(source, path) {
|
|
21465
22828
|
if (!source || !path) return void 0;
|
|
@@ -21483,18 +22846,133 @@ function readDocTemplateMetadataFromSnapshot(snapshot) {
|
|
|
21483
22846
|
} catch {
|
|
21484
22847
|
return {};
|
|
21485
22848
|
}
|
|
21486
|
-
}
|
|
21487
|
-
function writeDocTemplateMetadataToSnapshot(snapshot, metadata) {
|
|
21488
|
-
const resources = [...snapshot.resources ?? []].filter((r) => r.name !== YUDAO_DOCS_TEMPLATE_RESOURCE);
|
|
21489
|
-
const hasContent = Boolean(metadata.datasets?.length) || Boolean(metadata.sampleData && Object.keys(metadata.sampleData).length > 0) || Boolean(metadata.tableRowLoops && Object.keys(metadata.tableRowLoops).length > 0) || metadata.trackChangesEnabled !== void 0 || Boolean(metadata.trackAuthor) || Boolean(metadata.revisions?.length) || Boolean(metadata.visibilityClauses?.length) || Boolean(metadata.activeRole) || Boolean(metadata.medicalFormulas && Object.keys(metadata.medicalFormulas).length > 0) || Boolean(metadata.codeBlocks?.length) || Boolean(metadata.barcodeBlocks && Object.keys(metadata.barcodeBlocks).length > 0) || Boolean(metadata.callouts?.length) || Boolean(metadata.quotes?.length) || Boolean(metadata.latexFormulas && Object.keys(metadata.latexFormulas).length > 0) || Boolean(metadata.inlineFormulas && Object.keys(metadata.inlineFormulas).length > 0) || Boolean(metadata.docCharts && Object.keys(metadata.docCharts).length > 0) || Boolean(metadata.docShapes && Object.keys(metadata.docShapes).length > 0) || Boolean(metadata.tableRepeatHeaders && Object.keys(metadata.tableRepeatHeaders).length > 0) || Boolean(metadata.repeatingSections && Object.keys(metadata.repeatingSections).length > 0) || Boolean(metadata.bookmarks?.length) || Boolean(metadata.tocConfig) || Boolean(metadata.paragraphBorders && Object.keys(metadata.paragraphBorders).length > 0) || Boolean(metadata.paragraphTabStops && Object.keys(metadata.paragraphTabStops).length > 0) || Boolean(metadata.paragraphPagination && Object.keys(metadata.paragraphPagination).length > 0) || Boolean(metadata.collapsedHeadings?.length) || Boolean(metadata.columnGroupConfig) || Boolean(metadata.sectionBreakTypes && Object.keys(metadata.sectionBreakTypes).length > 0) || Boolean(metadata.printConfig && Object.keys(metadata.printConfig).length > 0) || Boolean(metadata.imageTransforms && Object.keys(metadata.imageTransforms).length > 0) || Boolean(metadata.smartArts && Object.keys(metadata.smartArts).length > 0) || Boolean(metadata.docFields && Object.keys(metadata.docFields).length > 0) || Boolean(metadata.captions?.length) || Boolean(metadata.citationSources?.length) || Boolean(metadata.buildingBlocks?.length) || Boolean(metadata.docAreas?.length) || Boolean(metadata.mainBadge) || Boolean(metadata.labelBadges && Object.keys(metadata.labelBadges).length > 0) || Boolean(metadata.cascadeRules?.length) || Boolean(metadata.cascadeBaselines && Object.keys(metadata.cascadeBaselines).length > 0) || Boolean(metadata.cascadeHeadingBaselines && Object.keys(metadata.cascadeHeadingBaselines).length > 0) || Boolean(metadata.styledSeparators && Object.keys(metadata.styledSeparators).length > 0) || Boolean(metadata.embedBlocks && Object.keys(metadata.embedBlocks).length > 0) || Boolean(metadata.macros && Object.keys(metadata.macros).length > 0) || Boolean(metadata.graffitiStrokes?.length) || Boolean(metadata.sdtExtendedSpecs && Object.keys(metadata.sdtExtendedSpecs).length > 0) || Boolean(metadata.noteSettings) || Boolean(metadata.docNotes?.length) || Boolean(metadata.company) || Boolean(metadata.customProperties && Object.keys(metadata.customProperties).length > 0) || Boolean(metadata.copyPastePolicy && Object.keys(metadata.copyPastePolicy).length > 0) || Boolean(metadata.sectionOrientations && Object.keys(metadata.sectionOrientations).length > 0) || Boolean(metadata.actionMacros?.length) || Boolean(metadata.paragraphDirections && Object.keys(metadata.paragraphDirections).length > 0) || Boolean(metadata.tableDirections && Object.keys(metadata.tableDirections).length > 0) || Boolean(metadata.tableBorderPresets && Object.keys(metadata.tableBorderPresets).length > 0) || Boolean(metadata.tableCellProperties && Object.keys(metadata.tableCellProperties).length > 0) || Boolean(metadata.listDefinitions && Object.keys(metadata.listDefinitions).length > 0) || Boolean(metadata.listParagraphChecks && Object.keys(metadata.listParagraphChecks).length > 0) || Boolean(metadata.comments?.length) || Boolean(metadata.titleProperties && Object.keys(metadata.titleProperties).length > 0);
|
|
21490
|
-
if (hasContent) {
|
|
21491
|
-
resources.push({
|
|
21492
|
-
id: YUDAO_DOCS_TEMPLATE_RESOURCE,
|
|
21493
|
-
name: YUDAO_DOCS_TEMPLATE_RESOURCE,
|
|
21494
|
-
data: JSON.stringify(metadata)
|
|
21495
|
-
});
|
|
22849
|
+
}
|
|
22850
|
+
function writeDocTemplateMetadataToSnapshot(snapshot, metadata) {
|
|
22851
|
+
const resources = [...snapshot.resources ?? []].filter((r) => r.name !== YUDAO_DOCS_TEMPLATE_RESOURCE);
|
|
22852
|
+
const hasContent = Boolean(metadata.datasets?.length) || Boolean(metadata.sampleData && Object.keys(metadata.sampleData).length > 0) || Boolean(metadata.tableRowLoops && Object.keys(metadata.tableRowLoops).length > 0) || metadata.trackChangesEnabled !== void 0 || Boolean(metadata.trackAuthor) || Boolean(metadata.revisions?.length) || Boolean(metadata.visibilityClauses?.length) || Boolean(metadata.activeRole) || Boolean(metadata.medicalFormulas && Object.keys(metadata.medicalFormulas).length > 0) || Boolean(metadata.codeBlocks?.length) || Boolean(metadata.barcodeBlocks && Object.keys(metadata.barcodeBlocks).length > 0) || Boolean(metadata.callouts?.length) || Boolean(metadata.quotes?.length) || Boolean(metadata.latexFormulas && Object.keys(metadata.latexFormulas).length > 0) || Boolean(metadata.inlineFormulas && Object.keys(metadata.inlineFormulas).length > 0) || Boolean(metadata.docCharts && Object.keys(metadata.docCharts).length > 0) || Boolean(metadata.docShapes && Object.keys(metadata.docShapes).length > 0) || Boolean(metadata.tableRepeatHeaders && Object.keys(metadata.tableRepeatHeaders).length > 0) || Boolean(metadata.repeatingSections && Object.keys(metadata.repeatingSections).length > 0) || Boolean(metadata.bookmarks?.length) || Boolean(metadata.tocConfig) || Boolean(metadata.paragraphBorders && Object.keys(metadata.paragraphBorders).length > 0) || Boolean(metadata.paragraphTabStops && Object.keys(metadata.paragraphTabStops).length > 0) || Boolean(metadata.paragraphPagination && Object.keys(metadata.paragraphPagination).length > 0) || Boolean(metadata.collapsedHeadings?.length) || Boolean(metadata.columnGroupConfig) || Boolean(metadata.sectionBreakTypes && Object.keys(metadata.sectionBreakTypes).length > 0) || Boolean(metadata.printConfig && Object.keys(metadata.printConfig).length > 0) || Boolean(metadata.imageTransforms && Object.keys(metadata.imageTransforms).length > 0) || Boolean(metadata.smartArts && Object.keys(metadata.smartArts).length > 0) || Boolean(metadata.docFields && Object.keys(metadata.docFields).length > 0) || Boolean(metadata.captions?.length) || Boolean(metadata.citationSources?.length) || Boolean(metadata.buildingBlocks?.length) || Boolean(metadata.docAreas?.length) || Boolean(metadata.mainBadge) || Boolean(metadata.labelBadges && Object.keys(metadata.labelBadges).length > 0) || Boolean(metadata.cascadeRules?.length) || Boolean(metadata.cascadeBaselines && Object.keys(metadata.cascadeBaselines).length > 0) || Boolean(metadata.cascadeHeadingBaselines && Object.keys(metadata.cascadeHeadingBaselines).length > 0) || Boolean(metadata.styledSeparators && Object.keys(metadata.styledSeparators).length > 0) || Boolean(metadata.embedBlocks && Object.keys(metadata.embedBlocks).length > 0) || Boolean(metadata.macros && Object.keys(metadata.macros).length > 0) || Boolean(metadata.graffitiStrokes?.length) || Boolean(metadata.sdtExtendedSpecs && Object.keys(metadata.sdtExtendedSpecs).length > 0) || Boolean(metadata.noteSettings) || Boolean(metadata.docNotes?.length) || Boolean(metadata.company) || Boolean(metadata.customProperties && Object.keys(metadata.customProperties).length > 0) || Boolean(metadata.copyPastePolicy && Object.keys(metadata.copyPastePolicy).length > 0) || Boolean(metadata.sectionOrientations && Object.keys(metadata.sectionOrientations).length > 0) || Boolean(metadata.actionMacros?.length) || Boolean(metadata.paragraphDirections && Object.keys(metadata.paragraphDirections).length > 0) || Boolean(metadata.tableDirections && Object.keys(metadata.tableDirections).length > 0) || Boolean(metadata.tableBorderPresets && Object.keys(metadata.tableBorderPresets).length > 0) || Boolean(metadata.tableCellProperties && Object.keys(metadata.tableCellProperties).length > 0) || Boolean(metadata.listDefinitions && Object.keys(metadata.listDefinitions).length > 0) || Boolean(metadata.listParagraphChecks && Object.keys(metadata.listParagraphChecks).length > 0) || Boolean(metadata.comments?.length) || Boolean(metadata.titleProperties && Object.keys(metadata.titleProperties).length > 0);
|
|
22853
|
+
if (hasContent) {
|
|
22854
|
+
resources.push({
|
|
22855
|
+
id: YUDAO_DOCS_TEMPLATE_RESOURCE,
|
|
22856
|
+
name: YUDAO_DOCS_TEMPLATE_RESOURCE,
|
|
22857
|
+
data: JSON.stringify(metadata)
|
|
22858
|
+
});
|
|
22859
|
+
}
|
|
22860
|
+
snapshot.resources = resources;
|
|
22861
|
+
return snapshot;
|
|
22862
|
+
}
|
|
22863
|
+
var WRAP_TEXT_STRING_TO_CODE = {
|
|
22864
|
+
bothSides: 0,
|
|
22865
|
+
left: 1,
|
|
22866
|
+
right: 2,
|
|
22867
|
+
largest: 3
|
|
22868
|
+
};
|
|
22869
|
+
function normalizeDocDrawingsAndPluginResource(snapshot) {
|
|
22870
|
+
if (!snapshot || typeof snapshot !== "object") return snapshot;
|
|
22871
|
+
for (const segMap of [snapshot.headers, snapshot.footers]) {
|
|
22872
|
+
if (!segMap || typeof segMap !== "object") continue;
|
|
22873
|
+
for (const seg of Object.values(segMap)) {
|
|
22874
|
+
const segTables = seg?.body?.tables;
|
|
22875
|
+
if (!Array.isArray(segTables) || segTables.length === 0) continue;
|
|
22876
|
+
for (const tbl of segTables) {
|
|
22877
|
+
const tid = tbl?.tableId;
|
|
22878
|
+
if (!tid) continue;
|
|
22879
|
+
if (snapshot.tableSource?.[tid] && !seg.tableSource?.[tid]) {
|
|
22880
|
+
seg.tableSource = { ...seg.tableSource ?? {}, [tid]: import_core13.Tools.deepClone(snapshot.tableSource[tid]) };
|
|
22881
|
+
} else if (seg.tableSource?.[tid] && !snapshot.tableSource?.[tid]) {
|
|
22882
|
+
snapshot.tableSource = {
|
|
22883
|
+
...snapshot.tableSource ?? {},
|
|
22884
|
+
[tid]: import_core13.Tools.deepClone(seg.tableSource[tid])
|
|
22885
|
+
};
|
|
22886
|
+
}
|
|
22887
|
+
}
|
|
22888
|
+
}
|
|
22889
|
+
}
|
|
22890
|
+
const existingResources = snapshot.resources;
|
|
22891
|
+
const pluginIdx = Array.isArray(existingResources) ? existingResources.findIndex((r) => r.name === DOC_DRAWING_PLUGIN_RESOURCE) : -1;
|
|
22892
|
+
let parsedPlugin;
|
|
22893
|
+
if (pluginIdx >= 0 && existingResources?.[pluginIdx]?.data) {
|
|
22894
|
+
try {
|
|
22895
|
+
const raw = JSON.parse(existingResources[pluginIdx].data);
|
|
22896
|
+
if (raw && typeof raw === "object") {
|
|
22897
|
+
parsedPlugin = raw;
|
|
22898
|
+
}
|
|
22899
|
+
} catch {
|
|
22900
|
+
parsedPlugin = void 0;
|
|
22901
|
+
}
|
|
22902
|
+
}
|
|
22903
|
+
const snapDrawings = snapshot.drawings && typeof snapshot.drawings === "object" ? snapshot.drawings : void 0;
|
|
22904
|
+
const snapKeys = Object.keys(snapDrawings ?? {});
|
|
22905
|
+
const pluginData = parsedPlugin?.data && typeof parsedPlugin.data === "object" ? parsedPlugin.data : {};
|
|
22906
|
+
const pluginKeys = Object.keys(pluginData);
|
|
22907
|
+
if (snapKeys.length === 0 && pluginKeys.length === 0) {
|
|
22908
|
+
if (pluginIdx >= 0 && Array.isArray(existingResources)) {
|
|
22909
|
+
snapshot.resources = existingResources.filter((r) => r.name !== DOC_DRAWING_PLUGIN_RESOURCE);
|
|
22910
|
+
}
|
|
22911
|
+
return snapshot;
|
|
22912
|
+
}
|
|
22913
|
+
const mergedDrawings = snapKeys.length > 0 ? { ...import_core13.Tools.deepClone(pluginData), ...import_core13.Tools.deepClone(snapDrawings) } : import_core13.Tools.deepClone(pluginData);
|
|
22914
|
+
const hfBlockIds = /* @__PURE__ */ new Set();
|
|
22915
|
+
for (const hdr of Object.values(snapshot.headers ?? {})) {
|
|
22916
|
+
for (const blk of hdr?.body?.customBlocks ?? []) {
|
|
22917
|
+
if (blk?.blockId) hfBlockIds.add(blk.blockId);
|
|
22918
|
+
}
|
|
22919
|
+
}
|
|
22920
|
+
for (const ftr of Object.values(snapshot.footers ?? {})) {
|
|
22921
|
+
for (const blk of ftr?.body?.customBlocks ?? []) {
|
|
22922
|
+
if (blk?.blockId) hfBlockIds.add(blk.blockId);
|
|
22923
|
+
}
|
|
22924
|
+
}
|
|
22925
|
+
const unitId = typeof snapshot.id === "string" && snapshot.id.length > 0 ? snapshot.id : void 0;
|
|
22926
|
+
for (const [drawingId, drw] of Object.entries(mergedDrawings)) {
|
|
22927
|
+
if (!drw || typeof drw !== "object") continue;
|
|
22928
|
+
drw.drawingId = drw.drawingId || drawingId;
|
|
22929
|
+
if (unitId) {
|
|
22930
|
+
drw.unitId = unitId;
|
|
22931
|
+
drw.subUnitId = unitId;
|
|
22932
|
+
}
|
|
22933
|
+
if (typeof drw.wrapText === "string" && drw.wrapText in WRAP_TEXT_STRING_TO_CODE) {
|
|
22934
|
+
drw.wrapText = WRAP_TEXT_STRING_TO_CODE[drw.wrapText];
|
|
22935
|
+
}
|
|
22936
|
+
if (drw.docTransform && typeof drw.docTransform === "object" && typeof drw.docTransform.wrapText === "string" && drw.docTransform.wrapText in WRAP_TEXT_STRING_TO_CODE) {
|
|
22937
|
+
drw.docTransform.wrapText = WRAP_TEXT_STRING_TO_CODE[drw.docTransform.wrapText];
|
|
22938
|
+
}
|
|
22939
|
+
if (hfBlockIds.has(drawingId)) {
|
|
22940
|
+
drw.isMultiTransform = import_core13.BooleanNumber.TRUE;
|
|
22941
|
+
drw.transforms = Array.isArray(drw.transforms) && drw.transforms.length > 0 ? drw.transforms : drw.transform ? [import_core13.Tools.deepClone(drw.transform)] : [];
|
|
22942
|
+
}
|
|
22943
|
+
}
|
|
22944
|
+
snapshot.drawings = mergedDrawings;
|
|
22945
|
+
const seedOrder = Array.isArray(snapshot.drawingsOrder) && snapshot.drawingsOrder.length > 0 ? snapshot.drawingsOrder : Array.isArray(parsedPlugin?.order) ? parsedPlugin.order : [];
|
|
22946
|
+
const seenOrder = /* @__PURE__ */ new Set();
|
|
22947
|
+
const normalizedOrder = [];
|
|
22948
|
+
for (const id of seedOrder) {
|
|
22949
|
+
if (typeof id === "string" && id in mergedDrawings && !seenOrder.has(id)) {
|
|
22950
|
+
seenOrder.add(id);
|
|
22951
|
+
normalizedOrder.push(id);
|
|
22952
|
+
}
|
|
22953
|
+
}
|
|
22954
|
+
for (const id of Object.keys(mergedDrawings)) {
|
|
22955
|
+
if (!seenOrder.has(id)) {
|
|
22956
|
+
seenOrder.add(id);
|
|
22957
|
+
normalizedOrder.push(id);
|
|
22958
|
+
}
|
|
21496
22959
|
}
|
|
21497
|
-
snapshot.
|
|
22960
|
+
snapshot.drawingsOrder = normalizedOrder;
|
|
22961
|
+
const serializedPluginEntry = {
|
|
22962
|
+
id: DOC_DRAWING_PLUGIN_RESOURCE,
|
|
22963
|
+
name: DOC_DRAWING_PLUGIN_RESOURCE,
|
|
22964
|
+
data: JSON.stringify({
|
|
22965
|
+
data: snapshot.drawings,
|
|
22966
|
+
order: snapshot.drawingsOrder
|
|
22967
|
+
})
|
|
22968
|
+
};
|
|
22969
|
+
const nextResources = [...existingResources ?? []];
|
|
22970
|
+
if (pluginIdx >= 0) {
|
|
22971
|
+
nextResources[pluginIdx] = serializedPluginEntry;
|
|
22972
|
+
} else {
|
|
22973
|
+
nextResources.push(serializedPluginEntry);
|
|
22974
|
+
}
|
|
22975
|
+
snapshot.resources = nextResources;
|
|
21498
22976
|
return snapshot;
|
|
21499
22977
|
}
|
|
21500
22978
|
function getLocalTodayIso() {
|
|
@@ -21585,7 +23063,56 @@ function stripSdtAffixes(rawText, spec) {
|
|
|
21585
23063
|
}
|
|
21586
23064
|
return text;
|
|
21587
23065
|
}
|
|
21588
|
-
var SDT_CHROME_TEXT_COLORS = /* @__PURE__ */ new Set(["#7d8698", "#4e5565", "#2c53f1", "#1b1c1f"]);
|
|
23066
|
+
var SDT_CHROME_TEXT_COLORS = /* @__PURE__ */ new Set(["#7d8698", "#9ca3af", "#4e5565", "#2c53f1", "#1b1c1f"]);
|
|
23067
|
+
var SDT_CHROME_BG_COLORS = /* @__PURE__ */ new Set(["#f3f5ff", "#eeeff1", "#eff6ff"]);
|
|
23068
|
+
function sanitizeLoopCellRunStyle(ts, anchorTypo) {
|
|
23069
|
+
if (!ts && !anchorTypo) return void 0;
|
|
23070
|
+
const out = {
|
|
23071
|
+
...ts ? import_core13.Tools.deepClone(ts) : {},
|
|
23072
|
+
...anchorTypo ? import_core13.Tools.deepClone(anchorTypo) : {}
|
|
23073
|
+
};
|
|
23074
|
+
const bgRgb = out.bg?.rgb?.trim().toLowerCase();
|
|
23075
|
+
if (bgRgb && SDT_CHROME_BG_COLORS.has(bgRgb)) {
|
|
23076
|
+
delete out.bg;
|
|
23077
|
+
}
|
|
23078
|
+
const clRgb = out.cl?.rgb?.trim().toLowerCase();
|
|
23079
|
+
if (clRgb && !anchorTypo?.cl?.rgb && SDT_CHROME_TEXT_COLORS.has(clRgb) && clRgb !== "#1b1c1f") {
|
|
23080
|
+
delete out.cl;
|
|
23081
|
+
}
|
|
23082
|
+
if (out.bl === 0 && anchorTypo?.bl === void 0 && (!ts || ts.bl === 0)) {
|
|
23083
|
+
delete out.bl;
|
|
23084
|
+
}
|
|
23085
|
+
return Object.keys(out).length > 0 ? out : void 0;
|
|
23086
|
+
}
|
|
23087
|
+
function stripDocEditorChromeForView(snapshot) {
|
|
23088
|
+
const cloned = import_core13.Tools.deepClone(snapshot);
|
|
23089
|
+
const cleanBody = (body) => {
|
|
23090
|
+
if (!body?.customRanges?.length || !body.textRuns?.length) return;
|
|
23091
|
+
for (const r of body.customRanges) {
|
|
23092
|
+
if (r.rangeType !== import_core13.CustomRangeType.SDT) continue;
|
|
23093
|
+
const resolved = parseSdtRangeToResolved(body, r);
|
|
23094
|
+
if (!resolved || resolved.showingPlaceholder || resolved.matchedHighlight || resolved.invalidHighlight) {
|
|
23095
|
+
continue;
|
|
23096
|
+
}
|
|
23097
|
+
if (resolved.visualChrome === "highlight") continue;
|
|
23098
|
+
for (const tr of body.textRuns) {
|
|
23099
|
+
if (tr.ed <= r.startIndex || tr.st > r.endIndex || !tr.ts) continue;
|
|
23100
|
+
const bgRgb = tr.ts.bg?.rgb?.trim().toLowerCase();
|
|
23101
|
+
if (bgRgb && SDT_CHROME_BG_COLORS.has(bgRgb)) {
|
|
23102
|
+
delete tr.ts.bg;
|
|
23103
|
+
}
|
|
23104
|
+
const clRgb = tr.ts.cl?.rgb?.trim().toLowerCase();
|
|
23105
|
+
if (clRgb === "#7d8698" || clRgb === "#9ca3af") {
|
|
23106
|
+
tr.ts.cl = { rgb: "#1b1c1f" };
|
|
23107
|
+
}
|
|
23108
|
+
}
|
|
23109
|
+
}
|
|
23110
|
+
};
|
|
23111
|
+
cleanBody(cloned.body);
|
|
23112
|
+
for (const h of Object.values(cloned.headers ?? {})) cleanBody(h?.body);
|
|
23113
|
+
for (const f of Object.values(cloned.footers ?? {})) cleanBody(f?.body);
|
|
23114
|
+
return cloned;
|
|
23115
|
+
}
|
|
21589
23116
|
function extractAnchorTypography(ts) {
|
|
21590
23117
|
if (!ts) return void 0;
|
|
21591
23118
|
const out = {};
|
|
@@ -21594,6 +23121,20 @@ function extractAnchorTypography(ts) {
|
|
|
21594
23121
|
out.ff = ts.ff;
|
|
21595
23122
|
has = true;
|
|
21596
23123
|
}
|
|
23124
|
+
if (ts.eastAsiaFontFamily !== void 0) {
|
|
23125
|
+
out.eastAsiaFontFamily = ts.eastAsiaFontFamily;
|
|
23126
|
+
has = true;
|
|
23127
|
+
}
|
|
23128
|
+
if (ts.fontHint !== void 0) {
|
|
23129
|
+
out.fontHint = ts.fontHint;
|
|
23130
|
+
has = true;
|
|
23131
|
+
}
|
|
23132
|
+
if (ts.yudaoRFonts !== void 0) {
|
|
23133
|
+
out.yudaoRFonts = import_core13.Tools.deepClone(
|
|
23134
|
+
ts.yudaoRFonts
|
|
23135
|
+
);
|
|
23136
|
+
has = true;
|
|
23137
|
+
}
|
|
21597
23138
|
if (ts.fs !== void 0) {
|
|
21598
23139
|
out.fs = ts.fs;
|
|
21599
23140
|
has = true;
|
|
@@ -22834,6 +24375,15 @@ function applyPictureOrSignatureSdtValueInSnapshot(snapshot, ctrl, rawImageValue
|
|
|
22834
24375
|
textStyle: style
|
|
22835
24376
|
});
|
|
22836
24377
|
writeSegmentBodyInSnapshot(snapshot, nextBody2, targetSegId);
|
|
24378
|
+
if (prevBlockId && snapshot.drawings && prevBlockId in snapshot.drawings) {
|
|
24379
|
+
const nextDrawings = { ...snapshot.drawings };
|
|
24380
|
+
delete nextDrawings[prevBlockId];
|
|
24381
|
+
snapshot.drawings = nextDrawings;
|
|
24382
|
+
if (Array.isArray(snapshot.drawingsOrder)) {
|
|
24383
|
+
snapshot.drawingsOrder = snapshot.drawingsOrder.filter((id) => id !== prevBlockId);
|
|
24384
|
+
}
|
|
24385
|
+
normalizeDocDrawingsAndPluginResource(snapshot);
|
|
24386
|
+
}
|
|
22837
24387
|
return true;
|
|
22838
24388
|
}
|
|
22839
24389
|
const blockId = prevBlockId || `sdt_img_${ctrl.id}`;
|
|
@@ -22895,6 +24445,7 @@ function applyPictureOrSignatureSdtValueInSnapshot(snapshot, ctrl, rawImageValue
|
|
|
22895
24445
|
const order = [...snapshot.drawingsOrder ?? []];
|
|
22896
24446
|
if (!order.includes(blockId)) order.push(blockId);
|
|
22897
24447
|
snapshot.drawingsOrder = order;
|
|
24448
|
+
normalizeDocDrawingsAndPluginResource(snapshot);
|
|
22898
24449
|
return true;
|
|
22899
24450
|
}
|
|
22900
24451
|
function parseTableRowsInStream(dataStream, tableStartIndex, tableEndExclusive) {
|
|
@@ -22989,21 +24540,178 @@ function listDocTables(snapshot) {
|
|
|
22989
24540
|
};
|
|
22990
24541
|
});
|
|
22991
24542
|
}
|
|
22992
|
-
function
|
|
22993
|
-
|
|
22994
|
-
|
|
24543
|
+
function resolveCandidateListPrefix(expr, data, fallbackFirstSegment) {
|
|
24544
|
+
const clean = expr.replace(/^#/, "");
|
|
24545
|
+
const dotPositions = [];
|
|
24546
|
+
for (let i = clean.length - 1; i > 0; i--) {
|
|
24547
|
+
if (clean[i] === ".") dotPositions.push(i);
|
|
24548
|
+
}
|
|
24549
|
+
if (dotPositions.length === 0) return "";
|
|
24550
|
+
for (const pos of dotPositions) {
|
|
24551
|
+
const cand = clean.slice(0, pos);
|
|
24552
|
+
const val = resolvePathValue(data, cand) ?? data?.[cand];
|
|
24553
|
+
if (Array.isArray(val)) return cand;
|
|
24554
|
+
}
|
|
24555
|
+
if (fallbackFirstSegment) {
|
|
24556
|
+
for (const pos of dotPositions) {
|
|
24557
|
+
const cand = clean.slice(0, pos);
|
|
24558
|
+
const val = resolvePathValue(data, cand);
|
|
24559
|
+
if (val === null || val === void 0 && Object.prototype.hasOwnProperty.call(data, cand)) {
|
|
24560
|
+
return cand;
|
|
24561
|
+
}
|
|
24562
|
+
const dotInCand = cand.lastIndexOf(".");
|
|
24563
|
+
if (dotInCand > 0) {
|
|
24564
|
+
const parentObj = resolvePathValue(data, cand.slice(0, dotInCand));
|
|
24565
|
+
const leafKey = cand.slice(dotInCand + 1);
|
|
24566
|
+
if (parentObj && typeof parentObj === "object" && Object.prototype.hasOwnProperty.call(parentObj, leafKey) && !(typeof parentObj[leafKey] === "object" && parentObj[leafKey] !== null && !Array.isArray(parentObj[leafKey]))) {
|
|
24567
|
+
return cand;
|
|
24568
|
+
}
|
|
24569
|
+
}
|
|
24570
|
+
}
|
|
24571
|
+
return clean.slice(0, dotPositions[dotPositions.length - 1]);
|
|
24572
|
+
}
|
|
24573
|
+
return "";
|
|
24574
|
+
}
|
|
24575
|
+
function replaceRowCellTokens(rawCellText, listKey, itemObj, rowSeqIndex, rootData, hasExplicitListKey = false) {
|
|
24576
|
+
return rawCellText.replace(ANY_CELL_TOKEN_RE, (full, hashPrefix, expr) => {
|
|
24577
|
+
const cleanExpr = expr.trim();
|
|
24578
|
+
if (cleanExpr === `${listKey}._index`) {
|
|
24579
|
+
return itemObj ? String(rowSeqIndex + 1) : "";
|
|
24580
|
+
}
|
|
24581
|
+
if (cleanExpr.startsWith(`${listKey}.`)) {
|
|
22995
24582
|
if (!itemObj) return "";
|
|
24583
|
+
const fieldPath = cleanExpr.slice(listKey.length + 1);
|
|
22996
24584
|
if (fieldPath === "_index") return String(rowSeqIndex + 1);
|
|
22997
24585
|
const val = resolvePathValue(itemObj, fieldPath);
|
|
22998
24586
|
return val == null ? "" : String(val);
|
|
22999
24587
|
}
|
|
23000
|
-
|
|
23001
|
-
|
|
23002
|
-
return String(
|
|
24588
|
+
if (hasExplicitListKey) {
|
|
24589
|
+
if (!itemObj) return "";
|
|
24590
|
+
if (cleanExpr === "_index") return String(rowSeqIndex + 1);
|
|
24591
|
+
const itemVal = resolvePathValue(itemObj, cleanExpr);
|
|
24592
|
+
if (itemVal !== void 0) {
|
|
24593
|
+
return itemVal == null ? "" : String(itemVal);
|
|
24594
|
+
}
|
|
24595
|
+
const rootVal = resolvePathValue(rootData, cleanExpr);
|
|
24596
|
+
if (rootVal !== void 0 && rootVal !== null && typeof rootVal !== "object") {
|
|
24597
|
+
return String(rootVal);
|
|
24598
|
+
}
|
|
24599
|
+
return "";
|
|
24600
|
+
}
|
|
24601
|
+
if (!hashPrefix) {
|
|
24602
|
+
const rootVal = resolvePathValue(rootData, cleanExpr);
|
|
24603
|
+
if (rootVal !== void 0 && rootVal !== null && typeof rootVal !== "object") {
|
|
24604
|
+
return String(rootVal);
|
|
24605
|
+
}
|
|
23003
24606
|
}
|
|
23004
24607
|
return full;
|
|
23005
24608
|
});
|
|
23006
24609
|
}
|
|
24610
|
+
function renderLoopCellContent(body, cell, cellSdts, detectedListKey, itemObj, rowSeqIndex, rootData, hasExplicitListKey) {
|
|
24611
|
+
if (cellSdts.length === 0) {
|
|
24612
|
+
return replaceRowCellTokens(
|
|
24613
|
+
cell.rawText,
|
|
24614
|
+
detectedListKey,
|
|
24615
|
+
itemObj,
|
|
24616
|
+
rowSeqIndex,
|
|
24617
|
+
rootData,
|
|
24618
|
+
hasExplicitListKey
|
|
24619
|
+
);
|
|
24620
|
+
}
|
|
24621
|
+
let out = "";
|
|
24622
|
+
let cursor = cell.contentStart;
|
|
24623
|
+
for (const { range, resolved } of cellSdts) {
|
|
24624
|
+
if (range.startIndex < cursor) continue;
|
|
24625
|
+
if (range.startIndex > cursor) {
|
|
24626
|
+
const pre = body.dataStream.slice(cursor, range.startIndex);
|
|
24627
|
+
out += replaceRowCellTokens(
|
|
24628
|
+
pre,
|
|
24629
|
+
detectedListKey,
|
|
24630
|
+
itemObj,
|
|
24631
|
+
rowSeqIndex,
|
|
24632
|
+
rootData,
|
|
24633
|
+
hasExplicitListKey
|
|
24634
|
+
);
|
|
24635
|
+
}
|
|
24636
|
+
if (itemObj === null) {
|
|
24637
|
+
out += "";
|
|
24638
|
+
} else {
|
|
24639
|
+
const candidates = [resolved.bindingPath, resolved.tag].filter(
|
|
24640
|
+
(c) => typeof c === "string" && c.trim().length > 0
|
|
24641
|
+
);
|
|
24642
|
+
let matched = false;
|
|
24643
|
+
let rawVal = void 0;
|
|
24644
|
+
for (const rawCand of candidates) {
|
|
24645
|
+
const cand = rawCand.trim().replace(/^#/, "");
|
|
24646
|
+
if (cand === `${detectedListKey}._index`) {
|
|
24647
|
+
rawVal = String(rowSeqIndex + 1);
|
|
24648
|
+
matched = true;
|
|
24649
|
+
break;
|
|
24650
|
+
}
|
|
24651
|
+
if (cand.startsWith(`${detectedListKey}.`)) {
|
|
24652
|
+
const subPath = cand.slice(detectedListKey.length + 1);
|
|
24653
|
+
rawVal = subPath === "_index" ? String(rowSeqIndex + 1) : resolvePathValue(itemObj, subPath);
|
|
24654
|
+
matched = true;
|
|
24655
|
+
break;
|
|
24656
|
+
}
|
|
24657
|
+
}
|
|
24658
|
+
if (!matched) {
|
|
24659
|
+
for (const rawCand of candidates) {
|
|
24660
|
+
const cand = rawCand.trim().replace(/^#/, "");
|
|
24661
|
+
if (cand === "_index") {
|
|
24662
|
+
rawVal = String(rowSeqIndex + 1);
|
|
24663
|
+
matched = true;
|
|
24664
|
+
break;
|
|
24665
|
+
}
|
|
24666
|
+
const directItemVal = resolvePathValue(itemObj, cand);
|
|
24667
|
+
if (directItemVal !== void 0) {
|
|
24668
|
+
rawVal = directItemVal;
|
|
24669
|
+
matched = true;
|
|
24670
|
+
break;
|
|
24671
|
+
}
|
|
24672
|
+
}
|
|
24673
|
+
}
|
|
24674
|
+
if (!matched) {
|
|
24675
|
+
for (const rawCand of candidates) {
|
|
24676
|
+
const cand = rawCand.trim().replace(/^#/, "");
|
|
24677
|
+
const rootVal = resolvePathValue(rootData, cand);
|
|
24678
|
+
if (rootVal !== void 0 && rootVal !== null && typeof rootVal !== "object") {
|
|
24679
|
+
rawVal = rootVal;
|
|
24680
|
+
matched = true;
|
|
24681
|
+
break;
|
|
24682
|
+
}
|
|
24683
|
+
}
|
|
24684
|
+
}
|
|
24685
|
+
if (!matched && hasExplicitListKey) {
|
|
24686
|
+
rawVal = "";
|
|
24687
|
+
matched = true;
|
|
24688
|
+
}
|
|
24689
|
+
if (!matched) {
|
|
24690
|
+
out += resolved.showingPlaceholder ? "" : resolved.displayText;
|
|
24691
|
+
} else if (typeof rawVal === "boolean") {
|
|
24692
|
+
out += formatSdtDisplayText(resolved, rawVal).text;
|
|
24693
|
+
} else if (rawVal == null || String(rawVal) === "") {
|
|
24694
|
+
out += "";
|
|
24695
|
+
} else {
|
|
24696
|
+
const strVal = Array.isArray(rawVal) ? rawVal.join(",") : String(rawVal);
|
|
24697
|
+
out += formatSdtDisplayText(resolved, strVal).text;
|
|
24698
|
+
}
|
|
24699
|
+
}
|
|
24700
|
+
cursor = Math.min(cell.textEndExclusive, range.endIndex + 1);
|
|
24701
|
+
}
|
|
24702
|
+
if (cursor < cell.textEndExclusive) {
|
|
24703
|
+
const tail = body.dataStream.slice(cursor, cell.textEndExclusive);
|
|
24704
|
+
out += replaceRowCellTokens(
|
|
24705
|
+
tail,
|
|
24706
|
+
detectedListKey,
|
|
24707
|
+
itemObj,
|
|
24708
|
+
rowSeqIndex,
|
|
24709
|
+
rootData,
|
|
24710
|
+
hasExplicitListKey
|
|
24711
|
+
);
|
|
24712
|
+
}
|
|
24713
|
+
return out;
|
|
24714
|
+
}
|
|
23007
24715
|
function expandDocTableRowLoopsInPlace(nextSnapshot, data, explicitLoops) {
|
|
23008
24716
|
const body = nextSnapshot.body;
|
|
23009
24717
|
if (!body?.tables?.length) return;
|
|
@@ -23012,92 +24720,226 @@ function expandDocTableRowLoopsInPlace(nextSnapshot, data, explicitLoops) {
|
|
|
23012
24720
|
...snapMeta.tableRowLoops ?? {},
|
|
23013
24721
|
...explicitLoops ?? {}
|
|
23014
24722
|
};
|
|
24723
|
+
const consumedLoopKeys = /* @__PURE__ */ new Set();
|
|
24724
|
+
let metaChanged = false;
|
|
23015
24725
|
for (let tIdx = body.tables.length - 1; tIdx >= 0; tIdx--) {
|
|
23016
24726
|
const tblRef = body.tables[tIdx];
|
|
23017
24727
|
const parsedRows = parseTableRowsInStream(body.dataStream, tblRef.startIndex, tblRef.endIndex);
|
|
23018
24728
|
if (parsedRows.length === 0) continue;
|
|
23019
24729
|
const tblSource = nextSnapshot.tableSource?.[tblRef.tableId];
|
|
24730
|
+
let remainingRowCount = parsedRows.length;
|
|
23020
24731
|
for (let rIdx = parsedRows.length - 1; rIdx >= 0; rIdx--) {
|
|
23021
24732
|
const rowSpan = parsedRows[rIdx];
|
|
23022
|
-
const
|
|
23023
|
-
|
|
24733
|
+
const loopKey = `${tblRef.tableId}:${rIdx}`;
|
|
24734
|
+
const explicitCfg = loopMap[loopKey];
|
|
24735
|
+
const hasExplicitListKey = Boolean(explicitCfg?.listKey?.trim());
|
|
24736
|
+
const rowCellSdts = rowSpan.cells.map((cell) => {
|
|
24737
|
+
const hits = [];
|
|
24738
|
+
for (const r of body.customRanges ?? []) {
|
|
24739
|
+
if (r.rangeType === import_core13.CustomRangeType.SDT && r.startIndex >= cell.contentStart && r.endIndex < cell.textEndExclusive) {
|
|
24740
|
+
const parsed = parseSdtRangeToResolved(body, r);
|
|
24741
|
+
if (parsed && parsed.kind !== "group") {
|
|
24742
|
+
hits.push({ range: r, resolved: parsed });
|
|
24743
|
+
}
|
|
24744
|
+
}
|
|
24745
|
+
}
|
|
24746
|
+
return hits.sort((a, b) => a.range.startIndex - b.range.startIndex);
|
|
24747
|
+
});
|
|
24748
|
+
let detectedListKey = explicitCfg?.listKey?.trim() ?? "";
|
|
23024
24749
|
if (!detectedListKey) {
|
|
23025
24750
|
const joinedCells = rowSpan.cells.map((c) => c.rawText).join(" ");
|
|
23026
|
-
|
|
23027
|
-
const explicitMatch =
|
|
23028
|
-
if (explicitMatch) {
|
|
23029
|
-
detectedListKey = explicitMatch[1];
|
|
23030
|
-
}
|
|
23031
|
-
|
|
24751
|
+
EXPLICIT_NESTED_LIST_TOKEN_RE.lastIndex = 0;
|
|
24752
|
+
const explicitMatch = EXPLICIT_NESTED_LIST_TOKEN_RE.exec(joinedCells);
|
|
24753
|
+
if (explicitMatch && explicitMatch[1].includes(".")) {
|
|
24754
|
+
detectedListKey = resolveCandidateListPrefix(explicitMatch[1], data, true);
|
|
24755
|
+
}
|
|
24756
|
+
if (!detectedListKey) {
|
|
24757
|
+
ANY_CELL_TOKEN_RE.lastIndex = 0;
|
|
23032
24758
|
let tokMatch;
|
|
23033
|
-
while ((tokMatch =
|
|
23034
|
-
const
|
|
23035
|
-
if (
|
|
23036
|
-
|
|
24759
|
+
while ((tokMatch = ANY_CELL_TOKEN_RE.exec(joinedCells)) !== null) {
|
|
24760
|
+
const expr = tokMatch[2];
|
|
24761
|
+
if (!expr.includes(".")) continue;
|
|
24762
|
+
const cand = resolveCandidateListPrefix(expr, data, false);
|
|
24763
|
+
if (cand) {
|
|
24764
|
+
detectedListKey = cand;
|
|
23037
24765
|
break;
|
|
23038
24766
|
}
|
|
23039
24767
|
}
|
|
23040
24768
|
}
|
|
24769
|
+
if (!detectedListKey) {
|
|
24770
|
+
for (const cellSdts of rowCellSdts) {
|
|
24771
|
+
for (const { resolved } of cellSdts) {
|
|
24772
|
+
for (const rawCand of [resolved.bindingPath, resolved.tag]) {
|
|
24773
|
+
if (rawCand && rawCand.includes(".")) {
|
|
24774
|
+
const cand = resolveCandidateListPrefix(rawCand, data, false);
|
|
24775
|
+
if (cand) {
|
|
24776
|
+
detectedListKey = cand;
|
|
24777
|
+
break;
|
|
24778
|
+
}
|
|
24779
|
+
}
|
|
24780
|
+
}
|
|
24781
|
+
if (detectedListKey) break;
|
|
24782
|
+
}
|
|
24783
|
+
if (detectedListKey) break;
|
|
24784
|
+
}
|
|
24785
|
+
}
|
|
23041
24786
|
}
|
|
23042
24787
|
if (!detectedListKey) continue;
|
|
23043
|
-
|
|
24788
|
+
consumedLoopKeys.add(loopKey);
|
|
24789
|
+
const rawItems = resolvePathValue(data, detectedListKey) ?? data?.[detectedListKey];
|
|
23044
24790
|
const items = Array.isArray(rawItems) ? rawItems : [];
|
|
23045
24791
|
const emptyStrategy = explicitCfg?.emptyStrategy ?? "keep-blank";
|
|
23046
24792
|
const repeatHeader = explicitCfg?.repeatHeaderRow ?? true;
|
|
23047
|
-
if (
|
|
23048
|
-
tblSource
|
|
23049
|
-
|
|
23050
|
-
|
|
23051
|
-
|
|
23052
|
-
|
|
24793
|
+
if (explicitCfg?.repeatHeaderRow === false) {
|
|
24794
|
+
if (tblSource?.tableRows) {
|
|
24795
|
+
const upper = Math.max(1, rIdx);
|
|
24796
|
+
for (let h = 0; h < upper && h < tblSource.tableRows.length; h++) {
|
|
24797
|
+
tblSource.tableRows[h] = {
|
|
24798
|
+
...tblSource.tableRows[h],
|
|
24799
|
+
repeatHeaderRow: import_core13.BooleanNumber.FALSE
|
|
24800
|
+
};
|
|
24801
|
+
}
|
|
24802
|
+
}
|
|
24803
|
+
if (snapMeta.tableRepeatHeaders && tblRef.tableId in snapMeta.tableRepeatHeaders) {
|
|
24804
|
+
delete snapMeta.tableRepeatHeaders[tblRef.tableId];
|
|
24805
|
+
metaChanged = true;
|
|
24806
|
+
}
|
|
24807
|
+
} else if (repeatHeader && rIdx > 0 && tblSource?.tableRows) {
|
|
24808
|
+
for (let h = 0; h < rIdx && h < tblSource.tableRows.length; h++) {
|
|
24809
|
+
tblSource.tableRows[h] = {
|
|
24810
|
+
...tblSource.tableRows[h],
|
|
24811
|
+
...h === 0 ? { isFirstRow: import_core13.BooleanNumber.TRUE } : {},
|
|
24812
|
+
repeatHeaderRow: import_core13.BooleanNumber.TRUE
|
|
24813
|
+
};
|
|
24814
|
+
}
|
|
23053
24815
|
}
|
|
23054
|
-
if (items.length === 0 && emptyStrategy === "remove" &&
|
|
24816
|
+
if (items.length === 0 && emptyStrategy === "remove" && remainingRowCount > 1) {
|
|
24817
|
+
remainingRowCount--;
|
|
23055
24818
|
const removeStart = rowSpan.rowStart;
|
|
23056
24819
|
const removeEnd = rowSpan.rowEndInclusive;
|
|
23057
|
-
const
|
|
23058
|
-
|
|
23059
|
-
body.
|
|
24820
|
+
const rowEndExclusive2 = removeEnd + 1;
|
|
24821
|
+
const removedLen = rowEndExclusive2 - removeStart;
|
|
24822
|
+
body.dataStream = body.dataStream.slice(0, removeStart) + body.dataStream.slice(rowEndExclusive2);
|
|
24823
|
+
body.paragraphs = (body.paragraphs ?? []).filter((p) => p.startIndex < removeStart || p.startIndex >= rowEndExclusive2).map((p) => ({
|
|
23060
24824
|
...p,
|
|
23061
|
-
startIndex: p.startIndex
|
|
24825
|
+
startIndex: p.startIndex >= rowEndExclusive2 ? p.startIndex - removedLen : p.startIndex
|
|
23062
24826
|
}));
|
|
23063
|
-
body.sectionBreaks = (body.sectionBreaks ?? []).filter((s) => s.startIndex < removeStart || s.startIndex
|
|
24827
|
+
body.sectionBreaks = (body.sectionBreaks ?? []).filter((s) => s.startIndex < removeStart || s.startIndex >= rowEndExclusive2).map((s) => ({
|
|
23064
24828
|
...s,
|
|
23065
|
-
startIndex: s.startIndex
|
|
24829
|
+
startIndex: s.startIndex >= rowEndExclusive2 ? s.startIndex - removedLen : s.startIndex
|
|
23066
24830
|
}));
|
|
23067
|
-
body.customBlocks = (body.customBlocks ?? []).filter((b) => b.startIndex < removeStart || b.startIndex
|
|
24831
|
+
body.customBlocks = (body.customBlocks ?? []).filter((b) => b.startIndex < removeStart || b.startIndex >= rowEndExclusive2).map((b) => ({
|
|
23068
24832
|
...b,
|
|
23069
|
-
startIndex: b.startIndex
|
|
24833
|
+
startIndex: b.startIndex >= rowEndExclusive2 ? b.startIndex - removedLen : b.startIndex
|
|
23070
24834
|
}));
|
|
23071
|
-
|
|
23072
|
-
|
|
23073
|
-
|
|
23074
|
-
|
|
23075
|
-
|
|
23076
|
-
|
|
24835
|
+
const nextRangesOnRemove = [];
|
|
24836
|
+
for (const r of body.customRanges ?? []) {
|
|
24837
|
+
if (r.endIndex < removeStart) {
|
|
24838
|
+
nextRangesOnRemove.push(r);
|
|
24839
|
+
} else if (r.startIndex >= rowEndExclusive2) {
|
|
24840
|
+
nextRangesOnRemove.push({
|
|
24841
|
+
...r,
|
|
24842
|
+
startIndex: r.startIndex - removedLen,
|
|
24843
|
+
endIndex: r.endIndex - removedLen
|
|
24844
|
+
});
|
|
24845
|
+
} else if (r.startIndex < removeStart && r.endIndex >= rowEndExclusive2) {
|
|
24846
|
+
nextRangesOnRemove.push({
|
|
24847
|
+
...r,
|
|
24848
|
+
endIndex: r.endIndex - removedLen
|
|
24849
|
+
});
|
|
24850
|
+
}
|
|
24851
|
+
}
|
|
24852
|
+
body.customRanges = nextRangesOnRemove;
|
|
24853
|
+
const nextRunsOnRemove = [];
|
|
24854
|
+
for (const tr of body.textRuns ?? []) {
|
|
24855
|
+
if (tr.ed <= removeStart) {
|
|
24856
|
+
nextRunsOnRemove.push(tr);
|
|
24857
|
+
} else if (tr.st >= rowEndExclusive2) {
|
|
24858
|
+
nextRunsOnRemove.push({ ...tr, st: tr.st - removedLen, ed: tr.ed - removedLen });
|
|
24859
|
+
} else if (tr.st < removeStart && tr.ed > rowEndExclusive2) {
|
|
24860
|
+
nextRunsOnRemove.push({ ...tr, ed: tr.ed - removedLen });
|
|
24861
|
+
} else if (tr.st < removeStart) {
|
|
24862
|
+
nextRunsOnRemove.push({ ...tr, ed: removeStart });
|
|
24863
|
+
} else if (tr.ed > rowEndExclusive2) {
|
|
24864
|
+
nextRunsOnRemove.push({ ...tr, st: removeStart, ed: tr.ed - removedLen });
|
|
24865
|
+
}
|
|
24866
|
+
}
|
|
24867
|
+
body.textRuns = nextRunsOnRemove.filter((r) => r.ed > r.st);
|
|
23077
24868
|
body.tables = body.tables.map((t, idx) => {
|
|
23078
|
-
if (idx === tIdx
|
|
23079
|
-
|
|
24869
|
+
if (idx === tIdx || t.startIndex <= removeStart && t.endIndex >= rowEndExclusive2) {
|
|
24870
|
+
return { ...t, endIndex: t.endIndex - removedLen };
|
|
24871
|
+
}
|
|
24872
|
+
if (t.startIndex >= rowEndExclusive2) {
|
|
23080
24873
|
return { ...t, startIndex: t.startIndex - removedLen, endIndex: t.endIndex - removedLen };
|
|
23081
24874
|
}
|
|
23082
24875
|
return t;
|
|
23083
24876
|
});
|
|
23084
24877
|
if (tblSource?.tableRows?.[rIdx]) {
|
|
23085
24878
|
tblSource.tableRows.splice(rIdx, 1);
|
|
24879
|
+
if (rIdx === 0 && tblSource.tableRows[0]) {
|
|
24880
|
+
tblSource.tableRows[0] = { ...tblSource.tableRows[0], isFirstRow: import_core13.BooleanNumber.TRUE };
|
|
24881
|
+
}
|
|
24882
|
+
}
|
|
24883
|
+
if (snapMeta.tableCellProperties) {
|
|
24884
|
+
const tblPrefix = `${tblRef.tableId}:`;
|
|
24885
|
+
const hasTblCellProps = Object.keys(snapMeta.tableCellProperties).some(
|
|
24886
|
+
(k) => k.startsWith(tblPrefix)
|
|
24887
|
+
);
|
|
24888
|
+
if (hasTblCellProps) {
|
|
24889
|
+
const shiftedCellProps = {};
|
|
24890
|
+
for (const [k, v] of Object.entries(snapMeta.tableCellProperties)) {
|
|
24891
|
+
if (!k.startsWith(tblPrefix)) {
|
|
24892
|
+
shiftedCellProps[k] = v;
|
|
24893
|
+
continue;
|
|
24894
|
+
}
|
|
24895
|
+
const rest = k.slice(tblPrefix.length);
|
|
24896
|
+
const sepIdx = rest.indexOf(":");
|
|
24897
|
+
if (sepIdx <= 0) {
|
|
24898
|
+
shiftedCellProps[k] = v;
|
|
24899
|
+
continue;
|
|
24900
|
+
}
|
|
24901
|
+
const oldRow = Number(rest.slice(0, sepIdx));
|
|
24902
|
+
const colPart = rest.slice(sepIdx + 1);
|
|
24903
|
+
if (!Number.isFinite(oldRow) || oldRow === rIdx) {
|
|
24904
|
+
continue;
|
|
24905
|
+
}
|
|
24906
|
+
const newRow = oldRow > rIdx ? oldRow - 1 : oldRow;
|
|
24907
|
+
shiftedCellProps[`${tblPrefix}${newRow}:${colPart}`] = v;
|
|
24908
|
+
}
|
|
24909
|
+
snapMeta.tableCellProperties = shiftedCellProps;
|
|
24910
|
+
metaChanged = true;
|
|
24911
|
+
}
|
|
23086
24912
|
}
|
|
23087
24913
|
continue;
|
|
23088
24914
|
}
|
|
23089
24915
|
const effectiveRows = items.length > 0 ? items : [null];
|
|
23090
|
-
|
|
24916
|
+
remainingRowCount += effectiveRows.length - 1;
|
|
24917
|
+
const effectiveEmptyStrategy = emptyStrategy === "remove" ? "keep-blank" : emptyStrategy;
|
|
24918
|
+
const cellStyles = rowSpan.cells.map((cell, cIdx) => {
|
|
24919
|
+
const cellSdts = rowCellSdts[cIdx];
|
|
24920
|
+
const nonSdtRun = (body.textRuns ?? []).find((tr) => {
|
|
24921
|
+
if (tr.ed <= cell.contentStart || tr.st >= cell.textEndExclusive) return false;
|
|
24922
|
+
return !cellSdts.some((s) => tr.st >= s.range.startIndex && tr.ed <= s.range.endIndex + 1);
|
|
24923
|
+
});
|
|
24924
|
+
if (nonSdtRun?.ts) {
|
|
24925
|
+
return sanitizeLoopCellRunStyle(nonSdtRun.ts);
|
|
24926
|
+
}
|
|
24927
|
+
const anchorTypo = cellSdts.length > 0 ? resolveRangeAnchorTypography(body, cellSdts[0].range) : void 0;
|
|
23091
24928
|
const hitRun = (body.textRuns ?? []).find(
|
|
23092
24929
|
(tr) => tr.st <= cell.contentStart && tr.ed > cell.contentStart
|
|
23093
24930
|
);
|
|
23094
|
-
return hitRun?.ts;
|
|
24931
|
+
return sanitizeLoopCellRunStyle(hitRun?.ts, anchorTypo);
|
|
23095
24932
|
});
|
|
23096
24933
|
const templateCellParas = rowSpan.cells.map(
|
|
23097
|
-
(cell) => (body.paragraphs ?? []).
|
|
24934
|
+
(cell) => (body.paragraphs ?? []).filter(
|
|
23098
24935
|
(p) => p.startIndex >= cell.contentStart && p.startIndex < cell.cellEndInclusive
|
|
23099
24936
|
)
|
|
23100
24937
|
);
|
|
24938
|
+
const templateCellSections = rowSpan.cells.map(
|
|
24939
|
+
(cell) => (body.sectionBreaks ?? []).find(
|
|
24940
|
+
(s) => s.startIndex >= cell.contentStart && s.startIndex < cell.cellEndInclusive
|
|
24941
|
+
)
|
|
24942
|
+
);
|
|
23101
24943
|
let builtStream = "";
|
|
23102
24944
|
const builtParas = [];
|
|
23103
24945
|
const builtSections = [];
|
|
@@ -23107,34 +24949,53 @@ function expandDocTableRowLoopsInPlace(nextSnapshot, data, explicitLoops) {
|
|
|
23107
24949
|
builtStream += import_core13.DataStreamTreeTokenType.TABLE_ROW_START;
|
|
23108
24950
|
rowSpan.cells.forEach((cell, cIdx) => {
|
|
23109
24951
|
builtStream += import_core13.DataStreamTreeTokenType.TABLE_CELL_START;
|
|
23110
|
-
|
|
23111
|
-
|
|
23112
|
-
|
|
23113
|
-
cellText = cIdx === 0 ? explicitCfg?.emptyPlaceholderText || "\u6682\u65E0\u660E\u7EC6\u6570\u636E" : "";
|
|
24952
|
+
let rawRendered;
|
|
24953
|
+
if (itemObj === null && effectiveEmptyStrategy === "placeholder") {
|
|
24954
|
+
rawRendered = cIdx === 0 ? explicitCfg?.emptyPlaceholderText || "\u6682\u65E0\u660E\u7EC6\u6570\u636E" : "";
|
|
23114
24955
|
} else {
|
|
23115
|
-
|
|
24956
|
+
rawRendered = renderLoopCellContent(
|
|
24957
|
+
body,
|
|
24958
|
+
cell,
|
|
24959
|
+
rowCellSdts[cIdx],
|
|
24960
|
+
detectedListKey,
|
|
24961
|
+
itemObj,
|
|
24962
|
+
cloneIdx,
|
|
24963
|
+
data,
|
|
24964
|
+
hasExplicitListKey
|
|
24965
|
+
);
|
|
23116
24966
|
}
|
|
23117
|
-
|
|
23118
|
-
const
|
|
23119
|
-
|
|
23120
|
-
|
|
23121
|
-
|
|
23122
|
-
|
|
23123
|
-
|
|
24967
|
+
const normalizedCellText = rawRendered.replace(/\r\n/g, "\r").replace(/\n/g, "\r");
|
|
24968
|
+
const cellLines = normalizedCellText.split("\r");
|
|
24969
|
+
const tplParasInCell = templateCellParas[cIdx];
|
|
24970
|
+
const fallbackTplPara = tplParasInCell.length > 0 ? tplParasInCell[tplParasInCell.length - 1] : void 0;
|
|
24971
|
+
cellLines.forEach((lineText, lineIdx) => {
|
|
24972
|
+
const lineStart = baseInsertOffset + builtStream.length;
|
|
24973
|
+
builtStream += lineText;
|
|
24974
|
+
const lineEnd = baseInsertOffset + builtStream.length;
|
|
24975
|
+
if (cellStyles[cIdx] && lineEnd > lineStart) {
|
|
24976
|
+
builtRuns.push({
|
|
24977
|
+
st: lineStart,
|
|
24978
|
+
ed: lineEnd,
|
|
24979
|
+
ts: import_core13.Tools.deepClone(cellStyles[cIdx])
|
|
24980
|
+
});
|
|
24981
|
+
}
|
|
24982
|
+
const pOffset = baseInsertOffset + builtStream.length;
|
|
24983
|
+
builtStream += import_core13.DataStreamTreeTokenType.PARAGRAPH;
|
|
24984
|
+
const tplPara = tplParasInCell[lineIdx] ?? fallbackTplPara;
|
|
24985
|
+
const isFinalLine = lineIdx === cellLines.length - 1;
|
|
24986
|
+
const deterministicParaId = cloneIdx === 0 && tplParasInCell[lineIdx]?.paragraphId ? tplParasInCell[lineIdx].paragraphId : cloneIdx === 0 && isFinalLine && fallbackTplPara?.paragraphId && cellLines.length === 1 ? fallbackTplPara.paragraphId : isFinalLine && cellLines.length === 1 ? `p_loop_${tblRef.tableId}_r${rIdx}_${cloneIdx}_c${cIdx}` : `p_loop_${tblRef.tableId}_r${rIdx}_${cloneIdx}_c${cIdx}_m${lineIdx}`;
|
|
24987
|
+
builtParas.push({
|
|
24988
|
+
...tplPara ? import_core13.Tools.deepClone(tplPara) : {},
|
|
24989
|
+
paragraphId: deterministicParaId,
|
|
24990
|
+
startIndex: pOffset
|
|
23124
24991
|
});
|
|
23125
|
-
}
|
|
23126
|
-
const pOffset = baseInsertOffset + builtStream.length;
|
|
23127
|
-
builtStream += import_core13.DataStreamTreeTokenType.PARAGRAPH;
|
|
23128
|
-
const tplPara = templateCellParas[cIdx];
|
|
23129
|
-
builtParas.push({
|
|
23130
|
-
...tplPara ? import_core13.Tools.deepClone(tplPara) : {},
|
|
23131
|
-
paragraphId: cloneIdx === 0 && tplPara?.paragraphId ? tplPara.paragraphId : `p_tr_${(0, import_core13.generateRandomId)(6)}`,
|
|
23132
|
-
startIndex: pOffset
|
|
23133
24992
|
});
|
|
23134
24993
|
const sOffset = baseInsertOffset + builtStream.length;
|
|
23135
24994
|
builtStream += import_core13.DataStreamTreeTokenType.SECTION_BREAK;
|
|
24995
|
+
const tplSec = templateCellSections[cIdx];
|
|
23136
24996
|
builtSections.push({
|
|
23137
|
-
|
|
24997
|
+
...tplSec ? import_core13.Tools.deepClone(tplSec) : {},
|
|
24998
|
+
sectionId: cloneIdx === 0 && tplSec?.sectionId ? tplSec.sectionId : `s_loop_${tblRef.tableId}_r${rIdx}_${cloneIdx}_c${cIdx}`,
|
|
23138
24999
|
startIndex: sOffset
|
|
23139
25000
|
});
|
|
23140
25001
|
builtStream += import_core13.DataStreamTreeTokenType.TABLE_CELL_END;
|
|
@@ -23143,57 +25004,141 @@ function expandDocTableRowLoopsInPlace(nextSnapshot, data, explicitLoops) {
|
|
|
23143
25004
|
});
|
|
23144
25005
|
const oldStart = rowSpan.rowStart;
|
|
23145
25006
|
const oldEnd = rowSpan.rowEndInclusive;
|
|
23146
|
-
const
|
|
25007
|
+
const rowEndExclusive = oldEnd + 1;
|
|
25008
|
+
const oldLen = rowEndExclusive - oldStart;
|
|
23147
25009
|
const delta = builtStream.length - oldLen;
|
|
23148
|
-
body.dataStream = body.dataStream.slice(0, oldStart) + builtStream + body.dataStream.slice(
|
|
25010
|
+
body.dataStream = body.dataStream.slice(0, oldStart) + builtStream + body.dataStream.slice(rowEndExclusive);
|
|
23149
25011
|
body.paragraphs = [
|
|
23150
25012
|
...(body.paragraphs ?? []).filter((p) => p.startIndex < oldStart),
|
|
23151
25013
|
...builtParas,
|
|
23152
|
-
...(body.paragraphs ?? []).filter((p) => p.startIndex
|
|
25014
|
+
...(body.paragraphs ?? []).filter((p) => p.startIndex >= rowEndExclusive).map((p) => ({ ...p, startIndex: p.startIndex + delta }))
|
|
23153
25015
|
].sort((a, b) => a.startIndex - b.startIndex);
|
|
23154
25016
|
body.sectionBreaks = [
|
|
23155
25017
|
...(body.sectionBreaks ?? []).filter((s) => s.startIndex < oldStart),
|
|
23156
25018
|
...builtSections,
|
|
23157
|
-
...(body.sectionBreaks ?? []).filter((s) => s.startIndex
|
|
25019
|
+
...(body.sectionBreaks ?? []).filter((s) => s.startIndex >= rowEndExclusive).map((s) => ({ ...s, startIndex: s.startIndex + delta }))
|
|
23158
25020
|
].sort((a, b) => a.startIndex - b.startIndex);
|
|
23159
|
-
body.customBlocks = (body.customBlocks ?? []).map(
|
|
23160
|
-
(b) => b.startIndex
|
|
23161
|
-
);
|
|
23162
|
-
body.customRanges = (body.customRanges ?? []).filter((r) => r.endIndex < oldStart || r.startIndex > oldEnd).map(
|
|
23163
|
-
(r) => r.startIndex > oldEnd ? { ...r, startIndex: r.startIndex + delta, endIndex: r.endIndex + delta } : r
|
|
25021
|
+
body.customBlocks = (body.customBlocks ?? []).filter((b) => b.startIndex < oldStart || b.startIndex >= rowEndExclusive).map(
|
|
25022
|
+
(b) => b.startIndex >= rowEndExclusive ? { ...b, startIndex: b.startIndex + delta } : b
|
|
23164
25023
|
);
|
|
25024
|
+
const nextCustomRanges = [];
|
|
25025
|
+
for (const r of body.customRanges ?? []) {
|
|
25026
|
+
if (r.endIndex < oldStart) {
|
|
25027
|
+
nextCustomRanges.push(r);
|
|
25028
|
+
} else if (r.startIndex >= rowEndExclusive) {
|
|
25029
|
+
nextCustomRanges.push({
|
|
25030
|
+
...r,
|
|
25031
|
+
startIndex: r.startIndex + delta,
|
|
25032
|
+
endIndex: r.endIndex + delta
|
|
25033
|
+
});
|
|
25034
|
+
} else if (r.startIndex < oldStart && r.endIndex >= rowEndExclusive) {
|
|
25035
|
+
nextCustomRanges.push({
|
|
25036
|
+
...r,
|
|
25037
|
+
endIndex: r.endIndex + delta
|
|
25038
|
+
});
|
|
25039
|
+
}
|
|
25040
|
+
}
|
|
25041
|
+
body.customRanges = nextCustomRanges;
|
|
23165
25042
|
const nextRuns = [];
|
|
23166
25043
|
for (const tr of body.textRuns ?? []) {
|
|
23167
25044
|
if (tr.ed <= oldStart) {
|
|
23168
25045
|
nextRuns.push(tr);
|
|
23169
|
-
} else if (tr.st
|
|
25046
|
+
} else if (tr.st >= rowEndExclusive) {
|
|
23170
25047
|
nextRuns.push({ ...tr, st: tr.st + delta, ed: tr.ed + delta });
|
|
23171
|
-
} else
|
|
23172
|
-
|
|
25048
|
+
} else {
|
|
25049
|
+
if (tr.st < oldStart) {
|
|
25050
|
+
nextRuns.push({ ...tr, ed: oldStart });
|
|
25051
|
+
}
|
|
25052
|
+
if (tr.ed > rowEndExclusive) {
|
|
25053
|
+
nextRuns.push({
|
|
25054
|
+
...tr,
|
|
25055
|
+
st: oldStart + builtStream.length,
|
|
25056
|
+
ed: tr.ed + delta
|
|
25057
|
+
});
|
|
25058
|
+
}
|
|
23173
25059
|
}
|
|
23174
25060
|
}
|
|
23175
25061
|
nextRuns.push(...builtRuns);
|
|
23176
25062
|
nextRuns.sort((a, b) => a.st - b.st || a.ed - b.ed);
|
|
23177
25063
|
body.textRuns = nextRuns.filter((r) => r.ed > r.st);
|
|
23178
25064
|
body.tables = body.tables.map((t, idx) => {
|
|
23179
|
-
if (idx === tIdx
|
|
23180
|
-
|
|
25065
|
+
if (idx === tIdx || t.startIndex <= oldStart && t.endIndex >= rowEndExclusive) {
|
|
25066
|
+
return { ...t, endIndex: t.endIndex + delta };
|
|
25067
|
+
}
|
|
25068
|
+
if (t.startIndex >= rowEndExclusive) {
|
|
23181
25069
|
return { ...t, startIndex: t.startIndex + delta, endIndex: t.endIndex + delta };
|
|
23182
25070
|
}
|
|
23183
25071
|
return t;
|
|
23184
25072
|
});
|
|
23185
25073
|
if (tblSource?.tableRows?.[rIdx]) {
|
|
23186
25074
|
const tplRow = tblSource.tableRows[rIdx];
|
|
23187
|
-
const clonedRowDefs = effectiveRows.map(() => {
|
|
25075
|
+
const clonedRowDefs = effectiveRows.map((_, cloneIdx) => {
|
|
23188
25076
|
const cloned = import_core13.Tools.deepClone(tplRow);
|
|
23189
|
-
cloned.isFirstRow = import_core13.BooleanNumber.FALSE;
|
|
25077
|
+
cloned.isFirstRow = rIdx === 0 && cloneIdx === 0 ? import_core13.BooleanNumber.TRUE : import_core13.BooleanNumber.FALSE;
|
|
23190
25078
|
cloned.repeatHeaderRow = import_core13.BooleanNumber.FALSE;
|
|
23191
25079
|
return cloned;
|
|
23192
25080
|
});
|
|
23193
25081
|
tblSource.tableRows.splice(rIdx, 1, ...clonedRowDefs);
|
|
23194
25082
|
}
|
|
25083
|
+
if (snapMeta.tableCellProperties && effectiveRows.length !== 1) {
|
|
25084
|
+
const tblPrefix = `${tblRef.tableId}:`;
|
|
25085
|
+
const hasTblCellProps = Object.keys(snapMeta.tableCellProperties).some(
|
|
25086
|
+
(k) => k.startsWith(tblPrefix)
|
|
25087
|
+
);
|
|
25088
|
+
if (hasTblCellProps) {
|
|
25089
|
+
const rowDelta = effectiveRows.length - 1;
|
|
25090
|
+
const shiftedCellProps = {};
|
|
25091
|
+
const tplRowCellProps = [];
|
|
25092
|
+
for (const [k, v] of Object.entries(snapMeta.tableCellProperties)) {
|
|
25093
|
+
if (!k.startsWith(tblPrefix)) {
|
|
25094
|
+
shiftedCellProps[k] = v;
|
|
25095
|
+
continue;
|
|
25096
|
+
}
|
|
25097
|
+
const rest = k.slice(tblPrefix.length);
|
|
25098
|
+
const sepIdx = rest.indexOf(":");
|
|
25099
|
+
if (sepIdx <= 0) {
|
|
25100
|
+
shiftedCellProps[k] = v;
|
|
25101
|
+
continue;
|
|
25102
|
+
}
|
|
25103
|
+
const oldRow = Number(rest.slice(0, sepIdx));
|
|
25104
|
+
const colPart = rest.slice(sepIdx + 1);
|
|
25105
|
+
if (!Number.isFinite(oldRow)) {
|
|
25106
|
+
shiftedCellProps[k] = v;
|
|
25107
|
+
continue;
|
|
25108
|
+
}
|
|
25109
|
+
if (oldRow === rIdx) {
|
|
25110
|
+
tplRowCellProps.push({ colPart, prop: v });
|
|
25111
|
+
} else if (oldRow > rIdx) {
|
|
25112
|
+
shiftedCellProps[`${tblPrefix}${oldRow + rowDelta}:${colPart}`] = v;
|
|
25113
|
+
} else {
|
|
25114
|
+
shiftedCellProps[k] = v;
|
|
25115
|
+
}
|
|
25116
|
+
}
|
|
25117
|
+
for (let cloneIdx = 0; cloneIdx < effectiveRows.length; cloneIdx++) {
|
|
25118
|
+
for (const { colPart, prop } of tplRowCellProps) {
|
|
25119
|
+
shiftedCellProps[`${tblPrefix}${rIdx + cloneIdx}:${colPart}`] = import_core13.Tools.deepClone(prop);
|
|
25120
|
+
}
|
|
25121
|
+
}
|
|
25122
|
+
snapMeta.tableCellProperties = shiftedCellProps;
|
|
25123
|
+
metaChanged = true;
|
|
25124
|
+
}
|
|
25125
|
+
}
|
|
23195
25126
|
}
|
|
23196
25127
|
}
|
|
25128
|
+
if (consumedLoopKeys.size > 0 || metaChanged) {
|
|
25129
|
+
const nextLoops = { ...snapMeta.tableRowLoops ?? {} };
|
|
25130
|
+
for (const k of consumedLoopKeys) {
|
|
25131
|
+
delete nextLoops[k];
|
|
25132
|
+
}
|
|
25133
|
+
const nextRepeatHeaders = snapMeta.tableRepeatHeaders ? { ...snapMeta.tableRepeatHeaders } : void 0;
|
|
25134
|
+
const nextCellProps = snapMeta.tableCellProperties ? { ...snapMeta.tableCellProperties } : void 0;
|
|
25135
|
+
writeDocTemplateMetadataToSnapshot(nextSnapshot, {
|
|
25136
|
+
...snapMeta,
|
|
25137
|
+
tableRowLoops: Object.keys(nextLoops).length > 0 ? nextLoops : void 0,
|
|
25138
|
+
tableRepeatHeaders: nextRepeatHeaders && Object.keys(nextRepeatHeaders).length > 0 ? nextRepeatHeaders : void 0,
|
|
25139
|
+
tableCellProperties: nextCellProps && Object.keys(nextCellProps).length > 0 ? nextCellProps : void 0
|
|
25140
|
+
});
|
|
25141
|
+
}
|
|
23197
25142
|
}
|
|
23198
25143
|
function parseIsoDateForExpr(raw) {
|
|
23199
25144
|
if (raw == null) return null;
|
|
@@ -23284,6 +25229,7 @@ function evaluateVisibleIfCondition(expr, data) {
|
|
|
23284
25229
|
function fillDatasetIntoDocSnapshot(snapshot, data, options) {
|
|
23285
25230
|
const nextSnapshot = import_core13.Tools.deepClone(snapshot);
|
|
23286
25231
|
if (!nextSnapshot.body) return nextSnapshot;
|
|
25232
|
+
const cleanFilledChrome = options?.cleanFilledChrome !== false;
|
|
23287
25233
|
expandDocTableRowLoopsInPlace(nextSnapshot, data, options?.tableRowLoops);
|
|
23288
25234
|
const controls = listDocSdtControls(nextSnapshot);
|
|
23289
25235
|
for (const ctrl of controls) {
|
|
@@ -23340,7 +25286,7 @@ function fillDatasetIntoDocSnapshot(snapshot, data, options) {
|
|
|
23340
25286
|
false,
|
|
23341
25287
|
true,
|
|
23342
25288
|
void 0,
|
|
23343
|
-
ctrl.visualChrome,
|
|
25289
|
+
cleanFilledChrome ? ctrl.visualChrome ?? "clean" : ctrl.visualChrome,
|
|
23344
25290
|
anchorTypo
|
|
23345
25291
|
);
|
|
23346
25292
|
const updatedSegBody2 = spliceMultiParagraphBodySpan(
|
|
@@ -23365,13 +25311,14 @@ function fillDatasetIntoDocSnapshot(snapshot, data, options) {
|
|
|
23365
25311
|
normalizedValue
|
|
23366
25312
|
);
|
|
23367
25313
|
const matchedHighlight = !showingPlaceholder ? matchSdtHighlightRule(ctrl.highlightRules, `${text} ${String(normalizedValue)}`) : void 0;
|
|
25314
|
+
const effectiveChrome = !showingPlaceholder && cleanFilledChrome ? ctrl.visualChrome ?? "clean" : ctrl.visualChrome;
|
|
23368
25315
|
const style = computeSdtVisualStyle(
|
|
23369
25316
|
ctrl.kind,
|
|
23370
25317
|
ctrl.lock,
|
|
23371
25318
|
showingPlaceholder,
|
|
23372
25319
|
Boolean(ctrl.bindingPath),
|
|
23373
25320
|
matchedHighlight,
|
|
23374
|
-
|
|
25321
|
+
effectiveChrome,
|
|
23375
25322
|
anchorTypo,
|
|
23376
25323
|
{
|
|
23377
25324
|
underlineBlank: ctrl.underlineBlank,
|
|
@@ -23417,7 +25364,7 @@ function fillDatasetIntoDocSnapshot(snapshot, data, options) {
|
|
|
23417
25364
|
const pStart = matchedParaIdx === 0 ? 0 : paras[matchedParaIdx - 1].startIndex + 1;
|
|
23418
25365
|
const pEnd = paras[matchedParaIdx].startIndex;
|
|
23419
25366
|
const rawLine = workingBody.dataStream.slice(pStart, pEnd);
|
|
23420
|
-
const rawArr = data[listKey];
|
|
25367
|
+
const rawArr = resolvePathValue(data, listKey) ?? data[listKey];
|
|
23421
25368
|
const items = Array.isArray(rawArr) ? rawArr : [];
|
|
23422
25369
|
const expandedLines = (items.length > 0 ? items : [{}]).map(
|
|
23423
25370
|
(itemObj, idx) => rawLine.replace(EXPLICIT_LIST_TOKEN_RE, (_full, lKey, subKey) => {
|
|
@@ -23440,7 +25387,7 @@ function fillDatasetIntoDocSnapshot(snapshot, data, options) {
|
|
|
23440
25387
|
const crPos = cursor + line.length;
|
|
23441
25388
|
newParaEntries.push({
|
|
23442
25389
|
...import_core13.Tools.deepClone(templatePara),
|
|
23443
|
-
paragraphId: k === 0 ? templatePara.paragraphId : `
|
|
25390
|
+
paragraphId: k === 0 ? templatePara.paragraphId : `${templatePara.paragraphId || `p_${matchedParaIdx}`}_loop_${k}`,
|
|
23444
25391
|
startIndex: crPos
|
|
23445
25392
|
});
|
|
23446
25393
|
cursor = crPos + 1;
|
|
@@ -23507,7 +25454,7 @@ function fillDatasetIntoDocSnapshot(snapshot, data, options) {
|
|
|
23507
25454
|
nextSnapshot.tableSource = cascadeOutcome.snapshot.tableSource;
|
|
23508
25455
|
nextSnapshot.resources = cascadeOutcome.snapshot.resources;
|
|
23509
25456
|
}
|
|
23510
|
-
evaluateComputedSdtControlsInPlace(nextSnapshot, data);
|
|
25457
|
+
evaluateComputedSdtControlsInPlace(nextSnapshot, data, cleanFilledChrome);
|
|
23511
25458
|
recalculateInlineFormulasInPlace(nextSnapshot, data);
|
|
23512
25459
|
evaluateDocTableFormulasInPlace(nextSnapshot);
|
|
23513
25460
|
const snapMeta = readDocTemplateMetadataFromSnapshot(nextSnapshot);
|
|
@@ -23519,6 +25466,10 @@ function fillDatasetIntoDocSnapshot(snapshot, data, options) {
|
|
|
23519
25466
|
}
|
|
23520
25467
|
}
|
|
23521
25468
|
}
|
|
25469
|
+
const hasDrawingsToNormalize = nextSnapshot.drawings && Object.keys(nextSnapshot.drawings).length > 0 || (nextSnapshot.resources ?? []).some((r) => r.name === DOC_DRAWING_PLUGIN_RESOURCE);
|
|
25470
|
+
if (hasDrawingsToNormalize) {
|
|
25471
|
+
normalizeDocDrawingsAndPluginResource(nextSnapshot);
|
|
25472
|
+
}
|
|
23522
25473
|
return nextSnapshot;
|
|
23523
25474
|
}
|
|
23524
25475
|
function makeDefaultCellBorder() {
|
|
@@ -23591,14 +25542,26 @@ function buildStructuredDocData(params) {
|
|
|
23591
25542
|
...seg.docField.instructionArgs ? { instructionArgs: seg.docField.instructionArgs } : {},
|
|
23592
25543
|
instrText: seg.docField.instrText,
|
|
23593
25544
|
value: valStr,
|
|
25545
|
+
...seg.docField.sourceKind ? { sourceKind: seg.docField.sourceKind } : {},
|
|
25546
|
+
...seg.docField.preserveStyle ? { preserveStyle: true } : {},
|
|
23594
25547
|
startIndex: st,
|
|
23595
25548
|
endIndex: ed - 1
|
|
23596
25549
|
};
|
|
23597
|
-
|
|
23598
|
-
st
|
|
23599
|
-
|
|
23600
|
-
|
|
23601
|
-
|
|
25550
|
+
if (seg.docField.preserveStyle) {
|
|
25551
|
+
if (seg.docField.style && ed > st) {
|
|
25552
|
+
textRuns.push({
|
|
25553
|
+
st,
|
|
25554
|
+
ed,
|
|
25555
|
+
ts: import_core13.Tools.deepClone(seg.docField.style)
|
|
25556
|
+
});
|
|
25557
|
+
}
|
|
25558
|
+
} else {
|
|
25559
|
+
textRuns.push({
|
|
25560
|
+
st,
|
|
25561
|
+
ed,
|
|
25562
|
+
ts: { cl: { rgb: "#2C53F1" }, bg: { rgb: "#F3F5FF" } }
|
|
25563
|
+
});
|
|
25564
|
+
}
|
|
23602
25565
|
customRanges.push({
|
|
23603
25566
|
rangeId: fldId,
|
|
23604
25567
|
rangeType: import_core13.CustomRangeType.CUSTOM,
|
|
@@ -23912,6 +25875,7 @@ function buildStructuredDocData(params) {
|
|
|
23912
25875
|
paragraphs.push({
|
|
23913
25876
|
startIndex: pIdx,
|
|
23914
25877
|
paragraphId: `p_${(0, import_core13.generateRandomId)(6)}`,
|
|
25878
|
+
...para.styleId ? { styleId: para.styleId } : {},
|
|
23915
25879
|
...para.paragraphStyle ? { paragraphStyle: para.paragraphStyle } : {},
|
|
23916
25880
|
...para.bullet ? { bullet: para.bullet } : {}
|
|
23917
25881
|
});
|
|
@@ -23981,6 +25945,9 @@ function buildStructuredDocData(params) {
|
|
|
23981
25945
|
},
|
|
23982
25946
|
rowSpan: cellObj.rowSpan ?? 1,
|
|
23983
25947
|
columnSpan: cellObj.colSpan ?? 1,
|
|
25948
|
+
...cellObj.tcWidthType ? { tcWidthType: cellObj.tcWidthType } : {},
|
|
25949
|
+
...cellObj.cellSize ? { size: import_core13.Tools.deepClone(cellObj.cellSize) } : {},
|
|
25950
|
+
...cellObj.yudaoTcWidthPct !== void 0 ? { yudaoTcWidthPct: cellObj.yudaoTcWidthPct } : {},
|
|
23984
25951
|
...cellObj.backgroundRgb ? { backgroundColor: { rgb: cellObj.backgroundRgb } } : {},
|
|
23985
25952
|
borderTop: toCellBorderObj(cellObj.borders?.top),
|
|
23986
25953
|
borderBottom: toCellBorderObj(cellObj.borders?.bottom),
|
|
@@ -23993,12 +25960,14 @@ function buildStructuredDocData(params) {
|
|
|
23993
25960
|
repeatHeaderMeta[tableId] = block.headerRowCount;
|
|
23994
25961
|
}
|
|
23995
25962
|
dataStream += import_core13.DataStreamTreeTokenType.TABLE_ROW_END;
|
|
25963
|
+
const rMeta = block.rowMeta?.[rIdx];
|
|
23996
25964
|
tableRows.push({
|
|
23997
25965
|
tableCells: cellDefs,
|
|
23998
|
-
trHeight: {
|
|
25966
|
+
trHeight: rMeta?.trHeight ? import_core13.Tools.deepClone(rMeta.trHeight) : {
|
|
23999
25967
|
val: { v: 24, u: import_core13.NumberUnitType.POINT },
|
|
24000
25968
|
hRule: import_core13.TableRowHeightRule.AT_LEAST
|
|
24001
25969
|
},
|
|
25970
|
+
...rMeta?.cantSplit !== void 0 ? { cantSplit: rMeta.cantSplit } : {},
|
|
24002
25971
|
isFirstRow: rIdx === 0 ? import_core13.BooleanNumber.TRUE : import_core13.BooleanNumber.FALSE,
|
|
24003
25972
|
repeatHeaderRow: rIdx < effectiveHdrCount ? import_core13.BooleanNumber.TRUE : import_core13.BooleanNumber.FALSE
|
|
24004
25973
|
});
|
|
@@ -24010,7 +25979,7 @@ function buildStructuredDocData(params) {
|
|
|
24010
25979
|
startIndex: tblStart,
|
|
24011
25980
|
endIndex: tblEndExclusive
|
|
24012
25981
|
});
|
|
24013
|
-
|
|
25982
|
+
const tblEntry = {
|
|
24014
25983
|
tableId,
|
|
24015
25984
|
tableRows,
|
|
24016
25985
|
tableColumns: colWidths.map((w) => ({
|
|
@@ -24024,14 +25993,19 @@ function buildStructuredDocData(params) {
|
|
|
24024
25993
|
positionV: { relativeFrom: 0, posOffset: 0 }
|
|
24025
25994
|
},
|
|
24026
25995
|
dist: { distT: 0, distB: 0, distL: 0, distR: 0 },
|
|
24027
|
-
size: {
|
|
25996
|
+
size: block.tableSize ? import_core13.Tools.deepClone(block.tableSize) : {
|
|
24028
25997
|
width: {
|
|
24029
25998
|
v: colWidths.reduce((a, b) => a + b, 0),
|
|
24030
25999
|
u: import_core13.NumberUnitType.POINT
|
|
24031
26000
|
},
|
|
24032
26001
|
type: 0
|
|
24033
|
-
}
|
|
26002
|
+
},
|
|
26003
|
+
...block.tableLayout !== void 0 ? { layout: block.tableLayout } : {},
|
|
26004
|
+
...block.yudaoTblWidthType ? { yudaoTblWidthType: block.yudaoTblWidthType } : {},
|
|
26005
|
+
...block.yudaoTblWidthDxa !== void 0 ? { yudaoTblWidthDxa: block.yudaoTblWidthDxa } : {},
|
|
26006
|
+
...block.yudaoTblWidthPct !== void 0 ? { yudaoTblWidthPct: block.yudaoTblWidthPct } : {}
|
|
24034
26007
|
};
|
|
26008
|
+
tableSource[tableId] = tblEntry;
|
|
24035
26009
|
if (block.rowLoop) {
|
|
24036
26010
|
rowLoopMeta[`${tableId}:${block.rowLoop.rowIndex}`] = {
|
|
24037
26011
|
tableId,
|
|
@@ -24097,6 +26071,9 @@ function buildStructuredDocData(params) {
|
|
|
24097
26071
|
} : {}
|
|
24098
26072
|
});
|
|
24099
26073
|
}
|
|
26074
|
+
if (docData.drawings && Object.keys(docData.drawings).length > 0) {
|
|
26075
|
+
normalizeDocDrawingsAndPluginResource(docData);
|
|
26076
|
+
}
|
|
24100
26077
|
return docData;
|
|
24101
26078
|
}
|
|
24102
26079
|
function extractDocCatalog(snapshot) {
|
|
@@ -24919,7 +26896,7 @@ function buildLiveDocFormContext(snapshot, extraData) {
|
|
|
24919
26896
|
ctx.__displayMap = displayMap;
|
|
24920
26897
|
return ctx;
|
|
24921
26898
|
}
|
|
24922
|
-
function evaluateComputedSdtControlsInPlace(snapshot, extraData) {
|
|
26899
|
+
function evaluateComputedSdtControlsInPlace(snapshot, extraData, cleanFilledChrome = false) {
|
|
24923
26900
|
if (!snapshot.body) return false;
|
|
24924
26901
|
const initialControls = listDocSdtControls(snapshot).filter((c) => Boolean(c.computedExpr?.trim()));
|
|
24925
26902
|
if (initialControls.length === 0) return false;
|
|
@@ -24954,13 +26931,14 @@ function evaluateComputedSdtControlsInPlace(snapshot, extraData) {
|
|
|
24954
26931
|
normalizedValue
|
|
24955
26932
|
);
|
|
24956
26933
|
const matchedHighlight = !showingPlaceholder ? matchSdtHighlightRule(latestResolved.highlightRules, `${text} ${String(normalizedValue)}`) : void 0;
|
|
26934
|
+
const effectiveChrome = !showingPlaceholder && cleanFilledChrome ? latestResolved.visualChrome ?? "clean" : latestResolved.visualChrome;
|
|
24957
26935
|
const style = computeSdtVisualStyle(
|
|
24958
26936
|
latestResolved.kind,
|
|
24959
26937
|
latestResolved.lock,
|
|
24960
26938
|
showingPlaceholder,
|
|
24961
26939
|
Boolean(latestResolved.bindingPath),
|
|
24962
26940
|
matchedHighlight,
|
|
24963
|
-
|
|
26941
|
+
effectiveChrome,
|
|
24964
26942
|
anchorTypo,
|
|
24965
26943
|
{
|
|
24966
26944
|
underlineBlank: latestResolved.underlineBlank,
|
|
@@ -25619,6 +27597,10 @@ DocSdtService = __decorateClass([
|
|
|
25619
27597
|
__decorateParam(0, import_core14.IUniverInstanceService)
|
|
25620
27598
|
], DocSdtService);
|
|
25621
27599
|
|
|
27600
|
+
// src/commands/doc-wave2.command.ts
|
|
27601
|
+
var import_core16 = require("@univerjs/core");
|
|
27602
|
+
var import_docs = require("@univerjs/docs");
|
|
27603
|
+
|
|
25622
27604
|
// src/commands/doc-v204.command.ts
|
|
25623
27605
|
var import_core15 = require("@univerjs/core");
|
|
25624
27606
|
var SyncDocAuxStateMutation = {
|
|
@@ -25646,11 +27628,17 @@ var SyncDocAuxStateMutation = {
|
|
|
25646
27628
|
if (params.footers !== void 0) {
|
|
25647
27629
|
snap.footers = import_core15.Tools.deepClone(params.footers);
|
|
25648
27630
|
}
|
|
27631
|
+
if (params.headers !== void 0 || params.footers !== void 0) {
|
|
27632
|
+
reinitializeDocHeaderFooterModels(docModel);
|
|
27633
|
+
}
|
|
25649
27634
|
if (params.metadata !== void 0) {
|
|
25650
27635
|
const nextMeta = import_core15.Tools.deepClone(params.metadata);
|
|
25651
27636
|
accessor.get(IDocSdtService).setTemplateMetadata(docModel.getUnitId(), nextMeta);
|
|
25652
27637
|
writeDocTemplateMetadataToSnapshot(snap, nextMeta);
|
|
25653
27638
|
}
|
|
27639
|
+
if (params.drawings !== void 0 || params.drawingsOrder !== void 0) {
|
|
27640
|
+
syncDocDrawingsToUniverServices(accessor, docModel.getUnitId(), snap);
|
|
27641
|
+
}
|
|
25654
27642
|
return true;
|
|
25655
27643
|
}
|
|
25656
27644
|
};
|
|
@@ -26488,8 +28476,6 @@ var RefreshDocTableOfContentsCommand = {
|
|
|
26488
28476
|
};
|
|
26489
28477
|
|
|
26490
28478
|
// src/commands/doc-wave2.command.ts
|
|
26491
|
-
var import_core16 = require("@univerjs/core");
|
|
26492
|
-
var import_docs = require("@univerjs/docs");
|
|
26493
28479
|
function buildAuxParams(unitId, snap, metadata) {
|
|
26494
28480
|
return {
|
|
26495
28481
|
unitId,
|
|
@@ -28419,6 +30405,49 @@ function getTargetDocModel(accessor, unitId) {
|
|
|
28419
30405
|
function buildBodyReplaceEditOp(prevBody, nextBody) {
|
|
28420
30406
|
return import_core20.JSONX.getInstance().replaceOp(["body"], prevBody, nextBody);
|
|
28421
30407
|
}
|
|
30408
|
+
function reinitializeDocHeaderFooterModels(docModel) {
|
|
30409
|
+
const anyModel = docModel;
|
|
30410
|
+
anyModel.headerModelMap?.forEach?.((m) => m?.dispose?.());
|
|
30411
|
+
anyModel.headerModelMap?.clear?.();
|
|
30412
|
+
anyModel.footerModelMap?.forEach?.((m) => m?.dispose?.());
|
|
30413
|
+
anyModel.footerModelMap?.clear?.();
|
|
30414
|
+
anyModel._initializeHeaderFooterModel?.();
|
|
30415
|
+
}
|
|
30416
|
+
function syncDocDrawingsToUniverServices(injector, unitId, snapshot) {
|
|
30417
|
+
if (!snapshot || typeof snapshot !== "object") return;
|
|
30418
|
+
if (!snapshot.id && unitId) {
|
|
30419
|
+
snapshot.id = unitId;
|
|
30420
|
+
}
|
|
30421
|
+
normalizeDocDrawingsAndPluginResource(snapshot);
|
|
30422
|
+
const accessor = injector;
|
|
30423
|
+
const docModel = getTargetDocModel(accessor, unitId);
|
|
30424
|
+
const nextDrawings = import_core20.Tools.deepClone(snapshot.drawings ?? {});
|
|
30425
|
+
const nextOrder = import_core20.Tools.deepClone(snapshot.drawingsOrder ?? []);
|
|
30426
|
+
if (docModel) {
|
|
30427
|
+
const liveSnap = docModel.getSnapshot();
|
|
30428
|
+
liveSnap.drawings = import_core20.Tools.deepClone(nextDrawings);
|
|
30429
|
+
liveSnap.drawingsOrder = import_core20.Tools.deepClone(nextOrder);
|
|
30430
|
+
if (snapshot.resources !== void 0) {
|
|
30431
|
+
liveSnap.resources = import_core20.Tools.deepClone(snapshot.resources);
|
|
30432
|
+
}
|
|
30433
|
+
docModel.resetDrawing?.(import_core20.Tools.deepClone(nextDrawings), import_core20.Tools.deepClone(nextOrder));
|
|
30434
|
+
}
|
|
30435
|
+
try {
|
|
30436
|
+
const resourceManagerService = accessor.get(import_core20.IResourceManagerService);
|
|
30437
|
+
const hook = resourceManagerService?.getAllResourceHooks?.().find((h) => h.pluginName === DOC_DRAWING_PLUGIN_RESOURCE);
|
|
30438
|
+
if (hook) {
|
|
30439
|
+
if (Object.keys(nextDrawings).length > 0) {
|
|
30440
|
+
hook.onLoad(unitId, {
|
|
30441
|
+
data: import_core20.Tools.deepClone(nextDrawings),
|
|
30442
|
+
order: import_core20.Tools.deepClone(nextOrder)
|
|
30443
|
+
});
|
|
30444
|
+
} else {
|
|
30445
|
+
hook.onUnLoad?.(unitId);
|
|
30446
|
+
}
|
|
30447
|
+
}
|
|
30448
|
+
} catch {
|
|
30449
|
+
}
|
|
30450
|
+
}
|
|
28422
30451
|
function syncSnapshotAuxFields(docModel, nextSnapshot) {
|
|
28423
30452
|
const liveSnap = docModel.getSnapshot();
|
|
28424
30453
|
if (nextSnapshot.tableSource !== void 0) {
|
|
@@ -28460,8 +30489,11 @@ function syncSnapshotAuxFields(docModel, nextSnapshot) {
|
|
|
28460
30489
|
if (nextSnapshot.documentStyle) {
|
|
28461
30490
|
liveSnap.documentStyle = import_core20.Tools.deepClone(nextSnapshot.documentStyle);
|
|
28462
30491
|
}
|
|
30492
|
+
if (nextSnapshot.headers !== void 0 || nextSnapshot.footers !== void 0) {
|
|
30493
|
+
reinitializeDocHeaderFooterModels(docModel);
|
|
30494
|
+
}
|
|
28463
30495
|
}
|
|
28464
|
-
function executeBodyUpdateViaRichTextMutation(accessor, docModel, nextBody, cursorOffset, bypassContentLock = false, allowInViewMode = false) {
|
|
30496
|
+
function executeBodyUpdateViaRichTextMutation(accessor, docModel, nextBody, cursorOffset, bypassContentLock = false, allowInViewMode = false, forceRecalculate = false) {
|
|
28465
30497
|
const sdtService = accessor.get(IDocSdtService);
|
|
28466
30498
|
const unitId = docModel.getUnitId();
|
|
28467
30499
|
if (!allowInViewMode && sdtService.getDocMode(unitId) === "view") {
|
|
@@ -28471,17 +30503,34 @@ function executeBodyUpdateViaRichTextMutation(accessor, docModel, nextBody, curs
|
|
|
28471
30503
|
const prevSnap = docModel.getSnapshot();
|
|
28472
30504
|
const prevBody = prevSnap.body;
|
|
28473
30505
|
if (!prevBody) return false;
|
|
28474
|
-
|
|
30506
|
+
const bodyEqual = import_core20.Tools.diffValue(prevBody, nextBody);
|
|
30507
|
+
if (bodyEqual && !forceRecalculate) return true;
|
|
28475
30508
|
const wasDisabled = Boolean(prevSnap.disabled);
|
|
28476
30509
|
if (allowInViewMode && wasDisabled) {
|
|
28477
30510
|
prevSnap.disabled = false;
|
|
28478
30511
|
}
|
|
28479
30512
|
try {
|
|
28480
|
-
|
|
30513
|
+
if (bodyEqual && forceRecalculate) {
|
|
30514
|
+
const tempBody = {
|
|
30515
|
+
...import_core20.Tools.deepClone(prevBody),
|
|
30516
|
+
payloads: { ...prevBody.payloads ?? {}, __recalc: (0, import_core20.generateRandomId)(4) }
|
|
30517
|
+
};
|
|
30518
|
+
const recalcUnlockOp = buildBodyReplaceEditOp(prevBody, tempBody);
|
|
30519
|
+
if (recalcUnlockOp) {
|
|
30520
|
+
commandService.syncExecuteCommand(import_docs4.RichTextEditingMutation.id, {
|
|
30521
|
+
unitId,
|
|
30522
|
+
actions: recalcUnlockOp,
|
|
30523
|
+
noHistory: true,
|
|
30524
|
+
noNeedSetTextRange: true
|
|
30525
|
+
});
|
|
30526
|
+
}
|
|
30527
|
+
}
|
|
30528
|
+
const liveBeforeLockCheck = docModel.getSnapshot().body;
|
|
30529
|
+
const hasLockedSdt = bypassContentLock && (liveBeforeLockCheck.customRanges ?? []).some(
|
|
28481
30530
|
(r) => r.rangeType === import_core20.CustomRangeType.SDT && r.properties?.lock && r.properties.lock !== "unlocked"
|
|
28482
30531
|
);
|
|
28483
30532
|
if (hasLockedSdt) {
|
|
28484
|
-
const unlockedBody = import_core20.Tools.deepClone(
|
|
30533
|
+
const unlockedBody = import_core20.Tools.deepClone(liveBeforeLockCheck);
|
|
28485
30534
|
unlockedBody.customRanges = (unlockedBody.customRanges ?? []).map(
|
|
28486
30535
|
(r) => r.rangeType === import_core20.CustomRangeType.SDT ? {
|
|
28487
30536
|
...r,
|
|
@@ -28491,7 +30540,7 @@ function executeBodyUpdateViaRichTextMutation(accessor, docModel, nextBody, curs
|
|
|
28491
30540
|
}
|
|
28492
30541
|
} : r
|
|
28493
30542
|
);
|
|
28494
|
-
const unlockActions = buildBodyReplaceEditOp(
|
|
30543
|
+
const unlockActions = buildBodyReplaceEditOp(liveBeforeLockCheck, unlockedBody);
|
|
28495
30544
|
if (unlockActions) {
|
|
28496
30545
|
commandService.syncExecuteCommand(import_docs4.RichTextEditingMutation.id, {
|
|
28497
30546
|
unitId,
|
|
@@ -28510,7 +30559,7 @@ function executeBodyUpdateViaRichTextMutation(accessor, docModel, nextBody, curs
|
|
|
28510
30559
|
actions,
|
|
28511
30560
|
textRanges: clampedCursor !== void 0 ? [{ startOffset: clampedCursor, endOffset: clampedCursor, collapsed: true }] : void 0,
|
|
28512
30561
|
noNeedSetTextRange: clampedCursor === void 0,
|
|
28513
|
-
noHistory: allowInViewMode && wasDisabled ? true : void 0
|
|
30562
|
+
noHistory: allowInViewMode && wasDisabled || bodyEqual ? true : void 0
|
|
28514
30563
|
});
|
|
28515
30564
|
if (typeof result === "boolean") return result;
|
|
28516
30565
|
return Boolean(result && Array.isArray(result.actions) && result.actions.length > 0);
|
|
@@ -28996,16 +31045,21 @@ var FillDocDatasetCommand = {
|
|
|
28996
31045
|
const sdtService = accessor.get(IDocSdtService);
|
|
28997
31046
|
if (sdtService.getDocMode(docModel.getUnitId()) === "view") return false;
|
|
28998
31047
|
const unitId = docModel.getUnitId();
|
|
28999
|
-
const
|
|
29000
|
-
const
|
|
29001
|
-
|
|
31048
|
+
const prevMeta = import_core20.Tools.deepClone(sdtService.getTemplateMetadata(unitId));
|
|
31049
|
+
const prevSnap = import_core20.Tools.deepClone(docModel.getSnapshot());
|
|
31050
|
+
const baseSnap = import_core20.Tools.deepClone(prevSnap);
|
|
31051
|
+
writeDocTemplateMetadataToSnapshot(baseSnap, prevMeta);
|
|
29002
31052
|
const filledSnapshot = fillDatasetIntoDocSnapshot(baseSnap, params.data, {
|
|
29003
|
-
tableRowLoops:
|
|
31053
|
+
tableRowLoops: prevMeta.tableRowLoops
|
|
29004
31054
|
});
|
|
29005
31055
|
if (!filledSnapshot.body) return false;
|
|
29006
|
-
|
|
29007
|
-
|
|
29008
|
-
|
|
31056
|
+
return executeWave2SnapshotUpdateWithUndoRedo(
|
|
31057
|
+
accessor,
|
|
31058
|
+
docModel,
|
|
31059
|
+
prevSnap,
|
|
31060
|
+
prevMeta,
|
|
31061
|
+
filledSnapshot
|
|
31062
|
+
);
|
|
29009
31063
|
}
|
|
29010
31064
|
};
|
|
29011
31065
|
var ReplaceDocUnitSnapshotCommand = {
|
|
@@ -29015,16 +31069,29 @@ var ReplaceDocUnitSnapshotCommand = {
|
|
|
29015
31069
|
if (!params?.snapshot?.body) return false;
|
|
29016
31070
|
const docModel = getTargetDocModel(accessor, params.unitId);
|
|
29017
31071
|
if (!docModel) return false;
|
|
29018
|
-
|
|
29019
|
-
const
|
|
29020
|
-
|
|
31072
|
+
const unitId = docModel.getUnitId();
|
|
31073
|
+
const normalizedSnap = import_core20.Tools.deepClone(params.snapshot);
|
|
31074
|
+
if (!normalizedSnap.id) {
|
|
31075
|
+
normalizedSnap.id = unitId;
|
|
31076
|
+
}
|
|
31077
|
+
normalizeDocDrawingsAndPluginResource(normalizedSnap);
|
|
31078
|
+
const prevSnap = docModel.getSnapshot();
|
|
31079
|
+
const auxChanged = normalizedSnap.headers !== void 0 && !import_core20.Tools.diffValue(prevSnap.headers ?? {}, normalizedSnap.headers ?? {}) || normalizedSnap.footers !== void 0 && !import_core20.Tools.diffValue(prevSnap.footers ?? {}, normalizedSnap.footers ?? {}) || normalizedSnap.drawings !== void 0 && !import_core20.Tools.diffValue(prevSnap.drawings ?? {}, normalizedSnap.drawings ?? {}) || normalizedSnap.drawingsOrder !== void 0 && !import_core20.Tools.diffValue(prevSnap.drawingsOrder ?? [], normalizedSnap.drawingsOrder ?? []) || normalizedSnap.documentStyle !== void 0 && !import_core20.Tools.diffValue(prevSnap.documentStyle ?? {}, normalizedSnap.documentStyle ?? {}) || normalizedSnap.styles !== void 0 && !import_core20.Tools.diffValue(prevSnap.styles ?? {}, normalizedSnap.styles ?? {}) || normalizedSnap.tableSource !== void 0 && !import_core20.Tools.diffValue(prevSnap.tableSource ?? {}, normalizedSnap.tableSource ?? {});
|
|
31080
|
+
syncSnapshotAuxFields(docModel, normalizedSnap);
|
|
31081
|
+
reinitializeDocHeaderFooterModels(docModel);
|
|
31082
|
+
syncDocDrawingsToUniverServices(accessor, unitId, normalizedSnap);
|
|
31083
|
+
const snapMeta = readDocTemplateMetadataFromSnapshot(normalizedSnap);
|
|
31084
|
+
const sdtService = accessor.get(IDocSdtService);
|
|
31085
|
+
sdtService.setTemplateMetadata(unitId, snapMeta);
|
|
31086
|
+
sdtService.bumpRevision(unitId);
|
|
29021
31087
|
return executeBodyUpdateViaRichTextMutation(
|
|
29022
31088
|
accessor,
|
|
29023
31089
|
docModel,
|
|
29024
|
-
|
|
31090
|
+
normalizedSnap.body,
|
|
29025
31091
|
0,
|
|
29026
31092
|
true,
|
|
29027
|
-
Boolean(params.allowInViewMode)
|
|
31093
|
+
Boolean(params.allowInViewMode),
|
|
31094
|
+
auxChanged
|
|
29028
31095
|
);
|
|
29029
31096
|
}
|
|
29030
31097
|
};
|
|
@@ -30863,6 +32930,17 @@ var DocExtensionRegistryService = class extends import_core23.Disposable {
|
|
|
30863
32930
|
// src/services/doc-io.service.ts
|
|
30864
32931
|
var import_core24 = require("@univerjs/core");
|
|
30865
32932
|
var import_rxjs4 = require("rxjs");
|
|
32933
|
+
var DOC_IO_CAPABILITY_FORMATS = [
|
|
32934
|
+
"docx",
|
|
32935
|
+
"doc",
|
|
32936
|
+
"rtf",
|
|
32937
|
+
"odt",
|
|
32938
|
+
"md",
|
|
32939
|
+
"html",
|
|
32940
|
+
"pdf",
|
|
32941
|
+
"txt",
|
|
32942
|
+
"json"
|
|
32943
|
+
];
|
|
30866
32944
|
var DocIoTargetError = class extends Error {
|
|
30867
32945
|
constructor(message) {
|
|
30868
32946
|
super(message);
|
|
@@ -30878,6 +32956,73 @@ async function normalizeToUint8Array(raw) {
|
|
|
30878
32956
|
if (raw instanceof ArrayBuffer) return new Uint8Array(raw);
|
|
30879
32957
|
return new Uint8Array(await raw.arrayBuffer());
|
|
30880
32958
|
}
|
|
32959
|
+
var DEFAULT_BROWSER_IMPORT_SET = /* @__PURE__ */ new Set([
|
|
32960
|
+
"docx",
|
|
32961
|
+
"doc",
|
|
32962
|
+
"rtf",
|
|
32963
|
+
"odt",
|
|
32964
|
+
"md",
|
|
32965
|
+
"html",
|
|
32966
|
+
"txt",
|
|
32967
|
+
"json"
|
|
32968
|
+
]);
|
|
32969
|
+
var DEFAULT_BROWSER_EXPORT_SET = /* @__PURE__ */ new Set([
|
|
32970
|
+
"docx",
|
|
32971
|
+
"doc",
|
|
32972
|
+
"rtf",
|
|
32973
|
+
"odt",
|
|
32974
|
+
"md",
|
|
32975
|
+
"html",
|
|
32976
|
+
"pdf",
|
|
32977
|
+
"txt",
|
|
32978
|
+
"json"
|
|
32979
|
+
]);
|
|
32980
|
+
function normalizeFormatKey(raw) {
|
|
32981
|
+
const lower = raw.trim().toLowerCase().replace(/^\./, "");
|
|
32982
|
+
if (lower === "markdown") return "md";
|
|
32983
|
+
if (lower === "htm") return "html";
|
|
32984
|
+
return lower;
|
|
32985
|
+
}
|
|
32986
|
+
function inferFormatFromFileName(fileName) {
|
|
32987
|
+
const m = fileName.trim().toLowerCase().match(/\.([^.]+)$/);
|
|
32988
|
+
if (!m) return "txt";
|
|
32989
|
+
return normalizeFormatKey(m[1]);
|
|
32990
|
+
}
|
|
32991
|
+
function normalizeImportWarnings(rawWarnings) {
|
|
32992
|
+
if (!Array.isArray(rawWarnings)) return [];
|
|
32993
|
+
return rawWarnings.map((item) => {
|
|
32994
|
+
if (typeof item === "string") {
|
|
32995
|
+
const trimmed = item.trim();
|
|
32996
|
+
return trimmed ? { code: "SERVER_IMPORT_WARNING", message: trimmed } : null;
|
|
32997
|
+
}
|
|
32998
|
+
if (item && typeof item === "object" && typeof item.message === "string") {
|
|
32999
|
+
const w = item;
|
|
33000
|
+
return {
|
|
33001
|
+
code: w.code || "SERVER_IMPORT_WARNING",
|
|
33002
|
+
message: w.message,
|
|
33003
|
+
...typeof w.count === "number" ? { count: w.count } : {}
|
|
33004
|
+
};
|
|
33005
|
+
}
|
|
33006
|
+
return null;
|
|
33007
|
+
}).filter((w) => w !== null);
|
|
33008
|
+
}
|
|
33009
|
+
function unwrapAdapterImportResult(rawResult) {
|
|
33010
|
+
if (rawResult && typeof rawResult === "object" && !("body" in rawResult && rawResult.body !== void 0) && ("snapshot" in rawResult || "documentData" in rawResult)) {
|
|
33011
|
+
const env = rawResult;
|
|
33012
|
+
const doc2 = env.snapshot ?? env.documentData ?? {};
|
|
33013
|
+
const envWarnings = normalizeImportWarnings(env.warnings);
|
|
33014
|
+
const attachedWarnings = normalizeImportWarnings(doc2?.__importWarnings);
|
|
33015
|
+
return {
|
|
33016
|
+
documentData: doc2,
|
|
33017
|
+
warnings: envWarnings.length > 0 ? envWarnings : attachedWarnings
|
|
33018
|
+
};
|
|
33019
|
+
}
|
|
33020
|
+
const doc = rawResult ?? {};
|
|
33021
|
+
const warnings = normalizeImportWarnings(
|
|
33022
|
+
rawResult?.warnings ?? rawResult?.__importWarnings
|
|
33023
|
+
);
|
|
33024
|
+
return { documentData: doc, warnings };
|
|
33025
|
+
}
|
|
30881
33026
|
var DocIoService = class extends import_core24.Disposable {
|
|
30882
33027
|
constructor() {
|
|
30883
33028
|
super();
|
|
@@ -30921,9 +33066,51 @@ var DocIoService = class extends import_core24.Disposable {
|
|
|
30921
33066
|
setAdapter(adapter) {
|
|
30922
33067
|
this._adapter$.next({ name: adapter.name ?? "custom-adapter", ...adapter });
|
|
30923
33068
|
}
|
|
33069
|
+
getDefaultIoTarget() {
|
|
33070
|
+
if (this._serviceDefaultIoTarget !== void 0) {
|
|
33071
|
+
return this._serviceDefaultIoTarget;
|
|
33072
|
+
}
|
|
33073
|
+
return this._adapter$.getValue().defaultIoTarget ?? "auto";
|
|
33074
|
+
}
|
|
33075
|
+
setDefaultIoTarget(target) {
|
|
33076
|
+
this._serviceDefaultIoTarget = target;
|
|
33077
|
+
this._adapter$.next({ ...this._adapter$.getValue() });
|
|
33078
|
+
}
|
|
30924
33079
|
getIoCapabilities() {
|
|
30925
33080
|
const adapter = this._adapter$.getValue();
|
|
30926
|
-
const
|
|
33081
|
+
const defaultIoTarget = this.getDefaultIoTarget();
|
|
33082
|
+
const hasServerImport = Boolean(adapter.importDoc);
|
|
33083
|
+
const hasServerExport = Boolean(adapter.exportDoc);
|
|
33084
|
+
const hasServerIo = hasServerImport || hasServerExport;
|
|
33085
|
+
const recommendedDefaultTarget = defaultIoTarget === "browser" ? "browser" : defaultIoTarget === "server" ? "server" : hasServerIo ? "server" : "browser";
|
|
33086
|
+
const browserFmtCfg = adapter.browserFormats;
|
|
33087
|
+
const browserImportOverride = typeof browserFmtCfg === "object" && browserFmtCfg !== null && Array.isArray(browserFmtCfg.import) ? new Set(browserFmtCfg.import.map(normalizeFormatKey)) : null;
|
|
33088
|
+
const browserExportOverride = typeof browserFmtCfg === "object" && browserFmtCfg !== null && Array.isArray(browserFmtCfg.export) ? new Set(browserFmtCfg.export.map(normalizeFormatKey)) : null;
|
|
33089
|
+
const serverImportOverride = Array.isArray(adapter.serverFormats?.import) ? new Set(adapter.serverFormats.import.map(normalizeFormatKey)) : null;
|
|
33090
|
+
const serverExportOverride = Array.isArray(adapter.serverFormats?.export) ? new Set(adapter.serverFormats.export.map(normalizeFormatKey)) : null;
|
|
33091
|
+
const computeDefaultTarget = (serverSupported) => {
|
|
33092
|
+
if (defaultIoTarget === "server") return "server";
|
|
33093
|
+
if (defaultIoTarget === "browser") return "browser";
|
|
33094
|
+
return serverSupported ? "server" : "browser";
|
|
33095
|
+
};
|
|
33096
|
+
const importFormats = {};
|
|
33097
|
+
const exportFormats = {};
|
|
33098
|
+
for (const fmt3 of DOC_IO_CAPABILITY_FORMATS) {
|
|
33099
|
+
const browserImport = browserFmtCfg === false ? false : browserImportOverride ? browserImportOverride.has(fmt3) : DEFAULT_BROWSER_IMPORT_SET.has(fmt3);
|
|
33100
|
+
const serverImport = !hasServerImport ? false : serverImportOverride ? serverImportOverride.has(fmt3) : true;
|
|
33101
|
+
importFormats[fmt3] = {
|
|
33102
|
+
browser: browserImport,
|
|
33103
|
+
server: serverImport,
|
|
33104
|
+
defaultTarget: computeDefaultTarget(serverImport)
|
|
33105
|
+
};
|
|
33106
|
+
const browserExport = browserFmtCfg === false ? false : browserExportOverride ? browserExportOverride.has(fmt3) : DEFAULT_BROWSER_EXPORT_SET.has(fmt3);
|
|
33107
|
+
const serverExport = !hasServerExport ? false : serverExportOverride ? serverExportOverride.has(fmt3) : true;
|
|
33108
|
+
exportFormats[fmt3] = {
|
|
33109
|
+
browser: browserExport,
|
|
33110
|
+
server: serverExport,
|
|
33111
|
+
defaultTarget: computeDefaultTarget(serverExport)
|
|
33112
|
+
};
|
|
33113
|
+
}
|
|
30927
33114
|
return {
|
|
30928
33115
|
browser: {
|
|
30929
33116
|
importDocx: true,
|
|
@@ -30935,17 +33122,38 @@ var DocIoService = class extends import_core24.Disposable {
|
|
|
30935
33122
|
},
|
|
30936
33123
|
server: {
|
|
30937
33124
|
adapterName: adapter.name || "frontend-default",
|
|
30938
|
-
importDoc:
|
|
30939
|
-
exportDoc:
|
|
33125
|
+
importDoc: hasServerImport,
|
|
33126
|
+
exportDoc: hasServerExport,
|
|
30940
33127
|
onSave: Boolean(adapter.onSave)
|
|
30941
33128
|
},
|
|
30942
|
-
|
|
33129
|
+
defaultIoTarget,
|
|
33130
|
+
recommendedDefaultTarget,
|
|
33131
|
+
formats: {
|
|
33132
|
+
import: importFormats,
|
|
33133
|
+
export: exportFormats
|
|
33134
|
+
}
|
|
30943
33135
|
};
|
|
30944
33136
|
}
|
|
33137
|
+
_resolveEffectiveTarget(operation, formatKey, requested) {
|
|
33138
|
+
if (requested === "browser") return "browser";
|
|
33139
|
+
if (requested === "server") return "server";
|
|
33140
|
+
const caps = this.getIoCapabilities();
|
|
33141
|
+
const fmtEntry = caps.formats[operation][formatKey];
|
|
33142
|
+
if (fmtEntry) return fmtEntry.defaultTarget;
|
|
33143
|
+
if (caps.defaultIoTarget === "server") return "server";
|
|
33144
|
+
if (caps.defaultIoTarget === "browser") return "browser";
|
|
33145
|
+
const hasHook = operation === "import" ? caps.server.importDoc : caps.server.exportDoc;
|
|
33146
|
+
return hasHook ? "server" : "browser";
|
|
33147
|
+
}
|
|
30945
33148
|
async importDocWithReport(file, options) {
|
|
30946
33149
|
let browserWarnings = [];
|
|
30947
33150
|
const defaultImport = async (f) => {
|
|
30948
33151
|
const lower = f.name.toLowerCase();
|
|
33152
|
+
const fmtKey2 = inferFormatFromFileName(f.name);
|
|
33153
|
+
const caps = this.getIoCapabilities();
|
|
33154
|
+
if (fmtKey2 === "pdf" || fmtKey2 in caps.formats.import && !caps.formats.import[fmtKey2].browser) {
|
|
33155
|
+
throw new Error(`\u5F53\u524D\u6D4F\u89C8\u5668\u672C\u5730\u5F15\u64CE\u4E0D\u652F\u6301\u76F4\u63A5\u5BFC\u5165 .${fmtKey2} \u683C\u5F0F\u6587\u4EF6`);
|
|
33156
|
+
}
|
|
30949
33157
|
const baseTitle = f.name.replace(/\.[^.]+$/, "") || "\u672A\u547D\u540D\u6587\u6863";
|
|
30950
33158
|
if (lower.endsWith(".docx")) {
|
|
30951
33159
|
const ab = await f.arrayBuffer();
|
|
@@ -30974,31 +33182,42 @@ var DocIoService = class extends import_core24.Disposable {
|
|
|
30974
33182
|
});
|
|
30975
33183
|
};
|
|
30976
33184
|
const adapter = this._adapter$.getValue();
|
|
30977
|
-
const
|
|
30978
|
-
const effective =
|
|
33185
|
+
const fmtKey = inferFormatFromFileName(file.name);
|
|
33186
|
+
const effective = this._resolveEffectiveTarget("import", fmtKey, options?.target);
|
|
30979
33187
|
if (effective === "server") {
|
|
30980
33188
|
if (!adapter.importDoc) {
|
|
30981
33189
|
throw new DocIoTargetError(
|
|
30982
33190
|
"\u5F53\u524D\u672A\u914D\u7F6E\u670D\u52A1\u7AEF Word \u5BFC\u5165\u63A5\u53E3\uFF08importDoc\uFF09\uFF0C\u672A\u81EA\u52A8\u964D\u7EA7\u81F3\u6D4F\u89C8\u5668\u7AEF\uFF1B\u8BF7\u5148\u63A5\u5165\u670D\u52A1\u7AEF\u9002\u914D\u5668\u6216\u6539\u9009\u300C\u6D4F\u89C8\u5668\u5904\u7406\u300D"
|
|
30983
33191
|
);
|
|
30984
33192
|
}
|
|
30985
|
-
|
|
30986
|
-
|
|
30987
|
-
|
|
30988
|
-
|
|
30989
|
-
|
|
30990
|
-
|
|
30991
|
-
|
|
30992
|
-
|
|
30993
|
-
|
|
30994
|
-
|
|
33193
|
+
try {
|
|
33194
|
+
const rawOutcome = await adapter.importDoc(file, {
|
|
33195
|
+
unitId: options?.unitId,
|
|
33196
|
+
defaultImport
|
|
33197
|
+
});
|
|
33198
|
+
const unwrapped = unwrapAdapterImportResult(rawOutcome);
|
|
33199
|
+
return {
|
|
33200
|
+
snapshot: unwrapped.documentData,
|
|
33201
|
+
documentData: unwrapped.documentData,
|
|
33202
|
+
warnings: unwrapped.warnings.length > 0 ? unwrapped.warnings : browserWarnings,
|
|
33203
|
+
executedBy: "server",
|
|
33204
|
+
fileName: file.name
|
|
33205
|
+
};
|
|
33206
|
+
} catch (err) {
|
|
33207
|
+
if (err && typeof err === "object" && !err.suggestedFallback) {
|
|
33208
|
+
err.suggestedFallback = "browser";
|
|
33209
|
+
}
|
|
33210
|
+
throw err;
|
|
33211
|
+
}
|
|
30995
33212
|
}
|
|
30996
33213
|
try {
|
|
30997
33214
|
const documentData = await defaultImport(file);
|
|
30998
33215
|
return {
|
|
33216
|
+
snapshot: documentData,
|
|
30999
33217
|
documentData,
|
|
31000
33218
|
warnings: browserWarnings,
|
|
31001
|
-
executedBy: "browser"
|
|
33219
|
+
executedBy: "browser",
|
|
33220
|
+
fileName: file.name
|
|
31002
33221
|
};
|
|
31003
33222
|
} catch (err) {
|
|
31004
33223
|
if (err && typeof err === "object") {
|
|
@@ -31014,6 +33233,10 @@ var DocIoService = class extends import_core24.Disposable {
|
|
|
31014
33233
|
async exportDoc(params) {
|
|
31015
33234
|
const format = params.format ?? "docx";
|
|
31016
33235
|
const defaultExport = async () => {
|
|
33236
|
+
const caps = this.getIoCapabilities();
|
|
33237
|
+
if (format in caps.formats.export && !caps.formats.export[format].browser) {
|
|
33238
|
+
throw new Error(`\u5F53\u524D\u6D4F\u89C8\u5668\u672C\u5730\u5F15\u64CE\u672A\u542F\u7528 .${format} \u683C\u5F0F\u5BFC\u51FA`);
|
|
33239
|
+
}
|
|
31017
33240
|
if (format === "docx") {
|
|
31018
33241
|
return exportDocxBytes(params.snapshot, params.data, {
|
|
31019
33242
|
signatureImageDataUrl: params.pdfOptions?.signatureImageDataUrl,
|
|
@@ -31079,27 +33302,38 @@ var DocIoService = class extends import_core24.Disposable {
|
|
|
31079
33302
|
const targetSnapshot2 = params.data ? fillDatasetIntoDocSnapshot(params.snapshot, params.data) : params.snapshot;
|
|
31080
33303
|
return exportDocToOdtBytes(targetSnapshot2);
|
|
31081
33304
|
}
|
|
33305
|
+
if (format === "txt") {
|
|
33306
|
+
const targetSnapshot2 = params.data ? fillDatasetIntoDocSnapshot(params.snapshot, params.data) : params.snapshot;
|
|
33307
|
+
const plain = (targetSnapshot2.body?.dataStream ?? "").replace(/\u001D\u001C/g, " ").replace(/\r/g, "\n").replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F]/g, "").replace(/\n+$/g, "\n");
|
|
33308
|
+
return new TextEncoder().encode(plain);
|
|
33309
|
+
}
|
|
31082
33310
|
const targetSnapshot = params.data ? fillDatasetIntoDocSnapshot(params.snapshot, params.data) : params.snapshot;
|
|
31083
33311
|
return new TextEncoder().encode(JSON.stringify(targetSnapshot, null, 2));
|
|
31084
33312
|
};
|
|
31085
33313
|
const adapter = this._adapter$.getValue();
|
|
31086
|
-
const
|
|
31087
|
-
const effective = requested === "auto" ? adapter.exportDoc ? "server" : "browser" : requested;
|
|
33314
|
+
const effective = this._resolveEffectiveTarget("export", format, params.target);
|
|
31088
33315
|
if (effective === "server") {
|
|
31089
33316
|
if (!adapter.exportDoc) {
|
|
31090
33317
|
throw new DocIoTargetError(
|
|
31091
33318
|
"\u5F53\u524D\u672A\u914D\u7F6E\u670D\u52A1\u7AEF Word/PDF \u5BFC\u51FA\u63A5\u53E3\uFF08exportDoc\uFF09\uFF0C\u672A\u81EA\u52A8\u964D\u7EA7\u81F3\u6D4F\u89C8\u5668\u7AEF\uFF1B\u8BF7\u5148\u63A5\u5165\u670D\u52A1\u7AEF\u9002\u914D\u5668\u6216\u6539\u9009\u300C\u6D4F\u89C8\u5668\u5904\u7406\u300D"
|
|
31092
33319
|
);
|
|
31093
33320
|
}
|
|
31094
|
-
|
|
31095
|
-
|
|
31096
|
-
|
|
31097
|
-
|
|
31098
|
-
|
|
31099
|
-
|
|
31100
|
-
|
|
31101
|
-
|
|
31102
|
-
|
|
33321
|
+
try {
|
|
33322
|
+
const raw = await adapter.exportDoc({
|
|
33323
|
+
unitId: params.unitId,
|
|
33324
|
+
snapshot: params.snapshot,
|
|
33325
|
+
format,
|
|
33326
|
+
data: params.data,
|
|
33327
|
+
pdfOptions: params.pdfOptions,
|
|
33328
|
+
defaultExport
|
|
33329
|
+
});
|
|
33330
|
+
return normalizeToUint8Array(raw);
|
|
33331
|
+
} catch (err) {
|
|
33332
|
+
if (err && typeof err === "object" && !err.suggestedFallback) {
|
|
33333
|
+
err.suggestedFallback = "browser";
|
|
33334
|
+
}
|
|
33335
|
+
throw err;
|
|
33336
|
+
}
|
|
31103
33337
|
}
|
|
31104
33338
|
try {
|
|
31105
33339
|
return await defaultExport();
|
|
@@ -31229,8 +33463,12 @@ var UniverDocsExtPlugin = class extends import_core25.Plugin {
|
|
|
31229
33463
|
];
|
|
31230
33464
|
dependencies.forEach((dep) => this._injector.add(dep));
|
|
31231
33465
|
this._injector.get(IDocActionMacroService);
|
|
33466
|
+
const ioService = this._injector.get(IDocIoService);
|
|
31232
33467
|
if (this._config.io) {
|
|
31233
|
-
|
|
33468
|
+
ioService.setAdapter(this._config.io);
|
|
33469
|
+
}
|
|
33470
|
+
if (this._config.defaultIoTarget) {
|
|
33471
|
+
ioService.setDefaultIoTarget(this._config.defaultIoTarget);
|
|
31234
33472
|
}
|
|
31235
33473
|
if (this._config.aiCopilot) {
|
|
31236
33474
|
this._injector.get(IDocAiCopilotService).setAdapter(this._config.aiCopilot);
|
|
@@ -31394,7 +33632,9 @@ UniverDocsExtPlugin = __decorateClass([
|
|
|
31394
33632
|
DEFAULT_CASCADER_OPTIONS,
|
|
31395
33633
|
DEFAULT_ENDNOTE_SETTINGS,
|
|
31396
33634
|
DEFAULT_FOOTNOTE_SETTINGS,
|
|
33635
|
+
DOC_DRAWING_PLUGIN_RESOURCE,
|
|
31397
33636
|
DOC_HYPERLINK_DEFAULT_COLOR,
|
|
33637
|
+
DOC_IO_CAPABILITY_FORMATS,
|
|
31398
33638
|
DOC_TRACK_DELETE_STYLE,
|
|
31399
33639
|
DOC_TRACK_INSERT_STYLE,
|
|
31400
33640
|
DeleteDocAreaCommand,
|
|
@@ -31725,6 +33965,7 @@ UniverDocsExtPlugin = __decorateClass([
|
|
|
31725
33965
|
listLiveSmartArts,
|
|
31726
33966
|
matchSdtHighlightRule,
|
|
31727
33967
|
mergeDocTableCellsInSnapshot,
|
|
33968
|
+
normalizeDocDrawingsAndPluginResource,
|
|
31728
33969
|
normalizeImageDataUriForSdt,
|
|
31729
33970
|
normalizeMacroName,
|
|
31730
33971
|
normalizeSdtListItems,
|
|
@@ -31744,6 +33985,7 @@ UniverDocsExtPlugin = __decorateClass([
|
|
|
31744
33985
|
recordDocTrackRevisionOnSnapshot,
|
|
31745
33986
|
refreshTableOfContentsInSnapshot,
|
|
31746
33987
|
registerDocMacro,
|
|
33988
|
+
reinitializeDocHeaderFooterModels,
|
|
31747
33989
|
removeBookmarkFromSnapshot,
|
|
31748
33990
|
removeCalloutFromSnapshot,
|
|
31749
33991
|
removeDocCascadeRule,
|
|
@@ -31820,7 +34062,9 @@ UniverDocsExtPlugin = __decorateClass([
|
|
|
31820
34062
|
spliceDocumentBodySpan,
|
|
31821
34063
|
spliceMultiParagraphBodySpan,
|
|
31822
34064
|
splitDocTableCellInSnapshot,
|
|
34065
|
+
stripDocEditorChromeForView,
|
|
31823
34066
|
stripSdtAffixes,
|
|
34067
|
+
syncDocDrawingsToUniverServices,
|
|
31824
34068
|
syncSnapshotAuxFields,
|
|
31825
34069
|
toControlSpecSnapshot,
|
|
31826
34070
|
toggleDocListCheckboxInSnapshot,
|