@yudaocode/univer-docs 1.6.209 → 1.6.211
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 +176 -0
- package/fixtures/word-template-protocol-v1.json +9135 -0
- package/lib/cjs/index.js +737 -134
- package/lib/cjs/index.js.map +1 -1
- package/lib/es/index.js +745 -144
- package/lib/es/index.js.map +1 -1
- package/lib/types/index.d.ts +51 -7
- package/package.json +5 -2
package/lib/cjs/index.js
CHANGED
|
@@ -47,6 +47,7 @@ __export(src_exports, {
|
|
|
47
47
|
DEFAULT_ENDNOTE_SETTINGS: () => DEFAULT_ENDNOTE_SETTINGS,
|
|
48
48
|
DEFAULT_FOOTNOTE_SETTINGS: () => DEFAULT_FOOTNOTE_SETTINGS,
|
|
49
49
|
DOC_HYPERLINK_DEFAULT_COLOR: () => DOC_HYPERLINK_DEFAULT_COLOR,
|
|
50
|
+
DOC_IO_CAPABILITY_FORMATS: () => DOC_IO_CAPABILITY_FORMATS,
|
|
50
51
|
DOC_TRACK_DELETE_STYLE: () => DOC_TRACK_DELETE_STYLE,
|
|
51
52
|
DOC_TRACK_INSERT_STYLE: () => DOC_TRACK_INSERT_STYLE,
|
|
52
53
|
DeleteDocAreaCommand: () => DeleteDocAreaCommand,
|
|
@@ -472,6 +473,7 @@ __export(src_exports, {
|
|
|
472
473
|
spliceDocumentBodySpan: () => spliceDocumentBodySpan,
|
|
473
474
|
spliceMultiParagraphBodySpan: () => spliceMultiParagraphBodySpan,
|
|
474
475
|
splitDocTableCellInSnapshot: () => splitDocTableCellInSnapshot,
|
|
476
|
+
stripDocEditorChromeForView: () => stripDocEditorChromeForView,
|
|
475
477
|
stripSdtAffixes: () => stripSdtAffixes,
|
|
476
478
|
syncSnapshotAuxFields: () => syncSnapshotAuxFields,
|
|
477
479
|
toControlSpecSnapshot: () => toControlSpecSnapshot,
|
|
@@ -10484,17 +10486,19 @@ function serializeSpanToRunsAndSdtXml(body, spanStart, spanEndExclusive, exportC
|
|
|
10484
10486
|
const sdtSliceRaw = stream.slice(sdtAtCursor.startIndex, sdtAtCursor.endIndex + 1);
|
|
10485
10487
|
const rawTs = findStyleAtBody(body, sdtAtCursor.startIndex);
|
|
10486
10488
|
let sdtRunStyle = rawTs;
|
|
10487
|
-
if (resolved && !resolved.matchedHighlight) {
|
|
10489
|
+
if (resolved && !resolved.matchedHighlight && !resolved.invalidHighlight) {
|
|
10488
10490
|
if (resolved.visualChrome === "underline") {
|
|
10489
10491
|
sdtRunStyle = {
|
|
10490
10492
|
...rawTs ?? {},
|
|
10491
10493
|
bg: void 0,
|
|
10492
10494
|
ul: rawTs?.ul?.s ? rawTs.ul : { s: 1 }
|
|
10493
10495
|
};
|
|
10494
|
-
} else if (resolved.visualChrome === "brackets" || resolved.visualChrome === "clean") {
|
|
10496
|
+
} else if (resolved.visualChrome === "brackets" || resolved.visualChrome === "clean" || !resolved.showingPlaceholder && resolved.visualChrome !== "highlight") {
|
|
10497
|
+
const rawBgLower = rawTs?.bg?.rgb?.trim().toLowerCase();
|
|
10498
|
+
const isEditorChromeBg = rawBgLower === "#f3f5ff" || rawBgLower === "#eeeff1" || rawBgLower === "#eff6ff";
|
|
10495
10499
|
sdtRunStyle = {
|
|
10496
10500
|
...rawTs ?? {},
|
|
10497
|
-
bg: void 0,
|
|
10501
|
+
bg: resolved.visualChrome === "brackets" || resolved.visualChrome === "clean" || isEditorChromeBg ? void 0 : rawTs?.bg,
|
|
10498
10502
|
ul: resolved.visualChrome === "clean" ? void 0 : rawTs?.ul
|
|
10499
10503
|
};
|
|
10500
10504
|
}
|
|
@@ -11504,7 +11508,7 @@ ${commentsItemsXml}
|
|
|
11504
11508
|
const liveSdtControls = listDocSdtControls(snapshot);
|
|
11505
11509
|
const serializedSdtExtendedSpecs = {};
|
|
11506
11510
|
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) {
|
|
11511
|
+
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
11512
|
serializedSdtExtendedSpecs[ctrl.id] = {
|
|
11509
11513
|
id: ctrl.id,
|
|
11510
11514
|
tag: ctrl.tag,
|
|
@@ -11517,6 +11521,9 @@ ${commentsItemsXml}
|
|
|
11517
11521
|
...ctrl.options?.length ? { options: ctrl.options } : {},
|
|
11518
11522
|
...ctrl.checkboxMarkType ? { checkboxMarkType: ctrl.checkboxMarkType } : {},
|
|
11519
11523
|
...ctrl.layoutDirection ? { layoutDirection: ctrl.layoutDirection } : {},
|
|
11524
|
+
...ctrl.visualChrome ? { visualChrome: ctrl.visualChrome } : {},
|
|
11525
|
+
...ctrl.prefix !== void 0 ? { prefix: ctrl.prefix } : {},
|
|
11526
|
+
...ctrl.postfix !== void 0 ? { postfix: ctrl.postfix } : {},
|
|
11520
11527
|
...ctrl.preText !== void 0 ? { preText: ctrl.preText } : {},
|
|
11521
11528
|
...ctrl.postText !== void 0 ? { postText: ctrl.postText } : {},
|
|
11522
11529
|
...ctrl.minWidthPt !== void 0 ? { minWidthPt: ctrl.minWidthPt } : {},
|
|
@@ -11551,7 +11558,7 @@ ${commentsItemsXml}
|
|
|
11551
11558
|
levels: def?.levels
|
|
11552
11559
|
});
|
|
11553
11560
|
}
|
|
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) {
|
|
11561
|
+
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
11562
|
extraZipFiles.push({
|
|
11556
11563
|
name: "docProps/yudao-meta.json",
|
|
11557
11564
|
content: JSON.stringify({
|
|
@@ -11577,6 +11584,7 @@ ${commentsItemsXml}
|
|
|
11577
11584
|
imageTransforms: templateMeta.imageTransforms,
|
|
11578
11585
|
printConfig: templateMeta.printConfig,
|
|
11579
11586
|
columnGroupConfig: templateMeta.columnGroupConfig,
|
|
11587
|
+
tableRowLoops: templateMeta.tableRowLoops,
|
|
11580
11588
|
tableRepeatHeaders: templateMeta.tableRepeatHeaders,
|
|
11581
11589
|
repeatingSections: templateMeta.repeatingSections,
|
|
11582
11590
|
tocConfig: templateMeta.tocConfig,
|
|
@@ -14563,6 +14571,9 @@ async function parseDocxBytesWithReport(bytes, title = "Imported Word Document")
|
|
|
14563
14571
|
...hit.options ? { options: hit.options } : {},
|
|
14564
14572
|
...hit.checkboxMarkType ? { checkboxMarkType: hit.checkboxMarkType } : {},
|
|
14565
14573
|
...hit.layoutDirection ? { layoutDirection: hit.layoutDirection } : {},
|
|
14574
|
+
...hit.visualChrome ? { visualChrome: hit.visualChrome } : {},
|
|
14575
|
+
...hit.prefix !== void 0 ? { prefix: hit.prefix } : {},
|
|
14576
|
+
...hit.postfix !== void 0 ? { postfix: hit.postfix } : {},
|
|
14566
14577
|
...hit.preText !== void 0 ? { preText: hit.preText } : {},
|
|
14567
14578
|
...hit.postText !== void 0 ? { postText: hit.postText } : {},
|
|
14568
14579
|
...hit.minWidthPt !== void 0 ? { minWidthPt: hit.minWidthPt } : {},
|
|
@@ -14621,6 +14632,44 @@ async function parseDocxBytesWithReport(bytes, title = "Imported Word Document")
|
|
|
14621
14632
|
oldToNewTblId.set(oldId, liveTables[idx].tableId);
|
|
14622
14633
|
}
|
|
14623
14634
|
});
|
|
14635
|
+
const remappedRowLoops = {
|
|
14636
|
+
...curMeta.tableRowLoops ?? {}
|
|
14637
|
+
};
|
|
14638
|
+
if (extraMeta.tableRowLoops && typeof extraMeta.tableRowLoops === "object") {
|
|
14639
|
+
for (const [k, cfg] of Object.entries(
|
|
14640
|
+
extraMeta.tableRowLoops
|
|
14641
|
+
)) {
|
|
14642
|
+
if (!cfg || typeof cfg !== "object") continue;
|
|
14643
|
+
const colonIdx = k.lastIndexOf(":");
|
|
14644
|
+
const rawTblId = cfg.tableId || (colonIdx > 0 ? k.slice(0, colonIdx) : k);
|
|
14645
|
+
const rawRowIdx = typeof cfg.rowIndex === "number" ? cfg.rowIndex : colonIdx > 0 ? Number(k.slice(colonIdx + 1)) : 0;
|
|
14646
|
+
const mappedTblId = oldToNewTblId.get(rawTblId) ?? (liveTables.length === 1 ? liveTables[0].tableId : rawTblId);
|
|
14647
|
+
const mappedKey = `${mappedTblId}:${rawRowIdx}`;
|
|
14648
|
+
remappedRowLoops[mappedKey] = {
|
|
14649
|
+
...cfg,
|
|
14650
|
+
tableId: mappedTblId,
|
|
14651
|
+
rowIndex: rawRowIdx
|
|
14652
|
+
};
|
|
14653
|
+
}
|
|
14654
|
+
}
|
|
14655
|
+
const remappedRepeatHeaders = {
|
|
14656
|
+
...curMeta.tableRepeatHeaders ?? {}
|
|
14657
|
+
};
|
|
14658
|
+
if (extraMeta.tableRepeatHeaders && typeof extraMeta.tableRepeatHeaders === "object") {
|
|
14659
|
+
for (const [oldTblId, hdrCount] of Object.entries(
|
|
14660
|
+
extraMeta.tableRepeatHeaders
|
|
14661
|
+
)) {
|
|
14662
|
+
if (typeof hdrCount !== "number") continue;
|
|
14663
|
+
const mappedTblId = oldToNewTblId.get(oldTblId) ?? (liveTables.length === 1 ? liveTables[0].tableId : oldTblId);
|
|
14664
|
+
remappedRepeatHeaders[mappedTblId] = hdrCount;
|
|
14665
|
+
const rows = docData.tableSource?.[mappedTblId]?.tableRows;
|
|
14666
|
+
if (rows) {
|
|
14667
|
+
rows.forEach((r, idx) => {
|
|
14668
|
+
r.repeatHeaderRow = idx < hdrCount ? import_core7.BooleanNumber.TRUE : import_core7.BooleanNumber.FALSE;
|
|
14669
|
+
});
|
|
14670
|
+
}
|
|
14671
|
+
}
|
|
14672
|
+
}
|
|
14624
14673
|
const remappedCellProps = {
|
|
14625
14674
|
...curMeta.tableCellProperties ?? {}
|
|
14626
14675
|
};
|
|
@@ -14705,6 +14754,8 @@ async function parseDocxBytesWithReport(bytes, title = "Imported Word Document")
|
|
|
14705
14754
|
...extraMeta.imageTransforms ? { imageTransforms: { ...curMeta.imageTransforms ?? {}, ...extraMeta.imageTransforms } } : {},
|
|
14706
14755
|
...extraMeta.printConfig ? { printConfig: { ...curMeta.printConfig ?? {}, ...extraMeta.printConfig } } : {},
|
|
14707
14756
|
...extraMeta.columnGroupConfig ? { columnGroupConfig: extraMeta.columnGroupConfig } : {},
|
|
14757
|
+
...Object.keys(remappedRowLoops).length > 0 ? { tableRowLoops: remappedRowLoops } : {},
|
|
14758
|
+
...Object.keys(remappedRepeatHeaders).length > 0 ? { tableRepeatHeaders: remappedRepeatHeaders } : {},
|
|
14708
14759
|
...extraMeta.repeatingSections ? { repeatingSections: extraMeta.repeatingSections } : {},
|
|
14709
14760
|
...extraMeta.tocConfig ? { tocConfig: extraMeta.tocConfig } : {},
|
|
14710
14761
|
...Array.isArray(extraMeta.docAreas) ? { docAreas: extraMeta.docAreas } : {},
|
|
@@ -21459,7 +21510,8 @@ var YUDAO_SDT_STORE_ID = "yudao-dataset-store";
|
|
|
21459
21510
|
var IDENT_PART = "[\\p{L}\\p{N}_-]+";
|
|
21460
21511
|
var PATH_PART = "[\\p{L}\\p{N}_.\\[\\]-]+";
|
|
21461
21512
|
var EXPLICIT_LIST_TOKEN_RE = new RegExp(`(?:\\$|#)\\{#(${IDENT_PART})\\.(${PATH_PART})\\}`, "gu");
|
|
21462
|
-
var
|
|
21513
|
+
var EXPLICIT_NESTED_LIST_TOKEN_RE = new RegExp(`(?:\\$|#)\\{#(${PATH_PART})\\}`, "gu");
|
|
21514
|
+
var ANY_CELL_TOKEN_RE = new RegExp(`(?:\\$|#)\\{(#?)(${PATH_PART})\\}`, "gu");
|
|
21463
21515
|
var INLINE_VALUE_TOKEN_RE = new RegExp(`(?:\\$|#)\\{(${PATH_PART})\\}`, "gu");
|
|
21464
21516
|
function resolvePathValue(source, path) {
|
|
21465
21517
|
if (!source || !path) return void 0;
|
|
@@ -21585,7 +21637,56 @@ function stripSdtAffixes(rawText, spec) {
|
|
|
21585
21637
|
}
|
|
21586
21638
|
return text;
|
|
21587
21639
|
}
|
|
21588
|
-
var SDT_CHROME_TEXT_COLORS = /* @__PURE__ */ new Set(["#7d8698", "#4e5565", "#2c53f1", "#1b1c1f"]);
|
|
21640
|
+
var SDT_CHROME_TEXT_COLORS = /* @__PURE__ */ new Set(["#7d8698", "#9ca3af", "#4e5565", "#2c53f1", "#1b1c1f"]);
|
|
21641
|
+
var SDT_CHROME_BG_COLORS = /* @__PURE__ */ new Set(["#f3f5ff", "#eeeff1", "#eff6ff"]);
|
|
21642
|
+
function sanitizeLoopCellRunStyle(ts, anchorTypo) {
|
|
21643
|
+
if (!ts && !anchorTypo) return void 0;
|
|
21644
|
+
const out = {
|
|
21645
|
+
...ts ? import_core13.Tools.deepClone(ts) : {},
|
|
21646
|
+
...anchorTypo ? import_core13.Tools.deepClone(anchorTypo) : {}
|
|
21647
|
+
};
|
|
21648
|
+
const bgRgb = out.bg?.rgb?.trim().toLowerCase();
|
|
21649
|
+
if (bgRgb && SDT_CHROME_BG_COLORS.has(bgRgb)) {
|
|
21650
|
+
delete out.bg;
|
|
21651
|
+
}
|
|
21652
|
+
const clRgb = out.cl?.rgb?.trim().toLowerCase();
|
|
21653
|
+
if (clRgb && !anchorTypo?.cl?.rgb && SDT_CHROME_TEXT_COLORS.has(clRgb) && clRgb !== "#1b1c1f") {
|
|
21654
|
+
delete out.cl;
|
|
21655
|
+
}
|
|
21656
|
+
if (out.bl === 0 && anchorTypo?.bl === void 0 && (!ts || ts.bl === 0)) {
|
|
21657
|
+
delete out.bl;
|
|
21658
|
+
}
|
|
21659
|
+
return Object.keys(out).length > 0 ? out : void 0;
|
|
21660
|
+
}
|
|
21661
|
+
function stripDocEditorChromeForView(snapshot) {
|
|
21662
|
+
const cloned = import_core13.Tools.deepClone(snapshot);
|
|
21663
|
+
const cleanBody = (body) => {
|
|
21664
|
+
if (!body?.customRanges?.length || !body.textRuns?.length) return;
|
|
21665
|
+
for (const r of body.customRanges) {
|
|
21666
|
+
if (r.rangeType !== import_core13.CustomRangeType.SDT) continue;
|
|
21667
|
+
const resolved = parseSdtRangeToResolved(body, r);
|
|
21668
|
+
if (!resolved || resolved.showingPlaceholder || resolved.matchedHighlight || resolved.invalidHighlight) {
|
|
21669
|
+
continue;
|
|
21670
|
+
}
|
|
21671
|
+
if (resolved.visualChrome === "highlight") continue;
|
|
21672
|
+
for (const tr of body.textRuns) {
|
|
21673
|
+
if (tr.ed <= r.startIndex || tr.st > r.endIndex || !tr.ts) continue;
|
|
21674
|
+
const bgRgb = tr.ts.bg?.rgb?.trim().toLowerCase();
|
|
21675
|
+
if (bgRgb && SDT_CHROME_BG_COLORS.has(bgRgb)) {
|
|
21676
|
+
delete tr.ts.bg;
|
|
21677
|
+
}
|
|
21678
|
+
const clRgb = tr.ts.cl?.rgb?.trim().toLowerCase();
|
|
21679
|
+
if (clRgb === "#7d8698" || clRgb === "#9ca3af") {
|
|
21680
|
+
tr.ts.cl = { rgb: "#1b1c1f" };
|
|
21681
|
+
}
|
|
21682
|
+
}
|
|
21683
|
+
}
|
|
21684
|
+
};
|
|
21685
|
+
cleanBody(cloned.body);
|
|
21686
|
+
for (const h of Object.values(cloned.headers ?? {})) cleanBody(h?.body);
|
|
21687
|
+
for (const f of Object.values(cloned.footers ?? {})) cleanBody(f?.body);
|
|
21688
|
+
return cloned;
|
|
21689
|
+
}
|
|
21589
21690
|
function extractAnchorTypography(ts) {
|
|
21590
21691
|
if (!ts) return void 0;
|
|
21591
21692
|
const out = {};
|
|
@@ -22989,21 +23090,178 @@ function listDocTables(snapshot) {
|
|
|
22989
23090
|
};
|
|
22990
23091
|
});
|
|
22991
23092
|
}
|
|
22992
|
-
function
|
|
22993
|
-
|
|
22994
|
-
|
|
23093
|
+
function resolveCandidateListPrefix(expr, data, fallbackFirstSegment) {
|
|
23094
|
+
const clean = expr.replace(/^#/, "");
|
|
23095
|
+
const dotPositions = [];
|
|
23096
|
+
for (let i = clean.length - 1; i > 0; i--) {
|
|
23097
|
+
if (clean[i] === ".") dotPositions.push(i);
|
|
23098
|
+
}
|
|
23099
|
+
if (dotPositions.length === 0) return "";
|
|
23100
|
+
for (const pos of dotPositions) {
|
|
23101
|
+
const cand = clean.slice(0, pos);
|
|
23102
|
+
const val = resolvePathValue(data, cand) ?? data?.[cand];
|
|
23103
|
+
if (Array.isArray(val)) return cand;
|
|
23104
|
+
}
|
|
23105
|
+
if (fallbackFirstSegment) {
|
|
23106
|
+
for (const pos of dotPositions) {
|
|
23107
|
+
const cand = clean.slice(0, pos);
|
|
23108
|
+
const val = resolvePathValue(data, cand);
|
|
23109
|
+
if (val === null || val === void 0 && Object.prototype.hasOwnProperty.call(data, cand)) {
|
|
23110
|
+
return cand;
|
|
23111
|
+
}
|
|
23112
|
+
const dotInCand = cand.lastIndexOf(".");
|
|
23113
|
+
if (dotInCand > 0) {
|
|
23114
|
+
const parentObj = resolvePathValue(data, cand.slice(0, dotInCand));
|
|
23115
|
+
const leafKey = cand.slice(dotInCand + 1);
|
|
23116
|
+
if (parentObj && typeof parentObj === "object" && Object.prototype.hasOwnProperty.call(parentObj, leafKey) && !(typeof parentObj[leafKey] === "object" && parentObj[leafKey] !== null && !Array.isArray(parentObj[leafKey]))) {
|
|
23117
|
+
return cand;
|
|
23118
|
+
}
|
|
23119
|
+
}
|
|
23120
|
+
}
|
|
23121
|
+
return clean.slice(0, dotPositions[dotPositions.length - 1]);
|
|
23122
|
+
}
|
|
23123
|
+
return "";
|
|
23124
|
+
}
|
|
23125
|
+
function replaceRowCellTokens(rawCellText, listKey, itemObj, rowSeqIndex, rootData, hasExplicitListKey = false) {
|
|
23126
|
+
return rawCellText.replace(ANY_CELL_TOKEN_RE, (full, hashPrefix, expr) => {
|
|
23127
|
+
const cleanExpr = expr.trim();
|
|
23128
|
+
if (cleanExpr === `${listKey}._index`) {
|
|
23129
|
+
return itemObj ? String(rowSeqIndex + 1) : "";
|
|
23130
|
+
}
|
|
23131
|
+
if (cleanExpr.startsWith(`${listKey}.`)) {
|
|
22995
23132
|
if (!itemObj) return "";
|
|
23133
|
+
const fieldPath = cleanExpr.slice(listKey.length + 1);
|
|
22996
23134
|
if (fieldPath === "_index") return String(rowSeqIndex + 1);
|
|
22997
23135
|
const val = resolvePathValue(itemObj, fieldPath);
|
|
22998
23136
|
return val == null ? "" : String(val);
|
|
22999
23137
|
}
|
|
23000
|
-
|
|
23001
|
-
|
|
23002
|
-
return String(
|
|
23138
|
+
if (hasExplicitListKey) {
|
|
23139
|
+
if (!itemObj) return "";
|
|
23140
|
+
if (cleanExpr === "_index") return String(rowSeqIndex + 1);
|
|
23141
|
+
const itemVal = resolvePathValue(itemObj, cleanExpr);
|
|
23142
|
+
if (itemVal !== void 0) {
|
|
23143
|
+
return itemVal == null ? "" : String(itemVal);
|
|
23144
|
+
}
|
|
23145
|
+
const rootVal = resolvePathValue(rootData, cleanExpr);
|
|
23146
|
+
if (rootVal !== void 0 && rootVal !== null && typeof rootVal !== "object") {
|
|
23147
|
+
return String(rootVal);
|
|
23148
|
+
}
|
|
23149
|
+
return "";
|
|
23150
|
+
}
|
|
23151
|
+
if (!hashPrefix) {
|
|
23152
|
+
const rootVal = resolvePathValue(rootData, cleanExpr);
|
|
23153
|
+
if (rootVal !== void 0 && rootVal !== null && typeof rootVal !== "object") {
|
|
23154
|
+
return String(rootVal);
|
|
23155
|
+
}
|
|
23003
23156
|
}
|
|
23004
23157
|
return full;
|
|
23005
23158
|
});
|
|
23006
23159
|
}
|
|
23160
|
+
function renderLoopCellContent(body, cell, cellSdts, detectedListKey, itemObj, rowSeqIndex, rootData, hasExplicitListKey) {
|
|
23161
|
+
if (cellSdts.length === 0) {
|
|
23162
|
+
return replaceRowCellTokens(
|
|
23163
|
+
cell.rawText,
|
|
23164
|
+
detectedListKey,
|
|
23165
|
+
itemObj,
|
|
23166
|
+
rowSeqIndex,
|
|
23167
|
+
rootData,
|
|
23168
|
+
hasExplicitListKey
|
|
23169
|
+
);
|
|
23170
|
+
}
|
|
23171
|
+
let out = "";
|
|
23172
|
+
let cursor = cell.contentStart;
|
|
23173
|
+
for (const { range, resolved } of cellSdts) {
|
|
23174
|
+
if (range.startIndex < cursor) continue;
|
|
23175
|
+
if (range.startIndex > cursor) {
|
|
23176
|
+
const pre = body.dataStream.slice(cursor, range.startIndex);
|
|
23177
|
+
out += replaceRowCellTokens(
|
|
23178
|
+
pre,
|
|
23179
|
+
detectedListKey,
|
|
23180
|
+
itemObj,
|
|
23181
|
+
rowSeqIndex,
|
|
23182
|
+
rootData,
|
|
23183
|
+
hasExplicitListKey
|
|
23184
|
+
);
|
|
23185
|
+
}
|
|
23186
|
+
if (itemObj === null) {
|
|
23187
|
+
out += "";
|
|
23188
|
+
} else {
|
|
23189
|
+
const candidates = [resolved.bindingPath, resolved.tag].filter(
|
|
23190
|
+
(c) => typeof c === "string" && c.trim().length > 0
|
|
23191
|
+
);
|
|
23192
|
+
let matched = false;
|
|
23193
|
+
let rawVal = void 0;
|
|
23194
|
+
for (const rawCand of candidates) {
|
|
23195
|
+
const cand = rawCand.trim().replace(/^#/, "");
|
|
23196
|
+
if (cand === `${detectedListKey}._index`) {
|
|
23197
|
+
rawVal = String(rowSeqIndex + 1);
|
|
23198
|
+
matched = true;
|
|
23199
|
+
break;
|
|
23200
|
+
}
|
|
23201
|
+
if (cand.startsWith(`${detectedListKey}.`)) {
|
|
23202
|
+
const subPath = cand.slice(detectedListKey.length + 1);
|
|
23203
|
+
rawVal = subPath === "_index" ? String(rowSeqIndex + 1) : resolvePathValue(itemObj, subPath);
|
|
23204
|
+
matched = true;
|
|
23205
|
+
break;
|
|
23206
|
+
}
|
|
23207
|
+
}
|
|
23208
|
+
if (!matched) {
|
|
23209
|
+
for (const rawCand of candidates) {
|
|
23210
|
+
const cand = rawCand.trim().replace(/^#/, "");
|
|
23211
|
+
if (cand === "_index") {
|
|
23212
|
+
rawVal = String(rowSeqIndex + 1);
|
|
23213
|
+
matched = true;
|
|
23214
|
+
break;
|
|
23215
|
+
}
|
|
23216
|
+
const directItemVal = resolvePathValue(itemObj, cand);
|
|
23217
|
+
if (directItemVal !== void 0) {
|
|
23218
|
+
rawVal = directItemVal;
|
|
23219
|
+
matched = true;
|
|
23220
|
+
break;
|
|
23221
|
+
}
|
|
23222
|
+
}
|
|
23223
|
+
}
|
|
23224
|
+
if (!matched) {
|
|
23225
|
+
for (const rawCand of candidates) {
|
|
23226
|
+
const cand = rawCand.trim().replace(/^#/, "");
|
|
23227
|
+
const rootVal = resolvePathValue(rootData, cand);
|
|
23228
|
+
if (rootVal !== void 0 && rootVal !== null && typeof rootVal !== "object") {
|
|
23229
|
+
rawVal = rootVal;
|
|
23230
|
+
matched = true;
|
|
23231
|
+
break;
|
|
23232
|
+
}
|
|
23233
|
+
}
|
|
23234
|
+
}
|
|
23235
|
+
if (!matched && hasExplicitListKey) {
|
|
23236
|
+
rawVal = "";
|
|
23237
|
+
matched = true;
|
|
23238
|
+
}
|
|
23239
|
+
if (!matched) {
|
|
23240
|
+
out += resolved.showingPlaceholder ? "" : resolved.displayText;
|
|
23241
|
+
} else if (typeof rawVal === "boolean") {
|
|
23242
|
+
out += formatSdtDisplayText(resolved, rawVal).text;
|
|
23243
|
+
} else if (rawVal == null || String(rawVal) === "") {
|
|
23244
|
+
out += "";
|
|
23245
|
+
} else {
|
|
23246
|
+
const strVal = Array.isArray(rawVal) ? rawVal.join(",") : String(rawVal);
|
|
23247
|
+
out += formatSdtDisplayText(resolved, strVal).text;
|
|
23248
|
+
}
|
|
23249
|
+
}
|
|
23250
|
+
cursor = Math.min(cell.textEndExclusive, range.endIndex + 1);
|
|
23251
|
+
}
|
|
23252
|
+
if (cursor < cell.textEndExclusive) {
|
|
23253
|
+
const tail = body.dataStream.slice(cursor, cell.textEndExclusive);
|
|
23254
|
+
out += replaceRowCellTokens(
|
|
23255
|
+
tail,
|
|
23256
|
+
detectedListKey,
|
|
23257
|
+
itemObj,
|
|
23258
|
+
rowSeqIndex,
|
|
23259
|
+
rootData,
|
|
23260
|
+
hasExplicitListKey
|
|
23261
|
+
);
|
|
23262
|
+
}
|
|
23263
|
+
return out;
|
|
23264
|
+
}
|
|
23007
23265
|
function expandDocTableRowLoopsInPlace(nextSnapshot, data, explicitLoops) {
|
|
23008
23266
|
const body = nextSnapshot.body;
|
|
23009
23267
|
if (!body?.tables?.length) return;
|
|
@@ -23012,92 +23270,196 @@ function expandDocTableRowLoopsInPlace(nextSnapshot, data, explicitLoops) {
|
|
|
23012
23270
|
...snapMeta.tableRowLoops ?? {},
|
|
23013
23271
|
...explicitLoops ?? {}
|
|
23014
23272
|
};
|
|
23273
|
+
const consumedLoopKeys = /* @__PURE__ */ new Set();
|
|
23274
|
+
let metaChanged = false;
|
|
23015
23275
|
for (let tIdx = body.tables.length - 1; tIdx >= 0; tIdx--) {
|
|
23016
23276
|
const tblRef = body.tables[tIdx];
|
|
23017
23277
|
const parsedRows = parseTableRowsInStream(body.dataStream, tblRef.startIndex, tblRef.endIndex);
|
|
23018
23278
|
if (parsedRows.length === 0) continue;
|
|
23019
23279
|
const tblSource = nextSnapshot.tableSource?.[tblRef.tableId];
|
|
23280
|
+
let remainingRowCount = parsedRows.length;
|
|
23020
23281
|
for (let rIdx = parsedRows.length - 1; rIdx >= 0; rIdx--) {
|
|
23021
23282
|
const rowSpan = parsedRows[rIdx];
|
|
23022
|
-
const
|
|
23023
|
-
|
|
23283
|
+
const loopKey = `${tblRef.tableId}:${rIdx}`;
|
|
23284
|
+
const explicitCfg = loopMap[loopKey];
|
|
23285
|
+
const hasExplicitListKey = Boolean(explicitCfg?.listKey?.trim());
|
|
23286
|
+
const rowCellSdts = rowSpan.cells.map((cell) => {
|
|
23287
|
+
const hits = [];
|
|
23288
|
+
for (const r of body.customRanges ?? []) {
|
|
23289
|
+
if (r.rangeType === import_core13.CustomRangeType.SDT && r.startIndex >= cell.contentStart && r.endIndex < cell.textEndExclusive) {
|
|
23290
|
+
const parsed = parseSdtRangeToResolved(body, r);
|
|
23291
|
+
if (parsed && parsed.kind !== "group") {
|
|
23292
|
+
hits.push({ range: r, resolved: parsed });
|
|
23293
|
+
}
|
|
23294
|
+
}
|
|
23295
|
+
}
|
|
23296
|
+
return hits.sort((a, b) => a.range.startIndex - b.range.startIndex);
|
|
23297
|
+
});
|
|
23298
|
+
let detectedListKey = explicitCfg?.listKey?.trim() ?? "";
|
|
23024
23299
|
if (!detectedListKey) {
|
|
23025
23300
|
const joinedCells = rowSpan.cells.map((c) => c.rawText).join(" ");
|
|
23026
|
-
|
|
23027
|
-
const explicitMatch =
|
|
23028
|
-
if (explicitMatch) {
|
|
23029
|
-
detectedListKey = explicitMatch[1];
|
|
23030
|
-
}
|
|
23031
|
-
|
|
23301
|
+
EXPLICIT_NESTED_LIST_TOKEN_RE.lastIndex = 0;
|
|
23302
|
+
const explicitMatch = EXPLICIT_NESTED_LIST_TOKEN_RE.exec(joinedCells);
|
|
23303
|
+
if (explicitMatch && explicitMatch[1].includes(".")) {
|
|
23304
|
+
detectedListKey = resolveCandidateListPrefix(explicitMatch[1], data, true);
|
|
23305
|
+
}
|
|
23306
|
+
if (!detectedListKey) {
|
|
23307
|
+
ANY_CELL_TOKEN_RE.lastIndex = 0;
|
|
23032
23308
|
let tokMatch;
|
|
23033
|
-
while ((tokMatch =
|
|
23034
|
-
const
|
|
23035
|
-
if (
|
|
23036
|
-
|
|
23309
|
+
while ((tokMatch = ANY_CELL_TOKEN_RE.exec(joinedCells)) !== null) {
|
|
23310
|
+
const expr = tokMatch[2];
|
|
23311
|
+
if (!expr.includes(".")) continue;
|
|
23312
|
+
const cand = resolveCandidateListPrefix(expr, data, false);
|
|
23313
|
+
if (cand) {
|
|
23314
|
+
detectedListKey = cand;
|
|
23037
23315
|
break;
|
|
23038
23316
|
}
|
|
23039
23317
|
}
|
|
23040
23318
|
}
|
|
23319
|
+
if (!detectedListKey) {
|
|
23320
|
+
for (const cellSdts of rowCellSdts) {
|
|
23321
|
+
for (const { resolved } of cellSdts) {
|
|
23322
|
+
for (const rawCand of [resolved.bindingPath, resolved.tag]) {
|
|
23323
|
+
if (rawCand && rawCand.includes(".")) {
|
|
23324
|
+
const cand = resolveCandidateListPrefix(rawCand, data, false);
|
|
23325
|
+
if (cand) {
|
|
23326
|
+
detectedListKey = cand;
|
|
23327
|
+
break;
|
|
23328
|
+
}
|
|
23329
|
+
}
|
|
23330
|
+
}
|
|
23331
|
+
if (detectedListKey) break;
|
|
23332
|
+
}
|
|
23333
|
+
if (detectedListKey) break;
|
|
23334
|
+
}
|
|
23335
|
+
}
|
|
23041
23336
|
}
|
|
23042
23337
|
if (!detectedListKey) continue;
|
|
23043
|
-
|
|
23338
|
+
consumedLoopKeys.add(loopKey);
|
|
23339
|
+
const rawItems = resolvePathValue(data, detectedListKey) ?? data?.[detectedListKey];
|
|
23044
23340
|
const items = Array.isArray(rawItems) ? rawItems : [];
|
|
23045
23341
|
const emptyStrategy = explicitCfg?.emptyStrategy ?? "keep-blank";
|
|
23046
23342
|
const repeatHeader = explicitCfg?.repeatHeaderRow ?? true;
|
|
23047
|
-
if (
|
|
23048
|
-
tblSource
|
|
23049
|
-
|
|
23050
|
-
|
|
23051
|
-
|
|
23052
|
-
|
|
23343
|
+
if (explicitCfg?.repeatHeaderRow === false) {
|
|
23344
|
+
if (tblSource?.tableRows) {
|
|
23345
|
+
const upper = Math.max(1, rIdx);
|
|
23346
|
+
for (let h = 0; h < upper && h < tblSource.tableRows.length; h++) {
|
|
23347
|
+
tblSource.tableRows[h] = {
|
|
23348
|
+
...tblSource.tableRows[h],
|
|
23349
|
+
repeatHeaderRow: import_core13.BooleanNumber.FALSE
|
|
23350
|
+
};
|
|
23351
|
+
}
|
|
23352
|
+
}
|
|
23353
|
+
if (snapMeta.tableRepeatHeaders && tblRef.tableId in snapMeta.tableRepeatHeaders) {
|
|
23354
|
+
delete snapMeta.tableRepeatHeaders[tblRef.tableId];
|
|
23355
|
+
metaChanged = true;
|
|
23356
|
+
}
|
|
23357
|
+
} else if (repeatHeader && rIdx > 0 && tblSource?.tableRows) {
|
|
23358
|
+
for (let h = 0; h < rIdx && h < tblSource.tableRows.length; h++) {
|
|
23359
|
+
tblSource.tableRows[h] = {
|
|
23360
|
+
...tblSource.tableRows[h],
|
|
23361
|
+
...h === 0 ? { isFirstRow: import_core13.BooleanNumber.TRUE } : {},
|
|
23362
|
+
repeatHeaderRow: import_core13.BooleanNumber.TRUE
|
|
23363
|
+
};
|
|
23364
|
+
}
|
|
23053
23365
|
}
|
|
23054
|
-
if (items.length === 0 && emptyStrategy === "remove" &&
|
|
23366
|
+
if (items.length === 0 && emptyStrategy === "remove" && remainingRowCount > 1) {
|
|
23367
|
+
remainingRowCount--;
|
|
23055
23368
|
const removeStart = rowSpan.rowStart;
|
|
23056
23369
|
const removeEnd = rowSpan.rowEndInclusive;
|
|
23057
|
-
const
|
|
23058
|
-
|
|
23059
|
-
body.
|
|
23370
|
+
const rowEndExclusive2 = removeEnd + 1;
|
|
23371
|
+
const removedLen = rowEndExclusive2 - removeStart;
|
|
23372
|
+
body.dataStream = body.dataStream.slice(0, removeStart) + body.dataStream.slice(rowEndExclusive2);
|
|
23373
|
+
body.paragraphs = (body.paragraphs ?? []).filter((p) => p.startIndex < removeStart || p.startIndex >= rowEndExclusive2).map((p) => ({
|
|
23060
23374
|
...p,
|
|
23061
|
-
startIndex: p.startIndex
|
|
23375
|
+
startIndex: p.startIndex >= rowEndExclusive2 ? p.startIndex - removedLen : p.startIndex
|
|
23062
23376
|
}));
|
|
23063
|
-
body.sectionBreaks = (body.sectionBreaks ?? []).filter((s) => s.startIndex < removeStart || s.startIndex
|
|
23377
|
+
body.sectionBreaks = (body.sectionBreaks ?? []).filter((s) => s.startIndex < removeStart || s.startIndex >= rowEndExclusive2).map((s) => ({
|
|
23064
23378
|
...s,
|
|
23065
|
-
startIndex: s.startIndex
|
|
23379
|
+
startIndex: s.startIndex >= rowEndExclusive2 ? s.startIndex - removedLen : s.startIndex
|
|
23066
23380
|
}));
|
|
23067
|
-
body.customBlocks = (body.customBlocks ?? []).filter((b) => b.startIndex < removeStart || b.startIndex
|
|
23381
|
+
body.customBlocks = (body.customBlocks ?? []).filter((b) => b.startIndex < removeStart || b.startIndex >= rowEndExclusive2).map((b) => ({
|
|
23068
23382
|
...b,
|
|
23069
|
-
startIndex: b.startIndex
|
|
23383
|
+
startIndex: b.startIndex >= rowEndExclusive2 ? b.startIndex - removedLen : b.startIndex
|
|
23070
23384
|
}));
|
|
23071
|
-
|
|
23072
|
-
|
|
23073
|
-
|
|
23074
|
-
|
|
23075
|
-
|
|
23076
|
-
|
|
23385
|
+
const nextRangesOnRemove = [];
|
|
23386
|
+
for (const r of body.customRanges ?? []) {
|
|
23387
|
+
if (r.endIndex < removeStart) {
|
|
23388
|
+
nextRangesOnRemove.push(r);
|
|
23389
|
+
} else if (r.startIndex >= rowEndExclusive2) {
|
|
23390
|
+
nextRangesOnRemove.push({
|
|
23391
|
+
...r,
|
|
23392
|
+
startIndex: r.startIndex - removedLen,
|
|
23393
|
+
endIndex: r.endIndex - removedLen
|
|
23394
|
+
});
|
|
23395
|
+
} else if (r.startIndex < removeStart && r.endIndex >= rowEndExclusive2) {
|
|
23396
|
+
nextRangesOnRemove.push({
|
|
23397
|
+
...r,
|
|
23398
|
+
endIndex: r.endIndex - removedLen
|
|
23399
|
+
});
|
|
23400
|
+
}
|
|
23401
|
+
}
|
|
23402
|
+
body.customRanges = nextRangesOnRemove;
|
|
23403
|
+
const nextRunsOnRemove = [];
|
|
23404
|
+
for (const tr of body.textRuns ?? []) {
|
|
23405
|
+
if (tr.ed <= removeStart) {
|
|
23406
|
+
nextRunsOnRemove.push(tr);
|
|
23407
|
+
} else if (tr.st >= rowEndExclusive2) {
|
|
23408
|
+
nextRunsOnRemove.push({ ...tr, st: tr.st - removedLen, ed: tr.ed - removedLen });
|
|
23409
|
+
} else if (tr.st < removeStart && tr.ed > rowEndExclusive2) {
|
|
23410
|
+
nextRunsOnRemove.push({ ...tr, ed: tr.ed - removedLen });
|
|
23411
|
+
} else if (tr.st < removeStart) {
|
|
23412
|
+
nextRunsOnRemove.push({ ...tr, ed: removeStart });
|
|
23413
|
+
} else if (tr.ed > rowEndExclusive2) {
|
|
23414
|
+
nextRunsOnRemove.push({ ...tr, st: removeStart, ed: tr.ed - removedLen });
|
|
23415
|
+
}
|
|
23416
|
+
}
|
|
23417
|
+
body.textRuns = nextRunsOnRemove.filter((r) => r.ed > r.st);
|
|
23077
23418
|
body.tables = body.tables.map((t, idx) => {
|
|
23078
|
-
if (idx === tIdx
|
|
23079
|
-
|
|
23419
|
+
if (idx === tIdx || t.startIndex <= removeStart && t.endIndex >= rowEndExclusive2) {
|
|
23420
|
+
return { ...t, endIndex: t.endIndex - removedLen };
|
|
23421
|
+
}
|
|
23422
|
+
if (t.startIndex >= rowEndExclusive2) {
|
|
23080
23423
|
return { ...t, startIndex: t.startIndex - removedLen, endIndex: t.endIndex - removedLen };
|
|
23081
23424
|
}
|
|
23082
23425
|
return t;
|
|
23083
23426
|
});
|
|
23084
23427
|
if (tblSource?.tableRows?.[rIdx]) {
|
|
23085
23428
|
tblSource.tableRows.splice(rIdx, 1);
|
|
23429
|
+
if (rIdx === 0 && tblSource.tableRows[0]) {
|
|
23430
|
+
tblSource.tableRows[0] = { ...tblSource.tableRows[0], isFirstRow: import_core13.BooleanNumber.TRUE };
|
|
23431
|
+
}
|
|
23086
23432
|
}
|
|
23087
23433
|
continue;
|
|
23088
23434
|
}
|
|
23089
23435
|
const effectiveRows = items.length > 0 ? items : [null];
|
|
23090
|
-
|
|
23436
|
+
remainingRowCount += effectiveRows.length - 1;
|
|
23437
|
+
const effectiveEmptyStrategy = emptyStrategy === "remove" ? "keep-blank" : emptyStrategy;
|
|
23438
|
+
const cellStyles = rowSpan.cells.map((cell, cIdx) => {
|
|
23439
|
+
const cellSdts = rowCellSdts[cIdx];
|
|
23440
|
+
const nonSdtRun = (body.textRuns ?? []).find((tr) => {
|
|
23441
|
+
if (tr.ed <= cell.contentStart || tr.st >= cell.textEndExclusive) return false;
|
|
23442
|
+
return !cellSdts.some((s) => tr.st >= s.range.startIndex && tr.ed <= s.range.endIndex + 1);
|
|
23443
|
+
});
|
|
23444
|
+
if (nonSdtRun?.ts) {
|
|
23445
|
+
return sanitizeLoopCellRunStyle(nonSdtRun.ts);
|
|
23446
|
+
}
|
|
23447
|
+
const anchorTypo = cellSdts.length > 0 ? resolveRangeAnchorTypography(body, cellSdts[0].range) : void 0;
|
|
23091
23448
|
const hitRun = (body.textRuns ?? []).find(
|
|
23092
23449
|
(tr) => tr.st <= cell.contentStart && tr.ed > cell.contentStart
|
|
23093
23450
|
);
|
|
23094
|
-
return hitRun?.ts;
|
|
23451
|
+
return sanitizeLoopCellRunStyle(hitRun?.ts, anchorTypo);
|
|
23095
23452
|
});
|
|
23096
23453
|
const templateCellParas = rowSpan.cells.map(
|
|
23097
|
-
(cell) => (body.paragraphs ?? []).
|
|
23454
|
+
(cell) => (body.paragraphs ?? []).filter(
|
|
23098
23455
|
(p) => p.startIndex >= cell.contentStart && p.startIndex < cell.cellEndInclusive
|
|
23099
23456
|
)
|
|
23100
23457
|
);
|
|
23458
|
+
const templateCellSections = rowSpan.cells.map(
|
|
23459
|
+
(cell) => (body.sectionBreaks ?? []).find(
|
|
23460
|
+
(s) => s.startIndex >= cell.contentStart && s.startIndex < cell.cellEndInclusive
|
|
23461
|
+
)
|
|
23462
|
+
);
|
|
23101
23463
|
let builtStream = "";
|
|
23102
23464
|
const builtParas = [];
|
|
23103
23465
|
const builtSections = [];
|
|
@@ -23107,34 +23469,53 @@ function expandDocTableRowLoopsInPlace(nextSnapshot, data, explicitLoops) {
|
|
|
23107
23469
|
builtStream += import_core13.DataStreamTreeTokenType.TABLE_ROW_START;
|
|
23108
23470
|
rowSpan.cells.forEach((cell, cIdx) => {
|
|
23109
23471
|
builtStream += import_core13.DataStreamTreeTokenType.TABLE_CELL_START;
|
|
23110
|
-
|
|
23111
|
-
|
|
23112
|
-
|
|
23113
|
-
cellText = cIdx === 0 ? explicitCfg?.emptyPlaceholderText || "\u6682\u65E0\u660E\u7EC6\u6570\u636E" : "";
|
|
23472
|
+
let rawRendered;
|
|
23473
|
+
if (itemObj === null && effectiveEmptyStrategy === "placeholder") {
|
|
23474
|
+
rawRendered = cIdx === 0 ? explicitCfg?.emptyPlaceholderText || "\u6682\u65E0\u660E\u7EC6\u6570\u636E" : "";
|
|
23114
23475
|
} else {
|
|
23115
|
-
|
|
23476
|
+
rawRendered = renderLoopCellContent(
|
|
23477
|
+
body,
|
|
23478
|
+
cell,
|
|
23479
|
+
rowCellSdts[cIdx],
|
|
23480
|
+
detectedListKey,
|
|
23481
|
+
itemObj,
|
|
23482
|
+
cloneIdx,
|
|
23483
|
+
data,
|
|
23484
|
+
hasExplicitListKey
|
|
23485
|
+
);
|
|
23116
23486
|
}
|
|
23117
|
-
|
|
23118
|
-
const
|
|
23119
|
-
|
|
23120
|
-
|
|
23121
|
-
|
|
23122
|
-
|
|
23123
|
-
|
|
23487
|
+
const normalizedCellText = rawRendered.replace(/\r\n/g, "\r").replace(/\n/g, "\r");
|
|
23488
|
+
const cellLines = normalizedCellText.split("\r");
|
|
23489
|
+
const tplParasInCell = templateCellParas[cIdx];
|
|
23490
|
+
const fallbackTplPara = tplParasInCell.length > 0 ? tplParasInCell[tplParasInCell.length - 1] : void 0;
|
|
23491
|
+
cellLines.forEach((lineText, lineIdx) => {
|
|
23492
|
+
const lineStart = baseInsertOffset + builtStream.length;
|
|
23493
|
+
builtStream += lineText;
|
|
23494
|
+
const lineEnd = baseInsertOffset + builtStream.length;
|
|
23495
|
+
if (cellStyles[cIdx] && lineEnd > lineStart) {
|
|
23496
|
+
builtRuns.push({
|
|
23497
|
+
st: lineStart,
|
|
23498
|
+
ed: lineEnd,
|
|
23499
|
+
ts: import_core13.Tools.deepClone(cellStyles[cIdx])
|
|
23500
|
+
});
|
|
23501
|
+
}
|
|
23502
|
+
const pOffset = baseInsertOffset + builtStream.length;
|
|
23503
|
+
builtStream += import_core13.DataStreamTreeTokenType.PARAGRAPH;
|
|
23504
|
+
const tplPara = tplParasInCell[lineIdx] ?? fallbackTplPara;
|
|
23505
|
+
const isFinalLine = lineIdx === cellLines.length - 1;
|
|
23506
|
+
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}`;
|
|
23507
|
+
builtParas.push({
|
|
23508
|
+
...tplPara ? import_core13.Tools.deepClone(tplPara) : {},
|
|
23509
|
+
paragraphId: deterministicParaId,
|
|
23510
|
+
startIndex: pOffset
|
|
23124
23511
|
});
|
|
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
23512
|
});
|
|
23134
23513
|
const sOffset = baseInsertOffset + builtStream.length;
|
|
23135
23514
|
builtStream += import_core13.DataStreamTreeTokenType.SECTION_BREAK;
|
|
23515
|
+
const tplSec = templateCellSections[cIdx];
|
|
23136
23516
|
builtSections.push({
|
|
23137
|
-
|
|
23517
|
+
...tplSec ? import_core13.Tools.deepClone(tplSec) : {},
|
|
23518
|
+
sectionId: cloneIdx === 0 && tplSec?.sectionId ? tplSec.sectionId : `s_loop_${tblRef.tableId}_r${rIdx}_${cloneIdx}_c${cIdx}`,
|
|
23138
23519
|
startIndex: sOffset
|
|
23139
23520
|
});
|
|
23140
23521
|
builtStream += import_core13.DataStreamTreeTokenType.TABLE_CELL_END;
|
|
@@ -23143,50 +23524,77 @@ function expandDocTableRowLoopsInPlace(nextSnapshot, data, explicitLoops) {
|
|
|
23143
23524
|
});
|
|
23144
23525
|
const oldStart = rowSpan.rowStart;
|
|
23145
23526
|
const oldEnd = rowSpan.rowEndInclusive;
|
|
23146
|
-
const
|
|
23527
|
+
const rowEndExclusive = oldEnd + 1;
|
|
23528
|
+
const oldLen = rowEndExclusive - oldStart;
|
|
23147
23529
|
const delta = builtStream.length - oldLen;
|
|
23148
|
-
body.dataStream = body.dataStream.slice(0, oldStart) + builtStream + body.dataStream.slice(
|
|
23530
|
+
body.dataStream = body.dataStream.slice(0, oldStart) + builtStream + body.dataStream.slice(rowEndExclusive);
|
|
23149
23531
|
body.paragraphs = [
|
|
23150
23532
|
...(body.paragraphs ?? []).filter((p) => p.startIndex < oldStart),
|
|
23151
23533
|
...builtParas,
|
|
23152
|
-
...(body.paragraphs ?? []).filter((p) => p.startIndex
|
|
23534
|
+
...(body.paragraphs ?? []).filter((p) => p.startIndex >= rowEndExclusive).map((p) => ({ ...p, startIndex: p.startIndex + delta }))
|
|
23153
23535
|
].sort((a, b) => a.startIndex - b.startIndex);
|
|
23154
23536
|
body.sectionBreaks = [
|
|
23155
23537
|
...(body.sectionBreaks ?? []).filter((s) => s.startIndex < oldStart),
|
|
23156
23538
|
...builtSections,
|
|
23157
|
-
...(body.sectionBreaks ?? []).filter((s) => s.startIndex
|
|
23539
|
+
...(body.sectionBreaks ?? []).filter((s) => s.startIndex >= rowEndExclusive).map((s) => ({ ...s, startIndex: s.startIndex + delta }))
|
|
23158
23540
|
].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
|
|
23541
|
+
body.customBlocks = (body.customBlocks ?? []).filter((b) => b.startIndex < oldStart || b.startIndex >= rowEndExclusive).map(
|
|
23542
|
+
(b) => b.startIndex >= rowEndExclusive ? { ...b, startIndex: b.startIndex + delta } : b
|
|
23164
23543
|
);
|
|
23544
|
+
const nextCustomRanges = [];
|
|
23545
|
+
for (const r of body.customRanges ?? []) {
|
|
23546
|
+
if (r.endIndex < oldStart) {
|
|
23547
|
+
nextCustomRanges.push(r);
|
|
23548
|
+
} else if (r.startIndex >= rowEndExclusive) {
|
|
23549
|
+
nextCustomRanges.push({
|
|
23550
|
+
...r,
|
|
23551
|
+
startIndex: r.startIndex + delta,
|
|
23552
|
+
endIndex: r.endIndex + delta
|
|
23553
|
+
});
|
|
23554
|
+
} else if (r.startIndex < oldStart && r.endIndex >= rowEndExclusive) {
|
|
23555
|
+
nextCustomRanges.push({
|
|
23556
|
+
...r,
|
|
23557
|
+
endIndex: r.endIndex + delta
|
|
23558
|
+
});
|
|
23559
|
+
}
|
|
23560
|
+
}
|
|
23561
|
+
body.customRanges = nextCustomRanges;
|
|
23165
23562
|
const nextRuns = [];
|
|
23166
23563
|
for (const tr of body.textRuns ?? []) {
|
|
23167
23564
|
if (tr.ed <= oldStart) {
|
|
23168
23565
|
nextRuns.push(tr);
|
|
23169
|
-
} else if (tr.st
|
|
23566
|
+
} else if (tr.st >= rowEndExclusive) {
|
|
23170
23567
|
nextRuns.push({ ...tr, st: tr.st + delta, ed: tr.ed + delta });
|
|
23171
|
-
} else
|
|
23172
|
-
|
|
23568
|
+
} else {
|
|
23569
|
+
if (tr.st < oldStart) {
|
|
23570
|
+
nextRuns.push({ ...tr, ed: oldStart });
|
|
23571
|
+
}
|
|
23572
|
+
if (tr.ed > rowEndExclusive) {
|
|
23573
|
+
nextRuns.push({
|
|
23574
|
+
...tr,
|
|
23575
|
+
st: oldStart + builtStream.length,
|
|
23576
|
+
ed: tr.ed + delta
|
|
23577
|
+
});
|
|
23578
|
+
}
|
|
23173
23579
|
}
|
|
23174
23580
|
}
|
|
23175
23581
|
nextRuns.push(...builtRuns);
|
|
23176
23582
|
nextRuns.sort((a, b) => a.st - b.st || a.ed - b.ed);
|
|
23177
23583
|
body.textRuns = nextRuns.filter((r) => r.ed > r.st);
|
|
23178
23584
|
body.tables = body.tables.map((t, idx) => {
|
|
23179
|
-
if (idx === tIdx
|
|
23180
|
-
|
|
23585
|
+
if (idx === tIdx || t.startIndex <= oldStart && t.endIndex >= rowEndExclusive) {
|
|
23586
|
+
return { ...t, endIndex: t.endIndex + delta };
|
|
23587
|
+
}
|
|
23588
|
+
if (t.startIndex >= rowEndExclusive) {
|
|
23181
23589
|
return { ...t, startIndex: t.startIndex + delta, endIndex: t.endIndex + delta };
|
|
23182
23590
|
}
|
|
23183
23591
|
return t;
|
|
23184
23592
|
});
|
|
23185
23593
|
if (tblSource?.tableRows?.[rIdx]) {
|
|
23186
23594
|
const tplRow = tblSource.tableRows[rIdx];
|
|
23187
|
-
const clonedRowDefs = effectiveRows.map(() => {
|
|
23595
|
+
const clonedRowDefs = effectiveRows.map((_, cloneIdx) => {
|
|
23188
23596
|
const cloned = import_core13.Tools.deepClone(tplRow);
|
|
23189
|
-
cloned.isFirstRow = import_core13.BooleanNumber.FALSE;
|
|
23597
|
+
cloned.isFirstRow = rIdx === 0 && cloneIdx === 0 ? import_core13.BooleanNumber.TRUE : import_core13.BooleanNumber.FALSE;
|
|
23190
23598
|
cloned.repeatHeaderRow = import_core13.BooleanNumber.FALSE;
|
|
23191
23599
|
return cloned;
|
|
23192
23600
|
});
|
|
@@ -23194,6 +23602,18 @@ function expandDocTableRowLoopsInPlace(nextSnapshot, data, explicitLoops) {
|
|
|
23194
23602
|
}
|
|
23195
23603
|
}
|
|
23196
23604
|
}
|
|
23605
|
+
if (consumedLoopKeys.size > 0 || metaChanged) {
|
|
23606
|
+
const nextLoops = { ...snapMeta.tableRowLoops ?? {} };
|
|
23607
|
+
for (const k of consumedLoopKeys) {
|
|
23608
|
+
delete nextLoops[k];
|
|
23609
|
+
}
|
|
23610
|
+
const nextRepeatHeaders = snapMeta.tableRepeatHeaders ? { ...snapMeta.tableRepeatHeaders } : void 0;
|
|
23611
|
+
writeDocTemplateMetadataToSnapshot(nextSnapshot, {
|
|
23612
|
+
...snapMeta,
|
|
23613
|
+
tableRowLoops: Object.keys(nextLoops).length > 0 ? nextLoops : void 0,
|
|
23614
|
+
tableRepeatHeaders: nextRepeatHeaders && Object.keys(nextRepeatHeaders).length > 0 ? nextRepeatHeaders : void 0
|
|
23615
|
+
});
|
|
23616
|
+
}
|
|
23197
23617
|
}
|
|
23198
23618
|
function parseIsoDateForExpr(raw) {
|
|
23199
23619
|
if (raw == null) return null;
|
|
@@ -23284,6 +23704,7 @@ function evaluateVisibleIfCondition(expr, data) {
|
|
|
23284
23704
|
function fillDatasetIntoDocSnapshot(snapshot, data, options) {
|
|
23285
23705
|
const nextSnapshot = import_core13.Tools.deepClone(snapshot);
|
|
23286
23706
|
if (!nextSnapshot.body) return nextSnapshot;
|
|
23707
|
+
const cleanFilledChrome = options?.cleanFilledChrome !== false;
|
|
23287
23708
|
expandDocTableRowLoopsInPlace(nextSnapshot, data, options?.tableRowLoops);
|
|
23288
23709
|
const controls = listDocSdtControls(nextSnapshot);
|
|
23289
23710
|
for (const ctrl of controls) {
|
|
@@ -23340,7 +23761,7 @@ function fillDatasetIntoDocSnapshot(snapshot, data, options) {
|
|
|
23340
23761
|
false,
|
|
23341
23762
|
true,
|
|
23342
23763
|
void 0,
|
|
23343
|
-
ctrl.visualChrome,
|
|
23764
|
+
cleanFilledChrome ? ctrl.visualChrome ?? "clean" : ctrl.visualChrome,
|
|
23344
23765
|
anchorTypo
|
|
23345
23766
|
);
|
|
23346
23767
|
const updatedSegBody2 = spliceMultiParagraphBodySpan(
|
|
@@ -23365,13 +23786,14 @@ function fillDatasetIntoDocSnapshot(snapshot, data, options) {
|
|
|
23365
23786
|
normalizedValue
|
|
23366
23787
|
);
|
|
23367
23788
|
const matchedHighlight = !showingPlaceholder ? matchSdtHighlightRule(ctrl.highlightRules, `${text} ${String(normalizedValue)}`) : void 0;
|
|
23789
|
+
const effectiveChrome = !showingPlaceholder && cleanFilledChrome ? ctrl.visualChrome ?? "clean" : ctrl.visualChrome;
|
|
23368
23790
|
const style = computeSdtVisualStyle(
|
|
23369
23791
|
ctrl.kind,
|
|
23370
23792
|
ctrl.lock,
|
|
23371
23793
|
showingPlaceholder,
|
|
23372
23794
|
Boolean(ctrl.bindingPath),
|
|
23373
23795
|
matchedHighlight,
|
|
23374
|
-
|
|
23796
|
+
effectiveChrome,
|
|
23375
23797
|
anchorTypo,
|
|
23376
23798
|
{
|
|
23377
23799
|
underlineBlank: ctrl.underlineBlank,
|
|
@@ -23417,7 +23839,7 @@ function fillDatasetIntoDocSnapshot(snapshot, data, options) {
|
|
|
23417
23839
|
const pStart = matchedParaIdx === 0 ? 0 : paras[matchedParaIdx - 1].startIndex + 1;
|
|
23418
23840
|
const pEnd = paras[matchedParaIdx].startIndex;
|
|
23419
23841
|
const rawLine = workingBody.dataStream.slice(pStart, pEnd);
|
|
23420
|
-
const rawArr = data[listKey];
|
|
23842
|
+
const rawArr = resolvePathValue(data, listKey) ?? data[listKey];
|
|
23421
23843
|
const items = Array.isArray(rawArr) ? rawArr : [];
|
|
23422
23844
|
const expandedLines = (items.length > 0 ? items : [{}]).map(
|
|
23423
23845
|
(itemObj, idx) => rawLine.replace(EXPLICIT_LIST_TOKEN_RE, (_full, lKey, subKey) => {
|
|
@@ -23440,7 +23862,7 @@ function fillDatasetIntoDocSnapshot(snapshot, data, options) {
|
|
|
23440
23862
|
const crPos = cursor + line.length;
|
|
23441
23863
|
newParaEntries.push({
|
|
23442
23864
|
...import_core13.Tools.deepClone(templatePara),
|
|
23443
|
-
paragraphId: k === 0 ? templatePara.paragraphId : `
|
|
23865
|
+
paragraphId: k === 0 ? templatePara.paragraphId : `${templatePara.paragraphId || `p_${matchedParaIdx}`}_loop_${k}`,
|
|
23444
23866
|
startIndex: crPos
|
|
23445
23867
|
});
|
|
23446
23868
|
cursor = crPos + 1;
|
|
@@ -23507,7 +23929,7 @@ function fillDatasetIntoDocSnapshot(snapshot, data, options) {
|
|
|
23507
23929
|
nextSnapshot.tableSource = cascadeOutcome.snapshot.tableSource;
|
|
23508
23930
|
nextSnapshot.resources = cascadeOutcome.snapshot.resources;
|
|
23509
23931
|
}
|
|
23510
|
-
evaluateComputedSdtControlsInPlace(nextSnapshot, data);
|
|
23932
|
+
evaluateComputedSdtControlsInPlace(nextSnapshot, data, cleanFilledChrome);
|
|
23511
23933
|
recalculateInlineFormulasInPlace(nextSnapshot, data);
|
|
23512
23934
|
evaluateDocTableFormulasInPlace(nextSnapshot);
|
|
23513
23935
|
const snapMeta = readDocTemplateMetadataFromSnapshot(nextSnapshot);
|
|
@@ -24919,7 +25341,7 @@ function buildLiveDocFormContext(snapshot, extraData) {
|
|
|
24919
25341
|
ctx.__displayMap = displayMap;
|
|
24920
25342
|
return ctx;
|
|
24921
25343
|
}
|
|
24922
|
-
function evaluateComputedSdtControlsInPlace(snapshot, extraData) {
|
|
25344
|
+
function evaluateComputedSdtControlsInPlace(snapshot, extraData, cleanFilledChrome = false) {
|
|
24923
25345
|
if (!snapshot.body) return false;
|
|
24924
25346
|
const initialControls = listDocSdtControls(snapshot).filter((c) => Boolean(c.computedExpr?.trim()));
|
|
24925
25347
|
if (initialControls.length === 0) return false;
|
|
@@ -24954,13 +25376,14 @@ function evaluateComputedSdtControlsInPlace(snapshot, extraData) {
|
|
|
24954
25376
|
normalizedValue
|
|
24955
25377
|
);
|
|
24956
25378
|
const matchedHighlight = !showingPlaceholder ? matchSdtHighlightRule(latestResolved.highlightRules, `${text} ${String(normalizedValue)}`) : void 0;
|
|
25379
|
+
const effectiveChrome = !showingPlaceholder && cleanFilledChrome ? latestResolved.visualChrome ?? "clean" : latestResolved.visualChrome;
|
|
24957
25380
|
const style = computeSdtVisualStyle(
|
|
24958
25381
|
latestResolved.kind,
|
|
24959
25382
|
latestResolved.lock,
|
|
24960
25383
|
showingPlaceholder,
|
|
24961
25384
|
Boolean(latestResolved.bindingPath),
|
|
24962
25385
|
matchedHighlight,
|
|
24963
|
-
|
|
25386
|
+
effectiveChrome,
|
|
24964
25387
|
anchorTypo,
|
|
24965
25388
|
{
|
|
24966
25389
|
underlineBlank: latestResolved.underlineBlank,
|
|
@@ -25619,6 +26042,10 @@ DocSdtService = __decorateClass([
|
|
|
25619
26042
|
__decorateParam(0, import_core14.IUniverInstanceService)
|
|
25620
26043
|
], DocSdtService);
|
|
25621
26044
|
|
|
26045
|
+
// src/commands/doc-wave2.command.ts
|
|
26046
|
+
var import_core16 = require("@univerjs/core");
|
|
26047
|
+
var import_docs = require("@univerjs/docs");
|
|
26048
|
+
|
|
25622
26049
|
// src/commands/doc-v204.command.ts
|
|
25623
26050
|
var import_core15 = require("@univerjs/core");
|
|
25624
26051
|
var SyncDocAuxStateMutation = {
|
|
@@ -26488,8 +26915,6 @@ var RefreshDocTableOfContentsCommand = {
|
|
|
26488
26915
|
};
|
|
26489
26916
|
|
|
26490
26917
|
// src/commands/doc-wave2.command.ts
|
|
26491
|
-
var import_core16 = require("@univerjs/core");
|
|
26492
|
-
var import_docs = require("@univerjs/docs");
|
|
26493
26918
|
function buildAuxParams(unitId, snap, metadata) {
|
|
26494
26919
|
return {
|
|
26495
26920
|
unitId,
|
|
@@ -28996,16 +29421,21 @@ var FillDocDatasetCommand = {
|
|
|
28996
29421
|
const sdtService = accessor.get(IDocSdtService);
|
|
28997
29422
|
if (sdtService.getDocMode(docModel.getUnitId()) === "view") return false;
|
|
28998
29423
|
const unitId = docModel.getUnitId();
|
|
28999
|
-
const
|
|
29000
|
-
const
|
|
29001
|
-
|
|
29424
|
+
const prevMeta = import_core20.Tools.deepClone(sdtService.getTemplateMetadata(unitId));
|
|
29425
|
+
const prevSnap = import_core20.Tools.deepClone(docModel.getSnapshot());
|
|
29426
|
+
const baseSnap = import_core20.Tools.deepClone(prevSnap);
|
|
29427
|
+
writeDocTemplateMetadataToSnapshot(baseSnap, prevMeta);
|
|
29002
29428
|
const filledSnapshot = fillDatasetIntoDocSnapshot(baseSnap, params.data, {
|
|
29003
|
-
tableRowLoops:
|
|
29429
|
+
tableRowLoops: prevMeta.tableRowLoops
|
|
29004
29430
|
});
|
|
29005
29431
|
if (!filledSnapshot.body) return false;
|
|
29006
|
-
|
|
29007
|
-
|
|
29008
|
-
|
|
29432
|
+
return executeWave2SnapshotUpdateWithUndoRedo(
|
|
29433
|
+
accessor,
|
|
29434
|
+
docModel,
|
|
29435
|
+
prevSnap,
|
|
29436
|
+
prevMeta,
|
|
29437
|
+
filledSnapshot
|
|
29438
|
+
);
|
|
29009
29439
|
}
|
|
29010
29440
|
};
|
|
29011
29441
|
var ReplaceDocUnitSnapshotCommand = {
|
|
@@ -30863,6 +31293,17 @@ var DocExtensionRegistryService = class extends import_core23.Disposable {
|
|
|
30863
31293
|
// src/services/doc-io.service.ts
|
|
30864
31294
|
var import_core24 = require("@univerjs/core");
|
|
30865
31295
|
var import_rxjs4 = require("rxjs");
|
|
31296
|
+
var DOC_IO_CAPABILITY_FORMATS = [
|
|
31297
|
+
"docx",
|
|
31298
|
+
"doc",
|
|
31299
|
+
"rtf",
|
|
31300
|
+
"odt",
|
|
31301
|
+
"md",
|
|
31302
|
+
"html",
|
|
31303
|
+
"pdf",
|
|
31304
|
+
"txt",
|
|
31305
|
+
"json"
|
|
31306
|
+
];
|
|
30866
31307
|
var DocIoTargetError = class extends Error {
|
|
30867
31308
|
constructor(message) {
|
|
30868
31309
|
super(message);
|
|
@@ -30878,6 +31319,73 @@ async function normalizeToUint8Array(raw) {
|
|
|
30878
31319
|
if (raw instanceof ArrayBuffer) return new Uint8Array(raw);
|
|
30879
31320
|
return new Uint8Array(await raw.arrayBuffer());
|
|
30880
31321
|
}
|
|
31322
|
+
var DEFAULT_BROWSER_IMPORT_SET = /* @__PURE__ */ new Set([
|
|
31323
|
+
"docx",
|
|
31324
|
+
"doc",
|
|
31325
|
+
"rtf",
|
|
31326
|
+
"odt",
|
|
31327
|
+
"md",
|
|
31328
|
+
"html",
|
|
31329
|
+
"txt",
|
|
31330
|
+
"json"
|
|
31331
|
+
]);
|
|
31332
|
+
var DEFAULT_BROWSER_EXPORT_SET = /* @__PURE__ */ new Set([
|
|
31333
|
+
"docx",
|
|
31334
|
+
"doc",
|
|
31335
|
+
"rtf",
|
|
31336
|
+
"odt",
|
|
31337
|
+
"md",
|
|
31338
|
+
"html",
|
|
31339
|
+
"pdf",
|
|
31340
|
+
"txt",
|
|
31341
|
+
"json"
|
|
31342
|
+
]);
|
|
31343
|
+
function normalizeFormatKey(raw) {
|
|
31344
|
+
const lower = raw.trim().toLowerCase().replace(/^\./, "");
|
|
31345
|
+
if (lower === "markdown") return "md";
|
|
31346
|
+
if (lower === "htm") return "html";
|
|
31347
|
+
return lower;
|
|
31348
|
+
}
|
|
31349
|
+
function inferFormatFromFileName(fileName) {
|
|
31350
|
+
const m = fileName.trim().toLowerCase().match(/\.([^.]+)$/);
|
|
31351
|
+
if (!m) return "txt";
|
|
31352
|
+
return normalizeFormatKey(m[1]);
|
|
31353
|
+
}
|
|
31354
|
+
function normalizeImportWarnings(rawWarnings) {
|
|
31355
|
+
if (!Array.isArray(rawWarnings)) return [];
|
|
31356
|
+
return rawWarnings.map((item) => {
|
|
31357
|
+
if (typeof item === "string") {
|
|
31358
|
+
const trimmed = item.trim();
|
|
31359
|
+
return trimmed ? { code: "SERVER_IMPORT_WARNING", message: trimmed } : null;
|
|
31360
|
+
}
|
|
31361
|
+
if (item && typeof item === "object" && typeof item.message === "string") {
|
|
31362
|
+
const w = item;
|
|
31363
|
+
return {
|
|
31364
|
+
code: w.code || "SERVER_IMPORT_WARNING",
|
|
31365
|
+
message: w.message,
|
|
31366
|
+
...typeof w.count === "number" ? { count: w.count } : {}
|
|
31367
|
+
};
|
|
31368
|
+
}
|
|
31369
|
+
return null;
|
|
31370
|
+
}).filter((w) => w !== null);
|
|
31371
|
+
}
|
|
31372
|
+
function unwrapAdapterImportResult(rawResult) {
|
|
31373
|
+
if (rawResult && typeof rawResult === "object" && !("body" in rawResult && rawResult.body !== void 0) && ("snapshot" in rawResult || "documentData" in rawResult)) {
|
|
31374
|
+
const env = rawResult;
|
|
31375
|
+
const doc2 = env.snapshot ?? env.documentData ?? {};
|
|
31376
|
+
const envWarnings = normalizeImportWarnings(env.warnings);
|
|
31377
|
+
const attachedWarnings = normalizeImportWarnings(doc2?.__importWarnings);
|
|
31378
|
+
return {
|
|
31379
|
+
documentData: doc2,
|
|
31380
|
+
warnings: envWarnings.length > 0 ? envWarnings : attachedWarnings
|
|
31381
|
+
};
|
|
31382
|
+
}
|
|
31383
|
+
const doc = rawResult ?? {};
|
|
31384
|
+
const warnings = normalizeImportWarnings(
|
|
31385
|
+
rawResult?.warnings ?? rawResult?.__importWarnings
|
|
31386
|
+
);
|
|
31387
|
+
return { documentData: doc, warnings };
|
|
31388
|
+
}
|
|
30881
31389
|
var DocIoService = class extends import_core24.Disposable {
|
|
30882
31390
|
constructor() {
|
|
30883
31391
|
super();
|
|
@@ -30921,9 +31429,51 @@ var DocIoService = class extends import_core24.Disposable {
|
|
|
30921
31429
|
setAdapter(adapter) {
|
|
30922
31430
|
this._adapter$.next({ name: adapter.name ?? "custom-adapter", ...adapter });
|
|
30923
31431
|
}
|
|
31432
|
+
getDefaultIoTarget() {
|
|
31433
|
+
if (this._serviceDefaultIoTarget !== void 0) {
|
|
31434
|
+
return this._serviceDefaultIoTarget;
|
|
31435
|
+
}
|
|
31436
|
+
return this._adapter$.getValue().defaultIoTarget ?? "auto";
|
|
31437
|
+
}
|
|
31438
|
+
setDefaultIoTarget(target) {
|
|
31439
|
+
this._serviceDefaultIoTarget = target;
|
|
31440
|
+
this._adapter$.next({ ...this._adapter$.getValue() });
|
|
31441
|
+
}
|
|
30924
31442
|
getIoCapabilities() {
|
|
30925
31443
|
const adapter = this._adapter$.getValue();
|
|
30926
|
-
const
|
|
31444
|
+
const defaultIoTarget = this.getDefaultIoTarget();
|
|
31445
|
+
const hasServerImport = Boolean(adapter.importDoc);
|
|
31446
|
+
const hasServerExport = Boolean(adapter.exportDoc);
|
|
31447
|
+
const hasServerIo = hasServerImport || hasServerExport;
|
|
31448
|
+
const recommendedDefaultTarget = defaultIoTarget === "browser" ? "browser" : defaultIoTarget === "server" ? "server" : hasServerIo ? "server" : "browser";
|
|
31449
|
+
const browserFmtCfg = adapter.browserFormats;
|
|
31450
|
+
const browserImportOverride = typeof browserFmtCfg === "object" && browserFmtCfg !== null && Array.isArray(browserFmtCfg.import) ? new Set(browserFmtCfg.import.map(normalizeFormatKey)) : null;
|
|
31451
|
+
const browserExportOverride = typeof browserFmtCfg === "object" && browserFmtCfg !== null && Array.isArray(browserFmtCfg.export) ? new Set(browserFmtCfg.export.map(normalizeFormatKey)) : null;
|
|
31452
|
+
const serverImportOverride = Array.isArray(adapter.serverFormats?.import) ? new Set(adapter.serverFormats.import.map(normalizeFormatKey)) : null;
|
|
31453
|
+
const serverExportOverride = Array.isArray(adapter.serverFormats?.export) ? new Set(adapter.serverFormats.export.map(normalizeFormatKey)) : null;
|
|
31454
|
+
const computeDefaultTarget = (serverSupported) => {
|
|
31455
|
+
if (defaultIoTarget === "server") return "server";
|
|
31456
|
+
if (defaultIoTarget === "browser") return "browser";
|
|
31457
|
+
return serverSupported ? "server" : "browser";
|
|
31458
|
+
};
|
|
31459
|
+
const importFormats = {};
|
|
31460
|
+
const exportFormats = {};
|
|
31461
|
+
for (const fmt3 of DOC_IO_CAPABILITY_FORMATS) {
|
|
31462
|
+
const browserImport = browserFmtCfg === false ? false : browserImportOverride ? browserImportOverride.has(fmt3) : DEFAULT_BROWSER_IMPORT_SET.has(fmt3);
|
|
31463
|
+
const serverImport = !hasServerImport ? false : serverImportOverride ? serverImportOverride.has(fmt3) : true;
|
|
31464
|
+
importFormats[fmt3] = {
|
|
31465
|
+
browser: browserImport,
|
|
31466
|
+
server: serverImport,
|
|
31467
|
+
defaultTarget: computeDefaultTarget(serverImport)
|
|
31468
|
+
};
|
|
31469
|
+
const browserExport = browserFmtCfg === false ? false : browserExportOverride ? browserExportOverride.has(fmt3) : DEFAULT_BROWSER_EXPORT_SET.has(fmt3);
|
|
31470
|
+
const serverExport = !hasServerExport ? false : serverExportOverride ? serverExportOverride.has(fmt3) : true;
|
|
31471
|
+
exportFormats[fmt3] = {
|
|
31472
|
+
browser: browserExport,
|
|
31473
|
+
server: serverExport,
|
|
31474
|
+
defaultTarget: computeDefaultTarget(serverExport)
|
|
31475
|
+
};
|
|
31476
|
+
}
|
|
30927
31477
|
return {
|
|
30928
31478
|
browser: {
|
|
30929
31479
|
importDocx: true,
|
|
@@ -30935,17 +31485,38 @@ var DocIoService = class extends import_core24.Disposable {
|
|
|
30935
31485
|
},
|
|
30936
31486
|
server: {
|
|
30937
31487
|
adapterName: adapter.name || "frontend-default",
|
|
30938
|
-
importDoc:
|
|
30939
|
-
exportDoc:
|
|
31488
|
+
importDoc: hasServerImport,
|
|
31489
|
+
exportDoc: hasServerExport,
|
|
30940
31490
|
onSave: Boolean(adapter.onSave)
|
|
30941
31491
|
},
|
|
30942
|
-
|
|
31492
|
+
defaultIoTarget,
|
|
31493
|
+
recommendedDefaultTarget,
|
|
31494
|
+
formats: {
|
|
31495
|
+
import: importFormats,
|
|
31496
|
+
export: exportFormats
|
|
31497
|
+
}
|
|
30943
31498
|
};
|
|
30944
31499
|
}
|
|
31500
|
+
_resolveEffectiveTarget(operation, formatKey, requested) {
|
|
31501
|
+
if (requested === "browser") return "browser";
|
|
31502
|
+
if (requested === "server") return "server";
|
|
31503
|
+
const caps = this.getIoCapabilities();
|
|
31504
|
+
const fmtEntry = caps.formats[operation][formatKey];
|
|
31505
|
+
if (fmtEntry) return fmtEntry.defaultTarget;
|
|
31506
|
+
if (caps.defaultIoTarget === "server") return "server";
|
|
31507
|
+
if (caps.defaultIoTarget === "browser") return "browser";
|
|
31508
|
+
const hasHook = operation === "import" ? caps.server.importDoc : caps.server.exportDoc;
|
|
31509
|
+
return hasHook ? "server" : "browser";
|
|
31510
|
+
}
|
|
30945
31511
|
async importDocWithReport(file, options) {
|
|
30946
31512
|
let browserWarnings = [];
|
|
30947
31513
|
const defaultImport = async (f) => {
|
|
30948
31514
|
const lower = f.name.toLowerCase();
|
|
31515
|
+
const fmtKey2 = inferFormatFromFileName(f.name);
|
|
31516
|
+
const caps = this.getIoCapabilities();
|
|
31517
|
+
if (fmtKey2 === "pdf" || fmtKey2 in caps.formats.import && !caps.formats.import[fmtKey2].browser) {
|
|
31518
|
+
throw new Error(`\u5F53\u524D\u6D4F\u89C8\u5668\u672C\u5730\u5F15\u64CE\u4E0D\u652F\u6301\u76F4\u63A5\u5BFC\u5165 .${fmtKey2} \u683C\u5F0F\u6587\u4EF6`);
|
|
31519
|
+
}
|
|
30949
31520
|
const baseTitle = f.name.replace(/\.[^.]+$/, "") || "\u672A\u547D\u540D\u6587\u6863";
|
|
30950
31521
|
if (lower.endsWith(".docx")) {
|
|
30951
31522
|
const ab = await f.arrayBuffer();
|
|
@@ -30974,31 +31545,42 @@ var DocIoService = class extends import_core24.Disposable {
|
|
|
30974
31545
|
});
|
|
30975
31546
|
};
|
|
30976
31547
|
const adapter = this._adapter$.getValue();
|
|
30977
|
-
const
|
|
30978
|
-
const effective =
|
|
31548
|
+
const fmtKey = inferFormatFromFileName(file.name);
|
|
31549
|
+
const effective = this._resolveEffectiveTarget("import", fmtKey, options?.target);
|
|
30979
31550
|
if (effective === "server") {
|
|
30980
31551
|
if (!adapter.importDoc) {
|
|
30981
31552
|
throw new DocIoTargetError(
|
|
30982
31553
|
"\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
31554
|
);
|
|
30984
31555
|
}
|
|
30985
|
-
|
|
30986
|
-
|
|
30987
|
-
|
|
30988
|
-
|
|
30989
|
-
|
|
30990
|
-
|
|
30991
|
-
|
|
30992
|
-
|
|
30993
|
-
|
|
30994
|
-
|
|
31556
|
+
try {
|
|
31557
|
+
const rawOutcome = await adapter.importDoc(file, {
|
|
31558
|
+
unitId: options?.unitId,
|
|
31559
|
+
defaultImport
|
|
31560
|
+
});
|
|
31561
|
+
const unwrapped = unwrapAdapterImportResult(rawOutcome);
|
|
31562
|
+
return {
|
|
31563
|
+
snapshot: unwrapped.documentData,
|
|
31564
|
+
documentData: unwrapped.documentData,
|
|
31565
|
+
warnings: unwrapped.warnings.length > 0 ? unwrapped.warnings : browserWarnings,
|
|
31566
|
+
executedBy: "server",
|
|
31567
|
+
fileName: file.name
|
|
31568
|
+
};
|
|
31569
|
+
} catch (err) {
|
|
31570
|
+
if (err && typeof err === "object" && !err.suggestedFallback) {
|
|
31571
|
+
err.suggestedFallback = "browser";
|
|
31572
|
+
}
|
|
31573
|
+
throw err;
|
|
31574
|
+
}
|
|
30995
31575
|
}
|
|
30996
31576
|
try {
|
|
30997
31577
|
const documentData = await defaultImport(file);
|
|
30998
31578
|
return {
|
|
31579
|
+
snapshot: documentData,
|
|
30999
31580
|
documentData,
|
|
31000
31581
|
warnings: browserWarnings,
|
|
31001
|
-
executedBy: "browser"
|
|
31582
|
+
executedBy: "browser",
|
|
31583
|
+
fileName: file.name
|
|
31002
31584
|
};
|
|
31003
31585
|
} catch (err) {
|
|
31004
31586
|
if (err && typeof err === "object") {
|
|
@@ -31014,6 +31596,10 @@ var DocIoService = class extends import_core24.Disposable {
|
|
|
31014
31596
|
async exportDoc(params) {
|
|
31015
31597
|
const format = params.format ?? "docx";
|
|
31016
31598
|
const defaultExport = async () => {
|
|
31599
|
+
const caps = this.getIoCapabilities();
|
|
31600
|
+
if (format in caps.formats.export && !caps.formats.export[format].browser) {
|
|
31601
|
+
throw new Error(`\u5F53\u524D\u6D4F\u89C8\u5668\u672C\u5730\u5F15\u64CE\u672A\u542F\u7528 .${format} \u683C\u5F0F\u5BFC\u51FA`);
|
|
31602
|
+
}
|
|
31017
31603
|
if (format === "docx") {
|
|
31018
31604
|
return exportDocxBytes(params.snapshot, params.data, {
|
|
31019
31605
|
signatureImageDataUrl: params.pdfOptions?.signatureImageDataUrl,
|
|
@@ -31079,27 +31665,38 @@ var DocIoService = class extends import_core24.Disposable {
|
|
|
31079
31665
|
const targetSnapshot2 = params.data ? fillDatasetIntoDocSnapshot(params.snapshot, params.data) : params.snapshot;
|
|
31080
31666
|
return exportDocToOdtBytes(targetSnapshot2);
|
|
31081
31667
|
}
|
|
31668
|
+
if (format === "txt") {
|
|
31669
|
+
const targetSnapshot2 = params.data ? fillDatasetIntoDocSnapshot(params.snapshot, params.data) : params.snapshot;
|
|
31670
|
+
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");
|
|
31671
|
+
return new TextEncoder().encode(plain);
|
|
31672
|
+
}
|
|
31082
31673
|
const targetSnapshot = params.data ? fillDatasetIntoDocSnapshot(params.snapshot, params.data) : params.snapshot;
|
|
31083
31674
|
return new TextEncoder().encode(JSON.stringify(targetSnapshot, null, 2));
|
|
31084
31675
|
};
|
|
31085
31676
|
const adapter = this._adapter$.getValue();
|
|
31086
|
-
const
|
|
31087
|
-
const effective = requested === "auto" ? adapter.exportDoc ? "server" : "browser" : requested;
|
|
31677
|
+
const effective = this._resolveEffectiveTarget("export", format, params.target);
|
|
31088
31678
|
if (effective === "server") {
|
|
31089
31679
|
if (!adapter.exportDoc) {
|
|
31090
31680
|
throw new DocIoTargetError(
|
|
31091
31681
|
"\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
31682
|
);
|
|
31093
31683
|
}
|
|
31094
|
-
|
|
31095
|
-
|
|
31096
|
-
|
|
31097
|
-
|
|
31098
|
-
|
|
31099
|
-
|
|
31100
|
-
|
|
31101
|
-
|
|
31102
|
-
|
|
31684
|
+
try {
|
|
31685
|
+
const raw = await adapter.exportDoc({
|
|
31686
|
+
unitId: params.unitId,
|
|
31687
|
+
snapshot: params.snapshot,
|
|
31688
|
+
format,
|
|
31689
|
+
data: params.data,
|
|
31690
|
+
pdfOptions: params.pdfOptions,
|
|
31691
|
+
defaultExport
|
|
31692
|
+
});
|
|
31693
|
+
return normalizeToUint8Array(raw);
|
|
31694
|
+
} catch (err) {
|
|
31695
|
+
if (err && typeof err === "object" && !err.suggestedFallback) {
|
|
31696
|
+
err.suggestedFallback = "browser";
|
|
31697
|
+
}
|
|
31698
|
+
throw err;
|
|
31699
|
+
}
|
|
31103
31700
|
}
|
|
31104
31701
|
try {
|
|
31105
31702
|
return await defaultExport();
|
|
@@ -31229,8 +31826,12 @@ var UniverDocsExtPlugin = class extends import_core25.Plugin {
|
|
|
31229
31826
|
];
|
|
31230
31827
|
dependencies.forEach((dep) => this._injector.add(dep));
|
|
31231
31828
|
this._injector.get(IDocActionMacroService);
|
|
31829
|
+
const ioService = this._injector.get(IDocIoService);
|
|
31232
31830
|
if (this._config.io) {
|
|
31233
|
-
|
|
31831
|
+
ioService.setAdapter(this._config.io);
|
|
31832
|
+
}
|
|
31833
|
+
if (this._config.defaultIoTarget) {
|
|
31834
|
+
ioService.setDefaultIoTarget(this._config.defaultIoTarget);
|
|
31234
31835
|
}
|
|
31235
31836
|
if (this._config.aiCopilot) {
|
|
31236
31837
|
this._injector.get(IDocAiCopilotService).setAdapter(this._config.aiCopilot);
|
|
@@ -31395,6 +31996,7 @@ UniverDocsExtPlugin = __decorateClass([
|
|
|
31395
31996
|
DEFAULT_ENDNOTE_SETTINGS,
|
|
31396
31997
|
DEFAULT_FOOTNOTE_SETTINGS,
|
|
31397
31998
|
DOC_HYPERLINK_DEFAULT_COLOR,
|
|
31999
|
+
DOC_IO_CAPABILITY_FORMATS,
|
|
31398
32000
|
DOC_TRACK_DELETE_STYLE,
|
|
31399
32001
|
DOC_TRACK_INSERT_STYLE,
|
|
31400
32002
|
DeleteDocAreaCommand,
|
|
@@ -31820,6 +32422,7 @@ UniverDocsExtPlugin = __decorateClass([
|
|
|
31820
32422
|
spliceDocumentBodySpan,
|
|
31821
32423
|
spliceMultiParagraphBodySpan,
|
|
31822
32424
|
splitDocTableCellInSnapshot,
|
|
32425
|
+
stripDocEditorChromeForView,
|
|
31823
32426
|
stripSdtAffixes,
|
|
31824
32427
|
syncSnapshotAuxFields,
|
|
31825
32428
|
toControlSpecSnapshot,
|