@yudaocode/univer-docs 1.6.218 → 1.6.219
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -5
- package/lib/cjs/index.js +2428 -543
- package/lib/cjs/index.js.map +1 -1
- package/lib/es/index.js +2207 -339
- package/lib/es/index.js.map +1 -1
- package/lib/types/index.d.ts +155 -7
- package/package.json +1 -1
package/lib/es/index.js
CHANGED
|
@@ -14,12 +14,12 @@ var __decorateParam = (index, decorator) => (target, key) => decorator(target, k
|
|
|
14
14
|
import {
|
|
15
15
|
CommandType as CommandType7,
|
|
16
16
|
CustomRangeType as CustomRangeType14,
|
|
17
|
-
generateRandomId as
|
|
17
|
+
generateRandomId as generateRandomId17,
|
|
18
18
|
ICommandService as ICommandService4,
|
|
19
19
|
IResourceManagerService,
|
|
20
20
|
IUniverInstanceService as IUniverInstanceService2,
|
|
21
21
|
JSONX as JSONX2,
|
|
22
|
-
Tools as
|
|
22
|
+
Tools as Tools22,
|
|
23
23
|
UniverInstanceType as UniverInstanceType2
|
|
24
24
|
} from "@univerjs/core";
|
|
25
25
|
import { DocSelectionManagerService as DocSelectionManagerService4, RichTextEditingMutation as RichTextEditingMutation2 } from "@univerjs/docs";
|
|
@@ -56,6 +56,11 @@ var YUDAO_DOCS_CODE_BLOCKS = "YUDAO_DOCS_CODE_BLOCKS";
|
|
|
56
56
|
var YUDAO_DOCS_CHARTS = "YUDAO_DOCS_CHARTS";
|
|
57
57
|
var YUDAO_DOCS_FOOTNOTES = "YUDAO_DOCS_FOOTNOTES";
|
|
58
58
|
var YUDAO_DOCS_MINI_SHEETS = "YUDAO_DOCS_MINI_SHEETS";
|
|
59
|
+
var YUDAO_DOCS_REVISIONS = "YUDAO_DOCS_REVISIONS";
|
|
60
|
+
var YUDAO_DOCS_SMARTART = "YUDAO_DOCS_SMARTART";
|
|
61
|
+
var YUDAO_DOCS_LINE_NUMBERING = "YUDAO_DOCS_LINE_NUMBERING";
|
|
62
|
+
var YUDAO_DOCS_CAPTIONS = "YUDAO_DOCS_CAPTIONS";
|
|
63
|
+
var YUDAO_DOCS_CROSS_REFS = "YUDAO_DOCS_CROSS_REFS";
|
|
59
64
|
var DocTemplateProtocolError = class extends Error {
|
|
60
65
|
constructor(code, message, details) {
|
|
61
66
|
super(message);
|
|
@@ -8298,43 +8303,7 @@ function emitPdfVectorWidgetOps(ops, widget, x, baselineY, widthPt) {
|
|
|
8298
8303
|
return;
|
|
8299
8304
|
}
|
|
8300
8305
|
if (widget.smartArt) {
|
|
8301
|
-
|
|
8302
|
-
const hPt = Math.max(110, sa.height ?? 160);
|
|
8303
|
-
const boxBottom = baselineY - 4;
|
|
8304
|
-
ops.push(`% SmartArt:${sa.layout}`);
|
|
8305
|
-
ops.push("1 1 1 rg");
|
|
8306
|
-
ops.push(`${fmtNum(x)} ${fmtNum(boxBottom)} ${fmtNum(widthPt)} ${fmtNum(hPt)} re f`);
|
|
8307
|
-
ops.push("0.89 0.9 0.92 RG 0.8 w");
|
|
8308
|
-
ops.push(`${fmtNum(x)} ${fmtNum(boxBottom)} ${fmtNum(widthPt)} ${fmtNum(hPt)} re S`);
|
|
8309
|
-
if (sa.title) {
|
|
8310
|
-
emitPdfMixedTextOps(ops, sa.title, x + 10, boxBottom + hPt - 16, 10, true, parseHexToPdfRgb("#1B1C1F"));
|
|
8311
|
-
}
|
|
8312
|
-
const nodes = sa.nodes ?? [];
|
|
8313
|
-
const n = Math.max(1, nodes.length);
|
|
8314
|
-
const padX = 12;
|
|
8315
|
-
const gap = 8;
|
|
8316
|
-
const nw = Math.max(36, (widthPt - padX * 2 - gap * (n - 1)) / n);
|
|
8317
|
-
const nh = Math.min(48, Math.max(28, hPt - 40));
|
|
8318
|
-
const ny = boxBottom + (hPt - nh) / 2 - (sa.title ? 4 : 0);
|
|
8319
|
-
nodes.forEach((nd, idx) => {
|
|
8320
|
-
const nx = x + padX + idx * (nw + gap);
|
|
8321
|
-
const fill = idx === 0 ? parseHexToPdfRgb("#2C53F1") : parseHexToPdfRgb("#F3F5FF");
|
|
8322
|
-
const stroke = parseHexToPdfRgb("#2C53F1");
|
|
8323
|
-
const txtCol = idx === 0 ? { r: 1, g: 1, b: 1 } : parseHexToPdfRgb("#1B1C1F");
|
|
8324
|
-
ops.push(`${fmtNum(fill.r)} ${fmtNum(fill.g)} ${fmtNum(fill.b)} rg`);
|
|
8325
|
-
ops.push(`${fmtNum(stroke.r)} ${fmtNum(stroke.g)} ${fmtNum(stroke.b)} RG 0.9 w`);
|
|
8326
|
-
ops.push(`${fmtNum(nx)} ${fmtNum(ny)} ${fmtNum(nw)} ${fmtNum(nh)} re B`);
|
|
8327
|
-
const lw = measureTextWidthPt(nd.label, 8.5);
|
|
8328
|
-
emitPdfMixedTextOps(
|
|
8329
|
-
ops,
|
|
8330
|
-
nd.label,
|
|
8331
|
-
nx + Math.max(2, (nw - lw) / 2),
|
|
8332
|
-
ny + nh / 2 - 3,
|
|
8333
|
-
8.5,
|
|
8334
|
-
true,
|
|
8335
|
-
txtCol
|
|
8336
|
-
);
|
|
8337
|
-
});
|
|
8306
|
+
emitPdfSmartArtWidgetOps(ops, widget.smartArt, x, baselineY - 4, widthPt);
|
|
8338
8307
|
return;
|
|
8339
8308
|
}
|
|
8340
8309
|
if (widget.labelBadge) {
|
|
@@ -8799,6 +8768,171 @@ function resolvePdfUnderlineSpec(ul) {
|
|
|
8799
8768
|
const color = ul.c !== 0 && ul.cl?.rgb ? parseHexToPdfRgb(ul.cl.rgb) : void 0;
|
|
8800
8769
|
return { enabled: true, style, color };
|
|
8801
8770
|
}
|
|
8771
|
+
function emitPdfSmartArtWidgetOps(ops, sa, x, boxBottom, widthPt) {
|
|
8772
|
+
const hPt = Math.max(110, sa.height ?? 160);
|
|
8773
|
+
const accentHex = sa.accentColor || "#2C53F1";
|
|
8774
|
+
const accentRgb = parseHexToPdfRgb(accentHex);
|
|
8775
|
+
const softRgb = parseHexToPdfRgb("#F3F5FF");
|
|
8776
|
+
const darkText = parseHexToPdfRgb("#1B1C1F");
|
|
8777
|
+
const subText = parseHexToPdfRgb("#64748B");
|
|
8778
|
+
const nodes = normalizeSmartArtNodes(sa.nodes);
|
|
8779
|
+
ops.push("q");
|
|
8780
|
+
ops.push(`% SmartArt:${sa.layout}`);
|
|
8781
|
+
ops.push("1 1 1 rg");
|
|
8782
|
+
ops.push(`${fmtNum(x)} ${fmtNum(boxBottom)} ${fmtNum(widthPt)} ${fmtNum(hPt)} re f`);
|
|
8783
|
+
ops.push("0.89 0.9 0.92 RG 0.8 w");
|
|
8784
|
+
ops.push(`${fmtNum(x)} ${fmtNum(boxBottom)} ${fmtNum(widthPt)} ${fmtNum(hPt)} re S`);
|
|
8785
|
+
const topOffset = sa.title ? 22 : 10;
|
|
8786
|
+
if (sa.title) {
|
|
8787
|
+
emitPdfMixedTextOps(ops, sa.title, x + 10, boxBottom + hPt - 15, 10, true, darkText);
|
|
8788
|
+
}
|
|
8789
|
+
const innerTop = boxBottom + hPt - topOffset;
|
|
8790
|
+
const innerH = Math.max(60, hPt - topOffset - 10);
|
|
8791
|
+
if (sa.layout === "hierarchy" && nodes.length > 0) {
|
|
8792
|
+
const root = nodes[0];
|
|
8793
|
+
const children = root.children?.length ? root.children : nodes.slice(1);
|
|
8794
|
+
const rw = Math.min(130, widthPt - 40);
|
|
8795
|
+
const rh = 28;
|
|
8796
|
+
const rx = x + (widthPt - rw) / 2;
|
|
8797
|
+
const ry = innerTop - rh - 4;
|
|
8798
|
+
const rFill = parseHexToPdfRgb(root.color || accentHex);
|
|
8799
|
+
ops.push(`${fmtNum(rFill.r)} ${fmtNum(rFill.g)} ${fmtNum(rFill.b)} rg`);
|
|
8800
|
+
ops.push(`${fmtNum(rx)} ${fmtNum(ry)} ${fmtNum(rw)} ${fmtNum(rh)} re f`);
|
|
8801
|
+
const rlw = measureTextWidthPt(root.label, 8.5);
|
|
8802
|
+
emitPdfMixedTextOps(ops, root.label, rx + Math.max(3, (rw - rlw) / 2), ry + rh / 2 - 3, 8.5, true, {
|
|
8803
|
+
r: 1,
|
|
8804
|
+
g: 1,
|
|
8805
|
+
b: 1
|
|
8806
|
+
});
|
|
8807
|
+
if (children.length > 0) {
|
|
8808
|
+
const cCount = children.length;
|
|
8809
|
+
const padX2 = 12;
|
|
8810
|
+
const gap2 = 8;
|
|
8811
|
+
const cw = Math.max(38, (widthPt - padX2 * 2 - gap2 * (cCount - 1)) / cCount);
|
|
8812
|
+
const ch = 28;
|
|
8813
|
+
const cy = boxBottom + 12;
|
|
8814
|
+
const midY = (ry + cy + ch) / 2;
|
|
8815
|
+
ops.push(`${fmtNum(accentRgb.r)} ${fmtNum(accentRgb.g)} ${fmtNum(accentRgb.b)} RG 0.9 w`);
|
|
8816
|
+
ops.push(`${fmtNum(x + widthPt / 2)} ${fmtNum(ry)} m ${fmtNum(x + widthPt / 2)} ${fmtNum(midY)} l S`);
|
|
8817
|
+
children.forEach((child, idx) => {
|
|
8818
|
+
const cx = x + padX2 + idx * (cw + gap2);
|
|
8819
|
+
const centerCx = cx + cw / 2;
|
|
8820
|
+
ops.push(`${fmtNum(x + widthPt / 2)} ${fmtNum(midY)} m ${fmtNum(centerCx)} ${fmtNum(midY)} l ${fmtNum(centerCx)} ${fmtNum(cy + ch)} l S`);
|
|
8821
|
+
const cStroke = parseHexToPdfRgb(child.color || accentHex);
|
|
8822
|
+
ops.push(`${fmtNum(softRgb.r)} ${fmtNum(softRgb.g)} ${fmtNum(softRgb.b)} rg`);
|
|
8823
|
+
ops.push(`${fmtNum(cStroke.r)} ${fmtNum(cStroke.g)} ${fmtNum(cStroke.b)} RG 0.9 w`);
|
|
8824
|
+
ops.push(`${fmtNum(cx)} ${fmtNum(cy)} ${fmtNum(cw)} ${fmtNum(ch)} re B`);
|
|
8825
|
+
const clw = measureTextWidthPt(child.label, 8);
|
|
8826
|
+
emitPdfMixedTextOps(
|
|
8827
|
+
ops,
|
|
8828
|
+
child.label,
|
|
8829
|
+
cx + Math.max(2, (cw - clw) / 2),
|
|
8830
|
+
cy + (child.subLabel ? ch - 11 : ch / 2 - 3),
|
|
8831
|
+
8,
|
|
8832
|
+
true,
|
|
8833
|
+
darkText
|
|
8834
|
+
);
|
|
8835
|
+
if (child.subLabel) {
|
|
8836
|
+
const slw = measureTextWidthPt(child.subLabel, 6.8);
|
|
8837
|
+
emitPdfMixedTextOps(ops, child.subLabel, cx + Math.max(2, (cw - slw) / 2), cy + 4, 6.8, false, subText);
|
|
8838
|
+
}
|
|
8839
|
+
});
|
|
8840
|
+
}
|
|
8841
|
+
ops.push("Q");
|
|
8842
|
+
return;
|
|
8843
|
+
}
|
|
8844
|
+
if (sa.layout === "matrix" && nodes.length > 0) {
|
|
8845
|
+
const qNodes = nodes.slice(0, 4);
|
|
8846
|
+
const padX2 = 12;
|
|
8847
|
+
const gap2 = 8;
|
|
8848
|
+
const cw = Math.max(48, (widthPt - padX2 * 2 - gap2) / 2);
|
|
8849
|
+
const ch = Math.max(26, (innerH - gap2) / 2);
|
|
8850
|
+
qNodes.forEach((nd, idx) => {
|
|
8851
|
+
const col = idx % 2;
|
|
8852
|
+
const row = Math.floor(idx / 2);
|
|
8853
|
+
const qx = x + padX2 + col * (cw + gap2);
|
|
8854
|
+
const qy = innerTop - (row + 1) * ch - row * gap2;
|
|
8855
|
+
const nStroke = parseHexToPdfRgb(nd.color || accentHex);
|
|
8856
|
+
ops.push(`${fmtNum(softRgb.r)} ${fmtNum(softRgb.g)} ${fmtNum(softRgb.b)} rg`);
|
|
8857
|
+
ops.push(`${fmtNum(nStroke.r)} ${fmtNum(nStroke.g)} ${fmtNum(nStroke.b)} RG 0.9 w`);
|
|
8858
|
+
ops.push(`${fmtNum(qx)} ${fmtNum(qy)} ${fmtNum(cw)} ${fmtNum(ch)} re B`);
|
|
8859
|
+
emitPdfMixedTextOps(ops, nd.label, qx + 8, qy + ch - 12, 8.5, true, darkText);
|
|
8860
|
+
if (nd.subLabel) {
|
|
8861
|
+
emitPdfMixedTextOps(ops, nd.subLabel, qx + 8, qy + 6, 7.2, false, subText);
|
|
8862
|
+
}
|
|
8863
|
+
});
|
|
8864
|
+
ops.push("Q");
|
|
8865
|
+
return;
|
|
8866
|
+
}
|
|
8867
|
+
if (sa.layout === "list" && nodes.length > 0) {
|
|
8868
|
+
const count = Math.min(5, nodes.length);
|
|
8869
|
+
const gap2 = 5;
|
|
8870
|
+
const rh = Math.max(18, (innerH - gap2 * (count - 1)) / count);
|
|
8871
|
+
nodes.slice(0, count).forEach((nd, idx) => {
|
|
8872
|
+
const ry = innerTop - (idx + 1) * rh - idx * gap2;
|
|
8873
|
+
const rx = x + 12;
|
|
8874
|
+
const rw = widthPt - 24;
|
|
8875
|
+
const barRgb = parseHexToPdfRgb(nd.color || accentHex);
|
|
8876
|
+
ops.push(`${fmtNum(softRgb.r)} ${fmtNum(softRgb.g)} ${fmtNum(softRgb.b)} rg`);
|
|
8877
|
+
ops.push(`${fmtNum(rx)} ${fmtNum(ry)} ${fmtNum(rw)} ${fmtNum(rh)} re f`);
|
|
8878
|
+
ops.push(`${fmtNum(barRgb.r)} ${fmtNum(barRgb.g)} ${fmtNum(barRgb.b)} rg`);
|
|
8879
|
+
ops.push(`${fmtNum(rx)} ${fmtNum(ry)} 4 ${fmtNum(rh)} re f`);
|
|
8880
|
+
emitPdfMixedTextOps(ops, nd.label, rx + 10, ry + rh / 2 - 3, 8.5, true, darkText);
|
|
8881
|
+
if (nd.subLabel) {
|
|
8882
|
+
const lw = measureTextWidthPt(nd.label, 8.5);
|
|
8883
|
+
emitPdfMixedTextOps(ops, nd.subLabel, rx + 18 + lw, ry + rh / 2 - 3, 7.5, false, subText);
|
|
8884
|
+
}
|
|
8885
|
+
});
|
|
8886
|
+
ops.push("Q");
|
|
8887
|
+
return;
|
|
8888
|
+
}
|
|
8889
|
+
const n = Math.max(1, nodes.length);
|
|
8890
|
+
const padX = 12;
|
|
8891
|
+
const gap = 10;
|
|
8892
|
+
const nw = Math.max(36, (widthPt - padX * 2 - gap * (n - 1)) / n);
|
|
8893
|
+
const nh = Math.min(48, Math.max(28, innerH - 12));
|
|
8894
|
+
const ny = boxBottom + (innerH - nh) / 2 + 6;
|
|
8895
|
+
nodes.forEach((nd, idx) => {
|
|
8896
|
+
const nx = x + padX + idx * (nw + gap);
|
|
8897
|
+
const nodeHex = nd.color || accentHex;
|
|
8898
|
+
const fill = idx === 0 ? parseHexToPdfRgb(nodeHex) : softRgb;
|
|
8899
|
+
const stroke = parseHexToPdfRgb(nodeHex);
|
|
8900
|
+
const txtCol = idx === 0 ? { r: 1, g: 1, b: 1 } : darkText;
|
|
8901
|
+
ops.push(`${fmtNum(fill.r)} ${fmtNum(fill.g)} ${fmtNum(fill.b)} rg`);
|
|
8902
|
+
ops.push(`${fmtNum(stroke.r)} ${fmtNum(stroke.g)} ${fmtNum(stroke.b)} RG 0.9 w`);
|
|
8903
|
+
ops.push(`${fmtNum(nx)} ${fmtNum(ny)} ${fmtNum(nw)} ${fmtNum(nh)} re B`);
|
|
8904
|
+
const lw = measureTextWidthPt(nd.label, 8.5);
|
|
8905
|
+
emitPdfMixedTextOps(
|
|
8906
|
+
ops,
|
|
8907
|
+
nd.label,
|
|
8908
|
+
nx + Math.max(2, (nw - lw) / 2),
|
|
8909
|
+
ny + (nd.subLabel ? nh - 13 : nh / 2 - 3),
|
|
8910
|
+
8.5,
|
|
8911
|
+
true,
|
|
8912
|
+
txtCol
|
|
8913
|
+
);
|
|
8914
|
+
if (nd.subLabel) {
|
|
8915
|
+
const slw = measureTextWidthPt(nd.subLabel, 7);
|
|
8916
|
+
emitPdfMixedTextOps(
|
|
8917
|
+
ops,
|
|
8918
|
+
nd.subLabel,
|
|
8919
|
+
nx + Math.max(2, (nw - slw) / 2),
|
|
8920
|
+
ny + 5,
|
|
8921
|
+
7,
|
|
8922
|
+
false,
|
|
8923
|
+
idx === 0 ? { r: 0.9, g: 0.94, b: 1 } : subText
|
|
8924
|
+
);
|
|
8925
|
+
}
|
|
8926
|
+
if (idx < n - 1) {
|
|
8927
|
+
const ax1 = nx + nw + 1.5;
|
|
8928
|
+
const ax2 = nx + nw + gap - 1.5;
|
|
8929
|
+
const ay = ny + nh / 2;
|
|
8930
|
+
ops.push(`${fmtNum(accentRgb.r)} ${fmtNum(accentRgb.g)} ${fmtNum(accentRgb.b)} RG 1 w`);
|
|
8931
|
+
ops.push(`${fmtNum(ax1)} ${fmtNum(ay)} m ${fmtNum(ax2)} ${fmtNum(ay)} l S`);
|
|
8932
|
+
}
|
|
8933
|
+
});
|
|
8934
|
+
ops.push("Q");
|
|
8935
|
+
}
|
|
8802
8936
|
function emitPdfUnderlineOps(ops, x, baselineY, widthPt, style, color) {
|
|
8803
8937
|
if (widthPt <= 0) return;
|
|
8804
8938
|
ops.push("q");
|
|
@@ -9410,10 +9544,23 @@ function paginateSingleDocToPdfPages(rawSnapshot, options, imageNamePrefix = "Im
|
|
|
9410
9544
|
const gutterPosition = (options?.gutterPosition ?? printCfg.gutterPosition) === "top" ? "top" : "left";
|
|
9411
9545
|
const pagelessMode = Boolean(options?.pagelessMode ?? printCfg.pagelessMode);
|
|
9412
9546
|
const autoHyphenation = Boolean(options?.autoHyphenation ?? printCfg.autoHyphenation);
|
|
9413
|
-
const
|
|
9414
|
-
const
|
|
9415
|
-
|
|
9416
|
-
|
|
9547
|
+
const lnCfg = getDocLineNumberingFromSnapshot(snapshot);
|
|
9548
|
+
const showLineNumbers = Boolean(
|
|
9549
|
+
options?.showLineNumbers ?? (lnCfg.enabled || printCfg.showLineNumbers)
|
|
9550
|
+
);
|
|
9551
|
+
const lineNumberStart = Math.max(
|
|
9552
|
+
1,
|
|
9553
|
+
Number(options?.lineNumberStart ?? lnCfg.start ?? printCfg.lineNumberStart ?? 1) || 1
|
|
9554
|
+
);
|
|
9555
|
+
const lineNumberCountBy = Math.max(
|
|
9556
|
+
1,
|
|
9557
|
+
Number(options?.lineNumberCountBy ?? lnCfg.countBy ?? printCfg.lineNumberCountBy ?? 1) || 1
|
|
9558
|
+
);
|
|
9559
|
+
const lineNumberRestart = options?.lineNumberRestart ?? lnCfg.restart ?? printCfg.lineNumberRestart ?? "newPage";
|
|
9560
|
+
const lineNumberOffsetPt = Math.max(
|
|
9561
|
+
8,
|
|
9562
|
+
Math.min(26, Math.round((lnCfg.distanceDxa ?? 360) / 20 * 0.55))
|
|
9563
|
+
);
|
|
9417
9564
|
const pageBorder = !fieldsOnly ? options?.pageBorder ?? printCfg.pageBorder : void 0;
|
|
9418
9565
|
const imageWatermarkDataUrl = fieldsOnly ? "" : String(options?.imageWatermarkDataUrl ?? printCfg.imageWatermarkDataUrl ?? "").trim();
|
|
9419
9566
|
const imageWatermarkOpacity = Math.max(
|
|
@@ -9771,19 +9918,20 @@ function paginateSingleDocToPdfPages(rawSnapshot, options, imageNamePrefix = "Im
|
|
|
9771
9918
|
const baselineY = cursorY - line.maxFontSize;
|
|
9772
9919
|
if (countLineNumber && showLineNumbers && !fieldsOnly && activeColIdx === 0) {
|
|
9773
9920
|
const curLn = globalLineNo++;
|
|
9774
|
-
const shouldShow =
|
|
9921
|
+
const shouldShow = lineNumberCountBy <= 1 ? true : curLn % lineNumberCountBy === 0;
|
|
9775
9922
|
lnRenderedIndex++;
|
|
9776
9923
|
if (shouldShow) {
|
|
9777
9924
|
const lnStr = String(curLn);
|
|
9778
9925
|
const lnW = measureTextWidthPt(lnStr, 8.5);
|
|
9926
|
+
ops.push(`% LineNumber:${curLn}`);
|
|
9779
9927
|
emitPdfMixedTextOps(
|
|
9780
9928
|
ops,
|
|
9781
9929
|
lnStr,
|
|
9782
|
-
marginLeft -
|
|
9930
|
+
marginLeft - lineNumberOffsetPt - lnW,
|
|
9783
9931
|
baselineY + 1,
|
|
9784
9932
|
8.5,
|
|
9785
9933
|
false,
|
|
9786
|
-
{ r: 0.
|
|
9934
|
+
{ r: 0.52, g: 0.58, b: 0.67 }
|
|
9787
9935
|
);
|
|
9788
9936
|
}
|
|
9789
9937
|
}
|
|
@@ -10621,6 +10769,21 @@ function paginateSingleDocToPdfPages(rawSnapshot, options, imageNamePrefix = "Im
|
|
|
10621
10769
|
if (colCount > 1 && pageSizes[pageSizes.length - 1]?.hasMultiColBody) {
|
|
10622
10770
|
emitColumnSeparatorsOnCurrentPage(currentPageColTopY, Math.max(baseMarginBottom, 56));
|
|
10623
10771
|
}
|
|
10772
|
+
if (!fieldsOnly && templateMeta.smartArts) {
|
|
10773
|
+
const inlineBlockIds = new Set((body.customBlocks ?? []).map((b) => b.blockId));
|
|
10774
|
+
for (const [saId, saSpec] of Object.entries(templateMeta.smartArts)) {
|
|
10775
|
+
if (!saSpec || inlineBlockIds.has(saId)) continue;
|
|
10776
|
+
const saH = Math.max(110, saSpec.height ?? 160);
|
|
10777
|
+
const saW = Math.min(getContentWidth(), saSpec.width ?? 400);
|
|
10778
|
+
if (!pagelessMode && cursorY - (saH + 12) < getEffectiveMarginBottom()) {
|
|
10779
|
+
startNewPage();
|
|
10780
|
+
}
|
|
10781
|
+
const ops = currentOps();
|
|
10782
|
+
const boxBottom = cursorY - saH - 4;
|
|
10783
|
+
emitPdfSmartArtWidgetOps(ops, saSpec, marginLeft, boxBottom, saW);
|
|
10784
|
+
cursorY = boxBottom - 8;
|
|
10785
|
+
}
|
|
10786
|
+
}
|
|
10624
10787
|
if (sigImgDataUrl) {
|
|
10625
10788
|
const sigReg = registerImageDataUrl(sigImgDataUrl);
|
|
10626
10789
|
if (sigReg.pdfImageName || sigReg.svgSource) {
|
|
@@ -13549,6 +13712,17 @@ function exportDocxBytes(rawSnapshot, data, exportOptions) {
|
|
|
13549
13712
|
const emittedChartIds = /* @__PURE__ */ new Set();
|
|
13550
13713
|
const chartContentTypeOverrides = [];
|
|
13551
13714
|
let chartSeq = 1;
|
|
13715
|
+
const liveSmartArtsForExport = listLiveSmartArts(snapshot);
|
|
13716
|
+
const liveSmartArtsById = /* @__PURE__ */ new Map();
|
|
13717
|
+
for (const sa of liveSmartArtsForExport) {
|
|
13718
|
+
liveSmartArtsById.set(sa.id, sa);
|
|
13719
|
+
}
|
|
13720
|
+
for (const [sid, sa] of Object.entries(exportMeta.smartArts ?? {})) {
|
|
13721
|
+
if (!liveSmartArtsById.has(sid)) {
|
|
13722
|
+
liveSmartArtsById.set(sid, { ...sa, id: sid });
|
|
13723
|
+
}
|
|
13724
|
+
}
|
|
13725
|
+
const emittedSmartArtIds = /* @__PURE__ */ new Set();
|
|
13552
13726
|
let imgSeq = 1;
|
|
13553
13727
|
for (const block of body.customBlocks ?? []) {
|
|
13554
13728
|
if ((block.noteType === "footnote" || block.noteType === "endnote") && block.noteId) {
|
|
@@ -13604,14 +13778,26 @@ function exportDocxBytes(rawSnapshot, data, exportOptions) {
|
|
|
13604
13778
|
continue;
|
|
13605
13779
|
}
|
|
13606
13780
|
const drawing = snapshot.drawings?.[block.blockId];
|
|
13607
|
-
const
|
|
13781
|
+
const smartArtSpec = liveSmartArtsById.get(block.blockId);
|
|
13782
|
+
const renderedSmartArtFallback = smartArtSpec && !(drawing?.source || drawing?.imageSource) ? renderSmartArtToSvgDataUri(smartArtSpec) : void 0;
|
|
13783
|
+
const source = drawing?.source || drawing?.imageSource || renderedSmartArtFallback?.dataUri;
|
|
13608
13784
|
if (typeof source === "string" && source.startsWith("data:image/")) {
|
|
13609
13785
|
const decoded = decodeDataUriImage(source);
|
|
13610
13786
|
if (decoded) {
|
|
13787
|
+
let mediaBytes = decoded.bytes;
|
|
13788
|
+
if (smartArtSpec && decoded.ext === "svg") {
|
|
13789
|
+
const svgStr = new TextDecoder().decode(decoded.bytes);
|
|
13790
|
+
const marker = `<!-- yudao-smartart:${encodeURIComponent(JSON.stringify(smartArtSpec))} -->`;
|
|
13791
|
+
const injectedSvg = svgStr.includes("yudao-smartart:") ? svgStr : svgStr.replace(/<\/svg>\s*$/i, `${marker}</svg>`);
|
|
13792
|
+
mediaBytes = new TextEncoder().encode(injectedSvg);
|
|
13793
|
+
emittedSmartArtIds.add(block.blockId);
|
|
13794
|
+
} else if (smartArtSpec) {
|
|
13795
|
+
emittedSmartArtIds.add(block.blockId);
|
|
13796
|
+
}
|
|
13611
13797
|
const rId = `rIdImg${imgSeq}`;
|
|
13612
13798
|
const mediaName = `media/image${imgSeq}.${decoded.ext}`;
|
|
13613
|
-
const wPt = drawing?.docTransform?.size?.width ?? 140;
|
|
13614
|
-
const hPt = drawing?.docTransform?.size?.height ?? 90;
|
|
13799
|
+
const wPt = drawing?.docTransform?.size?.width ?? renderedSmartArtFallback?.widthPt ?? 140;
|
|
13800
|
+
const hPt = drawing?.docTransform?.size?.height ?? renderedSmartArtFallback?.heightPt ?? 90;
|
|
13615
13801
|
const drwTransform = exportMeta.imageTransforms?.[block.blockId] ?? drawing?.yudaoTransform;
|
|
13616
13802
|
relEntries.push({
|
|
13617
13803
|
id: rId,
|
|
@@ -13620,7 +13806,7 @@ function exportDocxBytes(rawSnapshot, data, exportOptions) {
|
|
|
13620
13806
|
});
|
|
13621
13807
|
extraZipFiles.push({
|
|
13622
13808
|
name: `word/${mediaName}`,
|
|
13623
|
-
content:
|
|
13809
|
+
content: mediaBytes
|
|
13624
13810
|
});
|
|
13625
13811
|
imageExts.set(decoded.ext, decoded.mime);
|
|
13626
13812
|
const baseDrawingXml = buildInlineImageDrawingXml(
|
|
@@ -14012,9 +14198,11 @@ ${commentsItemsXml}
|
|
|
14012
14198
|
}
|
|
14013
14199
|
}
|
|
14014
14200
|
const serializedMiniSheetsMap = liveMiniSheetsArr.length > 0 ? Object.fromEntries(liveMiniSheetsArr.map((ms) => [ms.id, ms])) : templateMeta.miniSheets;
|
|
14015
|
-
const liveSmartArtsArr =
|
|
14201
|
+
const liveSmartArtsArr = Array.from(liveSmartArtsById.values());
|
|
14016
14202
|
const liveCaptions = listDocCaptions(snapshot);
|
|
14203
|
+
const liveCrossRefs = listDocCrossRefs(snapshot);
|
|
14017
14204
|
const liveCitations = listDocCitations(snapshot);
|
|
14205
|
+
const effLnCfg = getDocLineNumberingFromSnapshot(snapshot);
|
|
14018
14206
|
const serializedLatexMap = liveLatexArr.length > 0 ? Object.fromEntries(liveLatexArr.map((f) => [f.id, f])) : templateMeta.latexFormulas;
|
|
14019
14207
|
const serializedChartMap = liveChartsArr.length > 0 ? Object.fromEntries(liveChartsArr.map((c) => [c.id, c])) : templateMeta.docCharts;
|
|
14020
14208
|
const serializedShapeMap = liveShapesArr.length > 0 ? Object.fromEntries(liveShapesArr.map((s) => [s.id, s])) : templateMeta.docShapes;
|
|
@@ -14082,7 +14270,7 @@ ${commentsItemsXml}
|
|
|
14082
14270
|
levels: def?.levels
|
|
14083
14271
|
});
|
|
14084
14272
|
}
|
|
14085
|
-
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) || Boolean(serializedMiniSheetsMap && Object.keys(serializedMiniSheetsMap).length > 0) || Object.keys(serializedSdtExtendedSpecs).length > 0) {
|
|
14273
|
+
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(effLnCfg.enabled || templateMeta.lineNumbering) || Boolean(templateMeta.columnGroupConfig) || liveCaptions.length > 0 || liveCrossRefs.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) || Boolean(serializedMiniSheetsMap && Object.keys(serializedMiniSheetsMap).length > 0) || Object.keys(serializedSdtExtendedSpecs).length > 0) {
|
|
14086
14274
|
extraZipFiles.push({
|
|
14087
14275
|
name: "docProps/yudao-meta.json",
|
|
14088
14276
|
content: JSON.stringify({
|
|
@@ -14103,10 +14291,12 @@ ${commentsItemsXml}
|
|
|
14103
14291
|
inlineFormulas: serializedInlineFmlMap,
|
|
14104
14292
|
docFields: serializedFieldsMap,
|
|
14105
14293
|
captions: liveCaptions,
|
|
14294
|
+
crossRefs: liveCrossRefs,
|
|
14106
14295
|
citationSources: liveCitations,
|
|
14107
14296
|
buildingBlocks: templateMeta.buildingBlocks,
|
|
14108
14297
|
imageTransforms: templateMeta.imageTransforms,
|
|
14109
14298
|
printConfig: templateMeta.printConfig,
|
|
14299
|
+
lineNumbering: templateMeta.lineNumbering ?? (effLnCfg.enabled ? effLnCfg : void 0),
|
|
14110
14300
|
columnGroupConfig: templateMeta.columnGroupConfig,
|
|
14111
14301
|
tableRowLoops: templateMeta.tableRowLoops,
|
|
14112
14302
|
tableRepeatHeaders: templateMeta.tableRepeatHeaders,
|
|
@@ -14187,6 +14377,38 @@ ${commentsItemsXml}
|
|
|
14187
14377
|
emittedChartIds.add(chartId);
|
|
14188
14378
|
chartSeq++;
|
|
14189
14379
|
}
|
|
14380
|
+
for (const [saId, saSpec] of liveSmartArtsById.entries()) {
|
|
14381
|
+
if (emittedSmartArtIds.has(saId)) continue;
|
|
14382
|
+
const renderedSa = renderSmartArtToSvgDataUri(saSpec);
|
|
14383
|
+
const decodedSa = decodeDataUriImage(renderedSa.dataUri);
|
|
14384
|
+
if (!decodedSa) continue;
|
|
14385
|
+
const svgStr = new TextDecoder().decode(decodedSa.bytes);
|
|
14386
|
+
const marker = `<!-- yudao-smartart:${encodeURIComponent(JSON.stringify(saSpec))} -->`;
|
|
14387
|
+
const injectedSvg = svgStr.includes("yudao-smartart:") ? svgStr : svgStr.replace(/<\/svg>\s*$/i, `${marker}</svg>`);
|
|
14388
|
+
const rIdSa = `rIdImg${imgSeq}`;
|
|
14389
|
+
const mediaName = `media/image${imgSeq}.${decodedSa.ext}`;
|
|
14390
|
+
relEntries.push({
|
|
14391
|
+
id: rIdSa,
|
|
14392
|
+
type: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
|
|
14393
|
+
target: mediaName
|
|
14394
|
+
});
|
|
14395
|
+
extraZipFiles.push({
|
|
14396
|
+
name: `word/${mediaName}`,
|
|
14397
|
+
content: new TextEncoder().encode(injectedSvg)
|
|
14398
|
+
});
|
|
14399
|
+
imageExts.set(decodedSa.ext, decodedSa.mime);
|
|
14400
|
+
const saDrawingXml = buildInlineImageDrawingXml(
|
|
14401
|
+
rIdSa,
|
|
14402
|
+
imgSeq,
|
|
14403
|
+
renderedSa.widthPt,
|
|
14404
|
+
renderedSa.heightPt,
|
|
14405
|
+
saId
|
|
14406
|
+
);
|
|
14407
|
+
bodyBlocksXml += `
|
|
14408
|
+
<w:p>${saDrawingXml}</w:p>`;
|
|
14409
|
+
emittedSmartArtIds.add(saId);
|
|
14410
|
+
imgSeq++;
|
|
14411
|
+
}
|
|
14190
14412
|
const sigDataUrl = exportOptions?.signatureImageDataUrl ?? templateMeta.printConfig?.signatureImageDataUrl;
|
|
14191
14413
|
if (sigDataUrl && sigDataUrl.startsWith("data:image/")) {
|
|
14192
14414
|
const decodedSig = decodeDataUriImage(sigDataUrl);
|
|
@@ -14269,8 +14491,8 @@ ${commentsItemsXml}
|
|
|
14269
14491
|
pgBordersXml = `
|
|
14270
14492
|
<w:pgBorders w:offsetFrom="page"><w:top w:val="${bVal}" w:sz="${bSz}" w:space="${bSpace}" w:color="${bColor}"/><w:left w:val="${bVal}" w:sz="${bSz}" w:space="${bSpace}" w:color="${bColor}"/><w:bottom w:val="${bVal}" w:sz="${bSz}" w:space="${bSpace}" w:color="${bColor}"/><w:right w:val="${bVal}" w:sz="${bSz}" w:space="${bSpace}" w:color="${bColor}"/></w:pgBorders>`;
|
|
14271
14493
|
}
|
|
14272
|
-
const lnNumXml =
|
|
14273
|
-
<w:lnNumType w:countBy="${Math.max(1,
|
|
14494
|
+
const lnNumXml = effLnCfg.enabled ? `
|
|
14495
|
+
<w:lnNumType w:countBy="${Math.max(1, effLnCfg.countBy ?? 1)}" w:start="${Math.max(1, effLnCfg.start ?? 1)}" w:restart="${effLnCfg.restart ?? "newPage"}" w:distance="${Math.max(0, Math.round(effLnCfg.distanceDxa ?? 360))}"/>` : "";
|
|
14274
14496
|
const colCfg = getColumnGroupConfigFromSnapshot(snapshot);
|
|
14275
14497
|
let colsXml = "";
|
|
14276
14498
|
if (colCfg && colCfg.columnCount > 1) {
|
|
@@ -15802,6 +16024,20 @@ function extractDrawingFromXmlChunk(chunk, relsMap, entries, collectedDrawings,
|
|
|
15802
16024
|
const positionH = alignHCode !== void 0 ? { relativeFrom: relHCode, align: alignHCode } : { relativeFrom: relHCode, posOffset: posOffsetHPt };
|
|
15803
16025
|
const positionV = alignVCode !== void 0 ? { relativeFrom: relVCode, align: alignVCode } : { relativeFrom: relVCode, posOffset: posOffsetVPt };
|
|
15804
16026
|
const dataUri = `data:${mime};base64,${uint8ToBase64(imgBytes)}`;
|
|
16027
|
+
let parsedSmartArt;
|
|
16028
|
+
if (ext === "svg") {
|
|
16029
|
+
try {
|
|
16030
|
+
const svgText = new TextDecoder().decode(imgBytes);
|
|
16031
|
+
const saMatch = svgText.match(/<!--\s*yudao-smartart:([^\s-]+)\s*-->/);
|
|
16032
|
+
if (saMatch?.[1]) {
|
|
16033
|
+
const rawSa = JSON.parse(decodeURIComponent(saMatch[1]));
|
|
16034
|
+
if (rawSa && typeof rawSa === "object" && Array.isArray(rawSa.nodes)) {
|
|
16035
|
+
parsedSmartArt = { ...rawSa, id: blockId };
|
|
16036
|
+
}
|
|
16037
|
+
}
|
|
16038
|
+
} catch {
|
|
16039
|
+
}
|
|
16040
|
+
}
|
|
15805
16041
|
collectedDrawings[blockId] = {
|
|
15806
16042
|
unitId: docUnitId,
|
|
15807
16043
|
subUnitId: docUnitId,
|
|
@@ -15836,7 +16072,8 @@ function extractDrawingFromXmlChunk(chunk, relsMap, entries, collectedDrawings,
|
|
|
15836
16072
|
angle: rotDeg,
|
|
15837
16073
|
wrapText: wrapTextCode
|
|
15838
16074
|
},
|
|
15839
|
-
...Object.keys(parsedTransform).length > 0 ? { yudaoTransform: parsedTransform } : {}
|
|
16075
|
+
...Object.keys(parsedTransform).length > 0 ? { yudaoTransform: parsedTransform } : {},
|
|
16076
|
+
...parsedSmartArt ? { yudaoParsedSmartArt: parsedSmartArt } : {}
|
|
15840
16077
|
};
|
|
15841
16078
|
inlineBlocksQueue.push({ blockId });
|
|
15842
16079
|
return { blockId, dataUri };
|
|
@@ -18136,18 +18373,26 @@ async function parseDocxBytesWithReport(bytes, title = "Imported Word Document")
|
|
|
18136
18373
|
if (/<w:autoHyphenation(?:\s|\/|>)/.test(settingsXml) && !/<w:autoHyphenation\s[^>]*w:val="(?:0|false)"/.test(settingsXml)) {
|
|
18137
18374
|
parsedPrintCfg.autoHyphenation = true;
|
|
18138
18375
|
}
|
|
18139
|
-
|
|
18376
|
+
let parsedLineNumbering;
|
|
18377
|
+
const lnNumMatch = sectPrXml.match(/<w:lnNumType\b([^>]*)\/?>/) ?? xml.match(/<w:lnNumType\b([^>]*)\/?>/);
|
|
18140
18378
|
if (lnNumMatch) {
|
|
18141
18379
|
const lnAttrs = lnNumMatch[1] || "";
|
|
18142
18380
|
parsedPrintCfg.showLineNumbers = true;
|
|
18143
|
-
const cBy = Number(lnAttrs.match(/w:countBy="(\d+)"/)?.[1] ?? 1);
|
|
18144
|
-
const lSt = Number(lnAttrs.match(/w:start="(\d+)"/)?.[1] ?? 1);
|
|
18381
|
+
const cBy = Math.max(1, Number(lnAttrs.match(/w:countBy="(\d+)"/)?.[1] ?? 1));
|
|
18382
|
+
const lSt = Math.max(1, Number(lnAttrs.match(/w:start="(\d+)"/)?.[1] ?? 1));
|
|
18145
18383
|
const lRst = lnAttrs.match(/w:restart="([^"]+)"/)?.[1];
|
|
18146
|
-
|
|
18147
|
-
|
|
18148
|
-
|
|
18149
|
-
|
|
18150
|
-
|
|
18384
|
+
const lDist = lnAttrs.match(/w:distance="(\d+)"/)?.[1];
|
|
18385
|
+
const restartVal = lRst === "newPage" || lRst === "newSection" || lRst === "continuous" ? lRst : "newPage";
|
|
18386
|
+
parsedPrintCfg.lineNumberCountBy = cBy;
|
|
18387
|
+
parsedPrintCfg.lineNumberStart = lSt;
|
|
18388
|
+
parsedPrintCfg.lineNumberRestart = restartVal;
|
|
18389
|
+
parsedLineNumbering = {
|
|
18390
|
+
enabled: true,
|
|
18391
|
+
countBy: cBy,
|
|
18392
|
+
start: lSt,
|
|
18393
|
+
restart: restartVal,
|
|
18394
|
+
distanceDxa: lDist !== void 0 ? Math.max(0, Number(lDist)) : 360
|
|
18395
|
+
};
|
|
18151
18396
|
}
|
|
18152
18397
|
const pgBordersBlock = xml.match(/<w:pgBorders\b[\s\S]*?<\/w:pgBorders>/)?.[0] || "";
|
|
18153
18398
|
if (pgBordersBlock) {
|
|
@@ -18213,6 +18458,7 @@ async function parseDocxBytesWithReport(bytes, title = "Imported Word Document")
|
|
|
18213
18458
|
}
|
|
18214
18459
|
}
|
|
18215
18460
|
const xmlParsedCharts = {};
|
|
18461
|
+
const xmlParsedSmartArts = {};
|
|
18216
18462
|
const xmlImageTransforms = {};
|
|
18217
18463
|
for (const [drwId, drwObj] of Object.entries(collectedDrawings)) {
|
|
18218
18464
|
if (drwObj?.yudaoTransform) {
|
|
@@ -18222,15 +18468,127 @@ async function parseDocxBytesWithReport(bytes, title = "Imported Word Document")
|
|
|
18222
18468
|
xmlParsedCharts[drwId] = drwObj.yudaoParsedChart;
|
|
18223
18469
|
delete drwObj.yudaoParsedChart;
|
|
18224
18470
|
}
|
|
18471
|
+
if (drwObj?.yudaoParsedSmartArt) {
|
|
18472
|
+
xmlParsedSmartArts[drwId] = drwObj.yudaoParsedSmartArt;
|
|
18473
|
+
delete drwObj.yudaoParsedSmartArt;
|
|
18474
|
+
}
|
|
18225
18475
|
}
|
|
18226
|
-
if (Object.keys(xmlParsedCharts).length > 0 && docData.body?.customBlocks) {
|
|
18476
|
+
if ((Object.keys(xmlParsedCharts).length > 0 || Object.keys(xmlParsedSmartArts).length > 0) && docData.body?.customBlocks) {
|
|
18227
18477
|
for (const blk of docData.body.customBlocks) {
|
|
18228
18478
|
const ch = xmlParsedCharts[blk.blockId];
|
|
18229
18479
|
if (ch) {
|
|
18230
18480
|
attachDrawingMetaRangeOnBody(docData.body, blk.blockId, blk.startIndex, "docChart", ch);
|
|
18231
18481
|
}
|
|
18482
|
+
const sa = xmlParsedSmartArts[blk.blockId];
|
|
18483
|
+
if (sa) {
|
|
18484
|
+
attachSmartArtMetaRangeOnBody(docData.body, blk.blockId, blk.startIndex, sa);
|
|
18485
|
+
}
|
|
18232
18486
|
}
|
|
18233
18487
|
}
|
|
18488
|
+
let xmlParsedCaptions = [];
|
|
18489
|
+
let xmlParsedCrossRefs = [];
|
|
18490
|
+
if (docData.body?.paragraphs?.length && docData.body.customRanges?.length) {
|
|
18491
|
+
const bodyStream = docData.body.dataStream || "";
|
|
18492
|
+
const sortedBodyParas = [...docData.body.paragraphs].sort(
|
|
18493
|
+
(a, b) => a.startIndex - b.startIndex
|
|
18494
|
+
);
|
|
18495
|
+
let paraStart = 0;
|
|
18496
|
+
for (const p of sortedBodyParas) {
|
|
18497
|
+
const paraEndExcl = p.startIndex;
|
|
18498
|
+
const paraEndIncl = Math.max(paraStart, paraEndExcl - 1);
|
|
18499
|
+
const existingCap = docData.body.customRanges.find(
|
|
18500
|
+
(r) => r.properties?.yudaoBlockKind === "caption" && r.startIndex >= paraStart && r.startIndex <= paraEndExcl
|
|
18501
|
+
);
|
|
18502
|
+
if (!existingCap) {
|
|
18503
|
+
const seqRange = docData.body.customRanges.find(
|
|
18504
|
+
(r) => r.properties?.yudaoBlockKind === "docField" && String(r.properties?.field?.fieldType || "").toUpperCase() === "SEQ" && r.startIndex >= paraStart && r.endIndex < paraEndExcl
|
|
18505
|
+
);
|
|
18506
|
+
if (seqRange) {
|
|
18507
|
+
const seqArgs = String(seqRange.properties?.field?.instructionArgs || "").trim().split(/\s+/);
|
|
18508
|
+
const seqToken = (seqArgs[0] || "").replace(/^["']|["']$/g, "");
|
|
18509
|
+
const seqUpper = seqToken.toUpperCase();
|
|
18510
|
+
const bmInPara = docData.body.customRanges.find(
|
|
18511
|
+
(r) => r.rangeType === CustomRangeType5.BOOKMARK && r.startIndex >= paraStart && r.startIndex <= paraEndExcl && String(r.properties?.bookmarkName || r.properties?.name || "").startsWith("_Ref")
|
|
18512
|
+
);
|
|
18513
|
+
const isKnownCapSeq = seqUpper === "FIGURE" || seqUpper === "TABLE" || seqUpper === "EQUATION" || seqToken === "\u56FE" || seqToken === "\u8868" || seqToken === "\u516C\u5F0F" || Boolean(bmInPara);
|
|
18514
|
+
if (isKnownCapSeq) {
|
|
18515
|
+
const bmName = String(
|
|
18516
|
+
bmInPara?.properties?.bookmarkName || bmInPara?.properties?.name || ""
|
|
18517
|
+
);
|
|
18518
|
+
const rawToken = bmName.startsWith("_RefCap_") ? bmName.slice("_RefCap_".length) : bmName.startsWith("_Ref_") ? bmName.slice("_Ref_".length) : "";
|
|
18519
|
+
const capId = rawToken ? rawToken.startsWith("cap_") ? rawToken : `cap_${rawToken}` : `cap_${generateRandomId6(6)}`;
|
|
18520
|
+
const rawBeforeSeq = bodyStream.slice(paraStart, seqRange.startIndex).replace(/[\r\n\u0000-\u001F]/g, "").trim();
|
|
18521
|
+
const normCat = normalizeDocCaptionCategory(seqToken || "figure", rawBeforeSeq || void 0);
|
|
18522
|
+
const prefixLabel = rawBeforeSeq || normCat.prefixLabel;
|
|
18523
|
+
const seqValStr = bodyStream.slice(seqRange.startIndex, seqRange.endIndex + 1).replace(/[\r\n\u0000-\u001F]/g, "").trim();
|
|
18524
|
+
const seqNumber = Math.max(1, Number(seqValStr) || 1);
|
|
18525
|
+
const titleText = bodyStream.slice(seqRange.endIndex + 1, paraEndExcl).replace(/[\r\n\u0000-\u001F]/g, "").replace(/^[::\s]+/, "");
|
|
18526
|
+
const fullLineText = bodyStream.slice(paraStart, paraEndExcl).replace(/[\r\n\u0000-\u001F]/g, "");
|
|
18527
|
+
const capEntry = {
|
|
18528
|
+
id: capId,
|
|
18529
|
+
category: normCat.categoryKey,
|
|
18530
|
+
prefixLabel,
|
|
18531
|
+
seqNumber,
|
|
18532
|
+
number: seqNumber,
|
|
18533
|
+
title: titleText,
|
|
18534
|
+
anchorIndex: paraStart,
|
|
18535
|
+
fullText: fullLineText,
|
|
18536
|
+
bookmarkName: bmName || `_RefCap_${capId.replace(/^cap_/, "").replace(/[^A-Za-z0-9_]/g, "_")}`,
|
|
18537
|
+
fieldId: seqRange.rangeId,
|
|
18538
|
+
startIndex: paraStart,
|
|
18539
|
+
endIndex: paraEndIncl
|
|
18540
|
+
};
|
|
18541
|
+
docData.body.customRanges.push({
|
|
18542
|
+
rangeId: capId,
|
|
18543
|
+
rangeType: CustomRangeType5.CUSTOM,
|
|
18544
|
+
startIndex: paraStart,
|
|
18545
|
+
endIndex: paraEndIncl,
|
|
18546
|
+
wholeEntity: false,
|
|
18547
|
+
properties: {
|
|
18548
|
+
yudaoBlockKind: "caption",
|
|
18549
|
+
caption: capEntry
|
|
18550
|
+
}
|
|
18551
|
+
});
|
|
18552
|
+
}
|
|
18553
|
+
}
|
|
18554
|
+
}
|
|
18555
|
+
paraStart = p.startIndex + 1;
|
|
18556
|
+
}
|
|
18557
|
+
const capsAfterScan = listDocCaptions(docData);
|
|
18558
|
+
for (const r of docData.body.customRanges) {
|
|
18559
|
+
if (r.properties?.yudaoBlockKind !== "docField") continue;
|
|
18560
|
+
if (r.properties?.crossRef) continue;
|
|
18561
|
+
const fld = r.properties?.field;
|
|
18562
|
+
const fldType = String(fld?.fieldType || "").toUpperCase();
|
|
18563
|
+
if (fldType !== "REF") continue;
|
|
18564
|
+
const refArgs = String(fld?.instructionArgs || "").trim().split(/\s+/);
|
|
18565
|
+
const refBm = (refArgs[0] || "").replace(/^["']|["']$/g, "");
|
|
18566
|
+
const matchedCap = capsAfterScan.find(
|
|
18567
|
+
(c) => c.bookmarkName === refBm || `_RefCap_${c.id}` === refBm || `_Ref_${c.id}` === refBm
|
|
18568
|
+
);
|
|
18569
|
+
if (matchedCap || refBm.startsWith("_RefCap_")) {
|
|
18570
|
+
const targetCaptionId = matchedCap?.id || refBm.slice("_RefCap_".length);
|
|
18571
|
+
const renderedText = bodyStream.slice(r.startIndex, r.endIndex + 1).replace(/[\r\n\u0000-\u001F]/g, "");
|
|
18572
|
+
const instrStr = String(r.properties?.fieldInstr || fld?.instrText || "");
|
|
18573
|
+
const displayMode = /\s\\p\b/i.test(instrStr) || /^第\s*\d+\s*页$/.test(renderedText) ? "pageNumber" : matchedCap?.title && renderedText.includes(matchedCap.title) ? "fullCaption" : "labelAndNumber";
|
|
18574
|
+
const xrEntry = {
|
|
18575
|
+
id: r.rangeId,
|
|
18576
|
+
targetCaptionId,
|
|
18577
|
+
displayMode,
|
|
18578
|
+
renderedText,
|
|
18579
|
+
anchorIndex: r.startIndex,
|
|
18580
|
+
startIndex: r.startIndex,
|
|
18581
|
+
endIndex: r.endIndex
|
|
18582
|
+
};
|
|
18583
|
+
r.properties = {
|
|
18584
|
+
...r.properties ?? {},
|
|
18585
|
+
crossRef: xrEntry
|
|
18586
|
+
};
|
|
18587
|
+
}
|
|
18588
|
+
}
|
|
18589
|
+
xmlParsedCaptions = listDocCaptions(docData);
|
|
18590
|
+
xmlParsedCrossRefs = listDocCrossRefs(docData);
|
|
18591
|
+
}
|
|
18234
18592
|
if (Object.keys(xmlMiniSheets).length > 0 && docData.tableSource) {
|
|
18235
18593
|
for (const ms of Object.values(xmlMiniSheets)) {
|
|
18236
18594
|
if (ms.tableId && docData.tableSource[ms.tableId]) {
|
|
@@ -18293,7 +18651,7 @@ async function parseDocxBytesWithReport(bytes, title = "Imported Word Document")
|
|
|
18293
18651
|
}
|
|
18294
18652
|
}
|
|
18295
18653
|
}
|
|
18296
|
-
if (Object.keys(parsedPrintCfg).length > 0 || Object.keys(xmlImageTransforms).length > 0 || Object.keys(xmlParaBorders).length > 0 || Object.keys(xmlParaTabStops).length > 0 || Object.keys(xmlParaPagination).length > 0 || Object.keys(xmlParaDirections).length > 0 || Object.keys(xmlSectionOrientations).length > 0 || Object.keys(xmlTableDirections).length > 0 || Object.keys(xmlTableBorderPresets).length > 0 || Object.keys(xmlTableCellProperties).length > 0 || Object.keys(xmlListDefinitions).length > 0 || Boolean(xmlNoteSettings) || Boolean(xmlCompany) || Object.keys(xmlCustomProperties).length > 0 || Object.keys(xmlParsedCharts).length > 0 || Object.keys(xmlMiniSheets).length > 0 || Boolean(xmlTocConfig)) {
|
|
18654
|
+
if (Object.keys(parsedPrintCfg).length > 0 || Boolean(parsedLineNumbering) || Object.keys(xmlImageTransforms).length > 0 || Object.keys(xmlParaBorders).length > 0 || Object.keys(xmlParaTabStops).length > 0 || Object.keys(xmlParaPagination).length > 0 || Object.keys(xmlParaDirections).length > 0 || Object.keys(xmlSectionOrientations).length > 0 || Object.keys(xmlTableDirections).length > 0 || Object.keys(xmlTableBorderPresets).length > 0 || Object.keys(xmlTableCellProperties).length > 0 || Object.keys(xmlListDefinitions).length > 0 || Boolean(xmlNoteSettings) || Boolean(xmlCompany) || Object.keys(xmlCustomProperties).length > 0 || Object.keys(xmlParsedCharts).length > 0 || Object.keys(xmlParsedSmartArts).length > 0 || xmlParsedCaptions.length > 0 || xmlParsedCrossRefs.length > 0 || Object.keys(xmlMiniSheets).length > 0 || Boolean(xmlTocConfig)) {
|
|
18297
18655
|
const baseMeta = readDocTemplateMetadataFromSnapshot(docData);
|
|
18298
18656
|
const cleanedDocFields = baseMeta.docFields ? Object.fromEntries(
|
|
18299
18657
|
Object.entries(baseMeta.docFields).filter(
|
|
@@ -18304,8 +18662,12 @@ async function parseDocxBytesWithReport(bytes, title = "Imported Word Document")
|
|
|
18304
18662
|
...baseMeta,
|
|
18305
18663
|
...cleanedDocFields !== void 0 ? { docFields: cleanedDocFields } : {},
|
|
18306
18664
|
...Object.keys(xmlParsedCharts).length > 0 ? { docCharts: { ...baseMeta.docCharts ?? {}, ...xmlParsedCharts } } : {},
|
|
18665
|
+
...Object.keys(xmlParsedSmartArts).length > 0 ? { smartArts: { ...baseMeta.smartArts ?? {}, ...xmlParsedSmartArts } } : {},
|
|
18666
|
+
...xmlParsedCaptions.length > 0 ? { captions: xmlParsedCaptions } : {},
|
|
18667
|
+
...xmlParsedCrossRefs.length > 0 ? { crossRefs: xmlParsedCrossRefs } : {},
|
|
18307
18668
|
...Object.keys(xmlMiniSheets).length > 0 ? { miniSheets: { ...baseMeta.miniSheets ?? {}, ...xmlMiniSheets } } : {},
|
|
18308
18669
|
...Object.keys(parsedPrintCfg).length > 0 ? { printConfig: { ...baseMeta.printConfig ?? {}, ...parsedPrintCfg } } : {},
|
|
18670
|
+
...parsedLineNumbering ? { lineNumbering: parsedLineNumbering } : {},
|
|
18309
18671
|
...Object.keys(xmlImageTransforms).length > 0 ? { imageTransforms: { ...baseMeta.imageTransforms ?? {}, ...xmlImageTransforms } } : {},
|
|
18310
18672
|
...Object.keys(xmlParaBorders).length > 0 ? { paragraphBorders: { ...baseMeta.paragraphBorders ?? {}, ...xmlParaBorders } } : {},
|
|
18311
18673
|
...Object.keys(xmlParaTabStops).length > 0 ? { paragraphTabStops: { ...baseMeta.paragraphTabStops ?? {}, ...xmlParaTabStops } } : {},
|
|
@@ -18661,14 +19023,16 @@ async function parseDocxBytesWithReport(bytes, title = "Imported Word Document")
|
|
|
18661
19023
|
...extraMeta.latexFormulas ? { latexFormulas: extraMeta.latexFormulas } : {},
|
|
18662
19024
|
...extraMeta.docShapes ? { docCharts: { ...curMeta.docCharts ?? {}, ...extraMeta.docCharts ?? {} }, docShapes: extraMeta.docShapes } : {},
|
|
18663
19025
|
...extraMeta.docCharts ? { docCharts: { ...curMeta.docCharts ?? {}, ...extraMeta.docCharts } } : {},
|
|
18664
|
-
...extraMeta.smartArts ? { smartArts: extraMeta.smartArts } : {},
|
|
19026
|
+
...extraMeta.smartArts ? { smartArts: { ...curMeta.smartArts ?? {}, ...extraMeta.smartArts } } : {},
|
|
18665
19027
|
...extraMeta.inlineFormulas ? { inlineFormulas: extraMeta.inlineFormulas } : {},
|
|
18666
19028
|
...extraMeta.docFields ? { docFields: extraMeta.docFields } : {},
|
|
18667
|
-
...extraMeta.captions ? { captions: extraMeta.captions } : {},
|
|
19029
|
+
...extraMeta.captions ? { captions: curMeta.captions?.length ? curMeta.captions : extraMeta.captions } : {},
|
|
19030
|
+
...extraMeta.crossRefs ? { crossRefs: curMeta.crossRefs?.length ? curMeta.crossRefs : extraMeta.crossRefs } : {},
|
|
18668
19031
|
...extraMeta.citationSources ? { citationSources: extraMeta.citationSources } : {},
|
|
18669
19032
|
...extraMeta.buildingBlocks ? { buildingBlocks: extraMeta.buildingBlocks } : {},
|
|
18670
19033
|
...extraMeta.imageTransforms ? { imageTransforms: { ...curMeta.imageTransforms ?? {}, ...extraMeta.imageTransforms } } : {},
|
|
18671
19034
|
...extraMeta.printConfig ? { printConfig: { ...curMeta.printConfig ?? {}, ...extraMeta.printConfig } } : {},
|
|
19035
|
+
...extraMeta.lineNumbering ? { lineNumbering: { ...curMeta.lineNumbering ?? {}, ...extraMeta.lineNumbering } } : {},
|
|
18672
19036
|
...extraMeta.columnGroupConfig ? { columnGroupConfig: extraMeta.columnGroupConfig } : {},
|
|
18673
19037
|
...Object.keys(remappedRowLoops).length > 0 ? { tableRowLoops: remappedRowLoops } : {},
|
|
18674
19038
|
...Object.keys(remappedRepeatHeaders).length > 0 ? { tableRepeatHeaders: remappedRepeatHeaders } : {},
|
|
@@ -18816,9 +19180,60 @@ function getDocImageTransformFromSnapshot(snapshot, drawingId) {
|
|
|
18816
19180
|
}
|
|
18817
19181
|
var SMARTART_FILLS = ["#F3F5FF", "#E9EDFF", "#F9FAFB", "#EEEFF1"];
|
|
18818
19182
|
var SMARTART_BORDERS = ["#2C53F1", "#D2DAFA", "#7D8698", "#4E5565"];
|
|
19183
|
+
function mixSoftHexTint(hexColor, fallback = "#F3F5FF") {
|
|
19184
|
+
const clean = (hexColor || "").trim().replace(/^#/, "");
|
|
19185
|
+
if (!/^[0-9a-fA-F]{6}$/.test(clean)) return fallback;
|
|
19186
|
+
const r = parseInt(clean.slice(0, 2), 16);
|
|
19187
|
+
const g = parseInt(clean.slice(2, 4), 16);
|
|
19188
|
+
const b = parseInt(clean.slice(4, 6), 16);
|
|
19189
|
+
const tint = (c) => Math.min(255, Math.round(c * 0.1 + 255 * 0.9)).toString(16).padStart(2, "0").toUpperCase();
|
|
19190
|
+
return `#${tint(r)}${tint(g)}${tint(b)}`;
|
|
19191
|
+
}
|
|
19192
|
+
function preserveSmartArtNodeTree(rawNodes) {
|
|
19193
|
+
if (!Array.isArray(rawNodes) || rawNodes.length === 0) return [];
|
|
19194
|
+
return rawNodes.filter(Boolean).map((item) => {
|
|
19195
|
+
const id = item.id || `sa_n_${generateRandomId7(5)}`;
|
|
19196
|
+
const subLabel = item.subLabel ?? item.subtitle;
|
|
19197
|
+
const children = Array.isArray(item.children) && item.children.length > 0 ? preserveSmartArtNodeTree(item.children) : void 0;
|
|
19198
|
+
return {
|
|
19199
|
+
...Tools8.deepClone(item),
|
|
19200
|
+
id,
|
|
19201
|
+
label: item.label || "\u8282\u70B9",
|
|
19202
|
+
...subLabel !== void 0 ? { subLabel, subtitle: item.subtitle ?? subLabel } : {},
|
|
19203
|
+
...children ? { children } : {}
|
|
19204
|
+
};
|
|
19205
|
+
});
|
|
19206
|
+
}
|
|
19207
|
+
function normalizeSmartArtNodes(rawNodes) {
|
|
19208
|
+
if (!Array.isArray(rawNodes) || rawNodes.length === 0) return [];
|
|
19209
|
+
const flat = [];
|
|
19210
|
+
const walk = (items, inheritedParentId) => {
|
|
19211
|
+
for (const item of items) {
|
|
19212
|
+
if (!item) continue;
|
|
19213
|
+
const id = item.id || `sa_n_${generateRandomId7(5)}`;
|
|
19214
|
+
const subLabel = item.subLabel ?? item.subtitle;
|
|
19215
|
+
const parentId = item.parentId ?? inheritedParentId;
|
|
19216
|
+
flat.push({
|
|
19217
|
+
id,
|
|
19218
|
+
label: item.label || "\u8282\u70B9",
|
|
19219
|
+
...subLabel ? { subLabel } : {},
|
|
19220
|
+
...parentId ? { parentId } : {},
|
|
19221
|
+
...item.color ? { color: item.color } : {}
|
|
19222
|
+
});
|
|
19223
|
+
if (Array.isArray(item.children) && item.children.length > 0) {
|
|
19224
|
+
walk(item.children, id);
|
|
19225
|
+
}
|
|
19226
|
+
}
|
|
19227
|
+
};
|
|
19228
|
+
walk(rawNodes, void 0);
|
|
19229
|
+
return flat;
|
|
19230
|
+
}
|
|
18819
19231
|
function renderSmartArtSvg(spec) {
|
|
18820
19232
|
const layout = spec.layout ?? "process";
|
|
18821
|
-
const
|
|
19233
|
+
const accent = (spec.accentColor || "#2C53F1").trim();
|
|
19234
|
+
const softTint = mixSoftHexTint(accent, "#F3F5FF");
|
|
19235
|
+
const normalized = normalizeSmartArtNodes(spec.nodes);
|
|
19236
|
+
const nodes = normalized.length > 0 ? normalized : [
|
|
18822
19237
|
{ id: "n1", label: "\u6B65\u9AA4\u4E00" },
|
|
18823
19238
|
{ id: "n2", label: "\u6B65\u9AA4\u4E8C" },
|
|
18824
19239
|
{ id: "n3", label: "\u6B65\u9AA4\u4E09" }
|
|
@@ -18846,13 +19261,14 @@ function renderSmartArtSvg(spec) {
|
|
|
18846
19261
|
const boxY = topOffset + Math.floor((plotH - boxH) / 2);
|
|
18847
19262
|
nodes.forEach((node, idx) => {
|
|
18848
19263
|
const bx = padX + idx * (boxW + arrowGap);
|
|
18849
|
-
const
|
|
18850
|
-
const
|
|
19264
|
+
const nodeAccent = node.color || accent;
|
|
19265
|
+
const fill = idx === 0 ? mixSoftHexTint(nodeAccent, softTint) : SMARTART_FILLS[idx % SMARTART_FILLS.length];
|
|
19266
|
+
const stroke = idx === 0 ? nodeAccent : "#D2DAFA";
|
|
18851
19267
|
parts.push(
|
|
18852
19268
|
`<rect x="${bx}" y="${boxY}" width="${boxW}" height="${boxH}" rx="6" fill="${fill}" stroke="${stroke}" stroke-width="1.2"/>`
|
|
18853
19269
|
);
|
|
18854
19270
|
parts.push(
|
|
18855
|
-
`<rect x="${bx}" y="${boxY}" width="${boxW}" height="4" rx="2" fill="
|
|
19271
|
+
`<rect x="${bx}" y="${boxY}" width="${boxW}" height="4" rx="2" fill="${nodeAccent}"/>`
|
|
18856
19272
|
);
|
|
18857
19273
|
const labelY = node.subLabel ? boxY + boxH * 0.44 : boxY + boxH * 0.56;
|
|
18858
19274
|
parts.push(
|
|
@@ -18868,10 +19284,10 @@ function renderSmartArtSvg(spec) {
|
|
|
18868
19284
|
const ax2 = bx + boxW + arrowGap - 4;
|
|
18869
19285
|
const ay = boxY + boxH / 2;
|
|
18870
19286
|
parts.push(
|
|
18871
|
-
`<line x1="${ax1}" y1="${ay}" x2="${ax2}" y2="${ay}" stroke="
|
|
19287
|
+
`<line x1="${ax1}" y1="${ay}" x2="${ax2}" y2="${ay}" stroke="${accent}" stroke-width="1.5"/>`
|
|
18872
19288
|
);
|
|
18873
19289
|
parts.push(
|
|
18874
|
-
`<polygon points="${ax2 + 3},${ay} ${ax2 - 3},${ay - 3.5} ${ax2 - 3},${ay + 3.5}" fill="
|
|
19290
|
+
`<polygon points="${ax2 + 3},${ay} ${ax2 - 3},${ay - 3.5} ${ax2 - 3},${ay + 3.5}" fill="${accent}"/>`
|
|
18875
19291
|
);
|
|
18876
19292
|
}
|
|
18877
19293
|
});
|
|
@@ -18887,8 +19303,9 @@ function renderSmartArtSvg(spec) {
|
|
|
18887
19303
|
const rootH = 38;
|
|
18888
19304
|
const rootX = (width - rootW) / 2;
|
|
18889
19305
|
const rootY = topOffset + 4;
|
|
19306
|
+
const rootColor = effectiveRoot.color || accent;
|
|
18890
19307
|
parts.push(
|
|
18891
|
-
`<rect x="${rootX}" y="${rootY}" width="${rootW}" height="${rootH}" rx="6" fill="
|
|
19308
|
+
`<rect x="${rootX}" y="${rootY}" width="${rootW}" height="${rootH}" rx="6" fill="${rootColor}" stroke="${rootColor}" stroke-width="1"/>`
|
|
18892
19309
|
);
|
|
18893
19310
|
parts.push(
|
|
18894
19311
|
`<text x="${width / 2}" y="${rootY + (effectiveRoot.subLabel ? 16 : 23)}" text-anchor="middle" fill="#FFFFFF" font-size="11" font-weight="600" font-family="PingFang SC, Microsoft YaHei, sans-serif">${escapeSvgText(effectiveRoot.label)}</text>`
|
|
@@ -18916,14 +19333,17 @@ function renderSmartArtSvg(spec) {
|
|
|
18916
19333
|
`<line x1="${firstCx}" y1="${midBusY}" x2="${lastCx}" y2="${midBusY}" stroke="#7D8698" stroke-width="1.3"/>`
|
|
18917
19334
|
);
|
|
18918
19335
|
}
|
|
19336
|
+
const tier2CenterById = /* @__PURE__ */ new Map();
|
|
18919
19337
|
tier2.forEach((child, idx) => {
|
|
18920
19338
|
const cx = pad + idx * (cw + gap);
|
|
18921
19339
|
const centerX = cx + cw / 2;
|
|
19340
|
+
tier2CenterById.set(child.id, centerX);
|
|
19341
|
+
const cCol = child.color || accent;
|
|
18922
19342
|
parts.push(
|
|
18923
19343
|
`<line x1="${centerX}" y1="${midBusY}" x2="${centerX}" y2="${cy}" stroke="#7D8698" stroke-width="1.3"/>`
|
|
18924
19344
|
);
|
|
18925
19345
|
parts.push(
|
|
18926
|
-
`<rect x="${cx}" y="${cy}" width="${cw}" height="${ch}" rx="5" fill="
|
|
19346
|
+
`<rect x="${cx}" y="${cy}" width="${cw}" height="${ch}" rx="5" fill="${mixSoftHexTint(cCol, softTint)}" stroke="${cCol}" stroke-width="1.2"/>`
|
|
18927
19347
|
);
|
|
18928
19348
|
parts.push(
|
|
18929
19349
|
`<text x="${centerX}" y="${cy + (child.subLabel ? 17 : 24)}" text-anchor="middle" fill="#1B1C1F" font-size="10.5" font-weight="600" font-family="PingFang SC, Microsoft YaHei, sans-serif">${escapeSvgText(child.label)}</text>`
|
|
@@ -18945,8 +19365,9 @@ function renderSmartArtSvg(spec) {
|
|
|
18945
19365
|
grandchildren.forEach((gc, gIdx) => {
|
|
18946
19366
|
const gx = pad + gIdx * (gw + gGap);
|
|
18947
19367
|
const gCenterX = gx + gw / 2;
|
|
19368
|
+
const parentCx = (gc.parentId && tier2CenterById.get(gc.parentId)) ?? gCenterX;
|
|
18948
19369
|
parts.push(
|
|
18949
|
-
`<line x1="${
|
|
19370
|
+
`<line x1="${parentCx}" y1="${cy + ch}" x2="${gCenterX}" y2="${gy}" stroke="#CBD5E1" stroke-width="1.1"/>`
|
|
18950
19371
|
);
|
|
18951
19372
|
parts.push(
|
|
18952
19373
|
`<rect x="${gx}" y="${gy}" width="${gw}" height="${gh}" rx="4" fill="#F9FAFB" stroke="#E3E5EA" stroke-width="1"/>`
|
|
@@ -18962,7 +19383,7 @@ function renderSmartArtSvg(spec) {
|
|
|
18962
19383
|
const cy = topOffset + plotH / 2;
|
|
18963
19384
|
const orbitR = Math.max(36, Math.min(width * 0.3, plotH * 0.34));
|
|
18964
19385
|
parts.push(
|
|
18965
|
-
`<circle cx="${cx}" cy="${cy}" r="${orbitR}" fill="none" stroke="
|
|
19386
|
+
`<circle cx="${cx}" cy="${cy}" r="${orbitR}" fill="none" stroke="${accent}" stroke-opacity="0.35" stroke-width="2" stroke-dasharray="5,3"/>`
|
|
18966
19387
|
);
|
|
18967
19388
|
const n = nodes.length;
|
|
18968
19389
|
const nodeW = 86;
|
|
@@ -18971,8 +19392,9 @@ function renderSmartArtSvg(spec) {
|
|
|
18971
19392
|
const angle = -Math.PI / 2 + idx * 2 * Math.PI / Math.max(1, n);
|
|
18972
19393
|
const nx = cx + orbitR * Math.cos(angle) - nodeW / 2;
|
|
18973
19394
|
const ny = cy + orbitR * Math.sin(angle) - nodeH / 2;
|
|
19395
|
+
const nodeAccent = node.color || accent;
|
|
18974
19396
|
parts.push(
|
|
18975
|
-
`<rect x="${nx.toFixed(1)}" y="${ny.toFixed(1)}" width="${nodeW}" height="${nodeH}" rx="18" fill="${idx === 0 ?
|
|
19397
|
+
`<rect x="${nx.toFixed(1)}" y="${ny.toFixed(1)}" width="${nodeW}" height="${nodeH}" rx="18" fill="${idx === 0 ? nodeAccent : mixSoftHexTint(nodeAccent, softTint)}" stroke="${nodeAccent}" stroke-width="1.2"/>`
|
|
18976
19398
|
);
|
|
18977
19399
|
parts.push(
|
|
18978
19400
|
`<text x="${(nx + nodeW / 2).toFixed(1)}" y="${(ny + (node.subLabel ? 15 : 22)).toFixed(1)}" text-anchor="middle" fill="${idx === 0 ? "#FFFFFF" : "#1B1C1F"}" font-size="10" font-weight="600" font-family="PingFang SC, Microsoft YaHei, sans-serif">${escapeSvgText(node.label)}</text>`
|
|
@@ -18983,6 +19405,46 @@ function renderSmartArtSvg(spec) {
|
|
|
18983
19405
|
);
|
|
18984
19406
|
}
|
|
18985
19407
|
});
|
|
19408
|
+
} else if (layout === "list") {
|
|
19409
|
+
const idSet = new Set(nodes.map((n) => n.id));
|
|
19410
|
+
const groups = nodes.filter((n) => !n.parentId || !idSet.has(n.parentId));
|
|
19411
|
+
const effGroups = groups.length > 0 ? groups : nodes;
|
|
19412
|
+
const padX = 16;
|
|
19413
|
+
const gap = 10;
|
|
19414
|
+
const gCount = effGroups.length;
|
|
19415
|
+
const colW = Math.max(76, Math.floor((width - padX * 2 - gap * (gCount - 1)) / Math.max(1, gCount)));
|
|
19416
|
+
const cardH = Math.max(64, plotH - 8);
|
|
19417
|
+
const cardY = topOffset + 4;
|
|
19418
|
+
effGroups.forEach((grp, idx) => {
|
|
19419
|
+
const gx = padX + idx * (colW + gap);
|
|
19420
|
+
const grpAccent = grp.color || accent;
|
|
19421
|
+
const childItems = nodes.filter((n) => n.parentId === grp.id);
|
|
19422
|
+
parts.push(
|
|
19423
|
+
`<rect x="${gx}" y="${cardY}" width="${colW}" height="${cardH}" rx="6" fill="#F9FAFB" stroke="#E3E5EA" stroke-width="1.1"/>`
|
|
19424
|
+
);
|
|
19425
|
+
parts.push(
|
|
19426
|
+
`<rect x="${gx}" y="${cardY}" width="${colW}" height="26" rx="6" fill="${grpAccent}"/>`
|
|
19427
|
+
);
|
|
19428
|
+
parts.push(
|
|
19429
|
+
`<text x="${gx + 10}" y="${cardY + 17}" fill="#FFFFFF" font-size="10.5" font-weight="600" font-family="PingFang SC, Microsoft YaHei, sans-serif">${escapeSvgText(grp.label)}</text>`
|
|
19430
|
+
);
|
|
19431
|
+
let itemY = cardY + 42;
|
|
19432
|
+
if (grp.subLabel) {
|
|
19433
|
+
parts.push(
|
|
19434
|
+
`<text x="${gx + 10}" y="${itemY}" fill="#4E5565" font-size="9.5" font-family="PingFang SC, Microsoft YaHei, sans-serif">${escapeSvgText(grp.subLabel)}</text>`
|
|
19435
|
+
);
|
|
19436
|
+
itemY += 16;
|
|
19437
|
+
}
|
|
19438
|
+
childItems.slice(0, 4).forEach((ci) => {
|
|
19439
|
+
if (itemY <= cardY + cardH - 6) {
|
|
19440
|
+
parts.push(`<circle cx="${gx + 12}" cy="${itemY - 3}" r="2.2" fill="${grpAccent}"/>`);
|
|
19441
|
+
parts.push(
|
|
19442
|
+
`<text x="${gx + 18}" y="${itemY}" fill="#1B1C1F" font-size="9.5" font-family="PingFang SC, Microsoft YaHei, sans-serif">${escapeSvgText(ci.label)}</text>`
|
|
19443
|
+
);
|
|
19444
|
+
itemY += 16;
|
|
19445
|
+
}
|
|
19446
|
+
});
|
|
19447
|
+
});
|
|
18986
19448
|
} else if (layout === "pyramid") {
|
|
18987
19449
|
const n = nodes.length;
|
|
18988
19450
|
const tierGap = 4;
|
|
@@ -19000,8 +19462,9 @@ function renderSmartArtSvg(spec) {
|
|
|
19000
19462
|
const x1R = x1L + w1;
|
|
19001
19463
|
const x2L = (width - w2) / 2;
|
|
19002
19464
|
const x2R = x2L + w2;
|
|
19003
|
-
const
|
|
19004
|
-
const
|
|
19465
|
+
const nodeAccent = node.color || accent;
|
|
19466
|
+
const fill = idx === 0 ? nodeAccent : SMARTART_FILLS[idx % SMARTART_FILLS.length];
|
|
19467
|
+
const stroke = idx === 0 ? nodeAccent : SMARTART_BORDERS[idx % SMARTART_BORDERS.length];
|
|
19005
19468
|
const textFill = idx === 0 ? "#FFFFFF" : "#1B1C1F";
|
|
19006
19469
|
parts.push(
|
|
19007
19470
|
`<polygon points="${x1L.toFixed(1)},${y1} ${x1R.toFixed(1)},${y1} ${x2R.toFixed(1)},${y2} ${x2L.toFixed(1)},${y2}" fill="${fill}" stroke="${stroke}" stroke-width="1.1"/>`
|
|
@@ -19023,8 +19486,9 @@ function renderSmartArtSvg(spec) {
|
|
|
19023
19486
|
const c = idx % cols;
|
|
19024
19487
|
const cx = padX + c * (cellW + gap);
|
|
19025
19488
|
const cy = topOffset + r * (cellH + gap);
|
|
19026
|
-
const
|
|
19027
|
-
const
|
|
19489
|
+
const nodeAccent = node.color || accent;
|
|
19490
|
+
const fill = idx === 0 ? mixSoftHexTint(nodeAccent, softTint) : SMARTART_FILLS[idx % SMARTART_FILLS.length];
|
|
19491
|
+
const bdr = idx === 0 ? nodeAccent : "#D2DAFA";
|
|
19028
19492
|
parts.push(
|
|
19029
19493
|
`<rect x="${cx}" y="${cy}" width="${cellW}" height="${cellH}" rx="6" fill="${fill}" stroke="${bdr}" stroke-width="1.2"/>`
|
|
19030
19494
|
);
|
|
@@ -19075,11 +19539,16 @@ function attachSmartArtMetaRangeOnBody(body, blockId, insertOffset, spec) {
|
|
|
19075
19539
|
function insertSmartArtIntoSnapshot(sourceSnapshot, spec, offset) {
|
|
19076
19540
|
if (!sourceSnapshot.body) return null;
|
|
19077
19541
|
const id = spec.id || `smartart_${generateRandomId7(6)}`;
|
|
19542
|
+
const preservedNodes = preserveSmartArtNodeTree(spec.nodes);
|
|
19078
19543
|
const fullSpec = {
|
|
19079
19544
|
...Tools8.deepClone(spec),
|
|
19080
19545
|
id,
|
|
19081
19546
|
layout: spec.layout ?? "process",
|
|
19082
|
-
nodes:
|
|
19547
|
+
nodes: preservedNodes.length > 0 ? preservedNodes : [
|
|
19548
|
+
{ id: "n1", label: "\u6B65\u9AA4\u4E00" },
|
|
19549
|
+
{ id: "n2", label: "\u6B65\u9AA4\u4E8C" },
|
|
19550
|
+
{ id: "n3", label: "\u6B65\u9AA4\u4E09" }
|
|
19551
|
+
]
|
|
19083
19552
|
};
|
|
19084
19553
|
const rendered = renderSmartArtToSvgDataUri(fullSpec);
|
|
19085
19554
|
const inserted = insertInlineDrawingIntoSnapshot(sourceSnapshot, {
|
|
@@ -19112,11 +19581,15 @@ function updateSmartArtInSnapshot(sourceSnapshot, id, patch) {
|
|
|
19112
19581
|
const existing = currentList.find((s) => s.id === id);
|
|
19113
19582
|
const blk = (body.customBlocks ?? []).find((b) => b.blockId === id);
|
|
19114
19583
|
if (!existing && !blk) return null;
|
|
19115
|
-
const
|
|
19584
|
+
const mergedRaw = {
|
|
19116
19585
|
...existing ?? { id, layout: "process", nodes: [] },
|
|
19117
19586
|
...Tools8.deepClone(patch),
|
|
19118
19587
|
id
|
|
19119
19588
|
};
|
|
19589
|
+
const merged = {
|
|
19590
|
+
...mergedRaw,
|
|
19591
|
+
nodes: patch.nodes ? preserveSmartArtNodeTree(patch.nodes) : preserveSmartArtNodeTree(mergedRaw.nodes)
|
|
19592
|
+
};
|
|
19120
19593
|
const rendered = renderSmartArtToSvgDataUri(merged);
|
|
19121
19594
|
const nextSnapshot = Tools8.deepClone(sourceSnapshot);
|
|
19122
19595
|
const drw = nextSnapshot.drawings?.[id];
|
|
@@ -19549,6 +20022,48 @@ function splitDocTableCellInSnapshot(sourceSnapshot, tableIndex, row, col) {
|
|
|
19549
20022
|
}
|
|
19550
20023
|
return nextSnapshot;
|
|
19551
20024
|
}
|
|
20025
|
+
function normalizeDocCaptionCategory(rawCategory, explicitPrefixLabel) {
|
|
20026
|
+
const clean = String(rawCategory || "figure").trim().toLowerCase();
|
|
20027
|
+
if (clean === "table" || clean === "\u8868") {
|
|
20028
|
+
return {
|
|
20029
|
+
categoryKey: "table",
|
|
20030
|
+
prefixLabel: explicitPrefixLabel?.trim() || "\u8868",
|
|
20031
|
+
ooxmlSeqIdent: "Table"
|
|
20032
|
+
};
|
|
20033
|
+
}
|
|
20034
|
+
if (clean === "equation" || clean === "\u516C\u5F0F") {
|
|
20035
|
+
return {
|
|
20036
|
+
categoryKey: "equation",
|
|
20037
|
+
prefixLabel: explicitPrefixLabel?.trim() || "\u516C\u5F0F",
|
|
20038
|
+
ooxmlSeqIdent: "Equation"
|
|
20039
|
+
};
|
|
20040
|
+
}
|
|
20041
|
+
return {
|
|
20042
|
+
categoryKey: "figure",
|
|
20043
|
+
prefixLabel: explicitPrefixLabel?.trim() || "\u56FE",
|
|
20044
|
+
ooxmlSeqIdent: "Figure"
|
|
20045
|
+
};
|
|
20046
|
+
}
|
|
20047
|
+
function normalizeSeqCounterKey(rawSeqIdent) {
|
|
20048
|
+
const head = (rawSeqIdent || "Figure").trim().split(/[\s\\]+/)[0] || "Figure";
|
|
20049
|
+
const lower = head.toLowerCase();
|
|
20050
|
+
if (lower === "figure" || lower === "\u56FE") return "figure";
|
|
20051
|
+
if (lower === "table" || lower === "\u8868") return "table";
|
|
20052
|
+
if (lower === "equation" || lower === "\u516C\u5F0F") return "equation";
|
|
20053
|
+
return lower;
|
|
20054
|
+
}
|
|
20055
|
+
function formatCrossRefDisplayByMode(snapshot, cap, displayMode = "labelAndNumber") {
|
|
20056
|
+
const pfx = cap.prefixLabel || normalizeDocCaptionCategory(cap.category).prefixLabel;
|
|
20057
|
+
const seq = cap.seqNumber ?? cap.number ?? 1;
|
|
20058
|
+
if (displayMode === "fullCaption") {
|
|
20059
|
+
return cap.fullText || `${pfx} ${seq}${cap.title ? `\uFF1A${cap.title}` : ""}`;
|
|
20060
|
+
}
|
|
20061
|
+
if (displayMode === "pageNumber") {
|
|
20062
|
+
const pg = estimateDocOffsetPageNumber(snapshot, cap.anchorIndex ?? cap.startIndex ?? 0);
|
|
20063
|
+
return String(pg);
|
|
20064
|
+
}
|
|
20065
|
+
return `${pfx} ${seq}`;
|
|
20066
|
+
}
|
|
19552
20067
|
function formatTodayIso() {
|
|
19553
20068
|
const now = /* @__PURE__ */ new Date();
|
|
19554
20069
|
const y = now.getFullYear();
|
|
@@ -19639,20 +20154,24 @@ function evaluateSingleFieldValue(snapshot, fieldType, instructionArgs, seqCount
|
|
|
19639
20154
|
return caseHit ? String(caseHit[1]) : "";
|
|
19640
20155
|
}
|
|
19641
20156
|
case "SEQ": {
|
|
19642
|
-
const seqKey = (instructionArgs
|
|
20157
|
+
const seqKey = normalizeSeqCounterKey(instructionArgs);
|
|
19643
20158
|
const nextVal = (seqCounters.get(seqKey) ?? 0) + 1;
|
|
19644
20159
|
seqCounters.set(seqKey, nextVal);
|
|
19645
20160
|
return String(nextVal);
|
|
19646
20161
|
}
|
|
19647
20162
|
case "REF": {
|
|
19648
|
-
const
|
|
20163
|
+
const tokens = (instructionArgs || "").trim().split(/\s+/).filter(Boolean);
|
|
20164
|
+
const targetKey = tokens[0] || "";
|
|
19649
20165
|
if (!targetKey) return "[\u672A\u627E\u5230\u5F15\u7528\u6E90]";
|
|
20166
|
+
const hasPageSwitch = tokens.some((t) => t === "\\p");
|
|
20167
|
+
const hasFullSwitch = tokens.some((t) => t === "\\f");
|
|
20168
|
+
const mode = hasPageSwitch ? "pageNumber" : hasFullSwitch ? "fullCaption" : "labelAndNumber";
|
|
19650
20169
|
const captions = listDocCaptions(snapshot);
|
|
19651
20170
|
const hitCap = captions.find(
|
|
19652
20171
|
(c) => c.id === targetKey || c.bookmarkName === targetKey
|
|
19653
20172
|
);
|
|
19654
20173
|
if (hitCap) {
|
|
19655
|
-
return
|
|
20174
|
+
return formatCrossRefDisplayByMode(snapshot, hitCap, mode);
|
|
19656
20175
|
}
|
|
19657
20176
|
const bookmarks = listDocBookmarks(snapshot);
|
|
19658
20177
|
const hitBm = bookmarks.find((b) => b.id === targetKey || b.name === targetKey);
|
|
@@ -19676,7 +20195,7 @@ function insertDocFieldIntoSnapshot(sourceSnapshot, fieldType, instructionArgs,
|
|
|
19676
20195
|
const insertAt = clampSafeInsertOffset(nextBody, offset);
|
|
19677
20196
|
for (const existing of listDocFields(nextSnapshot)) {
|
|
19678
20197
|
if (existing.fieldType === "SEQ" && (existing.startIndex ?? 0) < insertAt) {
|
|
19679
|
-
const k = (existing.instructionArgs
|
|
20198
|
+
const k = normalizeSeqCounterKey(existing.instructionArgs);
|
|
19680
20199
|
seqCounters.set(k, (seqCounters.get(k) ?? 0) + 1);
|
|
19681
20200
|
}
|
|
19682
20201
|
}
|
|
@@ -19916,9 +20435,13 @@ function updateAllDocFieldsInSnapshot(snapshot, context) {
|
|
|
19916
20435
|
});
|
|
19917
20436
|
return changed;
|
|
19918
20437
|
}
|
|
19919
|
-
function insertCaptionIntoSnapshot(sourceSnapshot, category, title, offset) {
|
|
20438
|
+
function insertCaptionIntoSnapshot(sourceSnapshot, category, title, offset, explicitPrefixLabel) {
|
|
19920
20439
|
const body = sourceSnapshot.body;
|
|
19921
20440
|
if (!body) return null;
|
|
20441
|
+
const { categoryKey, prefixLabel, ooxmlSeqIdent } = normalizeDocCaptionCategory(
|
|
20442
|
+
category,
|
|
20443
|
+
explicitPrefixLabel
|
|
20444
|
+
);
|
|
19922
20445
|
const nextSnapshot = Tools8.deepClone(sourceSnapshot);
|
|
19923
20446
|
const nextBody = nextSnapshot.body;
|
|
19924
20447
|
const insertAt = clampSafeInsertOffset(nextBody, offset);
|
|
@@ -19927,15 +20450,16 @@ function insertCaptionIntoSnapshot(sourceSnapshot, category, title, offset) {
|
|
|
19927
20450
|
const hostStart = hostIdx > 0 ? sortedParas[hostIdx - 1].startIndex + 1 : 0;
|
|
19928
20451
|
const needsLeadingBreak = insertAt > hostStart;
|
|
19929
20452
|
let priorCount = 0;
|
|
19930
|
-
for (const
|
|
19931
|
-
|
|
20453
|
+
for (const existingCap of listDocCaptions(nextSnapshot)) {
|
|
20454
|
+
const normExisting = normalizeDocCaptionCategory(existingCap.category).categoryKey;
|
|
20455
|
+
if (normExisting === categoryKey && (existingCap.anchorIndex ?? existingCap.startIndex ?? 0) < insertAt) {
|
|
19932
20456
|
priorCount++;
|
|
19933
20457
|
}
|
|
19934
20458
|
}
|
|
19935
20459
|
const seqNumber = priorCount + 1;
|
|
19936
20460
|
const numStr = String(seqNumber);
|
|
19937
20461
|
const cleanTitle = (title ?? "").replace(/[\r\n]/g, " ").trim();
|
|
19938
|
-
const prefixStr = `${
|
|
20462
|
+
const prefixStr = `${prefixLabel} `;
|
|
19939
20463
|
const suffixStr = cleanTitle ? `\uFF1A${cleanTitle}` : "";
|
|
19940
20464
|
const captionLine = `${prefixStr}${numStr}${suffixStr}`;
|
|
19941
20465
|
const chunk = (needsLeadingBreak ? DataStreamTreeTokenType9.PARAGRAPH : "") + captionLine + DataStreamTreeTokenType9.PARAGRAPH;
|
|
@@ -19947,9 +20471,12 @@ function insertCaptionIntoSnapshot(sourceSnapshot, category, title, offset) {
|
|
|
19947
20471
|
const numStart = lineStart + prefixStr.length;
|
|
19948
20472
|
const numEndInclusive = numStart + numStr.length - 1;
|
|
19949
20473
|
const crPos = lineStart + captionLine.length;
|
|
19950
|
-
const
|
|
19951
|
-
const
|
|
19952
|
-
const
|
|
20474
|
+
const shortToken = generateRandomId7(6).replace(/[^A-Za-z0-9_]/g, "_");
|
|
20475
|
+
const captionId = `cap_${shortToken}`;
|
|
20476
|
+
const fieldId = `fld_seq_${shortToken}`;
|
|
20477
|
+
const bookmarkName = `_RefCap_${shortToken}`;
|
|
20478
|
+
const seqInstrArgs = `${ooxmlSeqIdent} \\* ARABIC`;
|
|
20479
|
+
const seqInstrText = `SEQ ${seqInstrArgs}`;
|
|
19953
20480
|
if (spliced.paragraphs) {
|
|
19954
20481
|
spliced.paragraphs = spliced.paragraphs.map(
|
|
19955
20482
|
(p) => p.startIndex === crPos ? {
|
|
@@ -19957,7 +20484,7 @@ function insertCaptionIntoSnapshot(sourceSnapshot, category, title, offset) {
|
|
|
19957
20484
|
paragraphStyle: {
|
|
19958
20485
|
...p.paragraphStyle ?? {},
|
|
19959
20486
|
horizontalAlign: 2,
|
|
19960
|
-
keepNext:
|
|
20487
|
+
keepNext: categoryKey === "table" ? 1 : 0,
|
|
19961
20488
|
yudaoCaptionId: captionId
|
|
19962
20489
|
}
|
|
19963
20490
|
} : p
|
|
@@ -19966,17 +20493,21 @@ function insertCaptionIntoSnapshot(sourceSnapshot, category, title, offset) {
|
|
|
19966
20493
|
const fieldEntry = {
|
|
19967
20494
|
id: fieldId,
|
|
19968
20495
|
fieldType: "SEQ",
|
|
19969
|
-
instructionArgs:
|
|
19970
|
-
instrText:
|
|
20496
|
+
instructionArgs: seqInstrArgs,
|
|
20497
|
+
instrText: seqInstrText,
|
|
19971
20498
|
value: numStr,
|
|
20499
|
+
sourceKind: "simple",
|
|
19972
20500
|
startIndex: numStart,
|
|
19973
20501
|
endIndex: numEndInclusive
|
|
19974
20502
|
};
|
|
19975
20503
|
const captionEntry = {
|
|
19976
20504
|
id: captionId,
|
|
19977
|
-
category,
|
|
20505
|
+
category: categoryKey,
|
|
20506
|
+
prefixLabel,
|
|
20507
|
+
seqNumber,
|
|
19978
20508
|
number: seqNumber,
|
|
19979
20509
|
title: cleanTitle,
|
|
20510
|
+
anchorIndex: lineStart,
|
|
19980
20511
|
fullText: captionLine,
|
|
19981
20512
|
bookmarkName,
|
|
19982
20513
|
fieldId,
|
|
@@ -19992,6 +20523,8 @@ function insertCaptionIntoSnapshot(sourceSnapshot, category, title, offset) {
|
|
|
19992
20523
|
endIndex: numEndInclusive,
|
|
19993
20524
|
properties: {
|
|
19994
20525
|
yudaoBlockKind: "docField",
|
|
20526
|
+
fieldInstr: seqInstrText,
|
|
20527
|
+
fieldSimple: true,
|
|
19995
20528
|
field: Tools8.deepClone(fieldEntry)
|
|
19996
20529
|
}
|
|
19997
20530
|
},
|
|
@@ -20020,19 +20553,14 @@ function insertCaptionIntoSnapshot(sourceSnapshot, category, title, offset) {
|
|
|
20020
20553
|
);
|
|
20021
20554
|
spliced.customRanges.sort((a, b) => a.startIndex - b.startIndex || a.endIndex - b.endIndex);
|
|
20022
20555
|
nextSnapshot.body = spliced;
|
|
20023
|
-
|
|
20556
|
+
recalculateDocCaptionsAndCrossRefs(nextSnapshot);
|
|
20024
20557
|
const refreshedCaptions = listDocCaptions(nextSnapshot);
|
|
20025
20558
|
const updatedCap = refreshedCaptions.find((c) => c.id === captionId) ?? captionEntry;
|
|
20026
|
-
const
|
|
20027
|
-
writeDocTemplateMetadataToSnapshot(nextSnapshot, {
|
|
20028
|
-
...meta,
|
|
20029
|
-
captions: refreshedCaptions,
|
|
20030
|
-
bookmarks: listDocBookmarks(nextSnapshot)
|
|
20031
|
-
});
|
|
20559
|
+
const liveEndOff = updatedCap.endIndex !== void 0 ? updatedCap.endIndex + 2 : crPos + 1;
|
|
20032
20560
|
return {
|
|
20033
20561
|
snapshot: nextSnapshot,
|
|
20034
20562
|
caption: updatedCap,
|
|
20035
|
-
endOffset: Math.min(Math.max(0, nextSnapshot.body.dataStream.length - 2),
|
|
20563
|
+
endOffset: Math.min(Math.max(0, nextSnapshot.body.dataStream.length - 2), liveEndOff)
|
|
20036
20564
|
};
|
|
20037
20565
|
}
|
|
20038
20566
|
function listDocCaptions(snapshot) {
|
|
@@ -20040,33 +20568,565 @@ function listDocCaptions(snapshot) {
|
|
|
20040
20568
|
const stream = body?.dataStream ?? "";
|
|
20041
20569
|
const fields = listDocFields(snapshot);
|
|
20042
20570
|
const out = [];
|
|
20571
|
+
const seenIds = /* @__PURE__ */ new Set();
|
|
20043
20572
|
for (const r of body?.customRanges ?? []) {
|
|
20044
20573
|
const props = r.properties;
|
|
20045
20574
|
if (props?.yudaoBlockKind === "caption" && props.caption) {
|
|
20046
20575
|
const cap = props.caption;
|
|
20576
|
+
const normCat = normalizeDocCaptionCategory(cap.category, cap.prefixLabel);
|
|
20047
20577
|
const linkedField = fields.find((f) => f.id === cap.fieldId);
|
|
20048
|
-
const
|
|
20578
|
+
const fallbackNum = cap.seqNumber ?? cap.number ?? 1;
|
|
20579
|
+
const liveNum = linkedField ? Number(linkedField.value) || fallbackNum : fallbackNum;
|
|
20049
20580
|
const liveText = stream.slice(r.startIndex, r.endIndex + 1).replace(/[\r\n\u0000-\u001F]/g, "");
|
|
20581
|
+
const extractedTitle = cap.title !== void 0 ? cap.title : liveText.replace(/^[^::]+[::]\s*/, "").trim();
|
|
20582
|
+
const id = r.rangeId || cap.id;
|
|
20583
|
+
seenIds.add(id);
|
|
20050
20584
|
out.push({
|
|
20051
20585
|
...Tools8.deepClone(cap),
|
|
20052
|
-
id
|
|
20586
|
+
id,
|
|
20587
|
+
category: normCat.categoryKey,
|
|
20588
|
+
prefixLabel: cap.prefixLabel || normCat.prefixLabel,
|
|
20589
|
+
seqNumber: liveNum,
|
|
20053
20590
|
number: liveNum,
|
|
20054
|
-
|
|
20591
|
+
title: extractedTitle,
|
|
20592
|
+
anchorIndex: r.startIndex,
|
|
20593
|
+
fullText: liveText || `${normCat.prefixLabel} ${liveNum}${extractedTitle ? `\uFF1A${extractedTitle}` : ""}`,
|
|
20055
20594
|
startIndex: r.startIndex,
|
|
20056
20595
|
endIndex: r.endIndex
|
|
20057
20596
|
});
|
|
20058
20597
|
}
|
|
20059
20598
|
}
|
|
20060
|
-
|
|
20599
|
+
if (out.length === 0) {
|
|
20600
|
+
const meta = readDocTemplateMetadataFromSnapshot(snapshot);
|
|
20601
|
+
for (const cap of meta.captions ?? []) {
|
|
20602
|
+
if (!cap || seenIds.has(cap.id)) continue;
|
|
20603
|
+
const normCat = normalizeDocCaptionCategory(cap.category, cap.prefixLabel);
|
|
20604
|
+
const seqNum = cap.seqNumber ?? cap.number ?? 1;
|
|
20605
|
+
const anchor = cap.anchorIndex ?? cap.startIndex ?? 0;
|
|
20606
|
+
out.push({
|
|
20607
|
+
...Tools8.deepClone(cap),
|
|
20608
|
+
category: normCat.categoryKey,
|
|
20609
|
+
prefixLabel: cap.prefixLabel || normCat.prefixLabel,
|
|
20610
|
+
seqNumber: seqNum,
|
|
20611
|
+
number: seqNum,
|
|
20612
|
+
anchorIndex: anchor,
|
|
20613
|
+
startIndex: cap.startIndex ?? anchor,
|
|
20614
|
+
fullText: cap.fullText || `${cap.prefixLabel || normCat.prefixLabel} ${seqNum}${cap.title ? `\uFF1A${cap.title}` : ""}`
|
|
20615
|
+
});
|
|
20616
|
+
}
|
|
20617
|
+
}
|
|
20618
|
+
return out.sort((a, b) => a.anchorIndex - b.anchorIndex);
|
|
20061
20619
|
}
|
|
20062
|
-
function
|
|
20063
|
-
|
|
20064
|
-
|
|
20065
|
-
|
|
20066
|
-
|
|
20067
|
-
|
|
20068
|
-
|
|
20620
|
+
function listDocCrossRefs(snapshot) {
|
|
20621
|
+
const body = snapshot?.body;
|
|
20622
|
+
const stream = body?.dataStream ?? "";
|
|
20623
|
+
const captions = listDocCaptions(snapshot);
|
|
20624
|
+
const out = [];
|
|
20625
|
+
const seenIds = /* @__PURE__ */ new Set();
|
|
20626
|
+
for (const r of body?.customRanges ?? []) {
|
|
20627
|
+
const props = r.properties;
|
|
20628
|
+
if (!props) continue;
|
|
20629
|
+
const explicitXref = props.crossRef;
|
|
20630
|
+
const rawInstr = String(props.fieldInstr || props.field?.instrText || "").trim();
|
|
20631
|
+
const isRefField = /^REF\s+/i.test(rawInstr);
|
|
20632
|
+
if (!explicitXref && !isRefField) continue;
|
|
20633
|
+
const tokens = rawInstr.replace(/^REF\s+/i, "").trim().split(/\s+/).filter(Boolean);
|
|
20634
|
+
const refTargetToken = tokens[0] || explicitXref?.bookmarkName || explicitXref?.targetCaptionId || "";
|
|
20635
|
+
const matchedCap = captions.find(
|
|
20636
|
+
(c) => c.id === explicitXref?.targetCaptionId || c.id === refTargetToken || c.bookmarkName === refTargetToken
|
|
20637
|
+
);
|
|
20638
|
+
if (!explicitXref && !matchedCap && !refTargetToken.startsWith("_RefCap_") && !refTargetToken.startsWith("_Ref_")) {
|
|
20639
|
+
continue;
|
|
20640
|
+
}
|
|
20641
|
+
const displayMode = explicitXref?.displayMode ?? (tokens.includes("\\p") ? "pageNumber" : tokens.includes("\\f") ? "fullCaption" : "labelAndNumber");
|
|
20642
|
+
const liveRendered = stream.slice(r.startIndex, r.endIndex + 1).replace(/[\r\n\u0000-\u001F]/g, "");
|
|
20643
|
+
const id = explicitXref?.id || r.rangeId;
|
|
20644
|
+
seenIds.add(id);
|
|
20645
|
+
out.push({
|
|
20646
|
+
id,
|
|
20647
|
+
targetCaptionId: matchedCap?.id || explicitXref?.targetCaptionId || refTargetToken,
|
|
20648
|
+
displayMode,
|
|
20649
|
+
renderedText: liveRendered || explicitXref?.renderedText || "",
|
|
20650
|
+
anchorIndex: r.startIndex,
|
|
20651
|
+
bookmarkName: matchedCap?.bookmarkName || explicitXref?.bookmarkName || refTargetToken,
|
|
20652
|
+
fieldId: r.rangeId,
|
|
20653
|
+
startIndex: r.startIndex,
|
|
20654
|
+
endIndex: r.endIndex
|
|
20655
|
+
});
|
|
20656
|
+
}
|
|
20657
|
+
if (out.length === 0) {
|
|
20658
|
+
const meta = readDocTemplateMetadataFromSnapshot(snapshot);
|
|
20659
|
+
for (const xr of meta.crossRefs ?? []) {
|
|
20660
|
+
if (!xr || seenIds.has(xr.id)) continue;
|
|
20661
|
+
out.push({
|
|
20662
|
+
...Tools8.deepClone(xr),
|
|
20663
|
+
anchorIndex: xr.anchorIndex ?? xr.startIndex ?? 0
|
|
20664
|
+
});
|
|
20665
|
+
}
|
|
20666
|
+
}
|
|
20667
|
+
return out.sort((a, b) => a.anchorIndex - b.anchorIndex);
|
|
20668
|
+
}
|
|
20669
|
+
function insertCrossReferenceIntoSnapshot(sourceSnapshot, targetBookmarkOrCaptionId, offset, options) {
|
|
20670
|
+
const rawTarget = targetBookmarkOrCaptionId?.trim();
|
|
20671
|
+
if (!rawTarget || !sourceSnapshot.body) return null;
|
|
20672
|
+
const displayMode = options?.displayMode ?? "labelAndNumber";
|
|
20673
|
+
const captions = listDocCaptions(sourceSnapshot);
|
|
20674
|
+
const hitCap = captions.find((c) => c.id === rawTarget || c.bookmarkName === rawTarget);
|
|
20675
|
+
let workingSnapshot = Tools8.deepClone(sourceSnapshot);
|
|
20676
|
+
let insertAt = clampSafeInsertOffset(workingSnapshot.body, offset);
|
|
20677
|
+
if (options?.prefixText) {
|
|
20678
|
+
workingSnapshot.body = spliceDocumentBodySpan(
|
|
20679
|
+
workingSnapshot.body,
|
|
20680
|
+
insertAt,
|
|
20681
|
+
insertAt - 1,
|
|
20682
|
+
options.prefixText
|
|
20683
|
+
);
|
|
20684
|
+
insertAt += options.prefixText.length;
|
|
20685
|
+
}
|
|
20686
|
+
if (!hitCap) {
|
|
20687
|
+
return insertDocFieldIntoSnapshot(workingSnapshot, "REF", `${rawTarget} \\h`, insertAt);
|
|
20688
|
+
}
|
|
20689
|
+
const bmName = hitCap.bookmarkName || `_RefCap_${hitCap.id.replace(/^cap_/, "").replace(/[^A-Za-z0-9_]/g, "_")}`;
|
|
20690
|
+
const modeSwitch = displayMode === "pageNumber" ? " \\p \\h" : displayMode === "fullCaption" ? " \\f \\h" : " \\h";
|
|
20691
|
+
const instrArgs = `${bmName}${modeSwitch}`;
|
|
20692
|
+
const instrText = `REF ${instrArgs}`;
|
|
20693
|
+
const renderedText = formatCrossRefDisplayByMode(workingSnapshot, hitCap, displayMode);
|
|
20694
|
+
const xrefId = `xref_${generateRandomId7(6)}`;
|
|
20695
|
+
const spliced = spliceDocumentBodySpan(
|
|
20696
|
+
workingSnapshot.body,
|
|
20697
|
+
insertAt,
|
|
20698
|
+
insertAt - 1,
|
|
20699
|
+
renderedText,
|
|
20700
|
+
{
|
|
20701
|
+
textStyle: {
|
|
20702
|
+
cl: { rgb: "#2C53F1" },
|
|
20703
|
+
bg: { rgb: "#F3F5FF" }
|
|
20704
|
+
}
|
|
20705
|
+
}
|
|
20706
|
+
);
|
|
20707
|
+
const fieldEntry = {
|
|
20708
|
+
id: xrefId,
|
|
20709
|
+
fieldType: "REF",
|
|
20710
|
+
instructionArgs: instrArgs,
|
|
20711
|
+
instrText,
|
|
20712
|
+
value: renderedText,
|
|
20713
|
+
sourceKind: "simple",
|
|
20714
|
+
startIndex: insertAt,
|
|
20715
|
+
endIndex: insertAt + Math.max(0, renderedText.length - 1)
|
|
20716
|
+
};
|
|
20717
|
+
const crossRefEntry = {
|
|
20718
|
+
id: xrefId,
|
|
20719
|
+
targetCaptionId: hitCap.id,
|
|
20720
|
+
displayMode,
|
|
20721
|
+
renderedText,
|
|
20722
|
+
anchorIndex: insertAt,
|
|
20723
|
+
bookmarkName: bmName,
|
|
20724
|
+
fieldId: xrefId,
|
|
20725
|
+
startIndex: insertAt,
|
|
20726
|
+
endIndex: insertAt + Math.max(0, renderedText.length - 1)
|
|
20727
|
+
};
|
|
20728
|
+
if (!spliced.customRanges) spliced.customRanges = [];
|
|
20729
|
+
spliced.customRanges.push({
|
|
20730
|
+
rangeId: xrefId,
|
|
20731
|
+
rangeType: CustomRangeType6.CUSTOM,
|
|
20732
|
+
startIndex: fieldEntry.startIndex,
|
|
20733
|
+
endIndex: fieldEntry.endIndex,
|
|
20734
|
+
properties: {
|
|
20735
|
+
yudaoBlockKind: "docField",
|
|
20736
|
+
fieldInstr: instrText,
|
|
20737
|
+
fieldSimple: true,
|
|
20738
|
+
field: Tools8.deepClone(fieldEntry),
|
|
20739
|
+
crossRef: Tools8.deepClone(crossRefEntry)
|
|
20740
|
+
}
|
|
20741
|
+
});
|
|
20742
|
+
spliced.customRanges.sort((a, b) => a.startIndex - b.startIndex || a.endIndex - b.endIndex);
|
|
20743
|
+
workingSnapshot.body = spliced;
|
|
20744
|
+
const meta = readDocTemplateMetadataFromSnapshot(workingSnapshot);
|
|
20745
|
+
const refreshedCrossRefs = listDocCrossRefs(workingSnapshot);
|
|
20746
|
+
writeDocTemplateMetadataToSnapshot(workingSnapshot, {
|
|
20747
|
+
...meta,
|
|
20748
|
+
docFields: {
|
|
20749
|
+
...meta.docFields ?? {},
|
|
20750
|
+
[xrefId]: fieldEntry
|
|
20751
|
+
},
|
|
20752
|
+
captions: listDocCaptions(workingSnapshot),
|
|
20753
|
+
crossRefs: refreshedCrossRefs
|
|
20754
|
+
});
|
|
20755
|
+
return {
|
|
20756
|
+
snapshot: workingSnapshot,
|
|
20757
|
+
field: fieldEntry,
|
|
20758
|
+
crossRef: refreshedCrossRefs.find((x) => x.id === xrefId) ?? crossRefEntry,
|
|
20759
|
+
endOffset: insertAt + renderedText.length
|
|
20760
|
+
};
|
|
20761
|
+
}
|
|
20762
|
+
function buildTableOfFiguresEntries(docData, categoryFilter) {
|
|
20763
|
+
if (!docData) return [];
|
|
20764
|
+
const captions = listDocCaptions(docData);
|
|
20765
|
+
const filterKey = categoryFilter && categoryFilter !== "all" ? normalizeDocCaptionCategory(categoryFilter).categoryKey : null;
|
|
20766
|
+
const out = [];
|
|
20767
|
+
for (const cap of captions) {
|
|
20768
|
+
const norm = normalizeDocCaptionCategory(cap.category, cap.prefixLabel);
|
|
20769
|
+
if (filterKey && norm.categoryKey !== filterKey) continue;
|
|
20770
|
+
const seq = cap.seqNumber ?? cap.number ?? 1;
|
|
20771
|
+
const pfx = cap.prefixLabel || norm.prefixLabel;
|
|
20772
|
+
const labelAndNumber = `${pfx} ${seq}`;
|
|
20773
|
+
const fullCaption = cap.title ? `${labelAndNumber}\uFF1A${cap.title}` : labelAndNumber;
|
|
20774
|
+
const pageNumber = estimateDocOffsetPageNumber(docData, cap.anchorIndex ?? cap.startIndex ?? 0);
|
|
20775
|
+
out.push({
|
|
20776
|
+
captionId: cap.id,
|
|
20777
|
+
category: norm.categoryKey,
|
|
20778
|
+
prefixLabel: pfx,
|
|
20779
|
+
seqNumber: seq,
|
|
20780
|
+
title: cap.title || "",
|
|
20781
|
+
labelAndNumber,
|
|
20782
|
+
fullCaption,
|
|
20783
|
+
pageNumber,
|
|
20784
|
+
anchorIndex: cap.anchorIndex ?? cap.startIndex ?? 0,
|
|
20785
|
+
formattedLine: `${fullCaption} ${pageNumber}`
|
|
20786
|
+
});
|
|
20787
|
+
}
|
|
20788
|
+
return out;
|
|
20789
|
+
}
|
|
20790
|
+
function insertTableOfFiguresIntoSnapshot(sourceSnapshot, options) {
|
|
20791
|
+
if (!sourceSnapshot.body) return null;
|
|
20792
|
+
const nextSnapshot = Tools8.deepClone(sourceSnapshot);
|
|
20793
|
+
recalculateDocCaptionsAndCrossRefs(nextSnapshot);
|
|
20794
|
+
const category = options?.category ?? "all";
|
|
20795
|
+
const showPageNumbers = options?.showPageNumbers ?? true;
|
|
20796
|
+
const entries = buildTableOfFiguresEntries(nextSnapshot, category);
|
|
20797
|
+
const headerTitle = options?.title?.trim() || (category === "all" ? "\u56FE\u8868\u76EE\u5F55" : `${normalizeDocCaptionCategory(category).prefixLabel}\u76EE\u5F55`);
|
|
20798
|
+
const lines = [headerTitle];
|
|
20799
|
+
if (entries.length === 0) {
|
|
20800
|
+
lines.push("\uFF08\u6682\u65E0\u9898\u6CE8\u6761\u76EE\uFF09");
|
|
20801
|
+
} else {
|
|
20802
|
+
for (const item of entries) {
|
|
20803
|
+
lines.push(showPageNumbers ? `${item.fullCaption} ${item.pageNumber}` : item.fullCaption);
|
|
20804
|
+
}
|
|
20805
|
+
}
|
|
20806
|
+
const tofStream = lines.join(DataStreamTreeTokenType9.PARAGRAPH);
|
|
20807
|
+
const body = nextSnapshot.body;
|
|
20808
|
+
const existingRange = (body.customRanges ?? []).find(
|
|
20809
|
+
(r) => r.properties?.yudaoBlockKind === "tableOfFigures"
|
|
20810
|
+
);
|
|
20811
|
+
if (existingRange && options?.offset === void 0) {
|
|
20812
|
+
const updatedBody2 = spliceMultiParagraphBodySpan(
|
|
20813
|
+
body,
|
|
20814
|
+
existingRange.startIndex,
|
|
20815
|
+
existingRange.endIndex,
|
|
20816
|
+
tofStream,
|
|
20817
|
+
{
|
|
20818
|
+
targetRangeId: existingRange.rangeId,
|
|
20819
|
+
updatedRangeProperties: {
|
|
20820
|
+
yudaoBlockKind: "tableOfFigures",
|
|
20821
|
+
title: headerTitle,
|
|
20822
|
+
category,
|
|
20823
|
+
showPageNumbers
|
|
20824
|
+
},
|
|
20825
|
+
textStyle: { fs: 10.5, cl: { rgb: "#31363F" } }
|
|
20826
|
+
}
|
|
20827
|
+
);
|
|
20828
|
+
applyTableOfFiguresParagraphStyles(updatedBody2, existingRange.startIndex, lines, showPageNumbers);
|
|
20829
|
+
nextSnapshot.body = updatedBody2;
|
|
20830
|
+
return {
|
|
20831
|
+
snapshot: nextSnapshot,
|
|
20832
|
+
entries,
|
|
20833
|
+
endOffset: existingRange.startIndex + tofStream.length
|
|
20834
|
+
};
|
|
20835
|
+
}
|
|
20836
|
+
const insertAt = clampSafeInsertOffset(body, options?.offset);
|
|
20837
|
+
const sortedParas = [...body.paragraphs ?? []].sort((a, b) => a.startIndex - b.startIndex);
|
|
20838
|
+
const hostIdx = sortedParas.findIndex((p) => p.startIndex >= insertAt);
|
|
20839
|
+
const hostStart = hostIdx > 0 ? sortedParas[hostIdx - 1].startIndex + 1 : 0;
|
|
20840
|
+
const needsLeadingBreak = insertAt > hostStart;
|
|
20841
|
+
const fullChunk = (needsLeadingBreak ? DataStreamTreeTokenType9.PARAGRAPH : "") + tofStream + DataStreamTreeTokenType9.PARAGRAPH;
|
|
20842
|
+
const updatedBody = spliceMultiParagraphBodySpan(body, insertAt, insertAt - 1, fullChunk, {
|
|
20843
|
+
textStyle: { fs: 10.5, cl: { rgb: "#31363F" } }
|
|
20844
|
+
});
|
|
20845
|
+
const blockStart = needsLeadingBreak ? insertAt + 1 : insertAt;
|
|
20846
|
+
const blockEndInclusive = blockStart + tofStream.length - 1;
|
|
20847
|
+
applyTableOfFiguresParagraphStyles(updatedBody, blockStart, lines, showPageNumbers);
|
|
20848
|
+
if (!updatedBody.customRanges) updatedBody.customRanges = [];
|
|
20849
|
+
updatedBody.customRanges.push({
|
|
20850
|
+
rangeId: `tof_${generateRandomId7(6)}`,
|
|
20851
|
+
rangeType: CustomRangeType6.CUSTOM,
|
|
20852
|
+
startIndex: blockStart,
|
|
20853
|
+
endIndex: blockEndInclusive,
|
|
20854
|
+
properties: {
|
|
20855
|
+
yudaoBlockKind: "tableOfFigures",
|
|
20856
|
+
title: headerTitle,
|
|
20857
|
+
category,
|
|
20858
|
+
showPageNumbers
|
|
20859
|
+
}
|
|
20860
|
+
});
|
|
20861
|
+
updatedBody.customRanges.sort((a, b) => a.startIndex - b.startIndex || a.endIndex - b.endIndex);
|
|
20862
|
+
nextSnapshot.body = updatedBody;
|
|
20863
|
+
return {
|
|
20864
|
+
snapshot: nextSnapshot,
|
|
20865
|
+
entries,
|
|
20866
|
+
endOffset: Math.min(Math.max(0, updatedBody.dataStream.length - 2), blockEndInclusive + 2)
|
|
20867
|
+
};
|
|
20868
|
+
}
|
|
20869
|
+
function applyTableOfFiguresParagraphStyles(body, blockStart, lines, showPageNumbers) {
|
|
20870
|
+
const titleEnd = blockStart + (lines[0]?.length ?? 0);
|
|
20871
|
+
if (titleEnd > blockStart) {
|
|
20872
|
+
body.textRuns = [
|
|
20873
|
+
...(body.textRuns ?? []).filter((r) => r.ed <= blockStart || r.st >= titleEnd),
|
|
20874
|
+
{ st: blockStart, ed: titleEnd, ts: { bl: 1, fs: 13, cl: { rgb: "#1B1C1F" } } }
|
|
20875
|
+
].sort((a, b) => a.st - b.st || a.ed - b.ed);
|
|
20876
|
+
}
|
|
20877
|
+
if (!showPageNumbers || !body.paragraphs) return;
|
|
20878
|
+
const itemParaEnds = /* @__PURE__ */ new Set();
|
|
20879
|
+
let cursor = blockStart;
|
|
20880
|
+
lines.forEach((ln, idx) => {
|
|
20881
|
+
const pEnd = cursor + ln.length;
|
|
20882
|
+
if (idx > 0 && ln.includes(" ")) {
|
|
20883
|
+
itemParaEnds.add(pEnd);
|
|
20884
|
+
}
|
|
20885
|
+
cursor = pEnd + 1;
|
|
20886
|
+
});
|
|
20887
|
+
body.paragraphs = body.paragraphs.map(
|
|
20888
|
+
(p) => itemParaEnds.has(p.startIndex) ? {
|
|
20889
|
+
...p,
|
|
20890
|
+
paragraphStyle: {
|
|
20891
|
+
...p.paragraphStyle ?? {},
|
|
20892
|
+
yudaoTabStops: [{ positionPt: 440, alignment: "right", leader: "dot" }]
|
|
20893
|
+
}
|
|
20894
|
+
} : p
|
|
20895
|
+
);
|
|
20896
|
+
}
|
|
20897
|
+
function recalculateDocCaptionsAndCrossRefs(docData) {
|
|
20898
|
+
if (!docData?.body) return docData;
|
|
20899
|
+
const counters = {
|
|
20900
|
+
figure: 0,
|
|
20901
|
+
table: 0,
|
|
20902
|
+
equation: 0
|
|
20903
|
+
};
|
|
20904
|
+
const captionRangeIds = (docData.body.customRanges ?? []).filter((r) => r.properties?.yudaoBlockKind === "caption").sort((a, b) => a.startIndex - b.startIndex || a.endIndex - b.endIndex).map((r) => r.rangeId);
|
|
20905
|
+
for (const capRangeId of captionRangeIds) {
|
|
20906
|
+
const liveBody = docData.body;
|
|
20907
|
+
const capRange = (liveBody.customRanges ?? []).find(
|
|
20908
|
+
(r) => r.rangeId === capRangeId && r.properties?.yudaoBlockKind === "caption"
|
|
20909
|
+
);
|
|
20910
|
+
if (!capRange) continue;
|
|
20911
|
+
const rawCap = capRange.properties?.caption ?? {};
|
|
20912
|
+
const norm = normalizeDocCaptionCategory(rawCap.category, rawCap.prefixLabel);
|
|
20913
|
+
const nextSeq = ++counters[norm.categoryKey];
|
|
20914
|
+
const nextNumStr = String(nextSeq);
|
|
20915
|
+
const seqInstrArgs = `${norm.ooxmlSeqIdent} \\* ARABIC`;
|
|
20916
|
+
const seqInstrText = `SEQ ${seqInstrArgs}`;
|
|
20917
|
+
const seqRange = (liveBody.customRanges ?? []).find((r) => {
|
|
20918
|
+
if (r.rangeId === rawCap.fieldId) return true;
|
|
20919
|
+
if (r.startIndex < capRange.startIndex || r.endIndex > capRange.endIndex) return false;
|
|
20920
|
+
const p = r.properties;
|
|
20921
|
+
const instr = String(p?.fieldInstr || p?.field?.instrText || "");
|
|
20922
|
+
return /^SEQ\b/i.test(instr.trim());
|
|
20923
|
+
});
|
|
20924
|
+
if (seqRange) {
|
|
20925
|
+
const curNumStr = liveBody.dataStream.slice(seqRange.startIndex, seqRange.endIndex + 1).replace(/[\r\n\u0000-\u001F]/g, "");
|
|
20926
|
+
const nextSeqField = {
|
|
20927
|
+
...seqRange.properties?.field ?? {},
|
|
20928
|
+
id: seqRange.rangeId,
|
|
20929
|
+
fieldType: "SEQ",
|
|
20930
|
+
instructionArgs: seqInstrArgs,
|
|
20931
|
+
instrText: seqInstrText,
|
|
20932
|
+
value: nextNumStr,
|
|
20933
|
+
sourceKind: "simple",
|
|
20934
|
+
startIndex: seqRange.startIndex,
|
|
20935
|
+
endIndex: seqRange.startIndex + nextNumStr.length - 1
|
|
20936
|
+
};
|
|
20937
|
+
if (curNumStr !== nextNumStr) {
|
|
20938
|
+
docData.body = spliceDocumentBodySpan(
|
|
20939
|
+
liveBody,
|
|
20940
|
+
seqRange.startIndex,
|
|
20941
|
+
seqRange.endIndex,
|
|
20942
|
+
nextNumStr,
|
|
20943
|
+
{
|
|
20944
|
+
targetRangeId: seqRange.rangeId,
|
|
20945
|
+
updatedRangeProperties: {
|
|
20946
|
+
yudaoBlockKind: "docField",
|
|
20947
|
+
fieldInstr: seqInstrText,
|
|
20948
|
+
fieldSimple: true,
|
|
20949
|
+
field: Tools8.deepClone(nextSeqField)
|
|
20950
|
+
},
|
|
20951
|
+
textStyle: { fs: 10, bl: 1, cl: { rgb: "#31363F" } }
|
|
20952
|
+
}
|
|
20953
|
+
);
|
|
20954
|
+
} else {
|
|
20955
|
+
seqRange.properties = {
|
|
20956
|
+
...seqRange.properties ?? {},
|
|
20957
|
+
yudaoBlockKind: "docField",
|
|
20958
|
+
fieldInstr: seqInstrText,
|
|
20959
|
+
fieldSimple: true,
|
|
20960
|
+
field: Tools8.deepClone(nextSeqField)
|
|
20961
|
+
};
|
|
20962
|
+
}
|
|
20963
|
+
} else {
|
|
20964
|
+
const expectedLine = `${norm.prefixLabel} ${nextNumStr}${rawCap.title ? `\uFF1A${rawCap.title}` : ""}`;
|
|
20965
|
+
const curLine = liveBody.dataStream.slice(capRange.startIndex, capRange.endIndex + 1).replace(/[\r\n\u0000-\u001F]/g, "");
|
|
20966
|
+
if (curLine !== expectedLine) {
|
|
20967
|
+
docData.body = spliceDocumentBodySpan(
|
|
20968
|
+
liveBody,
|
|
20969
|
+
capRange.startIndex,
|
|
20970
|
+
capRange.endIndex,
|
|
20971
|
+
expectedLine,
|
|
20972
|
+
{
|
|
20973
|
+
targetRangeId: capRange.rangeId,
|
|
20974
|
+
textStyle: { fs: 10, bl: 1, cl: { rgb: "#31363F" } }
|
|
20975
|
+
}
|
|
20976
|
+
);
|
|
20977
|
+
}
|
|
20978
|
+
}
|
|
20979
|
+
const refreshedCapRange = (docData.body.customRanges ?? []).find(
|
|
20980
|
+
(r) => r.rangeId === capRangeId && r.properties?.yudaoBlockKind === "caption"
|
|
20981
|
+
);
|
|
20982
|
+
if (refreshedCapRange) {
|
|
20983
|
+
const liveFull = docData.body.dataStream.slice(refreshedCapRange.startIndex, refreshedCapRange.endIndex + 1).replace(/[\r\n\u0000-\u001F]/g, "");
|
|
20984
|
+
const cleanTitle = rawCap.title !== void 0 ? rawCap.title : liveFull.replace(/^[^::]+[::]\s*/, "").trim();
|
|
20985
|
+
const bmName = rawCap.bookmarkName || `_RefCap_${capRangeId.replace(/^cap_/, "").replace(/[^A-Za-z0-9_]/g, "_")}`;
|
|
20986
|
+
const updatedCaption = {
|
|
20987
|
+
id: capRangeId,
|
|
20988
|
+
category: norm.categoryKey,
|
|
20989
|
+
prefixLabel: norm.prefixLabel,
|
|
20990
|
+
seqNumber: nextSeq,
|
|
20991
|
+
number: nextSeq,
|
|
20992
|
+
title: cleanTitle,
|
|
20993
|
+
anchorIndex: refreshedCapRange.startIndex,
|
|
20994
|
+
fullText: liveFull || `${norm.prefixLabel} ${nextSeq}${cleanTitle ? `\uFF1A${cleanTitle}` : ""}`,
|
|
20995
|
+
bookmarkName: bmName,
|
|
20996
|
+
fieldId: seqRange?.rangeId || rawCap.fieldId || "",
|
|
20997
|
+
startIndex: refreshedCapRange.startIndex,
|
|
20998
|
+
endIndex: refreshedCapRange.endIndex
|
|
20999
|
+
};
|
|
21000
|
+
refreshedCapRange.properties = {
|
|
21001
|
+
...refreshedCapRange.properties ?? {},
|
|
21002
|
+
yudaoBlockKind: "caption",
|
|
21003
|
+
caption: Tools8.deepClone(updatedCaption)
|
|
21004
|
+
};
|
|
21005
|
+
}
|
|
21006
|
+
}
|
|
21007
|
+
const captionsNow = listDocCaptions(docData);
|
|
21008
|
+
const xrefRangeIds = (docData.body.customRanges ?? []).filter((r) => {
|
|
21009
|
+
const p = r.properties;
|
|
21010
|
+
if (!p) return false;
|
|
21011
|
+
if (p.crossRef) return true;
|
|
21012
|
+
const instr = String(p.fieldInstr || p.field?.instrText || "").trim();
|
|
21013
|
+
return /^REF\s+/i.test(instr);
|
|
21014
|
+
}).sort((a, b) => a.startIndex - b.startIndex || a.endIndex - b.endIndex).map((r) => r.rangeId);
|
|
21015
|
+
for (const xrRangeId of xrefRangeIds) {
|
|
21016
|
+
const liveBody = docData.body;
|
|
21017
|
+
const xrRange = (liveBody.customRanges ?? []).find((r) => r.rangeId === xrRangeId);
|
|
21018
|
+
if (!xrRange) continue;
|
|
21019
|
+
const props = xrRange.properties ?? {};
|
|
21020
|
+
const explicitXr = props.crossRef;
|
|
21021
|
+
const rawInstr = String(props.fieldInstr || props.field?.instrText || "").trim();
|
|
21022
|
+
const tokens = rawInstr.replace(/^REF\s+/i, "").trim().split(/\s+/).filter(Boolean);
|
|
21023
|
+
const refTarget = tokens[0] || explicitXr?.bookmarkName || explicitXr?.targetCaptionId || "";
|
|
21024
|
+
const hitCap = captionsNow.find(
|
|
21025
|
+
(c) => c.id === explicitXr?.targetCaptionId || c.id === refTarget || c.bookmarkName === refTarget
|
|
21026
|
+
);
|
|
21027
|
+
if (!hitCap) continue;
|
|
21028
|
+
const displayMode = explicitXr?.displayMode ?? (tokens.includes("\\p") ? "pageNumber" : tokens.includes("\\f") ? "fullCaption" : "labelAndNumber");
|
|
21029
|
+
const nextRendered = formatCrossRefDisplayByMode(docData, hitCap, displayMode);
|
|
21030
|
+
const curRendered = liveBody.dataStream.slice(xrRange.startIndex, xrRange.endIndex + 1).replace(/[\r\n\u0000-\u001F]/g, "");
|
|
21031
|
+
const bmName = hitCap.bookmarkName || `_RefCap_${hitCap.id.replace(/^cap_/, "").replace(/[^A-Za-z0-9_]/g, "_")}`;
|
|
21032
|
+
const modeSwitch = displayMode === "pageNumber" ? " \\p \\h" : displayMode === "fullCaption" ? " \\f \\h" : " \\h";
|
|
21033
|
+
const nextInstrArgs = `${bmName}${modeSwitch}`;
|
|
21034
|
+
const nextInstrText = `REF ${nextInstrArgs}`;
|
|
21035
|
+
const nextStart = xrRange.startIndex;
|
|
21036
|
+
const nextEnd = nextStart + Math.max(0, nextRendered.length - 1);
|
|
21037
|
+
const updatedField = {
|
|
21038
|
+
...props.field ?? {},
|
|
21039
|
+
id: xrRangeId,
|
|
21040
|
+
fieldType: "REF",
|
|
21041
|
+
instructionArgs: nextInstrArgs,
|
|
21042
|
+
instrText: nextInstrText,
|
|
21043
|
+
value: nextRendered,
|
|
21044
|
+
sourceKind: props.field?.sourceKind ?? "simple",
|
|
21045
|
+
startIndex: nextStart,
|
|
21046
|
+
endIndex: nextEnd
|
|
21047
|
+
};
|
|
21048
|
+
const updatedXref = {
|
|
21049
|
+
id: explicitXr?.id || xrRangeId,
|
|
21050
|
+
targetCaptionId: hitCap.id,
|
|
21051
|
+
displayMode,
|
|
21052
|
+
renderedText: nextRendered,
|
|
21053
|
+
anchorIndex: nextStart,
|
|
21054
|
+
bookmarkName: bmName,
|
|
21055
|
+
fieldId: xrRangeId,
|
|
21056
|
+
startIndex: nextStart,
|
|
21057
|
+
endIndex: nextEnd
|
|
21058
|
+
};
|
|
21059
|
+
const nextProps = {
|
|
21060
|
+
...props,
|
|
21061
|
+
yudaoBlockKind: "docField",
|
|
21062
|
+
fieldInstr: nextInstrText,
|
|
21063
|
+
fieldSimple: updatedField.sourceKind !== "complex",
|
|
21064
|
+
field: Tools8.deepClone(updatedField),
|
|
21065
|
+
crossRef: Tools8.deepClone(updatedXref)
|
|
21066
|
+
};
|
|
21067
|
+
if (curRendered !== nextRendered) {
|
|
21068
|
+
docData.body = spliceDocumentBodySpan(
|
|
21069
|
+
liveBody,
|
|
21070
|
+
xrRange.startIndex,
|
|
21071
|
+
xrRange.endIndex,
|
|
21072
|
+
nextRendered,
|
|
21073
|
+
{
|
|
21074
|
+
targetRangeId: xrRangeId,
|
|
21075
|
+
updatedRangeProperties: nextProps,
|
|
21076
|
+
textStyle: props.field?.preserveStyle ? void 0 : { cl: { rgb: "#2C53F1" }, bg: { rgb: "#F3F5FF" } }
|
|
21077
|
+
}
|
|
21078
|
+
);
|
|
21079
|
+
} else {
|
|
21080
|
+
xrRange.properties = nextProps;
|
|
21081
|
+
}
|
|
21082
|
+
}
|
|
21083
|
+
const tofRange = (docData.body.customRanges ?? []).find(
|
|
21084
|
+
(r) => r.properties?.yudaoBlockKind === "tableOfFigures"
|
|
20069
21085
|
);
|
|
21086
|
+
if (tofRange) {
|
|
21087
|
+
const tProps = tofRange.properties ?? {};
|
|
21088
|
+
const cat = tProps.category ?? "all";
|
|
21089
|
+
const showPg = tProps.showPageNumbers !== false;
|
|
21090
|
+
const hdrTitle = String(tProps.title || "\u56FE\u8868\u76EE\u5F55");
|
|
21091
|
+
const items = buildTableOfFiguresEntries(docData, cat);
|
|
21092
|
+
const lines = [hdrTitle];
|
|
21093
|
+
if (items.length === 0) {
|
|
21094
|
+
lines.push("\uFF08\u6682\u65E0\u9898\u6CE8\u6761\u76EE\uFF09");
|
|
21095
|
+
} else {
|
|
21096
|
+
for (const it of items) {
|
|
21097
|
+
lines.push(showPg ? `${it.fullCaption} ${it.pageNumber}` : it.fullCaption);
|
|
21098
|
+
}
|
|
21099
|
+
}
|
|
21100
|
+
const tofStream = lines.join(DataStreamTreeTokenType9.PARAGRAPH);
|
|
21101
|
+
const updatedBody = spliceMultiParagraphBodySpan(
|
|
21102
|
+
docData.body,
|
|
21103
|
+
tofRange.startIndex,
|
|
21104
|
+
tofRange.endIndex,
|
|
21105
|
+
tofStream,
|
|
21106
|
+
{
|
|
21107
|
+
targetRangeId: tofRange.rangeId,
|
|
21108
|
+
updatedRangeProperties: tProps,
|
|
21109
|
+
textStyle: { fs: 10.5, cl: { rgb: "#31363F" } }
|
|
21110
|
+
}
|
|
21111
|
+
);
|
|
21112
|
+
applyTableOfFiguresParagraphStyles(updatedBody, tofRange.startIndex, lines, showPg);
|
|
21113
|
+
docData.body = updatedBody;
|
|
21114
|
+
}
|
|
21115
|
+
const finalCaptions = listDocCaptions(docData);
|
|
21116
|
+
const finalCrossRefs = listDocCrossRefs(docData);
|
|
21117
|
+
const finalFieldsMap = {};
|
|
21118
|
+
for (const f of listDocFields(docData)) {
|
|
21119
|
+
finalFieldsMap[f.id] = f;
|
|
21120
|
+
}
|
|
21121
|
+
const meta = readDocTemplateMetadataFromSnapshot(docData);
|
|
21122
|
+
writeDocTemplateMetadataToSnapshot(docData, {
|
|
21123
|
+
...meta,
|
|
21124
|
+
docFields: finalFieldsMap,
|
|
21125
|
+
captions: finalCaptions,
|
|
21126
|
+
crossRefs: finalCrossRefs,
|
|
21127
|
+
bookmarks: listDocBookmarks(docData)
|
|
21128
|
+
});
|
|
21129
|
+
return docData;
|
|
20070
21130
|
}
|
|
20071
21131
|
function insertCitationIntoSnapshot(sourceSnapshot, source, offset) {
|
|
20072
21132
|
const body = sourceSnapshot.body;
|
|
@@ -22072,6 +23132,7 @@ function reconcileTemplateMetadataWithLiveSnapshot(snapshot, baseMeta) {
|
|
|
22072
23132
|
}
|
|
22073
23133
|
nextMeta.docFields = liveFieldsMap;
|
|
22074
23134
|
nextMeta.captions = listDocCaptions(snapshot);
|
|
23135
|
+
nextMeta.crossRefs = listDocCrossRefs(snapshot);
|
|
22075
23136
|
nextMeta.collapsedHeadings = getCollapsedHeadingsFromSnapshot(snapshot);
|
|
22076
23137
|
const tocRange = (body.customRanges ?? []).find(
|
|
22077
23138
|
(r) => r.properties?.yudaoBlockKind === "toc"
|
|
@@ -24155,9 +25216,17 @@ function setDocPrintConfigInSnapshot(sourceSnapshot, patch) {
|
|
|
24155
25216
|
...meta.printConfig ?? {},
|
|
24156
25217
|
...Tools11.deepClone(patch)
|
|
24157
25218
|
};
|
|
25219
|
+
const syncedLineNumbering = patch.showLineNumbers !== void 0 || patch.lineNumberCountBy !== void 0 || patch.lineNumberStart !== void 0 || patch.lineNumberRestart !== void 0 ? {
|
|
25220
|
+
enabled: Boolean(merged.showLineNumbers),
|
|
25221
|
+
countBy: Math.max(1, merged.lineNumberCountBy ?? meta.lineNumbering?.countBy ?? 1),
|
|
25222
|
+
start: Math.max(1, merged.lineNumberStart ?? meta.lineNumbering?.start ?? 1),
|
|
25223
|
+
restart: merged.lineNumberRestart ?? meta.lineNumbering?.restart ?? "newPage",
|
|
25224
|
+
distanceDxa: meta.lineNumbering?.distanceDxa ?? 360
|
|
25225
|
+
} : meta.lineNumbering;
|
|
24158
25226
|
writeDocTemplateMetadataToSnapshot(nextSnapshot, {
|
|
24159
25227
|
...meta,
|
|
24160
|
-
printConfig: merged
|
|
25228
|
+
printConfig: merged,
|
|
25229
|
+
...syncedLineNumbering !== void 0 ? { lineNumbering: syncedLineNumbering } : {}
|
|
24161
25230
|
});
|
|
24162
25231
|
return nextSnapshot;
|
|
24163
25232
|
}
|
|
@@ -24165,6 +25234,63 @@ function getDocPrintConfigFromSnapshot(snapshot) {
|
|
|
24165
25234
|
const meta = readDocTemplateMetadataFromSnapshot(snapshot);
|
|
24166
25235
|
return Tools11.deepClone(meta.printConfig ?? {});
|
|
24167
25236
|
}
|
|
25237
|
+
function getDocLineNumberingFromSnapshot(snapshot) {
|
|
25238
|
+
const meta = readDocTemplateMetadataFromSnapshot(snapshot);
|
|
25239
|
+
if (meta.lineNumbering) {
|
|
25240
|
+
return {
|
|
25241
|
+
enabled: Boolean(meta.lineNumbering.enabled),
|
|
25242
|
+
countBy: Math.max(1, Number(meta.lineNumbering.countBy ?? 1) || 1),
|
|
25243
|
+
start: Math.max(1, Number(meta.lineNumbering.start ?? 1) || 1),
|
|
25244
|
+
restart: meta.lineNumbering.restart ?? "newPage",
|
|
25245
|
+
distanceDxa: Math.max(0, Math.round(Number(meta.lineNumbering.distanceDxa ?? 360) || 360))
|
|
25246
|
+
};
|
|
25247
|
+
}
|
|
25248
|
+
const printCfg = meta.printConfig;
|
|
25249
|
+
if (printCfg?.showLineNumbers) {
|
|
25250
|
+
return {
|
|
25251
|
+
enabled: true,
|
|
25252
|
+
countBy: Math.max(1, Number(printCfg.lineNumberCountBy ?? 1) || 1),
|
|
25253
|
+
start: Math.max(1, Number(printCfg.lineNumberStart ?? 1) || 1),
|
|
25254
|
+
restart: printCfg.lineNumberRestart ?? "newPage",
|
|
25255
|
+
distanceDxa: 360
|
|
25256
|
+
};
|
|
25257
|
+
}
|
|
25258
|
+
return {
|
|
25259
|
+
enabled: false,
|
|
25260
|
+
countBy: 1,
|
|
25261
|
+
start: 1,
|
|
25262
|
+
restart: "newPage",
|
|
25263
|
+
distanceDxa: 360
|
|
25264
|
+
};
|
|
25265
|
+
}
|
|
25266
|
+
function setDocLineNumberingInSnapshot(sourceSnapshot, patch) {
|
|
25267
|
+
const nextSnapshot = Tools11.deepClone(sourceSnapshot);
|
|
25268
|
+
const meta = readDocTemplateMetadataFromSnapshot(nextSnapshot);
|
|
25269
|
+
const current = getDocLineNumberingFromSnapshot(nextSnapshot);
|
|
25270
|
+
const merged = {
|
|
25271
|
+
enabled: patch.enabled !== void 0 ? Boolean(patch.enabled) : current.enabled,
|
|
25272
|
+
countBy: Math.max(1, Number(patch.countBy ?? current.countBy ?? 1) || 1),
|
|
25273
|
+
start: Math.max(1, Number(patch.start ?? current.start ?? 1) || 1),
|
|
25274
|
+
restart: patch.restart ?? current.restart ?? "newPage",
|
|
25275
|
+
distanceDxa: Math.max(
|
|
25276
|
+
0,
|
|
25277
|
+
Math.round(Number(patch.distanceDxa ?? current.distanceDxa ?? 360) || 360)
|
|
25278
|
+
)
|
|
25279
|
+
};
|
|
25280
|
+
const nextPrintCfg = {
|
|
25281
|
+
...meta.printConfig ?? {},
|
|
25282
|
+
showLineNumbers: merged.enabled,
|
|
25283
|
+
lineNumberCountBy: merged.countBy,
|
|
25284
|
+
lineNumberStart: merged.start,
|
|
25285
|
+
lineNumberRestart: merged.restart
|
|
25286
|
+
};
|
|
25287
|
+
writeDocTemplateMetadataToSnapshot(nextSnapshot, {
|
|
25288
|
+
...meta,
|
|
25289
|
+
lineNumbering: merged,
|
|
25290
|
+
printConfig: nextPrintCfg
|
|
25291
|
+
});
|
|
25292
|
+
return nextSnapshot;
|
|
25293
|
+
}
|
|
24168
25294
|
|
|
24169
25295
|
// src/utils/doc-cascade-and-particles.ts
|
|
24170
25296
|
var MAX_CASCADE_ITERATIONS = 10;
|
|
@@ -25598,6 +26724,19 @@ function parseNamedDocResourceArray(resources, resourceName) {
|
|
|
25598
26724
|
return [];
|
|
25599
26725
|
}
|
|
25600
26726
|
}
|
|
26727
|
+
function parseNamedDocResourceObject(resources, resourceName) {
|
|
26728
|
+
const entry = (resources ?? []).find((r) => r.name === resourceName);
|
|
26729
|
+
if (!entry?.data) return void 0;
|
|
26730
|
+
try {
|
|
26731
|
+
const parsed = JSON.parse(entry.data);
|
|
26732
|
+
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
26733
|
+
return parsed;
|
|
26734
|
+
}
|
|
26735
|
+
return void 0;
|
|
26736
|
+
} catch {
|
|
26737
|
+
return void 0;
|
|
26738
|
+
}
|
|
26739
|
+
}
|
|
25601
26740
|
function readDocTemplateMetadataFromSnapshot(snapshot) {
|
|
25602
26741
|
const resources = snapshot?.resources;
|
|
25603
26742
|
const entry = (resources ?? []).find((r) => r.name === YUDAO_DOCS_TEMPLATE_RESOURCE);
|
|
@@ -25655,6 +26794,45 @@ function readDocTemplateMetadataFromSnapshot(snapshot) {
|
|
|
25655
26794
|
});
|
|
25656
26795
|
base.miniSheets = mergedSheets;
|
|
25657
26796
|
}
|
|
26797
|
+
const revisionsRes = parseNamedDocResourceArray(resources, YUDAO_DOCS_REVISIONS);
|
|
26798
|
+
if (revisionsRes.length > 0 && !base.revisions?.length) {
|
|
26799
|
+
base.revisions = revisionsRes;
|
|
26800
|
+
}
|
|
26801
|
+
const smartArtsRes = parseNamedDocResourceArray(
|
|
26802
|
+
resources,
|
|
26803
|
+
YUDAO_DOCS_SMARTART
|
|
26804
|
+
);
|
|
26805
|
+
if (smartArtsRes.length > 0) {
|
|
26806
|
+
const mergedSmartArts = {
|
|
26807
|
+
...base.smartArts ?? {}
|
|
26808
|
+
};
|
|
26809
|
+
smartArtsRes.forEach((sa, idx) => {
|
|
26810
|
+
if (!sa || typeof sa !== "object") return;
|
|
26811
|
+
const sid = sa.id || `smartart_res_${idx + 1}`;
|
|
26812
|
+
if (!mergedSmartArts[sid]) {
|
|
26813
|
+
mergedSmartArts[sid] = { ...sa, id: sid };
|
|
26814
|
+
}
|
|
26815
|
+
});
|
|
26816
|
+
base.smartArts = mergedSmartArts;
|
|
26817
|
+
}
|
|
26818
|
+
const lineNumberingRes = parseNamedDocResourceObject(
|
|
26819
|
+
resources,
|
|
26820
|
+
YUDAO_DOCS_LINE_NUMBERING
|
|
26821
|
+
);
|
|
26822
|
+
if (lineNumberingRes && !base.lineNumbering) {
|
|
26823
|
+
base.lineNumbering = lineNumberingRes;
|
|
26824
|
+
}
|
|
26825
|
+
const captionsRes = parseNamedDocResourceArray(resources, YUDAO_DOCS_CAPTIONS);
|
|
26826
|
+
if (captionsRes.length > 0 && !base.captions?.length) {
|
|
26827
|
+
base.captions = captionsRes;
|
|
26828
|
+
}
|
|
26829
|
+
const crossRefsRes = parseNamedDocResourceArray(
|
|
26830
|
+
resources,
|
|
26831
|
+
YUDAO_DOCS_CROSS_REFS
|
|
26832
|
+
);
|
|
26833
|
+
if (crossRefsRes.length > 0 && !base.crossRefs?.length) {
|
|
26834
|
+
base.crossRefs = crossRefsRes;
|
|
26835
|
+
}
|
|
25658
26836
|
return base;
|
|
25659
26837
|
}
|
|
25660
26838
|
var SYNCED_NAMED_DOC_RESOURCES = /* @__PURE__ */ new Set([
|
|
@@ -25663,13 +26841,18 @@ var SYNCED_NAMED_DOC_RESOURCES = /* @__PURE__ */ new Set([
|
|
|
25663
26841
|
YUDAO_DOCS_CODE_BLOCKS,
|
|
25664
26842
|
YUDAO_DOCS_CHARTS,
|
|
25665
26843
|
YUDAO_DOCS_FOOTNOTES,
|
|
25666
|
-
YUDAO_DOCS_MINI_SHEETS
|
|
26844
|
+
YUDAO_DOCS_MINI_SHEETS,
|
|
26845
|
+
YUDAO_DOCS_REVISIONS,
|
|
26846
|
+
YUDAO_DOCS_SMARTART,
|
|
26847
|
+
YUDAO_DOCS_LINE_NUMBERING,
|
|
26848
|
+
YUDAO_DOCS_CAPTIONS,
|
|
26849
|
+
YUDAO_DOCS_CROSS_REFS
|
|
25667
26850
|
]);
|
|
25668
26851
|
function writeDocTemplateMetadataToSnapshot(snapshot, metadata) {
|
|
25669
26852
|
const resources = [...snapshot.resources ?? []].filter(
|
|
25670
26853
|
(r) => !SYNCED_NAMED_DOC_RESOURCES.has(r.name)
|
|
25671
26854
|
);
|
|
25672
|
-
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) || Boolean(metadata.miniSheets && Object.keys(metadata.miniSheets).length > 0);
|
|
26855
|
+
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) || Boolean(metadata.miniSheets && Object.keys(metadata.miniSheets).length > 0) || metadata.lineNumbering !== void 0 || Boolean(metadata.crossRefs?.length);
|
|
25673
26856
|
if (hasContent) {
|
|
25674
26857
|
resources.push({
|
|
25675
26858
|
id: YUDAO_DOCS_TEMPLATE_RESOURCE,
|
|
@@ -25712,6 +26895,41 @@ function writeDocTemplateMetadataToSnapshot(snapshot, metadata) {
|
|
|
25712
26895
|
data: JSON.stringify(Object.values(metadata.miniSheets))
|
|
25713
26896
|
});
|
|
25714
26897
|
}
|
|
26898
|
+
if (metadata.revisions?.length) {
|
|
26899
|
+
resources.push({
|
|
26900
|
+
id: YUDAO_DOCS_REVISIONS,
|
|
26901
|
+
name: YUDAO_DOCS_REVISIONS,
|
|
26902
|
+
data: JSON.stringify(metadata.revisions)
|
|
26903
|
+
});
|
|
26904
|
+
}
|
|
26905
|
+
if (metadata.smartArts && Object.keys(metadata.smartArts).length > 0) {
|
|
26906
|
+
resources.push({
|
|
26907
|
+
id: YUDAO_DOCS_SMARTART,
|
|
26908
|
+
name: YUDAO_DOCS_SMARTART,
|
|
26909
|
+
data: JSON.stringify(Object.values(metadata.smartArts))
|
|
26910
|
+
});
|
|
26911
|
+
}
|
|
26912
|
+
if (metadata.lineNumbering !== void 0) {
|
|
26913
|
+
resources.push({
|
|
26914
|
+
id: YUDAO_DOCS_LINE_NUMBERING,
|
|
26915
|
+
name: YUDAO_DOCS_LINE_NUMBERING,
|
|
26916
|
+
data: JSON.stringify(metadata.lineNumbering)
|
|
26917
|
+
});
|
|
26918
|
+
}
|
|
26919
|
+
if (metadata.captions?.length) {
|
|
26920
|
+
resources.push({
|
|
26921
|
+
id: YUDAO_DOCS_CAPTIONS,
|
|
26922
|
+
name: YUDAO_DOCS_CAPTIONS,
|
|
26923
|
+
data: JSON.stringify(metadata.captions)
|
|
26924
|
+
});
|
|
26925
|
+
}
|
|
26926
|
+
if (metadata.crossRefs?.length) {
|
|
26927
|
+
resources.push({
|
|
26928
|
+
id: YUDAO_DOCS_CROSS_REFS,
|
|
26929
|
+
name: YUDAO_DOCS_CROSS_REFS,
|
|
26930
|
+
data: JSON.stringify(metadata.crossRefs)
|
|
26931
|
+
});
|
|
26932
|
+
}
|
|
25715
26933
|
snapshot.resources = resources;
|
|
25716
26934
|
return snapshot;
|
|
25717
26935
|
}
|
|
@@ -30668,7 +31886,10 @@ var DocSdtService = class extends Disposable2 {
|
|
|
30668
31886
|
...fromSnap.miniSheets ?? {},
|
|
30669
31887
|
...cached.miniSheets ?? {}
|
|
30670
31888
|
}
|
|
30671
|
-
} : {}
|
|
31889
|
+
} : {},
|
|
31890
|
+
...cached.lineNumbering !== void 0 || fromSnap.lineNumbering !== void 0 ? { lineNumbering: cached.lineNumbering ?? fromSnap.lineNumbering } : {},
|
|
31891
|
+
...cached.captions !== void 0 || fromSnap.captions !== void 0 ? { captions: cached.captions ?? fromSnap.captions } : {},
|
|
31892
|
+
...cached.crossRefs !== void 0 || fromSnap.crossRefs !== void 0 ? { crossRefs: cached.crossRefs ?? fromSnap.crossRefs } : {}
|
|
30672
31893
|
};
|
|
30673
31894
|
}
|
|
30674
31895
|
setTemplateMetadata(unitId, metadata) {
|
|
@@ -30822,23 +32043,515 @@ DocSdtService = __decorateClass([
|
|
|
30822
32043
|
import {
|
|
30823
32044
|
CommandType as CommandType2,
|
|
30824
32045
|
CustomRangeType as CustomRangeType12,
|
|
30825
|
-
generateRandomId as
|
|
32046
|
+
generateRandomId as generateRandomId16,
|
|
30826
32047
|
ICommandService as ICommandService3,
|
|
30827
32048
|
IUndoRedoService as IUndoRedoService2,
|
|
30828
32049
|
JSONX,
|
|
30829
32050
|
RedoCommand,
|
|
30830
|
-
Tools as
|
|
32051
|
+
Tools as Tools17,
|
|
30831
32052
|
UndoCommand
|
|
30832
32053
|
} from "@univerjs/core";
|
|
30833
32054
|
import { RichTextEditingMutation } from "@univerjs/docs";
|
|
30834
32055
|
|
|
32056
|
+
// src/utils/doc-combine-revisions.ts
|
|
32057
|
+
import {
|
|
32058
|
+
DataStreamTreeTokenType as DataStreamTreeTokenType15,
|
|
32059
|
+
generateRandomId as generateRandomId14,
|
|
32060
|
+
Tools as Tools15
|
|
32061
|
+
} from "@univerjs/core";
|
|
32062
|
+
var AUTHOR_INSERT_PALETTE = [
|
|
32063
|
+
{ fg: "#2C53F1", bg: "#F3F5FF" },
|
|
32064
|
+
{ fg: "#059669", bg: "#ECFDF5" },
|
|
32065
|
+
{ fg: "#7C3AED", bg: "#F5F3FF" },
|
|
32066
|
+
{ fg: "#D97706", bg: "#FFFBEB" },
|
|
32067
|
+
{ fg: "#0284C7", bg: "#F0F9FF" }
|
|
32068
|
+
];
|
|
32069
|
+
var AUTHOR_DELETE_PALETTE = [
|
|
32070
|
+
{ fg: "#DC2626", bg: "#FEE2E2" },
|
|
32071
|
+
{ fg: "#BE123C", bg: "#FFE4E6" },
|
|
32072
|
+
{ fg: "#C2410C", bg: "#FFEDD5" },
|
|
32073
|
+
{ fg: "#B91C1C", bg: "#FEF2F2" },
|
|
32074
|
+
{ fg: "#9F1239", bg: "#FCE7F3" }
|
|
32075
|
+
];
|
|
32076
|
+
function extractEffectiveComparableStream(doc) {
|
|
32077
|
+
const raw = doc?.body?.dataStream ?? "";
|
|
32078
|
+
if (!raw) return "";
|
|
32079
|
+
const meta = readDocTemplateMetadataFromSnapshot(doc);
|
|
32080
|
+
const pendingDeletes = (meta.revisions ?? []).filter((r) => r.status === "pending" && r.type === "delete" && r.endIndex > r.startIndex).sort((a, b) => a.startIndex - b.startIndex);
|
|
32081
|
+
let effective = "";
|
|
32082
|
+
if (pendingDeletes.length === 0) {
|
|
32083
|
+
effective = raw;
|
|
32084
|
+
} else {
|
|
32085
|
+
let cursor = 0;
|
|
32086
|
+
for (const del of pendingDeletes) {
|
|
32087
|
+
const st = Math.max(cursor, Math.min(del.startIndex, raw.length));
|
|
32088
|
+
const ed = Math.max(st, Math.min(del.endIndex, raw.length));
|
|
32089
|
+
if (st > cursor) {
|
|
32090
|
+
effective += raw.slice(cursor, st);
|
|
32091
|
+
}
|
|
32092
|
+
cursor = ed;
|
|
32093
|
+
}
|
|
32094
|
+
if (cursor < raw.length) {
|
|
32095
|
+
effective += raw.slice(cursor);
|
|
32096
|
+
}
|
|
32097
|
+
}
|
|
32098
|
+
return effective.replace(/\r\n$/, "").replace(/\n$/, "").replace(/\r$/, "").replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F]/g, "");
|
|
32099
|
+
}
|
|
32100
|
+
function splitParagraphStrings(stream) {
|
|
32101
|
+
return stream.split("\r");
|
|
32102
|
+
}
|
|
32103
|
+
function tokenizeIntraParagraph(line) {
|
|
32104
|
+
if (!line) return [];
|
|
32105
|
+
const out = [];
|
|
32106
|
+
const re = /[A-Za-z0-9_]+|[ \t]+|[\u4E00-\u9FFF\u3400-\u4DBF]|./gu;
|
|
32107
|
+
let m;
|
|
32108
|
+
while ((m = re.exec(line)) !== null) {
|
|
32109
|
+
out.push(m[0]);
|
|
32110
|
+
}
|
|
32111
|
+
return out;
|
|
32112
|
+
}
|
|
32113
|
+
function computeParagraphSimilarity(a, b) {
|
|
32114
|
+
if (a === b) return 1;
|
|
32115
|
+
const ta = a.trim();
|
|
32116
|
+
const tb = b.trim();
|
|
32117
|
+
if (!ta && !tb) return 1;
|
|
32118
|
+
if (!ta || !tb) return 0;
|
|
32119
|
+
if (ta.length === 1 || tb.length === 1) {
|
|
32120
|
+
return ta === tb ? 1 : tb.includes(ta) || ta.includes(tb) ? 0.5 : 0;
|
|
32121
|
+
}
|
|
32122
|
+
const getBigrams = (s) => {
|
|
32123
|
+
const map = /* @__PURE__ */ new Map();
|
|
32124
|
+
for (let i = 0; i < s.length - 1; i++) {
|
|
32125
|
+
const bg = s.slice(i, i + 2);
|
|
32126
|
+
map.set(bg, (map.get(bg) ?? 0) + 1);
|
|
32127
|
+
}
|
|
32128
|
+
return map;
|
|
32129
|
+
};
|
|
32130
|
+
const bgA = getBigrams(ta);
|
|
32131
|
+
const bgB = getBigrams(tb);
|
|
32132
|
+
let overlap = 0;
|
|
32133
|
+
for (const [k, cntA] of bgA.entries()) {
|
|
32134
|
+
const cntB = bgB.get(k) ?? 0;
|
|
32135
|
+
if (cntB > 0) overlap += Math.min(cntA, cntB);
|
|
32136
|
+
}
|
|
32137
|
+
return 2 * overlap / Math.max(1, ta.length - 1 + (tb.length - 1));
|
|
32138
|
+
}
|
|
32139
|
+
function alignParagraphSequences(baseParas, revParas) {
|
|
32140
|
+
const B = baseParas.length;
|
|
32141
|
+
const R = revParas.length;
|
|
32142
|
+
if (B === 0 || R === 0) return [];
|
|
32143
|
+
if (B * R > 25e4) {
|
|
32144
|
+
const pairs = [];
|
|
32145
|
+
const len = Math.min(B, R);
|
|
32146
|
+
for (let i2 = 0; i2 < len; i2++) {
|
|
32147
|
+
pairs.push({ baseIdx: i2, revIdx: i2 });
|
|
32148
|
+
}
|
|
32149
|
+
return pairs;
|
|
32150
|
+
}
|
|
32151
|
+
const MIN_SIM = 0.3;
|
|
32152
|
+
const simMatrix = Array.from({ length: B }, () => new Float32Array(R));
|
|
32153
|
+
for (let i2 = 0; i2 < B; i2++) {
|
|
32154
|
+
for (let j2 = 0; j2 < R; j2++) {
|
|
32155
|
+
const sim = computeParagraphSimilarity(baseParas[i2], revParas[j2]);
|
|
32156
|
+
simMatrix[i2][j2] = sim >= MIN_SIM ? sim : -1;
|
|
32157
|
+
}
|
|
32158
|
+
}
|
|
32159
|
+
const dp = Array.from({ length: B + 1 }, () => new Float32Array(R + 1));
|
|
32160
|
+
for (let i2 = B - 1; i2 >= 0; i2--) {
|
|
32161
|
+
for (let j2 = R - 1; j2 >= 0; j2--) {
|
|
32162
|
+
let best = Math.max(dp[i2 + 1][j2], dp[i2][j2 + 1]);
|
|
32163
|
+
const sim = simMatrix[i2][j2];
|
|
32164
|
+
if (sim >= MIN_SIM) {
|
|
32165
|
+
const cand = sim + dp[i2 + 1][j2 + 1];
|
|
32166
|
+
if (cand >= best) best = cand;
|
|
32167
|
+
}
|
|
32168
|
+
dp[i2][j2] = best;
|
|
32169
|
+
}
|
|
32170
|
+
}
|
|
32171
|
+
const matched = [];
|
|
32172
|
+
let i = 0;
|
|
32173
|
+
let j = 0;
|
|
32174
|
+
while (i < B && j < R) {
|
|
32175
|
+
const sim = simMatrix[i][j];
|
|
32176
|
+
if (sim >= MIN_SIM && Math.abs(dp[i][j] - (sim + dp[i + 1][j + 1])) <= 1e-4) {
|
|
32177
|
+
matched.push({ baseIdx: i, revIdx: j });
|
|
32178
|
+
i++;
|
|
32179
|
+
j++;
|
|
32180
|
+
} else if (dp[i + 1][j] >= dp[i][j + 1]) {
|
|
32181
|
+
i++;
|
|
32182
|
+
} else {
|
|
32183
|
+
j++;
|
|
32184
|
+
}
|
|
32185
|
+
}
|
|
32186
|
+
return matched;
|
|
32187
|
+
}
|
|
32188
|
+
function alignTokensLcs(aTokens, bTokens) {
|
|
32189
|
+
let pfx = 0;
|
|
32190
|
+
while (pfx < aTokens.length && pfx < bTokens.length && aTokens[pfx] === bTokens[pfx]) {
|
|
32191
|
+
pfx++;
|
|
32192
|
+
}
|
|
32193
|
+
let sfx = 0;
|
|
32194
|
+
while (sfx < aTokens.length - pfx && sfx < bTokens.length - pfx && aTokens[aTokens.length - 1 - sfx] === bTokens[bTokens.length - 1 - sfx]) {
|
|
32195
|
+
sfx++;
|
|
32196
|
+
}
|
|
32197
|
+
const pairs = [];
|
|
32198
|
+
for (let k = 0; k < pfx; k++) {
|
|
32199
|
+
pairs.push({ aIdx: k, bIdx: k });
|
|
32200
|
+
}
|
|
32201
|
+
const midA = aTokens.slice(pfx, aTokens.length - sfx);
|
|
32202
|
+
const midB = bTokens.slice(pfx, bTokens.length - sfx);
|
|
32203
|
+
const n = midA.length;
|
|
32204
|
+
const m = midB.length;
|
|
32205
|
+
if (n > 0 && m > 0 && n * m <= 25e5) {
|
|
32206
|
+
const dp = Array.from({ length: n + 1 }, () => new Uint32Array(m + 1));
|
|
32207
|
+
for (let i2 = n - 1; i2 >= 0; i2--) {
|
|
32208
|
+
for (let j2 = m - 1; j2 >= 0; j2--) {
|
|
32209
|
+
if (midA[i2] === midB[j2]) {
|
|
32210
|
+
dp[i2][j2] = dp[i2 + 1][j2 + 1] + 1;
|
|
32211
|
+
} else {
|
|
32212
|
+
dp[i2][j2] = dp[i2 + 1][j2] >= dp[i2][j2 + 1] ? dp[i2 + 1][j2] : dp[i2][j2 + 1];
|
|
32213
|
+
}
|
|
32214
|
+
}
|
|
32215
|
+
}
|
|
32216
|
+
let i = 0;
|
|
32217
|
+
let j = 0;
|
|
32218
|
+
while (i < n && j < m) {
|
|
32219
|
+
if (midA[i] === midB[j]) {
|
|
32220
|
+
pairs.push({ aIdx: pfx + i, bIdx: pfx + j });
|
|
32221
|
+
i++;
|
|
32222
|
+
j++;
|
|
32223
|
+
} else if (dp[i + 1][j] >= dp[i][j + 1]) {
|
|
32224
|
+
i++;
|
|
32225
|
+
} else {
|
|
32226
|
+
j++;
|
|
32227
|
+
}
|
|
32228
|
+
}
|
|
32229
|
+
}
|
|
32230
|
+
for (let k = 0; k < sfx; k++) {
|
|
32231
|
+
pairs.push({
|
|
32232
|
+
aIdx: aTokens.length - sfx + k,
|
|
32233
|
+
bIdx: bTokens.length - sfx + k
|
|
32234
|
+
});
|
|
32235
|
+
}
|
|
32236
|
+
return pairs;
|
|
32237
|
+
}
|
|
32238
|
+
function getDocRevisionsFromSnapshot(docData) {
|
|
32239
|
+
if (!docData) return [];
|
|
32240
|
+
const meta = readDocTemplateMetadataFromSnapshot(docData);
|
|
32241
|
+
if (meta.revisions?.length) {
|
|
32242
|
+
return Tools15.deepClone(meta.revisions);
|
|
32243
|
+
}
|
|
32244
|
+
const resEntry = (docData.resources ?? []).find((r) => r.name === YUDAO_DOCS_REVISIONS);
|
|
32245
|
+
if (resEntry?.data) {
|
|
32246
|
+
try {
|
|
32247
|
+
const parsed = JSON.parse(resEntry.data);
|
|
32248
|
+
if (Array.isArray(parsed)) return parsed;
|
|
32249
|
+
} catch {
|
|
32250
|
+
}
|
|
32251
|
+
}
|
|
32252
|
+
return [];
|
|
32253
|
+
}
|
|
32254
|
+
function combineReviewedDocuments(baseDoc, reviewerCopies) {
|
|
32255
|
+
const nowIso = (/* @__PURE__ */ new Date()).toISOString();
|
|
32256
|
+
const baseStream = extractEffectiveComparableStream(baseDoc);
|
|
32257
|
+
const baseParaStrings = splitParagraphStrings(baseStream);
|
|
32258
|
+
const preparedParas = baseParaStrings.map((pStr) => {
|
|
32259
|
+
const tokens = tokenizeIntraParagraph(pStr);
|
|
32260
|
+
return {
|
|
32261
|
+
tokens,
|
|
32262
|
+
deletedByToken: Array.from({ length: tokens.length }, () => []),
|
|
32263
|
+
insertionsAtSlot: Array.from({ length: tokens.length + 1 }, () => [])
|
|
32264
|
+
};
|
|
32265
|
+
});
|
|
32266
|
+
const insertedParasAtBoundary = Array.from({ length: baseParaStrings.length + 1 }, () => []);
|
|
32267
|
+
reviewerCopies.forEach((copy, revIdx) => {
|
|
32268
|
+
if (!copy?.doc) return;
|
|
32269
|
+
const author = (copy.author || `\u5BA1\u9605\u4EBA${revIdx + 1}`).trim();
|
|
32270
|
+
const copyMeta = readDocTemplateMetadataFromSnapshot(copy.doc);
|
|
32271
|
+
const fallbackDate = copyMeta.revisions?.[0]?.createdAt || nowIso;
|
|
32272
|
+
const date = copy.date || fallbackDate;
|
|
32273
|
+
const revStream = extractEffectiveComparableStream(copy.doc);
|
|
32274
|
+
const revParaStrings = splitParagraphStrings(revStream);
|
|
32275
|
+
const aligned = alignParagraphSequences(baseParaStrings, revParaStrings);
|
|
32276
|
+
const anchors = [...aligned, { baseIdx: baseParaStrings.length, revIdx: revParaStrings.length }];
|
|
32277
|
+
let prevBase = -1;
|
|
32278
|
+
let prevRev = -1;
|
|
32279
|
+
for (const anchor of anchors) {
|
|
32280
|
+
const unBStart = prevBase + 1;
|
|
32281
|
+
const unBEnd = anchor.baseIdx;
|
|
32282
|
+
const unRStart = prevRev + 1;
|
|
32283
|
+
const unREnd = anchor.revIdx;
|
|
32284
|
+
const pairCount = Math.min(unBEnd - unBStart, unREnd - unRStart);
|
|
32285
|
+
for (let k = 0; k < pairCount; k++) {
|
|
32286
|
+
const bIdx = unBStart + k;
|
|
32287
|
+
const rIdx = unRStart + k;
|
|
32288
|
+
diffParagraphIntoPrepared(
|
|
32289
|
+
preparedParas[bIdx],
|
|
32290
|
+
revParaStrings[rIdx],
|
|
32291
|
+
revIdx,
|
|
32292
|
+
author,
|
|
32293
|
+
date
|
|
32294
|
+
);
|
|
32295
|
+
}
|
|
32296
|
+
for (let bIdx = unBStart + pairCount; bIdx < unBEnd; bIdx++) {
|
|
32297
|
+
const prep = preparedParas[bIdx];
|
|
32298
|
+
for (let t = 0; t < prep.tokens.length; t++) {
|
|
32299
|
+
prep.deletedByToken[t].push(revIdx);
|
|
32300
|
+
}
|
|
32301
|
+
}
|
|
32302
|
+
for (let rIdx = unRStart + pairCount; rIdx < unREnd; rIdx++) {
|
|
32303
|
+
const newParaText = revParaStrings[rIdx] ?? "";
|
|
32304
|
+
insertedParasAtBoundary[unBEnd].push({
|
|
32305
|
+
reviewerIdx: revIdx,
|
|
32306
|
+
author,
|
|
32307
|
+
date,
|
|
32308
|
+
text: newParaText
|
|
32309
|
+
});
|
|
32310
|
+
}
|
|
32311
|
+
if (anchor.baseIdx < baseParaStrings.length && anchor.revIdx < revParaStrings.length) {
|
|
32312
|
+
if (baseParaStrings[anchor.baseIdx] !== revParaStrings[anchor.revIdx]) {
|
|
32313
|
+
diffParagraphIntoPrepared(
|
|
32314
|
+
preparedParas[anchor.baseIdx],
|
|
32315
|
+
revParaStrings[anchor.revIdx],
|
|
32316
|
+
revIdx,
|
|
32317
|
+
author,
|
|
32318
|
+
date
|
|
32319
|
+
);
|
|
32320
|
+
}
|
|
32321
|
+
}
|
|
32322
|
+
prevBase = anchor.baseIdx;
|
|
32323
|
+
prevRev = anchor.revIdx;
|
|
32324
|
+
}
|
|
32325
|
+
});
|
|
32326
|
+
let dataStream = "";
|
|
32327
|
+
const paragraphs = [];
|
|
32328
|
+
const textRuns = [];
|
|
32329
|
+
const revisions = [];
|
|
32330
|
+
const reviewerMetaByIdx = reviewerCopies.map((c, idx) => {
|
|
32331
|
+
const copyMeta = c?.doc ? readDocTemplateMetadataFromSnapshot(c.doc) : {};
|
|
32332
|
+
return {
|
|
32333
|
+
author: (c?.author || `\u5BA1\u9605\u4EBA${idx + 1}`).trim(),
|
|
32334
|
+
date: c?.date || copyMeta.revisions?.[0]?.createdAt || nowIso
|
|
32335
|
+
};
|
|
32336
|
+
});
|
|
32337
|
+
const emitPlainSpan = (txt) => {
|
|
32338
|
+
if (!txt) return;
|
|
32339
|
+
const st = dataStream.length;
|
|
32340
|
+
dataStream += txt;
|
|
32341
|
+
const ed = dataStream.length;
|
|
32342
|
+
textRuns.push({
|
|
32343
|
+
st,
|
|
32344
|
+
ed,
|
|
32345
|
+
ts: { cl: { rgb: "#1B1C1F" } }
|
|
32346
|
+
});
|
|
32347
|
+
};
|
|
32348
|
+
const emitRevisionSpan = (type, reviewerIdx, txt, overrideAuthor, overrideDate) => {
|
|
32349
|
+
if (!txt) return;
|
|
32350
|
+
const info = reviewerMetaByIdx[reviewerIdx] ?? {
|
|
32351
|
+
author: overrideAuthor || "\u5BA1\u9605\u4EBA",
|
|
32352
|
+
date: overrideDate || nowIso
|
|
32353
|
+
};
|
|
32354
|
+
const author = overrideAuthor || info.author;
|
|
32355
|
+
const createdAt = overrideDate || info.date;
|
|
32356
|
+
const st = dataStream.length;
|
|
32357
|
+
dataStream += txt;
|
|
32358
|
+
const ed = dataStream.length;
|
|
32359
|
+
if (type === "delete") {
|
|
32360
|
+
const palette = AUTHOR_DELETE_PALETTE[reviewerIdx % AUTHOR_DELETE_PALETTE.length];
|
|
32361
|
+
textRuns.push({
|
|
32362
|
+
st,
|
|
32363
|
+
ed,
|
|
32364
|
+
ts: {
|
|
32365
|
+
cl: { rgb: palette.fg },
|
|
32366
|
+
st: { s: 1 },
|
|
32367
|
+
bg: { rgb: palette.bg }
|
|
32368
|
+
}
|
|
32369
|
+
});
|
|
32370
|
+
revisions.push({
|
|
32371
|
+
id: `rev_del_${generateRandomId14(6)}`,
|
|
32372
|
+
type: "delete",
|
|
32373
|
+
author,
|
|
32374
|
+
createdAt,
|
|
32375
|
+
startIndex: st,
|
|
32376
|
+
endIndex: ed,
|
|
32377
|
+
text: txt,
|
|
32378
|
+
status: "pending"
|
|
32379
|
+
});
|
|
32380
|
+
} else {
|
|
32381
|
+
const palette = AUTHOR_INSERT_PALETTE[reviewerIdx % AUTHOR_INSERT_PALETTE.length];
|
|
32382
|
+
textRuns.push({
|
|
32383
|
+
st,
|
|
32384
|
+
ed,
|
|
32385
|
+
ts: {
|
|
32386
|
+
cl: { rgb: palette.fg },
|
|
32387
|
+
ul: { s: 1 },
|
|
32388
|
+
bg: { rgb: palette.bg }
|
|
32389
|
+
}
|
|
32390
|
+
});
|
|
32391
|
+
revisions.push({
|
|
32392
|
+
id: `rev_ins_${generateRandomId14(6)}`,
|
|
32393
|
+
type: "insert",
|
|
32394
|
+
author,
|
|
32395
|
+
createdAt,
|
|
32396
|
+
startIndex: st,
|
|
32397
|
+
endIndex: ed,
|
|
32398
|
+
text: txt,
|
|
32399
|
+
status: "pending"
|
|
32400
|
+
});
|
|
32401
|
+
}
|
|
32402
|
+
};
|
|
32403
|
+
const emitParagraphEnd = (sourcePara) => {
|
|
32404
|
+
const pPos = dataStream.length;
|
|
32405
|
+
dataStream += DataStreamTreeTokenType15.PARAGRAPH;
|
|
32406
|
+
paragraphs.push({
|
|
32407
|
+
...sourcePara?.paragraphStyle ? { paragraphStyle: Tools15.deepClone(sourcePara.paragraphStyle) } : {},
|
|
32408
|
+
...sourcePara?.bullet ? { bullet: Tools15.deepClone(sourcePara.bullet) } : {},
|
|
32409
|
+
startIndex: pPos,
|
|
32410
|
+
paragraphId: `p_cmb_${generateRandomId14(5)}`
|
|
32411
|
+
});
|
|
32412
|
+
};
|
|
32413
|
+
const baseSortedParas = [...baseDoc.body?.paragraphs ?? []].sort(
|
|
32414
|
+
(a, b) => a.startIndex - b.startIndex
|
|
32415
|
+
);
|
|
32416
|
+
for (let pIdx = 0; pIdx <= preparedParas.length; pIdx++) {
|
|
32417
|
+
for (const insPara of insertedParasAtBoundary[pIdx]) {
|
|
32418
|
+
if (insPara.text) {
|
|
32419
|
+
emitRevisionSpan("insert", insPara.reviewerIdx, insPara.text, insPara.author, insPara.date);
|
|
32420
|
+
}
|
|
32421
|
+
emitParagraphEnd();
|
|
32422
|
+
}
|
|
32423
|
+
if (pIdx >= preparedParas.length) break;
|
|
32424
|
+
const prep = preparedParas[pIdx];
|
|
32425
|
+
const srcPara = baseSortedParas[pIdx];
|
|
32426
|
+
const flushSlotInsertions = (slot) => {
|
|
32427
|
+
for (const ins of prep.insertionsAtSlot[slot]) {
|
|
32428
|
+
const subLines = ins.text.split("\r");
|
|
32429
|
+
subLines.forEach((sub, sIdx) => {
|
|
32430
|
+
if (sub) {
|
|
32431
|
+
emitRevisionSpan("insert", ins.reviewerIdx, sub, ins.author, ins.date);
|
|
32432
|
+
}
|
|
32433
|
+
if (sIdx < subLines.length - 1) {
|
|
32434
|
+
emitParagraphEnd();
|
|
32435
|
+
}
|
|
32436
|
+
});
|
|
32437
|
+
}
|
|
32438
|
+
};
|
|
32439
|
+
flushSlotInsertions(0);
|
|
32440
|
+
let t = 0;
|
|
32441
|
+
while (t < prep.tokens.length) {
|
|
32442
|
+
const delReviewers = prep.deletedByToken[t];
|
|
32443
|
+
if (delReviewers.length === 0) {
|
|
32444
|
+
let buf = prep.tokens[t];
|
|
32445
|
+
t++;
|
|
32446
|
+
while (t < prep.tokens.length && prep.deletedByToken[t].length === 0 && prep.insertionsAtSlot[t].length === 0) {
|
|
32447
|
+
buf += prep.tokens[t];
|
|
32448
|
+
t++;
|
|
32449
|
+
}
|
|
32450
|
+
emitPlainSpan(buf);
|
|
32451
|
+
flushSlotInsertions(t);
|
|
32452
|
+
} else {
|
|
32453
|
+
const primaryReviewer = delReviewers[0];
|
|
32454
|
+
let delBuf = prep.tokens[t];
|
|
32455
|
+
t++;
|
|
32456
|
+
while (t < prep.tokens.length && prep.deletedByToken[t].length > 0 && prep.deletedByToken[t][0] === primaryReviewer && prep.insertionsAtSlot[t].length === 0) {
|
|
32457
|
+
delBuf += prep.tokens[t];
|
|
32458
|
+
t++;
|
|
32459
|
+
}
|
|
32460
|
+
emitRevisionSpan("delete", primaryReviewer, delBuf);
|
|
32461
|
+
flushSlotInsertions(t);
|
|
32462
|
+
}
|
|
32463
|
+
}
|
|
32464
|
+
emitParagraphEnd(srcPara);
|
|
32465
|
+
}
|
|
32466
|
+
if (paragraphs.length === 0) {
|
|
32467
|
+
emitParagraphEnd();
|
|
32468
|
+
}
|
|
32469
|
+
const secPos = dataStream.length;
|
|
32470
|
+
dataStream += DataStreamTreeTokenType15.SECTION_BREAK;
|
|
32471
|
+
const baseMeta = readDocTemplateMetadataFromSnapshot(baseDoc);
|
|
32472
|
+
const leadAuthor = reviewerMetaByIdx[0]?.author || baseMeta.trackAuthor || "\u5408\u5E76\u5BA1\u9605";
|
|
32473
|
+
const combinedDoc = {
|
|
32474
|
+
id: `doc_combine_${generateRandomId14(6)}`,
|
|
32475
|
+
title: `${baseDoc.title || "\u6587\u6863"} (\u591A\u65B9\u5BA1\u9605\u5408\u5E76)`,
|
|
32476
|
+
body: {
|
|
32477
|
+
dataStream,
|
|
32478
|
+
paragraphs,
|
|
32479
|
+
sectionBreaks: [{ startIndex: secPos, sectionId: `s_cmb_${generateRandomId14(5)}` }],
|
|
32480
|
+
textRuns,
|
|
32481
|
+
customRanges: []
|
|
32482
|
+
},
|
|
32483
|
+
documentStyle: Tools15.deepClone(
|
|
32484
|
+
baseDoc.documentStyle ?? {
|
|
32485
|
+
pageSize: { width: 595.28, height: 841.89 },
|
|
32486
|
+
marginTop: 56,
|
|
32487
|
+
marginBottom: 56,
|
|
32488
|
+
marginLeft: 64,
|
|
32489
|
+
marginRight: 64
|
|
32490
|
+
}
|
|
32491
|
+
),
|
|
32492
|
+
...baseDoc.styles ? { styles: Tools15.deepClone(baseDoc.styles) } : {},
|
|
32493
|
+
...baseDoc.headers ? { headers: Tools15.deepClone(baseDoc.headers) } : {},
|
|
32494
|
+
...baseDoc.footers ? { footers: Tools15.deepClone(baseDoc.footers) } : {}
|
|
32495
|
+
};
|
|
32496
|
+
writeDocTemplateMetadataToSnapshot(combinedDoc, {
|
|
32497
|
+
...baseMeta,
|
|
32498
|
+
trackChangesEnabled: true,
|
|
32499
|
+
trackAuthor: leadAuthor,
|
|
32500
|
+
revisions
|
|
32501
|
+
});
|
|
32502
|
+
return combinedDoc;
|
|
32503
|
+
}
|
|
32504
|
+
function diffParagraphIntoPrepared(prep, revParaStr, reviewerIdx, author, date) {
|
|
32505
|
+
const revTokens = tokenizeIntraParagraph(revParaStr);
|
|
32506
|
+
const matches = alignTokensLcs(prep.tokens, revTokens);
|
|
32507
|
+
const anchors = [...matches, { aIdx: prep.tokens.length, bIdx: revTokens.length }];
|
|
32508
|
+
let prevA = -1;
|
|
32509
|
+
let prevB = -1;
|
|
32510
|
+
for (const anc of anchors) {
|
|
32511
|
+
for (let a = prevA + 1; a < anc.aIdx; a++) {
|
|
32512
|
+
prep.deletedByToken[a].push(reviewerIdx);
|
|
32513
|
+
}
|
|
32514
|
+
if (anc.bIdx > prevB + 1) {
|
|
32515
|
+
const insText = revTokens.slice(prevB + 1, anc.bIdx).join("");
|
|
32516
|
+
if (insText) {
|
|
32517
|
+
prep.insertionsAtSlot[anc.aIdx].push({
|
|
32518
|
+
reviewerIdx,
|
|
32519
|
+
author,
|
|
32520
|
+
date,
|
|
32521
|
+
text: insText
|
|
32522
|
+
});
|
|
32523
|
+
}
|
|
32524
|
+
}
|
|
32525
|
+
prevA = anc.aIdx;
|
|
32526
|
+
prevB = anc.bIdx;
|
|
32527
|
+
}
|
|
32528
|
+
}
|
|
32529
|
+
async function combineReviewedDocxBytes(baseDocxBytes, reviewerDocxInputs) {
|
|
32530
|
+
const baseDoc = await parseDocxBytesToDocData(baseDocxBytes, "\u5BA1\u9605\u57FA\u51C6\u539F\u7A3F");
|
|
32531
|
+
const reviewerCopies = [];
|
|
32532
|
+
for (let i = 0; i < reviewerDocxInputs.length; i++) {
|
|
32533
|
+
const item = reviewerDocxInputs[i];
|
|
32534
|
+
const parsedDoc = await parseDocxBytesToDocData(
|
|
32535
|
+
item.bytes,
|
|
32536
|
+
`${item.author || `\u5BA1\u9605\u4EBA${i + 1}`}\u5BA1\u9605\u7A3F`
|
|
32537
|
+
);
|
|
32538
|
+
reviewerCopies.push({
|
|
32539
|
+
author: item.author,
|
|
32540
|
+
date: item.date,
|
|
32541
|
+
doc: parsedDoc
|
|
32542
|
+
});
|
|
32543
|
+
}
|
|
32544
|
+
const combinedDoc = combineReviewedDocuments(baseDoc, reviewerCopies);
|
|
32545
|
+
return exportDocxBytes(combinedDoc);
|
|
32546
|
+
}
|
|
32547
|
+
|
|
30835
32548
|
// src/commands/doc-v204.command.ts
|
|
30836
32549
|
import {
|
|
30837
32550
|
CommandType,
|
|
30838
|
-
generateRandomId as
|
|
32551
|
+
generateRandomId as generateRandomId15,
|
|
30839
32552
|
ICommandService as ICommandService2,
|
|
30840
32553
|
IUndoRedoService,
|
|
30841
|
-
Tools as
|
|
32554
|
+
Tools as Tools16
|
|
30842
32555
|
} from "@univerjs/core";
|
|
30843
32556
|
var SyncDocAuxStateMutation = {
|
|
30844
32557
|
id: "yudao-docs.mutation.sync-aux-state",
|
|
@@ -30848,28 +32561,28 @@ var SyncDocAuxStateMutation = {
|
|
|
30848
32561
|
if (!docModel) return false;
|
|
30849
32562
|
const snap = docModel.getSnapshot();
|
|
30850
32563
|
if (params.tableSource !== void 0) {
|
|
30851
|
-
snap.tableSource =
|
|
32564
|
+
snap.tableSource = Tools16.deepClone(params.tableSource);
|
|
30852
32565
|
}
|
|
30853
32566
|
if (params.drawings !== void 0) {
|
|
30854
|
-
snap.drawings =
|
|
32567
|
+
snap.drawings = Tools16.deepClone(params.drawings);
|
|
30855
32568
|
}
|
|
30856
32569
|
if (params.drawingsOrder !== void 0) {
|
|
30857
|
-
snap.drawingsOrder =
|
|
32570
|
+
snap.drawingsOrder = Tools16.deepClone(params.drawingsOrder);
|
|
30858
32571
|
}
|
|
30859
32572
|
if (params.documentStyle !== void 0) {
|
|
30860
|
-
snap.documentStyle =
|
|
32573
|
+
snap.documentStyle = Tools16.deepClone(params.documentStyle);
|
|
30861
32574
|
}
|
|
30862
32575
|
if (params.headers !== void 0) {
|
|
30863
|
-
snap.headers =
|
|
32576
|
+
snap.headers = Tools16.deepClone(params.headers);
|
|
30864
32577
|
}
|
|
30865
32578
|
if (params.footers !== void 0) {
|
|
30866
|
-
snap.footers =
|
|
32579
|
+
snap.footers = Tools16.deepClone(params.footers);
|
|
30867
32580
|
}
|
|
30868
32581
|
if (params.headers !== void 0 || params.footers !== void 0) {
|
|
30869
32582
|
reinitializeDocHeaderFooterModels(docModel);
|
|
30870
32583
|
}
|
|
30871
32584
|
if (params.metadata !== void 0) {
|
|
30872
|
-
const nextMeta =
|
|
32585
|
+
const nextMeta = Tools16.deepClone(params.metadata);
|
|
30873
32586
|
accessor.get(IDocSdtService).setTemplateMetadata(docModel.getUnitId(), nextMeta);
|
|
30874
32587
|
writeDocTemplateMetadataToSnapshot(snap, nextMeta);
|
|
30875
32588
|
}
|
|
@@ -30891,7 +32604,7 @@ var InsertDocCalloutCommand = {
|
|
|
30891
32604
|
const sdtService = accessor.get(IDocSdtService);
|
|
30892
32605
|
if (sdtService.getDocMode(unitId) === "view") return false;
|
|
30893
32606
|
const offset = resolveActiveInsertOffset(accessor, prevBody, params.offset);
|
|
30894
|
-
const workingSnap =
|
|
32607
|
+
const workingSnap = Tools16.deepClone(docModel.getSnapshot());
|
|
30895
32608
|
writeDocTemplateMetadataToSnapshot(workingSnap, sdtService.getTemplateMetadata(unitId));
|
|
30896
32609
|
const inserted = insertCalloutIntoSnapshot(workingSnap, params.spec, offset);
|
|
30897
32610
|
const nextMeta = readDocTemplateMetadataFromSnapshot(inserted.snapshot);
|
|
@@ -30915,7 +32628,7 @@ var UpdateDocCalloutCommand = {
|
|
|
30915
32628
|
const unitId = docModel.getUnitId();
|
|
30916
32629
|
const sdtService = accessor.get(IDocSdtService);
|
|
30917
32630
|
if (sdtService.getDocMode(unitId) === "view") return false;
|
|
30918
|
-
const workingSnap =
|
|
32631
|
+
const workingSnap = Tools16.deepClone(docModel.getSnapshot());
|
|
30919
32632
|
writeDocTemplateMetadataToSnapshot(workingSnap, sdtService.getTemplateMetadata(unitId));
|
|
30920
32633
|
const outcome = updateCalloutInSnapshot(workingSnap, params.id, params.patch);
|
|
30921
32634
|
if (!outcome) return false;
|
|
@@ -30939,7 +32652,7 @@ var RemoveDocCalloutCommand = {
|
|
|
30939
32652
|
const unitId = docModel.getUnitId();
|
|
30940
32653
|
const sdtService = accessor.get(IDocSdtService);
|
|
30941
32654
|
if (sdtService.getDocMode(unitId) === "view") return false;
|
|
30942
|
-
const workingSnap =
|
|
32655
|
+
const workingSnap = Tools16.deepClone(docModel.getSnapshot());
|
|
30943
32656
|
writeDocTemplateMetadataToSnapshot(workingSnap, sdtService.getTemplateMetadata(unitId));
|
|
30944
32657
|
const removed = removeCalloutFromSnapshot(workingSnap, params.id);
|
|
30945
32658
|
if (!removed) return false;
|
|
@@ -30959,7 +32672,7 @@ var InsertDocQuoteCommand = {
|
|
|
30959
32672
|
const sdtService = accessor.get(IDocSdtService);
|
|
30960
32673
|
if (sdtService.getDocMode(unitId) === "view") return false;
|
|
30961
32674
|
const offset = resolveActiveInsertOffset(accessor, prevBody, params.offset);
|
|
30962
|
-
const workingSnap =
|
|
32675
|
+
const workingSnap = Tools16.deepClone(docModel.getSnapshot());
|
|
30963
32676
|
writeDocTemplateMetadataToSnapshot(workingSnap, sdtService.getTemplateMetadata(unitId));
|
|
30964
32677
|
const inserted = insertQuoteIntoSnapshot(workingSnap, params.spec, offset);
|
|
30965
32678
|
sdtService.setTemplateMetadata(unitId, readDocTemplateMetadataFromSnapshot(inserted.snapshot));
|
|
@@ -30982,7 +32695,7 @@ var UpdateDocQuoteCommand = {
|
|
|
30982
32695
|
const unitId = docModel.getUnitId();
|
|
30983
32696
|
const sdtService = accessor.get(IDocSdtService);
|
|
30984
32697
|
if (sdtService.getDocMode(unitId) === "view") return false;
|
|
30985
|
-
const workingSnap =
|
|
32698
|
+
const workingSnap = Tools16.deepClone(docModel.getSnapshot());
|
|
30986
32699
|
writeDocTemplateMetadataToSnapshot(workingSnap, sdtService.getTemplateMetadata(unitId));
|
|
30987
32700
|
const outcome = updateQuoteInSnapshot(workingSnap, params.id, params.patch);
|
|
30988
32701
|
if (!outcome) return false;
|
|
@@ -31006,7 +32719,7 @@ var RemoveDocQuoteCommand = {
|
|
|
31006
32719
|
const unitId = docModel.getUnitId();
|
|
31007
32720
|
const sdtService = accessor.get(IDocSdtService);
|
|
31008
32721
|
if (sdtService.getDocMode(unitId) === "view") return false;
|
|
31009
|
-
const workingSnap =
|
|
32722
|
+
const workingSnap = Tools16.deepClone(docModel.getSnapshot());
|
|
31010
32723
|
writeDocTemplateMetadataToSnapshot(workingSnap, sdtService.getTemplateMetadata(unitId));
|
|
31011
32724
|
const removed = removeQuoteFromSnapshot(workingSnap, params.id);
|
|
31012
32725
|
if (!removed) return false;
|
|
@@ -31025,7 +32738,7 @@ var InsertDocLatexFormulaCommand = {
|
|
|
31025
32738
|
const unitId = docModel.getUnitId();
|
|
31026
32739
|
const sdtService = accessor.get(IDocSdtService);
|
|
31027
32740
|
if (sdtService.getDocMode(unitId) === "view") return false;
|
|
31028
|
-
const id = params.spec.id || `latex_${
|
|
32741
|
+
const id = params.spec.id || `latex_${generateRandomId15(6)}`;
|
|
31029
32742
|
const rendered = layoutLatexFormulaWidget(params.spec.latex, {
|
|
31030
32743
|
displayMode: params.spec.displayMode,
|
|
31031
32744
|
fontSize: params.spec.fontSize,
|
|
@@ -31056,7 +32769,7 @@ var InsertDocLatexFormulaCommand = {
|
|
|
31056
32769
|
"latexFormula",
|
|
31057
32770
|
fullSpec
|
|
31058
32771
|
);
|
|
31059
|
-
const prevMeta =
|
|
32772
|
+
const prevMeta = Tools16.deepClone(sdtService.getTemplateMetadata(unitId));
|
|
31060
32773
|
if (prevMeta.revisions?.length) {
|
|
31061
32774
|
prevMeta.revisions = shiftTrackRevisions(prevMeta.revisions, inserted.insertOffset, 0, 1);
|
|
31062
32775
|
}
|
|
@@ -31090,7 +32803,7 @@ var UpdateDocLatexFormulaCommand = {
|
|
|
31090
32803
|
const unitId = docModel.getUnitId();
|
|
31091
32804
|
const sdtService = accessor.get(IDocSdtService);
|
|
31092
32805
|
if (sdtService.getDocMode(unitId) === "view") return false;
|
|
31093
|
-
const prevMeta =
|
|
32806
|
+
const prevMeta = Tools16.deepClone(sdtService.getTemplateMetadata(unitId));
|
|
31094
32807
|
const existing = prevMeta.latexFormulas?.[params.id];
|
|
31095
32808
|
const blk = (prevBody.customBlocks ?? []).find((b) => b.blockId === params.id);
|
|
31096
32809
|
if (!existing && !blk) return false;
|
|
@@ -31120,7 +32833,7 @@ var UpdateDocLatexFormulaCommand = {
|
|
|
31120
32833
|
size: { width: rendered.widthPt, height: rendered.heightPt }
|
|
31121
32834
|
};
|
|
31122
32835
|
}
|
|
31123
|
-
const nextBody =
|
|
32836
|
+
const nextBody = Tools16.deepClone(prevBody);
|
|
31124
32837
|
if (blk) {
|
|
31125
32838
|
attachDrawingMetaRangeOnBody(nextBody, params.id, blk.startIndex, "latexFormula", merged);
|
|
31126
32839
|
}
|
|
@@ -31148,7 +32861,7 @@ var RemoveDocLatexFormulaCommand = {
|
|
|
31148
32861
|
if (sdtService.getDocMode(unitId) === "view") return false;
|
|
31149
32862
|
const nextBody = removeInlineDrawingBlockFromBody(prevBody, params.id);
|
|
31150
32863
|
if (!nextBody) return false;
|
|
31151
|
-
const prevMeta =
|
|
32864
|
+
const prevMeta = Tools16.deepClone(sdtService.getTemplateMetadata(unitId));
|
|
31152
32865
|
const nextMap = { ...prevMeta.latexFormulas ?? {} };
|
|
31153
32866
|
delete nextMap[params.id];
|
|
31154
32867
|
sdtService.setTemplateMetadata(unitId, {
|
|
@@ -31170,7 +32883,7 @@ var InsertDocInlineFormulaCommand = {
|
|
|
31170
32883
|
const sdtService = accessor.get(IDocSdtService);
|
|
31171
32884
|
if (sdtService.getDocMode(unitId) === "view") return false;
|
|
31172
32885
|
const offset = resolveActiveInsertOffset(accessor, prevBody, params.offset);
|
|
31173
|
-
const workingSnap =
|
|
32886
|
+
const workingSnap = Tools16.deepClone(docModel.getSnapshot());
|
|
31174
32887
|
writeDocTemplateMetadataToSnapshot(workingSnap, sdtService.getTemplateMetadata(unitId));
|
|
31175
32888
|
const inserted = insertInlineFormulaIntoSnapshot(workingSnap, params.spec, offset, params.extraVars);
|
|
31176
32889
|
sdtService.setTemplateMetadata(unitId, readDocTemplateMetadataFromSnapshot(inserted.snapshot));
|
|
@@ -31192,7 +32905,7 @@ var RecalculateDocInlineFormulasCommand = {
|
|
|
31192
32905
|
const unitId = docModel.getUnitId();
|
|
31193
32906
|
const sdtService = accessor.get(IDocSdtService);
|
|
31194
32907
|
if (sdtService.getDocMode(unitId) === "view") return false;
|
|
31195
|
-
const workingSnap =
|
|
32908
|
+
const workingSnap = Tools16.deepClone(docModel.getSnapshot());
|
|
31196
32909
|
writeDocTemplateMetadataToSnapshot(workingSnap, sdtService.getTemplateMetadata(unitId));
|
|
31197
32910
|
recalculateInlineFormulasInPlace(workingSnap, params?.extraVars);
|
|
31198
32911
|
sdtService.setTemplateMetadata(unitId, readDocTemplateMetadataFromSnapshot(workingSnap));
|
|
@@ -31216,9 +32929,9 @@ var InsertDocChartCommand = {
|
|
|
31216
32929
|
const unitId = docModel.getUnitId();
|
|
31217
32930
|
const sdtService = accessor.get(IDocSdtService);
|
|
31218
32931
|
if (sdtService.getDocMode(unitId) === "view") return false;
|
|
31219
|
-
const id = params.spec.id || `chart_${
|
|
32932
|
+
const id = params.spec.id || `chart_${generateRandomId15(6)}`;
|
|
31220
32933
|
const fullSpec = {
|
|
31221
|
-
...
|
|
32934
|
+
...Tools16.deepClone(params.spec),
|
|
31222
32935
|
id
|
|
31223
32936
|
};
|
|
31224
32937
|
const rendered = renderDocChartToSvgDataUri(fullSpec);
|
|
@@ -31238,7 +32951,7 @@ var InsertDocChartCommand = {
|
|
|
31238
32951
|
"docChart",
|
|
31239
32952
|
fullSpec
|
|
31240
32953
|
);
|
|
31241
|
-
const prevMeta =
|
|
32954
|
+
const prevMeta = Tools16.deepClone(sdtService.getTemplateMetadata(unitId));
|
|
31242
32955
|
const nextMeta = {
|
|
31243
32956
|
...prevMeta,
|
|
31244
32957
|
docCharts: {
|
|
@@ -31269,7 +32982,7 @@ var UpdateDocChartCommand = {
|
|
|
31269
32982
|
const unitId = docModel.getUnitId();
|
|
31270
32983
|
const sdtService = accessor.get(IDocSdtService);
|
|
31271
32984
|
if (sdtService.getDocMode(unitId) === "view") return false;
|
|
31272
|
-
const prevMeta =
|
|
32985
|
+
const prevMeta = Tools16.deepClone(sdtService.getTemplateMetadata(unitId));
|
|
31273
32986
|
const existing = prevMeta.docCharts?.[params.id];
|
|
31274
32987
|
const blk = (prevBody.customBlocks ?? []).find((b) => b.blockId === params.id);
|
|
31275
32988
|
if (!existing && !blk) return false;
|
|
@@ -31281,7 +32994,7 @@ var UpdateDocChartCommand = {
|
|
|
31281
32994
|
categories: [],
|
|
31282
32995
|
series: []
|
|
31283
32996
|
},
|
|
31284
|
-
...
|
|
32997
|
+
...Tools16.deepClone(params.patch),
|
|
31285
32998
|
id: params.id
|
|
31286
32999
|
};
|
|
31287
33000
|
const rendered = renderDocChartToSvgDataUri(merged);
|
|
@@ -31295,7 +33008,7 @@ var UpdateDocChartCommand = {
|
|
|
31295
33008
|
size: { width: rendered.widthPt, height: rendered.heightPt }
|
|
31296
33009
|
};
|
|
31297
33010
|
}
|
|
31298
|
-
const nextBody =
|
|
33011
|
+
const nextBody = Tools16.deepClone(prevBody);
|
|
31299
33012
|
if (blk) {
|
|
31300
33013
|
attachDrawingMetaRangeOnBody(nextBody, params.id, blk.startIndex, "docChart", merged);
|
|
31301
33014
|
}
|
|
@@ -31323,7 +33036,7 @@ var RemoveDocChartCommand = {
|
|
|
31323
33036
|
if (sdtService.getDocMode(unitId) === "view") return false;
|
|
31324
33037
|
const nextBody = removeInlineDrawingBlockFromBody(prevBody, params.id);
|
|
31325
33038
|
if (!nextBody) return false;
|
|
31326
|
-
const prevMeta =
|
|
33039
|
+
const prevMeta = Tools16.deepClone(sdtService.getTemplateMetadata(unitId));
|
|
31327
33040
|
const nextMap = { ...prevMeta.docCharts ?? {} };
|
|
31328
33041
|
delete nextMap[params.id];
|
|
31329
33042
|
sdtService.setTemplateMetadata(unitId, {
|
|
@@ -31344,10 +33057,10 @@ var InsertDocShapeCommand = {
|
|
|
31344
33057
|
const unitId = docModel.getUnitId();
|
|
31345
33058
|
const sdtService = accessor.get(IDocSdtService);
|
|
31346
33059
|
if (sdtService.getDocMode(unitId) === "view") return false;
|
|
31347
|
-
const id = params.spec.id || `shape_${
|
|
33060
|
+
const id = params.spec.id || `shape_${generateRandomId15(6)}`;
|
|
31348
33061
|
const resolvedKind = params.spec.shapeType ?? params.spec.kind ?? "roundRect";
|
|
31349
33062
|
const fullSpec = {
|
|
31350
|
-
...
|
|
33063
|
+
...Tools16.deepClone(params.spec),
|
|
31351
33064
|
id,
|
|
31352
33065
|
shapeType: resolvedKind,
|
|
31353
33066
|
kind: resolvedKind
|
|
@@ -31369,7 +33082,7 @@ var InsertDocShapeCommand = {
|
|
|
31369
33082
|
"docShape",
|
|
31370
33083
|
fullSpec
|
|
31371
33084
|
);
|
|
31372
|
-
const prevMeta =
|
|
33085
|
+
const prevMeta = Tools16.deepClone(sdtService.getTemplateMetadata(unitId));
|
|
31373
33086
|
const nextMeta = {
|
|
31374
33087
|
...prevMeta,
|
|
31375
33088
|
docShapes: {
|
|
@@ -31400,14 +33113,14 @@ var UpdateDocShapeCommand = {
|
|
|
31400
33113
|
const unitId = docModel.getUnitId();
|
|
31401
33114
|
const sdtService = accessor.get(IDocSdtService);
|
|
31402
33115
|
if (sdtService.getDocMode(unitId) === "view") return false;
|
|
31403
|
-
const prevMeta =
|
|
33116
|
+
const prevMeta = Tools16.deepClone(sdtService.getTemplateMetadata(unitId));
|
|
31404
33117
|
const existing = prevMeta.docShapes?.[params.id];
|
|
31405
33118
|
const blk = (prevBody.customBlocks ?? []).find((b) => b.blockId === params.id);
|
|
31406
33119
|
if (!existing && !blk) return false;
|
|
31407
33120
|
const resolvedKind = params.patch.shapeType ?? params.patch.kind ?? existing?.shapeType ?? existing?.kind ?? "roundRect";
|
|
31408
33121
|
const merged = {
|
|
31409
33122
|
...existing ?? { id: params.id },
|
|
31410
|
-
...
|
|
33123
|
+
...Tools16.deepClone(params.patch),
|
|
31411
33124
|
id: params.id,
|
|
31412
33125
|
shapeType: resolvedKind,
|
|
31413
33126
|
kind: resolvedKind
|
|
@@ -31423,7 +33136,7 @@ var UpdateDocShapeCommand = {
|
|
|
31423
33136
|
size: { width: rendered.widthPt, height: rendered.heightPt }
|
|
31424
33137
|
};
|
|
31425
33138
|
}
|
|
31426
|
-
const nextBody =
|
|
33139
|
+
const nextBody = Tools16.deepClone(prevBody);
|
|
31427
33140
|
if (blk) {
|
|
31428
33141
|
attachDrawingMetaRangeOnBody(nextBody, params.id, blk.startIndex, "docShape", merged);
|
|
31429
33142
|
}
|
|
@@ -31451,7 +33164,7 @@ var RemoveDocShapeCommand = {
|
|
|
31451
33164
|
if (sdtService.getDocMode(unitId) === "view") return false;
|
|
31452
33165
|
const nextBody = removeInlineDrawingBlockFromBody(prevBody, params.id);
|
|
31453
33166
|
if (!nextBody) return false;
|
|
31454
|
-
const prevMeta =
|
|
33167
|
+
const prevMeta = Tools16.deepClone(sdtService.getTemplateMetadata(unitId));
|
|
31455
33168
|
const nextMap = { ...prevMeta.docShapes ?? {} };
|
|
31456
33169
|
delete nextMap[params.id];
|
|
31457
33170
|
sdtService.setTemplateMetadata(unitId, {
|
|
@@ -31496,8 +33209,8 @@ var SetDocTableRepeatHeaderCommand = {
|
|
|
31496
33209
|
const unitId = docModel.getUnitId();
|
|
31497
33210
|
const sdtService = accessor.get(IDocSdtService);
|
|
31498
33211
|
if (sdtService.getDocMode(unitId) === "view") return false;
|
|
31499
|
-
const prevSnap =
|
|
31500
|
-
const prevMeta =
|
|
33212
|
+
const prevSnap = Tools16.deepClone(docModel.getSnapshot());
|
|
33213
|
+
const prevMeta = Tools16.deepClone(sdtService.getTemplateMetadata(unitId));
|
|
31501
33214
|
writeDocTemplateMetadataToSnapshot(prevSnap, prevMeta);
|
|
31502
33215
|
const updated = setDocTableRepeatHeaderInSnapshot(
|
|
31503
33216
|
prevSnap,
|
|
@@ -31580,7 +33293,7 @@ var InsertDocRepeatingSectionCommand = {
|
|
|
31580
33293
|
const unitId = docModel.getUnitId();
|
|
31581
33294
|
const sdtService = accessor.get(IDocSdtService);
|
|
31582
33295
|
if (sdtService.getDocMode(unitId) === "view") return false;
|
|
31583
|
-
const id = params.spec.id || `rep_${
|
|
33296
|
+
const id = params.spec.id || `rep_${generateRandomId15(6)}`;
|
|
31584
33297
|
const tag = params.spec.tag || params.spec.bindingPath;
|
|
31585
33298
|
const offset = resolveActiveInsertOffset(accessor, prevBody, params.offset);
|
|
31586
33299
|
const inserted = insertSdtControlIntoBody(
|
|
@@ -31597,13 +33310,13 @@ var InsertDocRepeatingSectionCommand = {
|
|
|
31597
33310
|
},
|
|
31598
33311
|
params.spec.templateText
|
|
31599
33312
|
);
|
|
31600
|
-
const prevMeta =
|
|
33313
|
+
const prevMeta = Tools16.deepClone(sdtService.getTemplateMetadata(unitId));
|
|
31601
33314
|
const nextMeta = {
|
|
31602
33315
|
...prevMeta,
|
|
31603
33316
|
repeatingSections: {
|
|
31604
33317
|
...prevMeta.repeatingSections ?? {},
|
|
31605
33318
|
[id]: {
|
|
31606
|
-
...
|
|
33319
|
+
...Tools16.deepClone(params.spec),
|
|
31607
33320
|
id,
|
|
31608
33321
|
tag
|
|
31609
33322
|
}
|
|
@@ -31633,7 +33346,7 @@ var InsertDocBookmarkCommand = {
|
|
|
31633
33346
|
const unitId = docModel.getUnitId();
|
|
31634
33347
|
const sdtService = accessor.get(IDocSdtService);
|
|
31635
33348
|
if (sdtService.getDocMode(unitId) === "view") return false;
|
|
31636
|
-
const workingSnap =
|
|
33349
|
+
const workingSnap = Tools16.deepClone(docModel.getSnapshot());
|
|
31637
33350
|
writeDocTemplateMetadataToSnapshot(workingSnap, sdtService.getTemplateMetadata(unitId));
|
|
31638
33351
|
const inserted = insertBookmarkIntoSnapshot(workingSnap, params.spec);
|
|
31639
33352
|
if (!inserted) return false;
|
|
@@ -31657,7 +33370,7 @@ var RemoveDocBookmarkCommand = {
|
|
|
31657
33370
|
const unitId = docModel.getUnitId();
|
|
31658
33371
|
const sdtService = accessor.get(IDocSdtService);
|
|
31659
33372
|
if (sdtService.getDocMode(unitId) === "view") return false;
|
|
31660
|
-
const workingSnap =
|
|
33373
|
+
const workingSnap = Tools16.deepClone(docModel.getSnapshot());
|
|
31661
33374
|
writeDocTemplateMetadataToSnapshot(workingSnap, sdtService.getTemplateMetadata(unitId));
|
|
31662
33375
|
const removed = removeBookmarkFromSnapshot(workingSnap, params.nameOrId);
|
|
31663
33376
|
if (!removed) return false;
|
|
@@ -31675,7 +33388,7 @@ var InsertDocTableOfContentsCommand = {
|
|
|
31675
33388
|
const unitId = docModel.getUnitId();
|
|
31676
33389
|
const sdtService = accessor.get(IDocSdtService);
|
|
31677
33390
|
if (sdtService.getDocMode(unitId) === "view") return false;
|
|
31678
|
-
const workingSnap =
|
|
33391
|
+
const workingSnap = Tools16.deepClone(docModel.getSnapshot());
|
|
31679
33392
|
writeDocTemplateMetadataToSnapshot(workingSnap, sdtService.getTemplateMetadata(unitId));
|
|
31680
33393
|
const inserted = insertTableOfContentsIntoSnapshot(workingSnap, params?.spec, params?.offset);
|
|
31681
33394
|
sdtService.setTemplateMetadata(unitId, readDocTemplateMetadataFromSnapshot(inserted.snapshot));
|
|
@@ -31697,7 +33410,7 @@ var RefreshDocTableOfContentsCommand = {
|
|
|
31697
33410
|
const unitId = docModel.getUnitId();
|
|
31698
33411
|
const sdtService = accessor.get(IDocSdtService);
|
|
31699
33412
|
if (sdtService.getDocMode(unitId) === "view") return false;
|
|
31700
|
-
const workingSnap =
|
|
33413
|
+
const workingSnap = Tools16.deepClone(docModel.getSnapshot());
|
|
31701
33414
|
writeDocTemplateMetadataToSnapshot(workingSnap, sdtService.getTemplateMetadata(unitId));
|
|
31702
33415
|
const refreshed = refreshTableOfContentsInSnapshot(workingSnap, params?.spec);
|
|
31703
33416
|
if (!refreshed) return false;
|
|
@@ -31716,13 +33429,13 @@ var RefreshDocTableOfContentsCommand = {
|
|
|
31716
33429
|
function buildAuxParams(unitId, snap, metadata) {
|
|
31717
33430
|
return {
|
|
31718
33431
|
unitId,
|
|
31719
|
-
tableSource:
|
|
31720
|
-
drawings:
|
|
31721
|
-
drawingsOrder:
|
|
31722
|
-
documentStyle:
|
|
31723
|
-
headers:
|
|
31724
|
-
footers:
|
|
31725
|
-
metadata:
|
|
33432
|
+
tableSource: Tools17.deepClone(snap.tableSource ?? {}),
|
|
33433
|
+
drawings: Tools17.deepClone(snap.drawings ?? {}),
|
|
33434
|
+
drawingsOrder: Tools17.deepClone(snap.drawingsOrder ?? []),
|
|
33435
|
+
documentStyle: Tools17.deepClone(snap.documentStyle ?? {}),
|
|
33436
|
+
headers: Tools17.deepClone(snap.headers ?? {}),
|
|
33437
|
+
footers: Tools17.deepClone(snap.footers ?? {}),
|
|
33438
|
+
metadata: Tools17.deepClone(metadata)
|
|
31726
33439
|
};
|
|
31727
33440
|
}
|
|
31728
33441
|
function executeWave2SnapshotUpdateWithUndoRedo(accessor, docModel, prevSnapshotClone, prevMetaClone, nextSnapshot, cursorOffset) {
|
|
@@ -31737,7 +33450,7 @@ function executeWave2SnapshotUpdateWithUndoRedo(accessor, docModel, prevSnapshot
|
|
|
31737
33450
|
const prevAux = buildAuxParams(unitId, prevSnapshotClone, prevMetaClone);
|
|
31738
33451
|
const nextAux = buildAuxParams(unitId, nextSnapshot, nextMeta);
|
|
31739
33452
|
commandService.syncExecuteCommand(SyncDocAuxStateMutation.id, nextAux);
|
|
31740
|
-
const bodyUnchanged =
|
|
33453
|
+
const bodyUnchanged = Tools17.diffValue(prevBody, nextBody);
|
|
31741
33454
|
const undoMutations = [{ id: SyncDocAuxStateMutation.id, params: prevAux }];
|
|
31742
33455
|
const redoMutations = [{ id: SyncDocAuxStateMutation.id, params: nextAux }];
|
|
31743
33456
|
if (!bodyUnchanged) {
|
|
@@ -31746,7 +33459,7 @@ function executeWave2SnapshotUpdateWithUndoRedo(accessor, docModel, prevSnapshot
|
|
|
31746
33459
|
);
|
|
31747
33460
|
if (hasLockedSdt) {
|
|
31748
33461
|
const livePrevBody = docModel.getSnapshot().body;
|
|
31749
|
-
const unlockedBody =
|
|
33462
|
+
const unlockedBody = Tools17.deepClone(livePrevBody);
|
|
31750
33463
|
unlockedBody.customRanges = (unlockedBody.customRanges ?? []).map(
|
|
31751
33464
|
(r) => r.rangeType === CustomRangeType12.SDT ? { ...r, properties: { ...r.properties, lock: "unlocked" } } : r
|
|
31752
33465
|
);
|
|
@@ -31813,9 +33526,9 @@ function prepareWorkingSnapshot(accessor, unitId) {
|
|
|
31813
33526
|
const resolvedUnitId = docModel.getUnitId();
|
|
31814
33527
|
const sdtService = accessor.get(IDocSdtService);
|
|
31815
33528
|
if (sdtService.getDocMode(resolvedUnitId) === "view") return null;
|
|
31816
|
-
const prevSnap =
|
|
31817
|
-
const prevMeta =
|
|
31818
|
-
const workingSnap =
|
|
33529
|
+
const prevSnap = Tools17.deepClone(docModel.getSnapshot());
|
|
33530
|
+
const prevMeta = Tools17.deepClone(sdtService.getTemplateMetadata(resolvedUnitId));
|
|
33531
|
+
const workingSnap = Tools17.deepClone(prevSnap);
|
|
31819
33532
|
writeDocTemplateMetadataToSnapshot(workingSnap, prevMeta);
|
|
31820
33533
|
return { docModel, unitId: resolvedUnitId, prevSnap, prevMeta, workingSnap };
|
|
31821
33534
|
}
|
|
@@ -32034,6 +33747,23 @@ var SetDocPrintConfigCommand = {
|
|
|
32034
33747
|
);
|
|
32035
33748
|
}
|
|
32036
33749
|
};
|
|
33750
|
+
var SetDocLineNumberingCommand = {
|
|
33751
|
+
id: "yudao-docs.command.set-line-numbering",
|
|
33752
|
+
type: CommandType2.COMMAND,
|
|
33753
|
+
handler: (accessor, params) => {
|
|
33754
|
+
if (!params?.config || typeof params.config.enabled !== "boolean") return false;
|
|
33755
|
+
const ctx = prepareWorkingSnapshot(accessor, params.unitId);
|
|
33756
|
+
if (!ctx) return false;
|
|
33757
|
+
const nextSnap = setDocLineNumberingInSnapshot(ctx.workingSnap, params.config);
|
|
33758
|
+
return executeWave2SnapshotUpdateWithUndoRedo(
|
|
33759
|
+
accessor,
|
|
33760
|
+
ctx.docModel,
|
|
33761
|
+
ctx.prevSnap,
|
|
33762
|
+
ctx.prevMeta,
|
|
33763
|
+
nextSnap
|
|
33764
|
+
);
|
|
33765
|
+
}
|
|
33766
|
+
};
|
|
32037
33767
|
var UpdateDocImageTransformCommand = {
|
|
32038
33768
|
id: "yudao-docs.command.update-image-transform",
|
|
32039
33769
|
type: CommandType2.COMMAND,
|
|
@@ -32060,15 +33790,29 @@ var InsertDocSmartArtCommand = {
|
|
|
32060
33790
|
id: "yudao-docs.command.insert-smartart",
|
|
32061
33791
|
type: CommandType2.COMMAND,
|
|
32062
33792
|
handler: (accessor, params) => {
|
|
32063
|
-
|
|
32064
|
-
|
|
32065
|
-
|
|
32066
|
-
|
|
33793
|
+
const rawSpec = params?.spec ?? {};
|
|
33794
|
+
const layout = rawSpec.layout ?? "process";
|
|
33795
|
+
const nodes = Array.isArray(rawSpec.nodes) && rawSpec.nodes.length > 0 ? rawSpec.nodes : [
|
|
33796
|
+
{ id: "n1", label: "\u9636\u6BB5\u4E00", subLabel: "\u9700\u6C42\u68B3\u7406" },
|
|
33797
|
+
{ id: "n2", label: "\u9636\u6BB5\u4E8C", subLabel: "\u65B9\u6848\u8BC4\u5BA1" },
|
|
33798
|
+
{ id: "n3", label: "\u9636\u6BB5\u4E09", subLabel: "\u4EA4\u4ED8\u9A8C\u6536" }
|
|
33799
|
+
];
|
|
33800
|
+
const ctx = prepareWorkingSnapshot(accessor, params?.unitId);
|
|
32067
33801
|
if (!ctx) return false;
|
|
32068
|
-
const offset = resolveActiveInsertOffset(accessor, ctx.workingSnap.body, params
|
|
32069
|
-
const id =
|
|
32070
|
-
const inserted = insertSmartArtIntoSnapshot(
|
|
33802
|
+
const offset = resolveActiveInsertOffset(accessor, ctx.workingSnap.body, params?.offset);
|
|
33803
|
+
const id = rawSpec.id || `smartart_${generateRandomId16(6)}`;
|
|
33804
|
+
const inserted = insertSmartArtIntoSnapshot(
|
|
33805
|
+
ctx.workingSnap,
|
|
33806
|
+
{
|
|
33807
|
+
...rawSpec,
|
|
33808
|
+
id,
|
|
33809
|
+
layout,
|
|
33810
|
+
nodes
|
|
33811
|
+
},
|
|
33812
|
+
offset
|
|
33813
|
+
);
|
|
32071
33814
|
if (!inserted) return false;
|
|
33815
|
+
params?.idOut?.(id);
|
|
32072
33816
|
return executeWave2SnapshotUpdateWithUndoRedo(
|
|
32073
33817
|
accessor,
|
|
32074
33818
|
ctx.docModel,
|
|
@@ -32105,9 +33849,12 @@ var RemoveDocSmartArtCommand = {
|
|
|
32105
33849
|
const ctx = prepareWorkingSnapshot(accessor, params.unitId);
|
|
32106
33850
|
if (!ctx) return false;
|
|
32107
33851
|
const nextBody = removeInlineDrawingBlockFromBody(ctx.workingSnap.body, params.id);
|
|
32108
|
-
|
|
32109
|
-
|
|
32110
|
-
nextSnap
|
|
33852
|
+
const prevMetaCheck = readDocTemplateMetadataFromSnapshot(ctx.workingSnap);
|
|
33853
|
+
if (!nextBody && !prevMetaCheck.smartArts?.[params.id]) return false;
|
|
33854
|
+
const nextSnap = Tools17.deepClone(ctx.workingSnap);
|
|
33855
|
+
if (nextBody) {
|
|
33856
|
+
nextSnap.body = nextBody;
|
|
33857
|
+
}
|
|
32111
33858
|
if (nextSnap.drawings) {
|
|
32112
33859
|
delete nextSnap.drawings[params.id];
|
|
32113
33860
|
}
|
|
@@ -32295,7 +34042,7 @@ var UpdateAllDocFieldsCommand = {
|
|
|
32295
34042
|
handler: (accessor, params) => {
|
|
32296
34043
|
const ctx = prepareWorkingSnapshot(accessor, params?.unitId);
|
|
32297
34044
|
if (!ctx) return false;
|
|
32298
|
-
const nextSnap =
|
|
34045
|
+
const nextSnap = Tools17.deepClone(ctx.workingSnap);
|
|
32299
34046
|
updateAllDocFieldsInSnapshot(nextSnap, params?.context);
|
|
32300
34047
|
return executeWave2SnapshotUpdateWithUndoRedo(
|
|
32301
34048
|
accessor,
|
|
@@ -32318,7 +34065,8 @@ var InsertDocCaptionCommand = {
|
|
|
32318
34065
|
ctx.workingSnap,
|
|
32319
34066
|
params.category,
|
|
32320
34067
|
params.title ?? "",
|
|
32321
|
-
offset
|
|
34068
|
+
offset,
|
|
34069
|
+
params.prefixLabel
|
|
32322
34070
|
);
|
|
32323
34071
|
if (!inserted) return false;
|
|
32324
34072
|
params.captionIdOut?.(inserted.caption.id);
|
|
@@ -32343,7 +34091,11 @@ var InsertDocCrossReferenceCommand = {
|
|
|
32343
34091
|
const inserted = insertCrossReferenceIntoSnapshot(
|
|
32344
34092
|
ctx.workingSnap,
|
|
32345
34093
|
params.targetBookmarkOrCaptionId,
|
|
32346
|
-
offset
|
|
34094
|
+
offset,
|
|
34095
|
+
{
|
|
34096
|
+
displayMode: params.displayMode ?? "labelAndNumber",
|
|
34097
|
+
prefixText: params.prefixText
|
|
34098
|
+
}
|
|
32347
34099
|
);
|
|
32348
34100
|
if (!inserted) return false;
|
|
32349
34101
|
params.fieldIdOut?.(inserted.field.id);
|
|
@@ -32357,6 +34109,96 @@ var InsertDocCrossReferenceCommand = {
|
|
|
32357
34109
|
);
|
|
32358
34110
|
}
|
|
32359
34111
|
};
|
|
34112
|
+
var InsertDocCrossRefCommand = {
|
|
34113
|
+
id: "yudao-docs.command.insert-doc-cross-ref",
|
|
34114
|
+
type: CommandType2.COMMAND,
|
|
34115
|
+
handler: (accessor, params) => {
|
|
34116
|
+
if (!params?.targetCaptionId?.trim()) return false;
|
|
34117
|
+
const ctx = prepareWorkingSnapshot(accessor, params.unitId);
|
|
34118
|
+
if (!ctx) return false;
|
|
34119
|
+
const offset = resolveActiveInsertOffset(accessor, ctx.workingSnap.body, params.offset);
|
|
34120
|
+
const inserted = insertCrossReferenceIntoSnapshot(
|
|
34121
|
+
ctx.workingSnap,
|
|
34122
|
+
params.targetCaptionId,
|
|
34123
|
+
offset,
|
|
34124
|
+
{
|
|
34125
|
+
displayMode: params.displayMode ?? "labelAndNumber",
|
|
34126
|
+
prefixText: params.prefixText
|
|
34127
|
+
}
|
|
34128
|
+
);
|
|
34129
|
+
if (!inserted) return false;
|
|
34130
|
+
params.crossRefIdOut?.(inserted.field.id);
|
|
34131
|
+
return executeWave2SnapshotUpdateWithUndoRedo(
|
|
34132
|
+
accessor,
|
|
34133
|
+
ctx.docModel,
|
|
34134
|
+
ctx.prevSnap,
|
|
34135
|
+
ctx.prevMeta,
|
|
34136
|
+
inserted.snapshot,
|
|
34137
|
+
inserted.endOffset
|
|
34138
|
+
);
|
|
34139
|
+
}
|
|
34140
|
+
};
|
|
34141
|
+
var BuildDocTableOfFiguresCommand = {
|
|
34142
|
+
id: "yudao-docs.command.build-table-of-figures",
|
|
34143
|
+
type: CommandType2.COMMAND,
|
|
34144
|
+
handler: (accessor, params) => {
|
|
34145
|
+
const ctx = prepareWorkingSnapshot(accessor, params?.unitId);
|
|
34146
|
+
if (!ctx) return false;
|
|
34147
|
+
const explicitOffset = params?.offset !== void 0 ? resolveActiveInsertOffset(accessor, ctx.workingSnap.body, params.offset) : void 0;
|
|
34148
|
+
const inserted = insertTableOfFiguresIntoSnapshot(ctx.workingSnap, {
|
|
34149
|
+
offset: explicitOffset,
|
|
34150
|
+
category: params?.category ?? "all",
|
|
34151
|
+
title: params?.title,
|
|
34152
|
+
showPageNumbers: params?.showPageNumbers
|
|
34153
|
+
});
|
|
34154
|
+
if (!inserted) return false;
|
|
34155
|
+
return executeWave2SnapshotUpdateWithUndoRedo(
|
|
34156
|
+
accessor,
|
|
34157
|
+
ctx.docModel,
|
|
34158
|
+
ctx.prevSnap,
|
|
34159
|
+
ctx.prevMeta,
|
|
34160
|
+
inserted.snapshot,
|
|
34161
|
+
inserted.endOffset
|
|
34162
|
+
);
|
|
34163
|
+
}
|
|
34164
|
+
};
|
|
34165
|
+
var RefreshDocCaptionsAndCrossRefsCommand = {
|
|
34166
|
+
id: "yudao-docs.command.refresh-captions-and-cross-refs",
|
|
34167
|
+
type: CommandType2.COMMAND,
|
|
34168
|
+
handler: (accessor, params) => {
|
|
34169
|
+
const ctx = prepareWorkingSnapshot(accessor, params?.unitId);
|
|
34170
|
+
if (!ctx) return false;
|
|
34171
|
+
const nextSnap = Tools17.deepClone(ctx.workingSnap);
|
|
34172
|
+
recalculateDocCaptionsAndCrossRefs(nextSnap);
|
|
34173
|
+
return executeWave2SnapshotUpdateWithUndoRedo(
|
|
34174
|
+
accessor,
|
|
34175
|
+
ctx.docModel,
|
|
34176
|
+
ctx.prevSnap,
|
|
34177
|
+
ctx.prevMeta,
|
|
34178
|
+
nextSnap
|
|
34179
|
+
);
|
|
34180
|
+
}
|
|
34181
|
+
};
|
|
34182
|
+
var CombineDocRevisionsCommand = {
|
|
34183
|
+
id: "yudao-docs.command.combine-doc-revisions",
|
|
34184
|
+
type: CommandType2.COMMAND,
|
|
34185
|
+
handler: (accessor, params) => {
|
|
34186
|
+
if (!Array.isArray(params?.reviewerCopies) || params.reviewerCopies.length === 0) {
|
|
34187
|
+
return false;
|
|
34188
|
+
}
|
|
34189
|
+
const ctx = prepareWorkingSnapshot(accessor, params.unitId);
|
|
34190
|
+
if (!ctx) return false;
|
|
34191
|
+
const baseSnapshot = params.baseDoc ?? ctx.workingSnap;
|
|
34192
|
+
const combined = combineReviewedDocuments(baseSnapshot, params.reviewerCopies);
|
|
34193
|
+
return executeWave2SnapshotUpdateWithUndoRedo(
|
|
34194
|
+
accessor,
|
|
34195
|
+
ctx.docModel,
|
|
34196
|
+
ctx.prevSnap,
|
|
34197
|
+
ctx.prevMeta,
|
|
34198
|
+
combined
|
|
34199
|
+
);
|
|
34200
|
+
}
|
|
34201
|
+
};
|
|
32360
34202
|
var InsertDocCitationCommand = {
|
|
32361
34203
|
id: "yudao-docs.command.insert-doc-citation",
|
|
32362
34204
|
type: CommandType2.COMMAND,
|
|
@@ -32431,6 +34273,7 @@ var ALL_DOC_WAVE2_COMMANDS = [
|
|
|
32431
34273
|
InsertDocColumnGroupCommand,
|
|
32432
34274
|
SetParagraphPaginationCommand,
|
|
32433
34275
|
SetDocPrintConfigCommand,
|
|
34276
|
+
SetDocLineNumberingCommand,
|
|
32434
34277
|
UpdateDocImageTransformCommand,
|
|
32435
34278
|
InsertDocSmartArtCommand,
|
|
32436
34279
|
UpdateDocSmartArtCommand,
|
|
@@ -32445,6 +34288,10 @@ var ALL_DOC_WAVE2_COMMANDS = [
|
|
|
32445
34288
|
UpdateAllDocFieldsCommand,
|
|
32446
34289
|
InsertDocCaptionCommand,
|
|
32447
34290
|
InsertDocCrossReferenceCommand,
|
|
34291
|
+
InsertDocCrossRefCommand,
|
|
34292
|
+
BuildDocTableOfFiguresCommand,
|
|
34293
|
+
RefreshDocCaptionsAndCrossRefsCommand,
|
|
34294
|
+
CombineDocRevisionsCommand,
|
|
32448
34295
|
InsertDocCitationCommand,
|
|
32449
34296
|
InsertDocBibliographyCommand,
|
|
32450
34297
|
InsertDocBuildingBlockCommand
|
|
@@ -32453,7 +34300,7 @@ var ALL_DOC_WAVE2_COMMANDS = [
|
|
|
32453
34300
|
// src/commands/doc-batch3.command.ts
|
|
32454
34301
|
import {
|
|
32455
34302
|
CommandType as CommandType3,
|
|
32456
|
-
Tools as
|
|
34303
|
+
Tools as Tools18
|
|
32457
34304
|
} from "@univerjs/core";
|
|
32458
34305
|
function prepareBatch3Snapshot(accessor, unitId) {
|
|
32459
34306
|
const docModel = getTargetDocModel(accessor, unitId);
|
|
@@ -32461,9 +34308,9 @@ function prepareBatch3Snapshot(accessor, unitId) {
|
|
|
32461
34308
|
const resolvedUnitId = docModel.getUnitId();
|
|
32462
34309
|
const sdtService = accessor.get(IDocSdtService);
|
|
32463
34310
|
if (sdtService.getDocMode(resolvedUnitId) === "view") return null;
|
|
32464
|
-
const prevSnap =
|
|
32465
|
-
const prevMeta =
|
|
32466
|
-
const workingSnap =
|
|
34311
|
+
const prevSnap = Tools18.deepClone(docModel.getSnapshot());
|
|
34312
|
+
const prevMeta = Tools18.deepClone(sdtService.getTemplateMetadata(resolvedUnitId));
|
|
34313
|
+
const workingSnap = Tools18.deepClone(prevSnap);
|
|
32467
34314
|
writeDocTemplateMetadataToSnapshot(workingSnap, prevMeta);
|
|
32468
34315
|
return { docModel, unitId: resolvedUnitId, prevSnap, prevMeta, workingSnap };
|
|
32469
34316
|
}
|
|
@@ -32852,7 +34699,7 @@ var ALL_DOC_BATCH3_COMMANDS = [
|
|
|
32852
34699
|
import {
|
|
32853
34700
|
CommandType as CommandType4,
|
|
32854
34701
|
CustomRangeType as CustomRangeType13,
|
|
32855
|
-
Tools as
|
|
34702
|
+
Tools as Tools19
|
|
32856
34703
|
} from "@univerjs/core";
|
|
32857
34704
|
import { DocSelectionManagerService } from "@univerjs/docs";
|
|
32858
34705
|
function prepareMutableSnapshot(accessor, unitId) {
|
|
@@ -32862,8 +34709,8 @@ function prepareMutableSnapshot(accessor, unitId) {
|
|
|
32862
34709
|
const resolvedUnitId = docModel.getUnitId();
|
|
32863
34710
|
const sdtService = accessor.get(IDocSdtService);
|
|
32864
34711
|
if (sdtService.getDocMode(resolvedUnitId) === "view") return null;
|
|
32865
|
-
const prevSnap =
|
|
32866
|
-
const prevMeta =
|
|
34712
|
+
const prevSnap = Tools19.deepClone(docModel.getSnapshot());
|
|
34713
|
+
const prevMeta = Tools19.deepClone(sdtService.getTemplateMetadata(resolvedUnitId));
|
|
32867
34714
|
writeDocTemplateMetadataToSnapshot(prevSnap, prevMeta);
|
|
32868
34715
|
return { docModel, unitId: resolvedUnitId, sdtService, workingSnap: prevSnap };
|
|
32869
34716
|
}
|
|
@@ -32883,7 +34730,7 @@ function commitUpdatedSnapshot(accessor, ctx, nextSnap, cursorOffset) {
|
|
|
32883
34730
|
syncSnapshotAuxFields(ctx.docModel, nextSnap);
|
|
32884
34731
|
ctx.sdtService.setTemplateMetadata(ctx.unitId, readDocTemplateMetadataFromSnapshot(nextSnap));
|
|
32885
34732
|
const prevBody = ctx.docModel.getSnapshot().body;
|
|
32886
|
-
if (
|
|
34733
|
+
if (Tools19.diffValue(prevBody, nextSnap.body)) {
|
|
32887
34734
|
ctx.sdtService.bumpRevision();
|
|
32888
34735
|
return true;
|
|
32889
34736
|
}
|
|
@@ -32903,7 +34750,7 @@ var HighlightInvalidDocSdtCommand = {
|
|
|
32903
34750
|
if (!ctx) return false;
|
|
32904
34751
|
const validation = params?.clear ? { valid: true, issues: [] } : validateDocForm(ctx.workingSnap);
|
|
32905
34752
|
const invalidIds = new Set(validation.issues.map((e) => e.controlId));
|
|
32906
|
-
const nextBody =
|
|
34753
|
+
const nextBody = Tools19.deepClone(ctx.workingSnap.body);
|
|
32907
34754
|
for (const rng of nextBody.customRanges ?? []) {
|
|
32908
34755
|
if (rng.rangeType !== CustomRangeType13.SDT) continue;
|
|
32909
34756
|
const resolved = parseSdtRangeToResolved(nextBody, rng);
|
|
@@ -33386,7 +35233,7 @@ var ALL_DOC_ROUND1_COMMANDS = [
|
|
|
33386
35233
|
// src/commands/doc-round3.command.ts
|
|
33387
35234
|
import {
|
|
33388
35235
|
CommandType as CommandType5,
|
|
33389
|
-
Tools as
|
|
35236
|
+
Tools as Tools20
|
|
33390
35237
|
} from "@univerjs/core";
|
|
33391
35238
|
import { DocSelectionManagerService as DocSelectionManagerService2 } from "@univerjs/docs";
|
|
33392
35239
|
function prepareRound3MutableSnapshot(accessor, unitId) {
|
|
@@ -33396,8 +35243,8 @@ function prepareRound3MutableSnapshot(accessor, unitId) {
|
|
|
33396
35243
|
const resolvedUnitId = docModel.getUnitId();
|
|
33397
35244
|
const sdtService = accessor.get(IDocSdtService);
|
|
33398
35245
|
if (sdtService.getDocMode(resolvedUnitId) === "view") return null;
|
|
33399
|
-
const prevSnap =
|
|
33400
|
-
const prevMeta =
|
|
35246
|
+
const prevSnap = Tools20.deepClone(docModel.getSnapshot());
|
|
35247
|
+
const prevMeta = Tools20.deepClone(sdtService.getTemplateMetadata(resolvedUnitId));
|
|
33401
35248
|
writeDocTemplateMetadataToSnapshot(prevSnap, prevMeta);
|
|
33402
35249
|
return { docModel, unitId: resolvedUnitId, sdtService, workingSnap: prevSnap };
|
|
33403
35250
|
}
|
|
@@ -33419,7 +35266,7 @@ function commitRound3Snapshot(accessor, ctx, nextSnap, cursorOffset) {
|
|
|
33419
35266
|
syncSnapshotAuxFields(ctx.docModel, nextSnap);
|
|
33420
35267
|
ctx.sdtService.setTemplateMetadata(ctx.unitId, readDocTemplateMetadataFromSnapshot(nextSnap));
|
|
33421
35268
|
const prevBody = ctx.docModel.getSnapshot().body;
|
|
33422
|
-
if (
|
|
35269
|
+
if (Tools20.diffValue(prevBody, nextSnap.body)) {
|
|
33423
35270
|
ctx.sdtService.bumpRevision(ctx.unitId);
|
|
33424
35271
|
return true;
|
|
33425
35272
|
}
|
|
@@ -33644,7 +35491,7 @@ var ALL_DOC_ROUND3_COMMANDS = [
|
|
|
33644
35491
|
// src/commands/doc-pro.command.ts
|
|
33645
35492
|
import {
|
|
33646
35493
|
CommandType as CommandType6,
|
|
33647
|
-
Tools as
|
|
35494
|
+
Tools as Tools21
|
|
33648
35495
|
} from "@univerjs/core";
|
|
33649
35496
|
import { DocSelectionManagerService as DocSelectionManagerService3 } from "@univerjs/docs";
|
|
33650
35497
|
var InsertDocBlockquoteCommand = {
|
|
@@ -33700,9 +35547,9 @@ var UpdateDocCodeBlockCommand = {
|
|
|
33700
35547
|
const unitId = docModel.getUnitId();
|
|
33701
35548
|
const sdtService = accessor.get(IDocSdtService);
|
|
33702
35549
|
if (sdtService.getDocMode(unitId) === "view") return false;
|
|
33703
|
-
const prevSnap =
|
|
33704
|
-
const prevMeta =
|
|
33705
|
-
const workingSnap =
|
|
35550
|
+
const prevSnap = Tools21.deepClone(docModel.getSnapshot());
|
|
35551
|
+
const prevMeta = Tools21.deepClone(sdtService.getTemplateMetadata(unitId));
|
|
35552
|
+
const workingSnap = Tools21.deepClone(prevSnap);
|
|
33706
35553
|
writeDocTemplateMetadataToSnapshot(workingSnap, prevMeta);
|
|
33707
35554
|
const updated = updateSyntaxCodeBlockInSnapshot(workingSnap, params.id, {
|
|
33708
35555
|
code: params.code,
|
|
@@ -33729,9 +35576,9 @@ var RemoveDocCodeBlockCommand = {
|
|
|
33729
35576
|
const unitId = docModel.getUnitId();
|
|
33730
35577
|
const sdtService = accessor.get(IDocSdtService);
|
|
33731
35578
|
if (sdtService.getDocMode(unitId) === "view") return false;
|
|
33732
|
-
const prevSnap =
|
|
33733
|
-
const prevMeta =
|
|
33734
|
-
const workingSnap =
|
|
35579
|
+
const prevSnap = Tools21.deepClone(docModel.getSnapshot());
|
|
35580
|
+
const prevMeta = Tools21.deepClone(sdtService.getTemplateMetadata(unitId));
|
|
35581
|
+
const workingSnap = Tools21.deepClone(prevSnap);
|
|
33735
35582
|
writeDocTemplateMetadataToSnapshot(workingSnap, prevMeta);
|
|
33736
35583
|
const removed = removeSyntaxCodeBlockFromSnapshot(workingSnap, params.id);
|
|
33737
35584
|
if (!removed) return false;
|
|
@@ -33755,14 +35602,14 @@ var ApplyDocMarkdownShortcutCommand = {
|
|
|
33755
35602
|
const sdtService = accessor.get(IDocSdtService);
|
|
33756
35603
|
if (sdtService.getDocMode(unitId) === "view") return false;
|
|
33757
35604
|
const offset = resolveActiveInsertOffset(accessor, prevBody, params?.offset);
|
|
33758
|
-
const prevSnap =
|
|
33759
|
-
const prevMeta =
|
|
33760
|
-
const workingSnap =
|
|
35605
|
+
const prevSnap = Tools21.deepClone(docModel.getSnapshot());
|
|
35606
|
+
const prevMeta = Tools21.deepClone(sdtService.getTemplateMetadata(unitId));
|
|
35607
|
+
const workingSnap = Tools21.deepClone(prevSnap);
|
|
33761
35608
|
writeDocTemplateMetadataToSnapshot(workingSnap, prevMeta);
|
|
33762
35609
|
const outcome = applyDocMarkdownShortcutInSnapshot(workingSnap, offset);
|
|
33763
35610
|
if (!outcome) return false;
|
|
33764
35611
|
if (outcome.snapshot.lists) {
|
|
33765
|
-
docModel.getSnapshot().lists =
|
|
35612
|
+
docModel.getSnapshot().lists = Tools21.deepClone(outcome.snapshot.lists);
|
|
33766
35613
|
}
|
|
33767
35614
|
return executeWave2SnapshotUpdateWithUndoRedo(
|
|
33768
35615
|
accessor,
|
|
@@ -33785,9 +35632,9 @@ var InsertDocMiniSheetCommand = {
|
|
|
33785
35632
|
const sdtService = accessor.get(IDocSdtService);
|
|
33786
35633
|
if (sdtService.getDocMode(unitId) === "view") return false;
|
|
33787
35634
|
const offset = resolveActiveInsertOffset(accessor, prevBody, params?.offset);
|
|
33788
|
-
const prevSnap =
|
|
33789
|
-
const prevMeta =
|
|
33790
|
-
const workingSnap =
|
|
35635
|
+
const prevSnap = Tools21.deepClone(docModel.getSnapshot());
|
|
35636
|
+
const prevMeta = Tools21.deepClone(sdtService.getTemplateMetadata(unitId));
|
|
35637
|
+
const workingSnap = Tools21.deepClone(prevSnap);
|
|
33791
35638
|
writeDocTemplateMetadataToSnapshot(workingSnap, prevMeta);
|
|
33792
35639
|
const inserted = insertDocMiniSheetInSnapshot(workingSnap, params?.spec, offset);
|
|
33793
35640
|
return executeWave2SnapshotUpdateWithUndoRedo(
|
|
@@ -33810,9 +35657,9 @@ var UpdateDocMiniSheetCommand = {
|
|
|
33810
35657
|
const unitId = docModel.getUnitId();
|
|
33811
35658
|
const sdtService = accessor.get(IDocSdtService);
|
|
33812
35659
|
if (sdtService.getDocMode(unitId) === "view") return false;
|
|
33813
|
-
const prevSnap =
|
|
33814
|
-
const prevMeta =
|
|
33815
|
-
const workingSnap =
|
|
35660
|
+
const prevSnap = Tools21.deepClone(docModel.getSnapshot());
|
|
35661
|
+
const prevMeta = Tools21.deepClone(sdtService.getTemplateMetadata(unitId));
|
|
35662
|
+
const workingSnap = Tools21.deepClone(prevSnap);
|
|
33816
35663
|
writeDocTemplateMetadataToSnapshot(workingSnap, prevMeta);
|
|
33817
35664
|
const updated = updateDocMiniSheetInSnapshot(workingSnap, params.id, params.patch);
|
|
33818
35665
|
if (!updated) return false;
|
|
@@ -33835,9 +35682,9 @@ var RemoveDocMiniSheetCommand = {
|
|
|
33835
35682
|
const unitId = docModel.getUnitId();
|
|
33836
35683
|
const sdtService = accessor.get(IDocSdtService);
|
|
33837
35684
|
if (sdtService.getDocMode(unitId) === "view") return false;
|
|
33838
|
-
const prevSnap =
|
|
33839
|
-
const prevMeta =
|
|
33840
|
-
const workingSnap =
|
|
35685
|
+
const prevSnap = Tools21.deepClone(docModel.getSnapshot());
|
|
35686
|
+
const prevMeta = Tools21.deepClone(sdtService.getTemplateMetadata(unitId));
|
|
35687
|
+
const workingSnap = Tools21.deepClone(prevSnap);
|
|
33841
35688
|
writeDocTemplateMetadataToSnapshot(workingSnap, prevMeta);
|
|
33842
35689
|
const removed = removeDocMiniSheetFromSnapshot(workingSnap, params.id);
|
|
33843
35690
|
if (!removed) return false;
|
|
@@ -33875,9 +35722,9 @@ var ConvertTextToTableCommand = {
|
|
|
33875
35722
|
if (params?.text !== void 0 && typeof startOffset !== "number") {
|
|
33876
35723
|
startOffset = resolveActiveInsertOffset(accessor, prevBody);
|
|
33877
35724
|
}
|
|
33878
|
-
const prevSnap =
|
|
33879
|
-
const prevMeta =
|
|
33880
|
-
const workingSnap =
|
|
35725
|
+
const prevSnap = Tools21.deepClone(docModel.getSnapshot());
|
|
35726
|
+
const prevMeta = Tools21.deepClone(sdtService.getTemplateMetadata(unitId));
|
|
35727
|
+
const workingSnap = Tools21.deepClone(prevSnap);
|
|
33881
35728
|
writeDocTemplateMetadataToSnapshot(workingSnap, prevMeta);
|
|
33882
35729
|
const converted = convertSelectedTextToTableInSnapshot(workingSnap, {
|
|
33883
35730
|
text: params?.text,
|
|
@@ -33919,9 +35766,9 @@ var ConvertTableToTextCommand = {
|
|
|
33919
35766
|
} catch {
|
|
33920
35767
|
}
|
|
33921
35768
|
}
|
|
33922
|
-
const prevSnap =
|
|
33923
|
-
const prevMeta =
|
|
33924
|
-
const workingSnap =
|
|
35769
|
+
const prevSnap = Tools21.deepClone(docModel.getSnapshot());
|
|
35770
|
+
const prevMeta = Tools21.deepClone(sdtService.getTemplateMetadata(unitId));
|
|
35771
|
+
const workingSnap = Tools21.deepClone(prevSnap);
|
|
33925
35772
|
writeDocTemplateMetadataToSnapshot(workingSnap, prevMeta);
|
|
33926
35773
|
const converted = convertDocTableToTextInSnapshot(
|
|
33927
35774
|
workingSnap,
|
|
@@ -33951,9 +35798,9 @@ var SetDocTableCellFormulaCommand = {
|
|
|
33951
35798
|
const unitId = docModel.getUnitId();
|
|
33952
35799
|
const sdtService = accessor.get(IDocSdtService);
|
|
33953
35800
|
if (sdtService.getDocMode(unitId) === "view") return false;
|
|
33954
|
-
const prevSnap =
|
|
33955
|
-
const prevMeta =
|
|
33956
|
-
const workingSnap =
|
|
35801
|
+
const prevSnap = Tools21.deepClone(docModel.getSnapshot());
|
|
35802
|
+
const prevMeta = Tools21.deepClone(sdtService.getTemplateMetadata(unitId));
|
|
35803
|
+
const workingSnap = Tools21.deepClone(prevSnap);
|
|
33957
35804
|
writeDocTemplateMetadataToSnapshot(workingSnap, prevMeta);
|
|
33958
35805
|
const updated = setDocTableCellFormulaInSnapshot(
|
|
33959
35806
|
workingSnap,
|
|
@@ -33981,9 +35828,9 @@ var RecalculateDocTableFormulasCommand = {
|
|
|
33981
35828
|
const unitId = docModel.getUnitId();
|
|
33982
35829
|
const sdtService = accessor.get(IDocSdtService);
|
|
33983
35830
|
if (sdtService.getDocMode(unitId) === "view") return false;
|
|
33984
|
-
const prevSnap =
|
|
33985
|
-
const prevMeta =
|
|
33986
|
-
const workingSnap =
|
|
35831
|
+
const prevSnap = Tools21.deepClone(docModel.getSnapshot());
|
|
35832
|
+
const prevMeta = Tools21.deepClone(sdtService.getTemplateMetadata(unitId));
|
|
35833
|
+
const workingSnap = Tools21.deepClone(prevSnap);
|
|
33987
35834
|
writeDocTemplateMetadataToSnapshot(workingSnap, prevMeta);
|
|
33988
35835
|
const recalculated = recalculateDocTableFormulas(workingSnap);
|
|
33989
35836
|
sdtService.setTemplateMetadata(unitId, readDocTemplateMetadataFromSnapshot(recalculated));
|
|
@@ -34038,16 +35885,16 @@ function syncDocDrawingsToUniverServices(injector, unitId, snapshot) {
|
|
|
34038
35885
|
normalizeDocDrawingsAndPluginResource(snapshot);
|
|
34039
35886
|
const accessor = injector;
|
|
34040
35887
|
const docModel = getTargetDocModel(accessor, unitId);
|
|
34041
|
-
const nextDrawings =
|
|
34042
|
-
const nextOrder =
|
|
35888
|
+
const nextDrawings = Tools22.deepClone(snapshot.drawings ?? {});
|
|
35889
|
+
const nextOrder = Tools22.deepClone(snapshot.drawingsOrder ?? []);
|
|
34043
35890
|
if (docModel) {
|
|
34044
35891
|
const liveSnap = docModel.getSnapshot();
|
|
34045
|
-
liveSnap.drawings =
|
|
34046
|
-
liveSnap.drawingsOrder =
|
|
35892
|
+
liveSnap.drawings = Tools22.deepClone(nextDrawings);
|
|
35893
|
+
liveSnap.drawingsOrder = Tools22.deepClone(nextOrder);
|
|
34047
35894
|
if (snapshot.resources !== void 0) {
|
|
34048
|
-
liveSnap.resources =
|
|
35895
|
+
liveSnap.resources = Tools22.deepClone(snapshot.resources);
|
|
34049
35896
|
}
|
|
34050
|
-
docModel.resetDrawing?.(
|
|
35897
|
+
docModel.resetDrawing?.(Tools22.deepClone(nextDrawings), Tools22.deepClone(nextOrder));
|
|
34051
35898
|
}
|
|
34052
35899
|
try {
|
|
34053
35900
|
const resourceManagerService = accessor.get(IResourceManagerService);
|
|
@@ -34055,8 +35902,8 @@ function syncDocDrawingsToUniverServices(injector, unitId, snapshot) {
|
|
|
34055
35902
|
if (hook) {
|
|
34056
35903
|
if (Object.keys(nextDrawings).length > 0) {
|
|
34057
35904
|
hook.onLoad(unitId, {
|
|
34058
|
-
data:
|
|
34059
|
-
order:
|
|
35905
|
+
data: Tools22.deepClone(nextDrawings),
|
|
35906
|
+
order: Tools22.deepClone(nextOrder)
|
|
34060
35907
|
});
|
|
34061
35908
|
} else {
|
|
34062
35909
|
hook.onUnLoad?.(unitId);
|
|
@@ -34068,43 +35915,43 @@ function syncDocDrawingsToUniverServices(injector, unitId, snapshot) {
|
|
|
34068
35915
|
function syncSnapshotAuxFields(docModel, nextSnapshot) {
|
|
34069
35916
|
const liveSnap = docModel.getSnapshot();
|
|
34070
35917
|
if (nextSnapshot.tableSource !== void 0) {
|
|
34071
|
-
liveSnap.tableSource =
|
|
35918
|
+
liveSnap.tableSource = Tools22.deepClone(nextSnapshot.tableSource);
|
|
34072
35919
|
}
|
|
34073
35920
|
if (nextSnapshot.headers !== void 0) {
|
|
34074
|
-
liveSnap.headers =
|
|
35921
|
+
liveSnap.headers = Tools22.deepClone(nextSnapshot.headers);
|
|
34075
35922
|
}
|
|
34076
35923
|
if (nextSnapshot.footers !== void 0) {
|
|
34077
|
-
liveSnap.footers =
|
|
35924
|
+
liveSnap.footers = Tools22.deepClone(nextSnapshot.footers);
|
|
34078
35925
|
}
|
|
34079
35926
|
if (nextSnapshot.notes !== void 0) {
|
|
34080
|
-
liveSnap.notes =
|
|
35927
|
+
liveSnap.notes = Tools22.deepClone(nextSnapshot.notes);
|
|
34081
35928
|
}
|
|
34082
35929
|
if (nextSnapshot.noteSettings !== void 0) {
|
|
34083
|
-
liveSnap.noteSettings =
|
|
35930
|
+
liveSnap.noteSettings = Tools22.deepClone(nextSnapshot.noteSettings);
|
|
34084
35931
|
}
|
|
34085
35932
|
if (nextSnapshot.footnotes !== void 0) {
|
|
34086
|
-
liveSnap.footnotes =
|
|
35933
|
+
liveSnap.footnotes = Tools22.deepClone(nextSnapshot.footnotes);
|
|
34087
35934
|
}
|
|
34088
35935
|
if (nextSnapshot.endnotes !== void 0) {
|
|
34089
|
-
liveSnap.endnotes =
|
|
35936
|
+
liveSnap.endnotes = Tools22.deepClone(nextSnapshot.endnotes);
|
|
34090
35937
|
}
|
|
34091
35938
|
if (nextSnapshot.drawings !== void 0) {
|
|
34092
|
-
liveSnap.drawings =
|
|
35939
|
+
liveSnap.drawings = Tools22.deepClone(nextSnapshot.drawings);
|
|
34093
35940
|
}
|
|
34094
35941
|
if (nextSnapshot.drawingsOrder !== void 0) {
|
|
34095
|
-
liveSnap.drawingsOrder =
|
|
35942
|
+
liveSnap.drawingsOrder = Tools22.deepClone(nextSnapshot.drawingsOrder);
|
|
34096
35943
|
}
|
|
34097
35944
|
if (nextSnapshot.lists !== void 0) {
|
|
34098
|
-
liveSnap.lists =
|
|
35945
|
+
liveSnap.lists = Tools22.deepClone(nextSnapshot.lists);
|
|
34099
35946
|
}
|
|
34100
35947
|
if (nextSnapshot.styles !== void 0) {
|
|
34101
|
-
liveSnap.styles =
|
|
35948
|
+
liveSnap.styles = Tools22.deepClone(nextSnapshot.styles);
|
|
34102
35949
|
}
|
|
34103
35950
|
if (nextSnapshot.resources !== void 0) {
|
|
34104
|
-
liveSnap.resources =
|
|
35951
|
+
liveSnap.resources = Tools22.deepClone(nextSnapshot.resources);
|
|
34105
35952
|
}
|
|
34106
35953
|
if (nextSnapshot.documentStyle) {
|
|
34107
|
-
liveSnap.documentStyle =
|
|
35954
|
+
liveSnap.documentStyle = Tools22.deepClone(nextSnapshot.documentStyle);
|
|
34108
35955
|
}
|
|
34109
35956
|
if (nextSnapshot.headers !== void 0 || nextSnapshot.footers !== void 0) {
|
|
34110
35957
|
reinitializeDocHeaderFooterModels(docModel);
|
|
@@ -34120,7 +35967,7 @@ function executeBodyUpdateViaRichTextMutation(accessor, docModel, nextBody, curs
|
|
|
34120
35967
|
const prevSnap = docModel.getSnapshot();
|
|
34121
35968
|
const prevBody = prevSnap.body;
|
|
34122
35969
|
if (!prevBody) return false;
|
|
34123
|
-
const bodyEqual =
|
|
35970
|
+
const bodyEqual = Tools22.diffValue(prevBody, nextBody);
|
|
34124
35971
|
if (bodyEqual && !forceRecalculate) return true;
|
|
34125
35972
|
const wasDisabled = Boolean(prevSnap.disabled);
|
|
34126
35973
|
if (allowInViewMode && wasDisabled) {
|
|
@@ -34129,8 +35976,8 @@ function executeBodyUpdateViaRichTextMutation(accessor, docModel, nextBody, curs
|
|
|
34129
35976
|
try {
|
|
34130
35977
|
if (bodyEqual && forceRecalculate) {
|
|
34131
35978
|
const tempBody = {
|
|
34132
|
-
...
|
|
34133
|
-
payloads: { ...prevBody.payloads ?? {}, __recalc:
|
|
35979
|
+
...Tools22.deepClone(prevBody),
|
|
35980
|
+
payloads: { ...prevBody.payloads ?? {}, __recalc: generateRandomId17(4) }
|
|
34134
35981
|
};
|
|
34135
35982
|
const recalcUnlockOp = buildBodyReplaceEditOp(prevBody, tempBody);
|
|
34136
35983
|
if (recalcUnlockOp) {
|
|
@@ -34147,7 +35994,7 @@ function executeBodyUpdateViaRichTextMutation(accessor, docModel, nextBody, curs
|
|
|
34147
35994
|
(r) => r.rangeType === CustomRangeType14.SDT && r.properties?.lock && r.properties.lock !== "unlocked"
|
|
34148
35995
|
);
|
|
34149
35996
|
if (hasLockedSdt) {
|
|
34150
|
-
const unlockedBody =
|
|
35997
|
+
const unlockedBody = Tools22.deepClone(liveBeforeLockCheck);
|
|
34151
35998
|
unlockedBody.customRanges = (unlockedBody.customRanges ?? []).map(
|
|
34152
35999
|
(r) => r.rangeType === CustomRangeType14.SDT ? {
|
|
34153
36000
|
...r,
|
|
@@ -34258,7 +36105,7 @@ var InsertDocSdtCommand = {
|
|
|
34258
36105
|
typeof wrapEndOffset === "number" && wrapEndOffset > insertOffset ? { wrapEndOffset } : void 0
|
|
34259
36106
|
);
|
|
34260
36107
|
if (targetSegmentId && targetBody !== liveSnap.body) {
|
|
34261
|
-
const clonedSnap =
|
|
36108
|
+
const clonedSnap = Tools22.deepClone(liveSnap);
|
|
34262
36109
|
writeSegmentBodyInSnapshot(clonedSnap, insertedBody, targetSegmentId);
|
|
34263
36110
|
if (isImgInitial) {
|
|
34264
36111
|
const insertedRange = insertedBody.customRanges?.find((r) => r.rangeId === controlId);
|
|
@@ -34280,7 +36127,7 @@ var InsertDocSdtCommand = {
|
|
|
34280
36127
|
let finalBody = insertedBody;
|
|
34281
36128
|
let finalCursor = endOffset;
|
|
34282
36129
|
if (isImgInitial) {
|
|
34283
|
-
const clonedSnap = { ...
|
|
36130
|
+
const clonedSnap = { ...Tools22.deepClone(liveSnap), body: insertedBody };
|
|
34284
36131
|
const insertedRange = insertedBody.customRanges?.find((r) => r.rangeId === controlId);
|
|
34285
36132
|
const resolved = insertedRange ? parseSdtRangeToResolved(insertedBody, insertedRange) : null;
|
|
34286
36133
|
if (resolved && applyPictureOrSignatureSdtValueInSnapshot(clonedSnap, resolved, String(params.initialValue))) {
|
|
@@ -34325,7 +36172,7 @@ var UpdateDocSdtValueCommand = {
|
|
|
34325
36172
|
return false;
|
|
34326
36173
|
}
|
|
34327
36174
|
if (hitSegmentId && prevBody !== liveSnap.body) {
|
|
34328
|
-
const clonedSnap =
|
|
36175
|
+
const clonedSnap = Tools22.deepClone(liveSnap);
|
|
34329
36176
|
if (resolved.kind === "picture" || resolved.kind === "signature") {
|
|
34330
36177
|
applyPictureOrSignatureSdtValueInSnapshot(
|
|
34331
36178
|
clonedSnap,
|
|
@@ -34383,8 +36230,8 @@ var UpdateDocSdtValueCommand = {
|
|
|
34383
36230
|
});
|
|
34384
36231
|
return true;
|
|
34385
36232
|
}
|
|
34386
|
-
const baseMeta =
|
|
34387
|
-
const workingSnap =
|
|
36233
|
+
const baseMeta = Tools22.deepClone(sdtService.getTemplateMetadata(unitId));
|
|
36234
|
+
const workingSnap = Tools22.deepClone(liveSnap);
|
|
34388
36235
|
let approxNewLen = 1;
|
|
34389
36236
|
if (resolved.kind === "picture" || resolved.kind === "signature") {
|
|
34390
36237
|
applyPictureOrSignatureSdtValueInSnapshot(
|
|
@@ -34501,7 +36348,7 @@ var UpdateDocSdtPropertiesCommand = {
|
|
|
34501
36348
|
};
|
|
34502
36349
|
const hasEmbeddedBlock = prevBody.dataStream.slice(targetRange.startIndex, targetRange.endIndex + 1).includes("\b");
|
|
34503
36350
|
if (mergedSpec.kind === "group" || (mergedSpec.kind === "picture" || mergedSpec.kind === "signature") && hasEmbeddedBlock) {
|
|
34504
|
-
const nextBody2 =
|
|
36351
|
+
const nextBody2 = Tools22.deepClone(prevBody);
|
|
34505
36352
|
const nextProps2 = buildSdtPropertiesFromSpec(
|
|
34506
36353
|
mergedSpec,
|
|
34507
36354
|
current.showingPlaceholder,
|
|
@@ -34511,7 +36358,7 @@ var UpdateDocSdtPropertiesCommand = {
|
|
|
34511
36358
|
(r) => r.rangeId === current.id ? { ...r, properties: nextProps2 } : r
|
|
34512
36359
|
);
|
|
34513
36360
|
if (hitSegmentId && prevBody !== liveSnap.body) {
|
|
34514
|
-
const clonedSnap =
|
|
36361
|
+
const clonedSnap = Tools22.deepClone(liveSnap);
|
|
34515
36362
|
writeSegmentBodyInSnapshot(clonedSnap, nextBody2, hitSegmentId);
|
|
34516
36363
|
syncSnapshotAuxFields(docModel, clonedSnap);
|
|
34517
36364
|
sdtService.bumpRevision();
|
|
@@ -34558,15 +36405,15 @@ var UpdateDocSdtPropertiesCommand = {
|
|
|
34558
36405
|
}
|
|
34559
36406
|
);
|
|
34560
36407
|
if (hitSegmentId && prevBody !== liveSnap.body) {
|
|
34561
|
-
const clonedSnap =
|
|
36408
|
+
const clonedSnap = Tools22.deepClone(liveSnap);
|
|
34562
36409
|
writeSegmentBodyInSnapshot(clonedSnap, nextBody, hitSegmentId);
|
|
34563
36410
|
syncSnapshotAuxFields(docModel, clonedSnap);
|
|
34564
36411
|
sdtService.bumpRevision();
|
|
34565
36412
|
return true;
|
|
34566
36413
|
}
|
|
34567
|
-
const baseMeta =
|
|
36414
|
+
const baseMeta = Tools22.deepClone(sdtService.getTemplateMetadata(unitId));
|
|
34568
36415
|
const workingSnap = {
|
|
34569
|
-
...
|
|
36416
|
+
...Tools22.deepClone(liveSnap),
|
|
34570
36417
|
body: nextBody
|
|
34571
36418
|
};
|
|
34572
36419
|
writeDocTemplateMetadataToSnapshot(workingSnap, baseMeta);
|
|
@@ -34602,10 +36449,10 @@ var DeleteDocSdtCommand = {
|
|
|
34602
36449
|
return false;
|
|
34603
36450
|
}
|
|
34604
36451
|
if (hitSegmentId && prevBody !== liveSnap.body) {
|
|
34605
|
-
const clonedSnap =
|
|
36452
|
+
const clonedSnap = Tools22.deepClone(liveSnap);
|
|
34606
36453
|
let nextSegBody;
|
|
34607
36454
|
if (params.keepText) {
|
|
34608
|
-
nextSegBody =
|
|
36455
|
+
nextSegBody = Tools22.deepClone(prevBody);
|
|
34609
36456
|
nextSegBody.customRanges = (nextSegBody.customRanges ?? []).filter(
|
|
34610
36457
|
(r) => r.rangeId !== params.controlId
|
|
34611
36458
|
);
|
|
@@ -34623,11 +36470,11 @@ var DeleteDocSdtCommand = {
|
|
|
34623
36470
|
sdtService.bumpRevision();
|
|
34624
36471
|
return true;
|
|
34625
36472
|
}
|
|
34626
|
-
const unlockedPrev =
|
|
36473
|
+
const unlockedPrev = Tools22.deepClone(prevBody);
|
|
34627
36474
|
unlockedPrev.customRanges = (unlockedPrev.customRanges ?? []).map(
|
|
34628
36475
|
(r) => r.rangeId === params.controlId ? { ...r, properties: { ...r.properties, lock: "unlocked" } } : r
|
|
34629
36476
|
);
|
|
34630
|
-
if (!
|
|
36477
|
+
if (!Tools22.diffValue(prevBody, unlockedPrev)) {
|
|
34631
36478
|
const unlockOp = buildBodyReplaceEditOp(prevBody, unlockedPrev);
|
|
34632
36479
|
accessor.get(ICommandService4).syncExecuteCommand(RichTextEditingMutation2.id, {
|
|
34633
36480
|
unitId: docModel.getUnitId(),
|
|
@@ -34639,7 +36486,7 @@ var DeleteDocSdtCommand = {
|
|
|
34639
36486
|
const baseBody = docModel.getSnapshot().body;
|
|
34640
36487
|
let nextBody;
|
|
34641
36488
|
if (params.keepText) {
|
|
34642
|
-
nextBody =
|
|
36489
|
+
nextBody = Tools22.deepClone(baseBody);
|
|
34643
36490
|
nextBody.customRanges = (nextBody.customRanges ?? []).filter((r) => r.rangeId !== params.controlId);
|
|
34644
36491
|
} else {
|
|
34645
36492
|
nextBody = spliceDocumentBodySpan(baseBody, targetRange.startIndex, targetRange.endIndex, "");
|
|
@@ -34662,9 +36509,9 @@ var FillDocDatasetCommand = {
|
|
|
34662
36509
|
const sdtService = accessor.get(IDocSdtService);
|
|
34663
36510
|
if (sdtService.getDocMode(docModel.getUnitId()) === "view") return false;
|
|
34664
36511
|
const unitId = docModel.getUnitId();
|
|
34665
|
-
const prevMeta =
|
|
34666
|
-
const prevSnap =
|
|
34667
|
-
const baseSnap =
|
|
36512
|
+
const prevMeta = Tools22.deepClone(sdtService.getTemplateMetadata(unitId));
|
|
36513
|
+
const prevSnap = Tools22.deepClone(docModel.getSnapshot());
|
|
36514
|
+
const baseSnap = Tools22.deepClone(prevSnap);
|
|
34668
36515
|
writeDocTemplateMetadataToSnapshot(baseSnap, prevMeta);
|
|
34669
36516
|
const filledSnapshot = fillDatasetIntoDocSnapshot(baseSnap, params.data, {
|
|
34670
36517
|
tableRowLoops: prevMeta.tableRowLoops
|
|
@@ -34698,8 +36545,8 @@ function restoreDocUnitStateOnFailure(accessor, docModel, unitId, prevSnapClone,
|
|
|
34698
36545
|
const sdtService = accessor.get(IDocSdtService);
|
|
34699
36546
|
try {
|
|
34700
36547
|
const curBody = docModel.getSnapshot().body;
|
|
34701
|
-
if (curBody && prevSnapClone.body && !
|
|
34702
|
-
const revertActions = buildBodyReplaceEditOp(curBody,
|
|
36548
|
+
if (curBody && prevSnapClone.body && !Tools22.diffValue(curBody, prevSnapClone.body)) {
|
|
36549
|
+
const revertActions = buildBodyReplaceEditOp(curBody, Tools22.deepClone(prevSnapClone.body));
|
|
34703
36550
|
if (revertActions) {
|
|
34704
36551
|
const liveRef = docModel.getSnapshot();
|
|
34705
36552
|
const wasDisabled = Boolean(liveRef.disabled);
|
|
@@ -34719,12 +36566,12 @@ function restoreDocUnitStateOnFailure(accessor, docModel, unitId, prevSnapClone,
|
|
|
34719
36566
|
} catch {
|
|
34720
36567
|
}
|
|
34721
36568
|
try {
|
|
34722
|
-
syncDocDrawingsToUniverServices(accessor, unitId,
|
|
36569
|
+
syncDocDrawingsToUniverServices(accessor, unitId, Tools22.deepClone(prevSnapClone));
|
|
34723
36570
|
} catch {
|
|
34724
36571
|
}
|
|
34725
|
-
sdtService.setTemplateMetadata(unitId,
|
|
36572
|
+
sdtService.setTemplateMetadata(unitId, Tools22.deepClone(prevMetaClone));
|
|
34726
36573
|
const liveSnap = docModel.getSnapshot();
|
|
34727
|
-
const exactPrev =
|
|
36574
|
+
const exactPrev = Tools22.deepClone(prevSnapClone);
|
|
34728
36575
|
for (const key of Object.keys(liveSnap)) {
|
|
34729
36576
|
if (!(key in exactPrev)) {
|
|
34730
36577
|
delete liveSnap[key];
|
|
@@ -34746,10 +36593,10 @@ var ReplaceDocUnitSnapshotCommand = {
|
|
|
34746
36593
|
if (!allowInViewMode && sdtService.getDocMode(unitId) === "view") {
|
|
34747
36594
|
return false;
|
|
34748
36595
|
}
|
|
34749
|
-
const prevSnapClone =
|
|
34750
|
-
const prevMetaClone =
|
|
36596
|
+
const prevSnapClone = Tools22.deepClone(docModel.getSnapshot());
|
|
36597
|
+
const prevMetaClone = Tools22.deepClone(sdtService.getTemplateMetadata(unitId));
|
|
34751
36598
|
try {
|
|
34752
|
-
const normalizedSnap =
|
|
36599
|
+
const normalizedSnap = Tools22.deepClone(params.snapshot);
|
|
34753
36600
|
if (!normalizedSnap.id) {
|
|
34754
36601
|
normalizedSnap.id = unitId;
|
|
34755
36602
|
}
|
|
@@ -34757,7 +36604,7 @@ var ReplaceDocUnitSnapshotCommand = {
|
|
|
34757
36604
|
if (!isValidReplacementDocSnapshot(normalizedSnap)) {
|
|
34758
36605
|
return false;
|
|
34759
36606
|
}
|
|
34760
|
-
const auxChanged = normalizedSnap.headers !== void 0 && !
|
|
36607
|
+
const auxChanged = normalizedSnap.headers !== void 0 && !Tools22.diffValue(prevSnapClone.headers ?? {}, normalizedSnap.headers ?? {}) || normalizedSnap.footers !== void 0 && !Tools22.diffValue(prevSnapClone.footers ?? {}, normalizedSnap.footers ?? {}) || normalizedSnap.drawings !== void 0 && !Tools22.diffValue(prevSnapClone.drawings ?? {}, normalizedSnap.drawings ?? {}) || normalizedSnap.drawingsOrder !== void 0 && !Tools22.diffValue(prevSnapClone.drawingsOrder ?? [], normalizedSnap.drawingsOrder ?? []) || normalizedSnap.documentStyle !== void 0 && !Tools22.diffValue(prevSnapClone.documentStyle ?? {}, normalizedSnap.documentStyle ?? {}) || normalizedSnap.styles !== void 0 && !Tools22.diffValue(prevSnapClone.styles ?? {}, normalizedSnap.styles ?? {}) || normalizedSnap.tableSource !== void 0 && !Tools22.diffValue(prevSnapClone.tableSource ?? {}, normalizedSnap.tableSource ?? {});
|
|
34761
36608
|
syncSnapshotAuxFields(docModel, normalizedSnap);
|
|
34762
36609
|
reinitializeDocHeaderFooterModels(docModel);
|
|
34763
36610
|
syncDocDrawingsToUniverServices(accessor, unitId, normalizedSnap);
|
|
@@ -34985,7 +36832,7 @@ var InsertDocMedicalFormulaCommand = {
|
|
|
34985
36832
|
const sdtService = accessor.get(IDocSdtService);
|
|
34986
36833
|
if (sdtService.getDocMode(unitId) === "view") return false;
|
|
34987
36834
|
const layout = layoutMedicalFormulaWidget(params.spec);
|
|
34988
|
-
const prevMeta =
|
|
36835
|
+
const prevMeta = Tools22.deepClone(sdtService.getTemplateMetadata(unitId));
|
|
34989
36836
|
const liveSnap = docModel.getSnapshot();
|
|
34990
36837
|
if (params.blockId && liveSnap.drawings?.[params.blockId]) {
|
|
34991
36838
|
const drw = liveSnap.drawings[params.blockId];
|
|
@@ -35005,7 +36852,7 @@ var InsertDocMedicalFormulaCommand = {
|
|
|
35005
36852
|
...prevMeta.medicalFormulas ?? {},
|
|
35006
36853
|
[params.blockId]: {
|
|
35007
36854
|
blockId: params.blockId,
|
|
35008
|
-
spec:
|
|
36855
|
+
spec: Tools22.deepClone(params.spec),
|
|
35009
36856
|
widthPt: layout.widthPt,
|
|
35010
36857
|
heightPt: layout.heightPt,
|
|
35011
36858
|
plainSummary: layout.plainSummary
|
|
@@ -35038,7 +36885,7 @@ var InsertDocMedicalFormulaCommand = {
|
|
|
35038
36885
|
...prevMeta.medicalFormulas ?? {},
|
|
35039
36886
|
[inserted.blockId]: {
|
|
35040
36887
|
blockId: inserted.blockId,
|
|
35041
|
-
spec:
|
|
36888
|
+
spec: Tools22.deepClone(params.spec),
|
|
35042
36889
|
widthPt: layout.widthPt,
|
|
35043
36890
|
heightPt: layout.heightPt,
|
|
35044
36891
|
plainSummary: layout.plainSummary
|
|
@@ -35079,7 +36926,7 @@ var InsertDocCodeBlockCommand = {
|
|
|
35079
36926
|
offset
|
|
35080
36927
|
);
|
|
35081
36928
|
const insertedLen = inserted.entry.endIndex - inserted.entry.startIndex;
|
|
35082
|
-
const prevMeta =
|
|
36929
|
+
const prevMeta = Tools22.deepClone(sdtService.getTemplateMetadata(unitId));
|
|
35083
36930
|
if (prevMeta.revisions?.length && insertedLen > 0) {
|
|
35084
36931
|
prevMeta.revisions = shiftTrackRevisions(
|
|
35085
36932
|
prevMeta.revisions,
|
|
@@ -35116,7 +36963,7 @@ var InsertDocQrOrBarcodeBlockCommand = {
|
|
|
35116
36963
|
const unitId = docModel.getUnitId();
|
|
35117
36964
|
const sdtService = accessor.get(IDocSdtService);
|
|
35118
36965
|
if (sdtService.getDocMode(unitId) === "view") return false;
|
|
35119
|
-
const prevMeta =
|
|
36966
|
+
const prevMeta = Tools22.deepClone(sdtService.getTemplateMetadata(unitId));
|
|
35120
36967
|
const widthPt = params.spec.widthPt ?? (params.spec.kind === "barcode" ? 140 : 68);
|
|
35121
36968
|
const heightPt = params.spec.heightPt ?? (params.spec.kind === "barcode" ? 44 : 68);
|
|
35122
36969
|
const dataUri = buildQrOrBarcodeDataUri(params.spec, prevMeta.sampleData);
|
|
@@ -35143,7 +36990,7 @@ var InsertDocQrOrBarcodeBlockCommand = {
|
|
|
35143
36990
|
...prevMeta.barcodeBlocks ?? {},
|
|
35144
36991
|
[inserted.blockId]: {
|
|
35145
36992
|
blockId: inserted.blockId,
|
|
35146
|
-
spec:
|
|
36993
|
+
spec: Tools22.deepClone(params.spec),
|
|
35147
36994
|
widthPt,
|
|
35148
36995
|
heightPt
|
|
35149
36996
|
}
|
|
@@ -35165,13 +37012,13 @@ var InsertDocQrOrBarcodeBlockCommand = {
|
|
|
35165
37012
|
// src/exporter/doc-markdown.ts
|
|
35166
37013
|
import {
|
|
35167
37014
|
CustomRangeType as CustomRangeType15,
|
|
35168
|
-
DataStreamTreeTokenType as
|
|
35169
|
-
generateRandomId as
|
|
37015
|
+
DataStreamTreeTokenType as DataStreamTreeTokenType16,
|
|
37016
|
+
generateRandomId as generateRandomId18,
|
|
35170
37017
|
NumberUnitType as NumberUnitType8,
|
|
35171
37018
|
TableAlignmentType as TableAlignmentType4,
|
|
35172
37019
|
TableRowHeightRule as TableRowHeightRule6,
|
|
35173
37020
|
TableTextWrapType as TableTextWrapType4,
|
|
35174
|
-
Tools as
|
|
37021
|
+
Tools as Tools23
|
|
35175
37022
|
} from "@univerjs/core";
|
|
35176
37023
|
var GFM_CALLOUT_PRESETS = {
|
|
35177
37024
|
NOTE: { preset: "info", bg: "#F3F5FF", border: "#2C53F1", text: "#1B1C1F" },
|
|
@@ -35216,9 +37063,9 @@ function emitMarkdownInlineSegments(rawLine, baseStyle, ctx) {
|
|
|
35216
37063
|
if (imgMatch) {
|
|
35217
37064
|
const alt = imgMatch[1] || "";
|
|
35218
37065
|
const src = imgMatch[2] || "";
|
|
35219
|
-
const blockId = `md_img_${
|
|
37066
|
+
const blockId = `md_img_${generateRandomId18(6)}`;
|
|
35220
37067
|
const st = ctx.getOffset();
|
|
35221
|
-
ctx.appendStream(
|
|
37068
|
+
ctx.appendStream(DataStreamTreeTokenType16.CUSTOM_BLOCK);
|
|
35222
37069
|
ctx.pushCustomBlock(st, blockId);
|
|
35223
37070
|
const dataUri = src.startsWith("data:image/") ? src : buildPlaceholderImageDataUri(alt, src);
|
|
35224
37071
|
ctx.registerDrawing(blockId, {
|
|
@@ -35267,7 +37114,7 @@ function emitMarkdownInlineSegments(rawLine, baseStyle, ctx) {
|
|
|
35267
37114
|
const ed = ctx.getOffset();
|
|
35268
37115
|
if (ed > st) {
|
|
35269
37116
|
ctx.pushRange({
|
|
35270
|
-
rangeId: `lnk_${
|
|
37117
|
+
rangeId: `lnk_${generateRandomId18(6)}`,
|
|
35271
37118
|
rangeType: CustomRangeType15.HYPERLINK,
|
|
35272
37119
|
startIndex: st,
|
|
35273
37120
|
endIndex: ed - 1,
|
|
@@ -35316,10 +37163,10 @@ function emitMarkdownInlineSegments(rawLine, baseStyle, ctx) {
|
|
|
35316
37163
|
if (closeIdx > searchFrom) {
|
|
35317
37164
|
const latex = rawLine.slice(searchFrom, closeIdx).trim();
|
|
35318
37165
|
if (latex) {
|
|
35319
|
-
const id = `ltx_${
|
|
37166
|
+
const id = `ltx_${generateRandomId18(6)}`;
|
|
35320
37167
|
const rendered = layoutLatexFormulaWidget(latex, { displayMode: isDouble });
|
|
35321
37168
|
const st = ctx.getOffset();
|
|
35322
|
-
ctx.appendStream(
|
|
37169
|
+
ctx.appendStream(DataStreamTreeTokenType16.CUSTOM_BLOCK);
|
|
35323
37170
|
ctx.pushCustomBlock(st, id);
|
|
35324
37171
|
const spec = {
|
|
35325
37172
|
id,
|
|
@@ -35362,7 +37209,7 @@ function emitMarkdownInlineSegments(rawLine, baseStyle, ctx) {
|
|
|
35362
37209
|
properties: {
|
|
35363
37210
|
yudaoBlockKind: "latexFormula",
|
|
35364
37211
|
blockId: id,
|
|
35365
|
-
spec:
|
|
37212
|
+
spec: Tools23.deepClone(spec)
|
|
35366
37213
|
}
|
|
35367
37214
|
});
|
|
35368
37215
|
i = closeIdx + delim.length;
|
|
@@ -35462,7 +37309,7 @@ function isGfmSeparatorRow(line) {
|
|
|
35462
37309
|
return aligns;
|
|
35463
37310
|
}
|
|
35464
37311
|
function importMarkdownToDocData(markdown, title = "Markdown Document") {
|
|
35465
|
-
const unitId = `doc_${
|
|
37312
|
+
const unitId = `doc_${generateRandomId18(6)}`;
|
|
35466
37313
|
const rawLines = (markdown ?? "").replace(/\r\n/g, "\n").replace(/\r/g, "\n").split("\n");
|
|
35467
37314
|
let resolvedTitle = title;
|
|
35468
37315
|
let dataStream = "";
|
|
@@ -35503,8 +37350,8 @@ function importMarkdownToDocData(markdown, title = "Markdown Document") {
|
|
|
35503
37350
|
};
|
|
35504
37351
|
const finishParagraph = (paragraphStyle, bullet) => {
|
|
35505
37352
|
const pIdx = dataStream.length;
|
|
35506
|
-
dataStream +=
|
|
35507
|
-
const pId = `p_${
|
|
37353
|
+
dataStream += DataStreamTreeTokenType16.PARAGRAPH;
|
|
37354
|
+
const pId = `p_${generateRandomId18(6)}`;
|
|
35508
37355
|
paragraphs.push({
|
|
35509
37356
|
startIndex: pIdx,
|
|
35510
37357
|
paragraphId: pId,
|
|
@@ -35550,10 +37397,10 @@ function importMarkdownToDocData(markdown, title = "Markdown Document") {
|
|
|
35550
37397
|
mathContent = mathLines.join("\n").trim();
|
|
35551
37398
|
}
|
|
35552
37399
|
if (mathContent) {
|
|
35553
|
-
const id = `ltx_${
|
|
37400
|
+
const id = `ltx_${generateRandomId18(6)}`;
|
|
35554
37401
|
const rendered = layoutLatexFormulaWidget(mathContent, { displayMode: true });
|
|
35555
37402
|
const st = dataStream.length;
|
|
35556
|
-
dataStream +=
|
|
37403
|
+
dataStream += DataStreamTreeTokenType16.CUSTOM_BLOCK;
|
|
35557
37404
|
customBlocks.push({ startIndex: st, blockId: id, blockType: 0 });
|
|
35558
37405
|
const spec = {
|
|
35559
37406
|
id,
|
|
@@ -35646,7 +37493,7 @@ function importMarkdownToDocData(markdown, title = "Markdown Document") {
|
|
|
35646
37493
|
finishParagraph({ spaceAbove: { v: idx === 0 ? 4 : 0 }, spaceBelow: { v: 0 } });
|
|
35647
37494
|
});
|
|
35648
37495
|
codeBlocksMeta.push({
|
|
35649
|
-
id: `code_${
|
|
37496
|
+
id: `code_${generateRandomId18(6)}`,
|
|
35650
37497
|
language: lang,
|
|
35651
37498
|
code: codeLines.join("\n"),
|
|
35652
37499
|
startIndex: blockStart,
|
|
@@ -35699,7 +37546,7 @@ function importMarkdownToDocData(markdown, title = "Markdown Document") {
|
|
|
35699
37546
|
const cStart = dataStream.length;
|
|
35700
37547
|
emitMarkdownInlineSegments(fullText, { cl: { rgb: cfg.text }, fs: 10.5 }, inlineCtx);
|
|
35701
37548
|
const cEnd = Math.max(cStart, dataStream.length - 1);
|
|
35702
|
-
const cId = `callout_${
|
|
37549
|
+
const cId = `callout_${generateRandomId18(6)}`;
|
|
35703
37550
|
const entry = {
|
|
35704
37551
|
id: cId,
|
|
35705
37552
|
preset: cfg.preset,
|
|
@@ -35720,7 +37567,7 @@ function importMarkdownToDocData(markdown, title = "Markdown Document") {
|
|
|
35720
37567
|
properties: {
|
|
35721
37568
|
yudaoBlockKind: "callout",
|
|
35722
37569
|
gfmType: gfmKind,
|
|
35723
|
-
callout:
|
|
37570
|
+
callout: Tools23.deepClone(entry)
|
|
35724
37571
|
}
|
|
35725
37572
|
});
|
|
35726
37573
|
calloutsMeta.push(entry);
|
|
@@ -35737,7 +37584,7 @@ function importMarkdownToDocData(markdown, title = "Markdown Document") {
|
|
|
35737
37584
|
const qStart = dataStream.length;
|
|
35738
37585
|
emitMarkdownInlineSegments(qText, { it: 1, cl: { rgb: "#4E5565" } }, inlineCtx);
|
|
35739
37586
|
const qEnd = Math.max(qStart, dataStream.length - 1);
|
|
35740
|
-
const qId = `quote_${
|
|
37587
|
+
const qId = `quote_${generateRandomId18(6)}`;
|
|
35741
37588
|
const qEntry = {
|
|
35742
37589
|
id: qId,
|
|
35743
37590
|
text: qText,
|
|
@@ -35753,7 +37600,7 @@ function importMarkdownToDocData(markdown, title = "Markdown Document") {
|
|
|
35753
37600
|
endIndex: qEnd,
|
|
35754
37601
|
properties: {
|
|
35755
37602
|
yudaoBlockKind: "quote",
|
|
35756
|
-
quote:
|
|
37603
|
+
quote: Tools23.deepClone(qEntry)
|
|
35757
37604
|
}
|
|
35758
37605
|
});
|
|
35759
37606
|
quotesMeta.push(qEntry);
|
|
@@ -35772,10 +37619,10 @@ function importMarkdownToDocData(markdown, title = "Markdown Document") {
|
|
|
35772
37619
|
}
|
|
35773
37620
|
const colCount = Math.max(1, headerCells.length, aligns.length, ...bodyRows.map((r) => r.length));
|
|
35774
37621
|
const allRows = [headerCells, ...bodyRows];
|
|
35775
|
-
const tableId = `tbl_${
|
|
37622
|
+
const tableId = `tbl_${generateRandomId18(6)}`;
|
|
35776
37623
|
mdTableAligns[tableId] = Array.from({ length: colCount }, (_, c) => aligns[c] ?? "none");
|
|
35777
37624
|
const tblStart = dataStream.length;
|
|
35778
|
-
dataStream +=
|
|
37625
|
+
dataStream += DataStreamTreeTokenType16.TABLE_START;
|
|
35779
37626
|
const tableRows = [];
|
|
35780
37627
|
const colW = Math.floor(460 / colCount);
|
|
35781
37628
|
const cellBorder = {
|
|
@@ -35783,32 +37630,32 @@ function importMarkdownToDocData(markdown, title = "Markdown Document") {
|
|
|
35783
37630
|
width: { v: 1, u: NumberUnitType8.POINT }
|
|
35784
37631
|
};
|
|
35785
37632
|
allRows.forEach((rowCells, rIdx) => {
|
|
35786
|
-
dataStream +=
|
|
37633
|
+
dataStream += DataStreamTreeTokenType16.TABLE_ROW_START;
|
|
35787
37634
|
const cellDefs = [];
|
|
35788
37635
|
for (let cIdx = 0; cIdx < colCount; cIdx++) {
|
|
35789
37636
|
const cellRaw = rowCells[cIdx] ?? "";
|
|
35790
37637
|
const colAlign = aligns[cIdx] ?? "none";
|
|
35791
37638
|
const hAlign = colAlign === "center" ? 2 : colAlign === "right" ? 3 : 1;
|
|
35792
|
-
dataStream +=
|
|
37639
|
+
dataStream += DataStreamTreeTokenType16.TABLE_CELL_START;
|
|
35793
37640
|
emitMarkdownInlineSegments(
|
|
35794
37641
|
cellRaw,
|
|
35795
37642
|
rIdx === 0 ? { bl: 1, cl: { rgb: "#1B1C1F" } } : void 0,
|
|
35796
37643
|
inlineCtx
|
|
35797
37644
|
);
|
|
35798
37645
|
const pPos = dataStream.length;
|
|
35799
|
-
dataStream +=
|
|
37646
|
+
dataStream += DataStreamTreeTokenType16.PARAGRAPH;
|
|
35800
37647
|
paragraphs.push({
|
|
35801
37648
|
startIndex: pPos,
|
|
35802
|
-
paragraphId: `p_tc_${
|
|
37649
|
+
paragraphId: `p_tc_${generateRandomId18(6)}`,
|
|
35803
37650
|
paragraphStyle: { horizontalAlign: hAlign }
|
|
35804
37651
|
});
|
|
35805
37652
|
const sPos = dataStream.length;
|
|
35806
|
-
dataStream +=
|
|
37653
|
+
dataStream += DataStreamTreeTokenType16.SECTION_BREAK;
|
|
35807
37654
|
sectionBreaks.push({
|
|
35808
37655
|
startIndex: sPos,
|
|
35809
|
-
sectionId: `s_tc_${
|
|
37656
|
+
sectionId: `s_tc_${generateRandomId18(6)}`
|
|
35810
37657
|
});
|
|
35811
|
-
dataStream +=
|
|
37658
|
+
dataStream += DataStreamTreeTokenType16.TABLE_CELL_END;
|
|
35812
37659
|
cellDefs.push({
|
|
35813
37660
|
margin: {
|
|
35814
37661
|
start: { v: 8, u: NumberUnitType8.POINT },
|
|
@@ -35825,7 +37672,7 @@ function importMarkdownToDocData(markdown, title = "Markdown Document") {
|
|
|
35825
37672
|
borderRight: cellBorder
|
|
35826
37673
|
});
|
|
35827
37674
|
}
|
|
35828
|
-
dataStream +=
|
|
37675
|
+
dataStream += DataStreamTreeTokenType16.TABLE_ROW_END;
|
|
35829
37676
|
tableRows.push({
|
|
35830
37677
|
tableCells: cellDefs,
|
|
35831
37678
|
trHeight: { val: { v: 24, u: NumberUnitType8.POINT }, hRule: TableRowHeightRule6.AT_LEAST },
|
|
@@ -35833,7 +37680,7 @@ function importMarkdownToDocData(markdown, title = "Markdown Document") {
|
|
|
35833
37680
|
repeatHeaderRow: rIdx === 0 ? 1 : 0
|
|
35834
37681
|
});
|
|
35835
37682
|
});
|
|
35836
|
-
dataStream +=
|
|
37683
|
+
dataStream += DataStreamTreeTokenType16.TABLE_END;
|
|
35837
37684
|
tables.push({
|
|
35838
37685
|
tableId,
|
|
35839
37686
|
startIndex: tblStart,
|
|
@@ -35869,7 +37716,7 @@ function importMarkdownToDocData(markdown, title = "Markdown Document") {
|
|
|
35869
37716
|
const glyphType = taskMatch ? "checkbox" : olMatch ? "decimal" : "bullet";
|
|
35870
37717
|
const itemContent = taskMatch ? taskMatch[3] : ulMatch ? ulMatch[2] : olMatch[3];
|
|
35871
37718
|
if (!activeListId || activeListRootGlyph !== glyphType) {
|
|
35872
|
-
activeListId = `list_${glyphType === "decimal" ? "order" : glyphType}_${
|
|
37719
|
+
activeListId = `list_${glyphType === "decimal" ? "order" : glyphType}_${generateRandomId18(5)}`;
|
|
35873
37720
|
activeListRootGlyph = glyphType;
|
|
35874
37721
|
}
|
|
35875
37722
|
emitMarkdownInlineSegments(itemContent, void 0, inlineCtx);
|
|
@@ -35905,10 +37752,10 @@ function importMarkdownToDocData(markdown, title = "Markdown Document") {
|
|
|
35905
37752
|
finishParagraph();
|
|
35906
37753
|
}
|
|
35907
37754
|
const secIdx = dataStream.length;
|
|
35908
|
-
dataStream +=
|
|
37755
|
+
dataStream += DataStreamTreeTokenType16.SECTION_BREAK;
|
|
35909
37756
|
sectionBreaks.push({
|
|
35910
37757
|
startIndex: secIdx,
|
|
35911
|
-
sectionId: `s_${
|
|
37758
|
+
sectionId: `s_${generateRandomId18(6)}`
|
|
35912
37759
|
});
|
|
35913
37760
|
const docData = {
|
|
35914
37761
|
id: unitId,
|
|
@@ -36002,7 +37849,7 @@ function serializeSpanToMarkdownInline(snapshot, body, start, endExclusive, late
|
|
|
36002
37849
|
cursor = linkRange.endIndex + 1;
|
|
36003
37850
|
continue;
|
|
36004
37851
|
}
|
|
36005
|
-
if (stream[cursor] ===
|
|
37852
|
+
if (stream[cursor] === DataStreamTreeTokenType16.CUSTOM_BLOCK) {
|
|
36006
37853
|
const blk = blocks.find((b) => b.startIndex === cursor);
|
|
36007
37854
|
if (blk) {
|
|
36008
37855
|
const ltx = latexById.get(blk.blockId);
|
|
@@ -36034,7 +37881,7 @@ $$` : `$${ltx.latex}$`;
|
|
|
36034
37881
|
);
|
|
36035
37882
|
const ts = findStyle(cursor);
|
|
36036
37883
|
let runEnd = cursor + 1;
|
|
36037
|
-
while (runEnd < nextSpecial && stream[runEnd] !==
|
|
37884
|
+
while (runEnd < nextSpecial && stream[runEnd] !== DataStreamTreeTokenType16.CUSTOM_BLOCK && findStyle(runEnd) === ts) {
|
|
36038
37885
|
runEnd++;
|
|
36039
37886
|
}
|
|
36040
37887
|
out += formatStyledChunk(stream.slice(cursor, runEnd), ts);
|
|
@@ -36221,7 +38068,7 @@ import {
|
|
|
36221
38068
|
import { DocSelectionManagerService as DocSelectionManagerService5, RichTextEditingMutation as RichTextEditingMutation3 } from "@univerjs/docs";
|
|
36222
38069
|
|
|
36223
38070
|
// src/services/doc-ai-copilot.service.ts
|
|
36224
|
-
import { createIdentifier as createIdentifier3, Disposable as Disposable3, generateRandomId as
|
|
38071
|
+
import { createIdentifier as createIdentifier3, Disposable as Disposable3, generateRandomId as generateRandomId19 } from "@univerjs/core";
|
|
36225
38072
|
import { BehaviorSubject as BehaviorSubject2 } from "rxjs";
|
|
36226
38073
|
function extractContractClauseLines(snapshot) {
|
|
36227
38074
|
const body = snapshot?.body;
|
|
@@ -36292,7 +38139,7 @@ function auditContractRisksOffline(snapshot) {
|
|
|
36292
38139
|
if (!flaggedUnilateral && unilateralRe.test(line.text)) {
|
|
36293
38140
|
flaggedUnilateral = true;
|
|
36294
38141
|
findings.push({
|
|
36295
|
-
id: `risk_${
|
|
38142
|
+
id: `risk_${generateRandomId19(5)}`,
|
|
36296
38143
|
severity: "high",
|
|
36297
38144
|
category: "unilateral_termination",
|
|
36298
38145
|
clauseTitle: line.clauseTitle,
|
|
@@ -36303,7 +38150,7 @@ function auditContractRisksOffline(snapshot) {
|
|
|
36303
38150
|
if (!flaggedUnlimited && unlimitedRe.test(line.text)) {
|
|
36304
38151
|
flaggedUnlimited = true;
|
|
36305
38152
|
findings.push({
|
|
36306
|
-
id: `risk_${
|
|
38153
|
+
id: `risk_${generateRandomId19(5)}`,
|
|
36307
38154
|
severity: "high",
|
|
36308
38155
|
category: "unlimited_liability",
|
|
36309
38156
|
clauseTitle: line.clauseTitle,
|
|
@@ -36347,7 +38194,7 @@ function auditContractRisksOffline(snapshot) {
|
|
|
36347
38194
|
if (highRateDetected) {
|
|
36348
38195
|
flaggedPenalty = true;
|
|
36349
38196
|
findings.push({
|
|
36350
|
-
id: `risk_${
|
|
38197
|
+
id: `risk_${generateRandomId19(5)}`,
|
|
36351
38198
|
severity: "high",
|
|
36352
38199
|
category: "excessive_penalty",
|
|
36353
38200
|
clauseTitle: line.clauseTitle,
|
|
@@ -36359,7 +38206,7 @@ function auditContractRisksOffline(snapshot) {
|
|
|
36359
38206
|
}
|
|
36360
38207
|
if (fullText.trim().length > 0 && !jurisdictionRe.test(fullText)) {
|
|
36361
38208
|
findings.push({
|
|
36362
|
-
id: `risk_${
|
|
38209
|
+
id: `risk_${generateRandomId19(5)}`,
|
|
36363
38210
|
severity: "medium",
|
|
36364
38211
|
category: "missing_jurisdiction",
|
|
36365
38212
|
clauseTitle: "\u4E89\u8BAE\u89E3\u51B3\u4E0E\u7BA1\u8F96\u6761\u6B3E",
|
|
@@ -36372,7 +38219,7 @@ function auditContractRisksOffline(snapshot) {
|
|
|
36372
38219
|
const isEmpty = ctrl.kind === "checkbox" ? ctrl.value !== true : ctrl.showingPlaceholder || String(ctrl.value ?? "").trim() === "";
|
|
36373
38220
|
if (ctrl.required && isEmpty) {
|
|
36374
38221
|
findings.push({
|
|
36375
|
-
id: `risk_${
|
|
38222
|
+
id: `risk_${generateRandomId19(5)}`,
|
|
36376
38223
|
severity: "medium",
|
|
36377
38224
|
category: "blank_required_sdt",
|
|
36378
38225
|
clauseTitle: `\u5FC5\u586B\u8981\u7D20\uFF1A${ctrl.alias}`,
|
|
@@ -37421,7 +39268,7 @@ var UniverDocsExtPlugin = class extends Plugin {
|
|
|
37421
39268
|
}
|
|
37422
39269
|
this.disposeWithMe(
|
|
37423
39270
|
this._commandService.onCommandExecuted((commandInfo) => {
|
|
37424
|
-
if (commandInfo.id === RichTextEditingMutation3.id || commandInfo.id === ReplaceDocUnitSnapshotCommand.id) {
|
|
39271
|
+
if (commandInfo.id === RichTextEditingMutation3.id || commandInfo.id === ReplaceDocUnitSnapshotCommand.id || commandInfo.id === SyncDocAuxStateMutation.id) {
|
|
37425
39272
|
const mutUnitId = commandInfo.params?.unitId;
|
|
37426
39273
|
sdtService.emitContentChange(mutUnitId);
|
|
37427
39274
|
return;
|
|
@@ -37458,9 +39305,11 @@ export {
|
|
|
37458
39305
|
ApplyDocMacrosCommand,
|
|
37459
39306
|
ApplyDocMarkdownShortcutCommand,
|
|
37460
39307
|
AutoFitDocTableCommand,
|
|
39308
|
+
BuildDocTableOfFiguresCommand,
|
|
37461
39309
|
CancelDocHyperlinkCommand,
|
|
37462
39310
|
CleanUpDocFormattingCommand,
|
|
37463
39311
|
ClearDocGraffitiStrokesCommand,
|
|
39312
|
+
CombineDocRevisionsCommand,
|
|
37464
39313
|
CompareDocSnapshotsToTrackCommand,
|
|
37465
39314
|
ConvertTableToTextCommand,
|
|
37466
39315
|
ConvertTextToDocTableCommand,
|
|
@@ -37512,6 +39361,7 @@ export {
|
|
|
37512
39361
|
InsertDocCitationCommand,
|
|
37513
39362
|
InsertDocCodeBlockCommand,
|
|
37514
39363
|
InsertDocColumnGroupCommand,
|
|
39364
|
+
InsertDocCrossRefCommand,
|
|
37515
39365
|
InsertDocCrossReferenceCommand,
|
|
37516
39366
|
InsertDocEmbedBlockCommand,
|
|
37517
39367
|
InsertDocEndnoteCommand,
|
|
@@ -37544,6 +39394,7 @@ export {
|
|
|
37544
39394
|
RecalculateDocInlineFormulasCommand,
|
|
37545
39395
|
RecalculateDocTableFormulasCommand,
|
|
37546
39396
|
RecordDocRevisionCommand,
|
|
39397
|
+
RefreshDocCaptionsAndCrossRefsCommand,
|
|
37547
39398
|
RefreshDocTableOfContentsCommand,
|
|
37548
39399
|
RemoveDocBookmarkCommand,
|
|
37549
39400
|
RemoveDocCalloutCommand,
|
|
@@ -37571,6 +39422,7 @@ export {
|
|
|
37571
39422
|
SetDocCascadeRulesCommand,
|
|
37572
39423
|
SetDocCopyPastePolicyCommand,
|
|
37573
39424
|
SetDocCustomPropertiesCommand,
|
|
39425
|
+
SetDocLineNumberingCommand,
|
|
37574
39426
|
SetDocListGlyphTypeCommand,
|
|
37575
39427
|
SetDocListLevelCommand,
|
|
37576
39428
|
SetDocMainBadgeCommand,
|
|
@@ -37616,10 +39468,15 @@ export {
|
|
|
37616
39468
|
UpdateDocShapeCommand,
|
|
37617
39469
|
UpdateDocSmartArtCommand,
|
|
37618
39470
|
YUDAO_DOCS_CALLOUTS,
|
|
39471
|
+
YUDAO_DOCS_CAPTIONS,
|
|
37619
39472
|
YUDAO_DOCS_CHARTS,
|
|
37620
39473
|
YUDAO_DOCS_CODE_BLOCKS,
|
|
39474
|
+
YUDAO_DOCS_CROSS_REFS,
|
|
37621
39475
|
YUDAO_DOCS_FOOTNOTES,
|
|
39476
|
+
YUDAO_DOCS_LINE_NUMBERING,
|
|
37622
39477
|
YUDAO_DOCS_MINI_SHEETS,
|
|
39478
|
+
YUDAO_DOCS_REVISIONS,
|
|
39479
|
+
YUDAO_DOCS_SMARTART,
|
|
37623
39480
|
YUDAO_DOCS_TEMPLATE_RESOURCE,
|
|
37624
39481
|
addDocCascadeRuleInSnapshot as addDocCascadeRule,
|
|
37625
39482
|
addDocCascadeRuleInSnapshot,
|
|
@@ -37647,6 +39504,7 @@ export {
|
|
|
37647
39504
|
buildQrOrBarcodeSvg,
|
|
37648
39505
|
buildSdtPropertiesFromSpec,
|
|
37649
39506
|
buildStructuredDocData,
|
|
39507
|
+
buildTableOfFiguresEntries,
|
|
37650
39508
|
buildTocBlockLines,
|
|
37651
39509
|
buildVisualComparisonSnapshot,
|
|
37652
39510
|
canRoleEditSdtControl,
|
|
@@ -37656,6 +39514,8 @@ export {
|
|
|
37656
39514
|
clearDocGraffitiStrokesInSnapshot as clearDocGraffitiStrokes,
|
|
37657
39515
|
clearDocGraffitiStrokesInSnapshot,
|
|
37658
39516
|
clearRegisteredDocMacros,
|
|
39517
|
+
combineReviewedDocuments,
|
|
39518
|
+
combineReviewedDocxBytes,
|
|
37659
39519
|
compareDocTableCellValues,
|
|
37660
39520
|
computeAuthorInitials,
|
|
37661
39521
|
computeSdtVisualStyle,
|
|
@@ -37746,12 +39606,14 @@ export {
|
|
|
37746
39606
|
getDocImageTransformFromSnapshot,
|
|
37747
39607
|
getDocLabelBadgesFromSnapshot as getDocLabelBadges,
|
|
37748
39608
|
getDocLabelBadgesFromSnapshot,
|
|
39609
|
+
getDocLineNumberingFromSnapshot,
|
|
37749
39610
|
getDocListsFromSnapshot,
|
|
37750
39611
|
getDocMainBadgeFromSnapshot as getDocMainBadge,
|
|
37751
39612
|
getDocMainBadgeFromSnapshot,
|
|
37752
39613
|
getDocNoteSettingsFromSnapshot,
|
|
37753
39614
|
getDocParagraphDirection,
|
|
37754
39615
|
getDocPrintConfigFromSnapshot,
|
|
39616
|
+
getDocRevisionsFromSnapshot,
|
|
37755
39617
|
getDocTableCellProperties,
|
|
37756
39618
|
getDocTableDirection,
|
|
37757
39619
|
getDocTitleEntriesFromSnapshot,
|
|
@@ -37808,6 +39670,7 @@ export {
|
|
|
37808
39670
|
insertStyledSeparatorInSnapshot,
|
|
37809
39671
|
insertSyntaxCodeBlockIntoSnapshot,
|
|
37810
39672
|
insertTableOfContentsIntoSnapshot,
|
|
39673
|
+
insertTableOfFiguresIntoSnapshot,
|
|
37811
39674
|
inspectDocxExportCapabilities,
|
|
37812
39675
|
isDynamicPageFieldInstruction,
|
|
37813
39676
|
isEditBlockedByTitleLock,
|
|
@@ -37822,6 +39685,7 @@ export {
|
|
|
37822
39685
|
listDocCitations,
|
|
37823
39686
|
listDocCodeBlocks,
|
|
37824
39687
|
listDocCommentsFromSnapshot,
|
|
39688
|
+
listDocCrossRefs,
|
|
37825
39689
|
listDocFields,
|
|
37826
39690
|
listDocHyperlinks,
|
|
37827
39691
|
listDocInlineFormulas,
|
|
@@ -37839,11 +39703,13 @@ export {
|
|
|
37839
39703
|
miniSheetCellKey,
|
|
37840
39704
|
miniSheetColIndexToLetters,
|
|
37841
39705
|
miniSheetLettersToColIndex,
|
|
39706
|
+
normalizeDocCaptionCategory,
|
|
37842
39707
|
normalizeDocCodeLanguageLabel,
|
|
37843
39708
|
normalizeDocDrawingsAndPluginResource,
|
|
37844
39709
|
normalizeImageDataUriForSdt,
|
|
37845
39710
|
normalizeMacroName,
|
|
37846
39711
|
normalizeSdtListItems,
|
|
39712
|
+
normalizeSmartArtNodes,
|
|
37847
39713
|
numberToChineseUpperMoney,
|
|
37848
39714
|
parseDateRangePair,
|
|
37849
39715
|
parseDocBindingKey,
|
|
@@ -37857,6 +39723,7 @@ export {
|
|
|
37857
39723
|
parseSdtRangeToResolved,
|
|
37858
39724
|
parseTableRowsInStream,
|
|
37859
39725
|
readDocTemplateMetadataFromSnapshot,
|
|
39726
|
+
recalculateDocCaptionsAndCrossRefs,
|
|
37860
39727
|
recalculateDocTableFormulas,
|
|
37861
39728
|
recalculateInlineFormulasInPlace,
|
|
37862
39729
|
reconcileTemplateMetadataWithLiveSnapshot,
|
|
@@ -37922,6 +39789,7 @@ export {
|
|
|
37922
39789
|
setDocCascadeRulesInSnapshot,
|
|
37923
39790
|
setDocCopyPastePolicyInSnapshot,
|
|
37924
39791
|
setDocCustomPropertiesInSnapshot,
|
|
39792
|
+
setDocLineNumberingInSnapshot,
|
|
37925
39793
|
setDocListGlyphTypeInSnapshot,
|
|
37926
39794
|
setDocListLevelInSnapshot,
|
|
37927
39795
|
setDocMainBadgeInSnapshot as setDocMainBadge,
|