@yudaocode/univer-pdfs-ui 1.6.210 → 1.6.211

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/es/index.js CHANGED
@@ -598,47 +598,47 @@ async function readBrowserFileAsOverlayOutcome(file, options) {
598
598
  return {
599
599
  mode: "overlay",
600
600
  sourceDocumentRef: validated.sourceDocumentRef,
601
- pageSizes: validated.pageSizes
601
+ pageSizes: validated.pageSizes,
602
+ ...validated.warnings?.length ? { warnings: validated.warnings } : {}
602
603
  };
603
604
  }
604
605
  var UploadBasePdfOperation = {
605
606
  id: "pdfs-ui.operation.upload-base-pdf",
606
607
  type: CommandType.OPERATION,
607
608
  handler: (accessor, params) => {
608
- if (typeof document === "undefined") return false;
609
609
  const featureService = accessor.get(IPdfsUIFeatureService);
610
610
  if (!featureService.isEditorEnabled()) return false;
611
+ const selectionService = accessor.get(IPdfSelectionService);
612
+ selectionService.commitActiveEditing();
613
+ selectionService.setEditingElement(null);
614
+ if (!params?.file) {
615
+ featureService.setModalTab("import");
616
+ selectionService.setPreviewOpen(true);
617
+ return true;
618
+ }
611
619
  const commandService = accessor.get(ICommandService);
612
620
  const instanceService = accessor.get(IUniverInstanceService);
613
621
  const ioService = accessor.get(IPdfIoService);
614
- const input = document.createElement("input");
615
- input.type = "file";
616
- input.accept = "application/pdf";
617
- input.onchange = async () => {
618
- const file = input.files?.[0];
619
- if (!file) return;
620
- const unit = instanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_PDF);
621
- if (!unit) return;
622
- const outcome = await ioService.importPdf(file, {
623
- unitId: unit.getUnitId(),
624
- snapshot: unit.save(),
625
- defaultImport: (f) => readBrowserFileAsOverlayOutcome(f, { password: params?.password })
626
- });
622
+ const unit = params.unitId ? instanceService.getUnit(params.unitId, UniverInstanceType.UNIVER_PDF) : instanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_PDF);
623
+ if (!unit) return false;
624
+ return ioService.importPdf(params.file, {
625
+ unitId: unit.getUnitId(),
626
+ snapshot: unit.save(),
627
+ target: params.target,
628
+ password: params.password
629
+ }).then((outcome) => {
627
630
  if (outcome.mode === "snapshot") {
628
- commandService.syncExecuteCommand(ReplacePdfSnapshotCommand.id, {
631
+ return commandService.syncExecuteCommand(ReplacePdfSnapshotCommand.id, {
629
632
  unitId: unit.getUnitId(),
630
633
  snapshot: outcome.snapshot
631
634
  });
632
- } else {
633
- commandService.syncExecuteCommand(ImportPdfSourceCommand.id, {
634
- unitId: unit.getUnitId(),
635
- sourceDocumentRef: outcome.sourceDocumentRef,
636
- pageSizes: outcome.pageSizes
637
- });
638
635
  }
639
- };
640
- input.click();
641
- return true;
636
+ return commandService.syncExecuteCommand(ImportPdfSourceCommand.id, {
637
+ unitId: unit.getUnitId(),
638
+ sourceDocumentRef: outcome.sourceDocumentRef,
639
+ pageSizes: outcome.pageSizes
640
+ });
641
+ });
642
642
  }
643
643
  };
644
644
  var SavePdfToHostOperation = {
@@ -8236,6 +8236,7 @@ import {
8236
8236
  exportSignedPdfWithAuditSeal,
8237
8237
  fromPdfmeTemplate,
8238
8238
  importFormDataFromXfdf as importFormDataFromXfdf2,
8239
+ ImportPdfSourceCommand as ImportPdfSourceCommand2,
8239
8240
  inspectPdfExportCapabilities,
8240
8241
  IPdfIoService as IPdfIoService4,
8241
8242
  IPdfSelectionService as IPdfSelectionService6,
@@ -8247,16 +8248,43 @@ import {
8247
8248
  UNIVER_PDF_SCHEMA
8248
8249
  } from "@yudaocode/univer-pdfs";
8249
8250
  import { useEffect as useEffect4, useRef as useRef3, useState as useState5 } from "react";
8250
- import { jsx as jsx6, jsxs as jsxs6 } from "react/jsx-runtime";
8251
+ import { Fragment as Fragment4, jsx as jsx6, jsxs as jsxs6 } from "react/jsx-runtime";
8252
+ function resolveInitialModalIoTarget(caps, tab = "preview") {
8253
+ if (caps.defaultIoTarget === "server") return "server";
8254
+ if (caps.defaultIoTarget === "browser") return "browser";
8255
+ const op = tab === "import" ? "import" : "export";
8256
+ return caps.formats?.[op]?.pdf?.defaultTarget ?? caps.recommendedDefaultTarget;
8257
+ }
8258
+ function resolveFallbackTarget(err, attemptedTarget) {
8259
+ if (err?.suggestedFallback === "browser" || err?.suggestedFallback === "server") {
8260
+ return err.suggestedFallback;
8261
+ }
8262
+ return attemptedTarget === "server" ? "browser" : "server";
8263
+ }
8251
8264
  function uint8ToDataUri(bytes) {
8252
8265
  let binary = "";
8253
8266
  const chunkSize = 32768;
8254
8267
  for (let i = 0; i < bytes.length; i += chunkSize) {
8255
8268
  binary += String.fromCharCode(...bytes.subarray(i, i + chunkSize));
8256
8269
  }
8257
- return `data:application/pdf;base64,${btoa(binary)}`;
8270
+ if (typeof btoa === "function") {
8271
+ return `data:application/pdf;base64,${btoa(binary)}`;
8272
+ }
8273
+ return `data:application/pdf;base64,${Buffer.from(bytes).toString("base64")}`;
8274
+ }
8275
+ function triggerBlobDownload(bytes, fileName) {
8276
+ if (typeof document === "undefined" || typeof URL === "undefined" || typeof URL.createObjectURL !== "function") {
8277
+ return;
8278
+ }
8279
+ const blob = new Blob([bytes.slice().buffer], { type: "application/pdf" });
8280
+ const url = URL.createObjectURL(blob);
8281
+ const a = document.createElement("a");
8282
+ a.href = url;
8283
+ a.download = fileName;
8284
+ a.click();
8285
+ setTimeout(() => URL.revokeObjectURL(url), 1e3);
8258
8286
  }
8259
- var PdfRenderedPagesViewer = ({ pdfBytes }) => {
8287
+ var PdfRenderedPagesViewer = ({ pdfBytes, hasError }) => {
8260
8288
  const [dataUri, setDataUri] = useState5("");
8261
8289
  const [pageSizes, setPageSizes] = useState5([]);
8262
8290
  const canvasRefs = useRef3([]);
@@ -8282,7 +8310,7 @@ var PdfRenderedPagesViewer = ({ pdfBytes }) => {
8282
8310
  });
8283
8311
  }, [dataUri, pageSizes]);
8284
8312
  if (!pdfBytes || pageSizes.length === 0) {
8285
- return /* @__PURE__ */ jsx6("div", { className: "univer-pdf-empty-stage", children: "\u6B63\u5728\u7F16\u8BD1\u9AD8\u6E05 PDF \u9875\u9762..." });
8313
+ return /* @__PURE__ */ jsx6("div", { className: "univer-pdf-empty-stage", children: hasError ? "\u5F53\u524D\u901A\u9053\u672A\u751F\u6210 PDF \u9884\u89C8\uFF0C\u8BF7\u67E5\u770B\u5DE6\u4FA7\u63D0\u793A\u6216\u5207\u6362\u901A\u9053\u91CD\u8BD5" : "\u6B63\u5728\u7F16\u8BD1\u9AD8\u6E05 PDF \u9875\u9762..." });
8286
8314
  }
8287
8315
  return /* @__PURE__ */ jsx6(
8288
8316
  "div",
@@ -8321,6 +8349,205 @@ var PdfRenderedPagesViewer = ({ pdfBytes }) => {
8321
8349
  }
8322
8350
  );
8323
8351
  };
8352
+ var PdfUnifiedIoSection = ({
8353
+ ioTarget,
8354
+ browserAvailable,
8355
+ serverAvailable,
8356
+ snapSizeKb,
8357
+ editorEnabled,
8358
+ importing,
8359
+ rendering,
8360
+ selectedFileName,
8361
+ pendingImport,
8362
+ ioError,
8363
+ fileInputRef,
8364
+ onSelectTarget,
8365
+ onFileInputChange,
8366
+ onPickFileClick,
8367
+ onConfirmImport,
8368
+ onCancelImport,
8369
+ onSwitchAndRetry
8370
+ }) => {
8371
+ const stagedPageCount = pendingImport ? pendingImport.outcome.mode === "overlay" ? pendingImport.outcome.pageSizes.length || pendingImport.outcome.sourceDocumentRef.pageCount || pendingImport.snapshot.document.pageOrder.length : pendingImport.snapshot.document.pageOrder.length : 0;
8372
+ return /* @__PURE__ */ jsxs6(Fragment4, { children: [
8373
+ /* @__PURE__ */ jsxs6(
8374
+ "div",
8375
+ {
8376
+ style: {
8377
+ padding: "7px 9px",
8378
+ background: "#FFFFFF",
8379
+ border: "1px solid #E3E5EA",
8380
+ borderRadius: 6,
8381
+ display: "flex",
8382
+ flexDirection: "column",
8383
+ gap: 6
8384
+ },
8385
+ children: [
8386
+ /* @__PURE__ */ jsxs6("div", { style: { display: "flex", justifyContent: "space-between", fontSize: 11 }, children: [
8387
+ /* @__PURE__ */ jsx6("span", { style: { fontWeight: 600, color: "#1B1C1F" }, children: "\u5BFC\u5165\u5BFC\u51FA\u6267\u884C\u901A\u9053\uFF08\u6309\u6B21\u9009\u62E9\uFF09" }),
8388
+ /* @__PURE__ */ jsxs6("span", { style: { color: "#7D8698" }, children: [
8389
+ "\u5FEB\u7167 ",
8390
+ snapSizeKb,
8391
+ " KB"
8392
+ ] })
8393
+ ] }),
8394
+ /* @__PURE__ */ jsxs6("div", { className: "univer-pdf-segmented", children: [
8395
+ /* @__PURE__ */ jsxs6(
8396
+ "button",
8397
+ {
8398
+ type: "button",
8399
+ "data-testid": "yudao-io-target-browser",
8400
+ "aria-pressed": ioTarget === "browser",
8401
+ className: `univer-pdf-segmented-item ${ioTarget === "browser" ? "is-active" : ""}`,
8402
+ onClick: () => onSelectTarget("browser"),
8403
+ children: [
8404
+ /* @__PURE__ */ jsx6(UiBrowserIcon, {}),
8405
+ /* @__PURE__ */ jsx6("span", { children: "\u6D4F\u89C8\u5668\u5904\u7406" }),
8406
+ /* @__PURE__ */ jsx6("span", { className: `univer-pdf-io-badge ${browserAvailable ? "is-ready" : "is-unconfigured"}`, children: browserAvailable ? "\u53EF\u7528" : "\u672A\u63A5\u5165" })
8407
+ ]
8408
+ }
8409
+ ),
8410
+ /* @__PURE__ */ jsxs6(
8411
+ "button",
8412
+ {
8413
+ type: "button",
8414
+ "data-testid": "yudao-io-target-server",
8415
+ "aria-pressed": ioTarget === "server",
8416
+ className: `univer-pdf-segmented-item ${ioTarget === "server" ? "is-active" : ""}`,
8417
+ onClick: () => onSelectTarget("server"),
8418
+ children: [
8419
+ /* @__PURE__ */ jsx6(UiServerIcon, {}),
8420
+ /* @__PURE__ */ jsx6("span", { children: "\u670D\u52A1\u7AEF\u5904\u7406" }),
8421
+ /* @__PURE__ */ jsx6("span", { className: `univer-pdf-io-badge ${serverAvailable ? "is-ready" : "is-unconfigured"}`, children: serverAvailable ? "\u53EF\u7528" : "\u672A\u63A5\u5165" })
8422
+ ]
8423
+ }
8424
+ )
8425
+ ] })
8426
+ ]
8427
+ }
8428
+ ),
8429
+ editorEnabled && /* @__PURE__ */ jsxs6("div", { className: "univer-pdf-io-import-box", children: [
8430
+ /* @__PURE__ */ jsxs6("div", { style: { display: "flex", alignItems: "center", justifyContent: "space-between", gap: 6 }, children: [
8431
+ /* @__PURE__ */ jsx6("span", { style: { fontSize: 11.5, fontWeight: 600, color: "#1B1C1F" }, children: "PDF / \u6A21\u677F\u5206\u9636\u6BB5\u5BFC\u5165" }),
8432
+ selectedFileName && !pendingImport && /* @__PURE__ */ jsx6(
8433
+ "span",
8434
+ {
8435
+ style: {
8436
+ fontSize: 10.5,
8437
+ color: "#4E5565",
8438
+ overflow: "hidden",
8439
+ textOverflow: "ellipsis",
8440
+ whiteSpace: "nowrap",
8441
+ maxWidth: 140
8442
+ },
8443
+ title: selectedFileName,
8444
+ children: selectedFileName
8445
+ }
8446
+ )
8447
+ ] }),
8448
+ /* @__PURE__ */ jsx6(
8449
+ "input",
8450
+ {
8451
+ ref: fileInputRef,
8452
+ type: "file",
8453
+ accept: "application/pdf,.pdf,.json",
8454
+ "data-testid": "yudao-io-file-input",
8455
+ style: { display: "none" },
8456
+ onChange: onFileInputChange
8457
+ }
8458
+ ),
8459
+ /* @__PURE__ */ jsxs6(
8460
+ "button",
8461
+ {
8462
+ type: "button",
8463
+ "data-testid": "yudao-io-pick-file",
8464
+ className: "univer-pdf-mini-btn is-soft-primary",
8465
+ style: { display: "inline-flex", alignItems: "center", justifyContent: "center", gap: 5 },
8466
+ disabled: importing || rendering,
8467
+ onClick: onPickFileClick,
8468
+ children: [
8469
+ /* @__PURE__ */ jsx6(UiFilePdfIcon, {}),
8470
+ /* @__PURE__ */ jsx6("span", { children: importing ? "\u6B63\u5728\u89E3\u6790\u5BFC\u5165\u6587\u4EF6..." : "\u9009\u62E9 PDF \u5BFC\u5165" })
8471
+ ]
8472
+ }
8473
+ ),
8474
+ pendingImport && /* @__PURE__ */ jsxs6("div", { className: "univer-pdf-io-staged-card", "data-testid": "yudao-io-staged-result", children: [
8475
+ /* @__PURE__ */ jsxs6("div", { style: { display: "flex", alignItems: "center", justifyContent: "space-between", gap: 6 }, children: [
8476
+ /* @__PURE__ */ jsx6(
8477
+ "span",
8478
+ {
8479
+ style: {
8480
+ fontSize: 11.5,
8481
+ fontWeight: 600,
8482
+ color: "#1B1C1F",
8483
+ overflow: "hidden",
8484
+ textOverflow: "ellipsis",
8485
+ whiteSpace: "nowrap"
8486
+ },
8487
+ title: pendingImport.fileName || selectedFileName || "imported.pdf",
8488
+ children: pendingImport.fileName || selectedFileName || "imported.pdf"
8489
+ }
8490
+ ),
8491
+ /* @__PURE__ */ jsx6("span", { className: "univer-pdf-io-badge is-ready", children: pendingImport.executedBy === "server" ? "\u670D\u52A1\u7AEF\u5904\u7406" : "\u6D4F\u89C8\u5668\u5904\u7406" })
8492
+ ] }),
8493
+ /* @__PURE__ */ jsxs6("div", { style: { fontSize: 11, color: "#4E5565" }, children: [
8494
+ "\u5171 ",
8495
+ stagedPageCount,
8496
+ " \u9875 \xB7 \u6A21\u5F0F\uFF1A",
8497
+ pendingImport.outcome.mode === "overlay" ? "\u5E95\u56FE\u53E0\u52A0" : "\u5B8C\u6574\u5FEB\u7167",
8498
+ "\uFF08\u5C1A\u672A\u4FEE\u6539\u5F53\u524D\u8BBE\u8BA1\u5668\uFF09"
8499
+ ] }),
8500
+ /* @__PURE__ */ jsx6(
8501
+ "div",
8502
+ {
8503
+ "data-testid": "yudao-io-warnings",
8504
+ className: `univer-pdf-io-warnings-box ${pendingImport.warnings.length === 0 ? "is-clean" : ""}`,
8505
+ children: pendingImport.warnings.length > 0 ? pendingImport.warnings.map((w, idx) => /* @__PURE__ */ jsxs6("div", { "data-warning-code": w.code, children: [
8506
+ "\u2022 ",
8507
+ w.message
8508
+ ] }, `${w.code}-${idx}`)) : /* @__PURE__ */ jsx6("span", { children: "\u517C\u5BB9\u6027\u68C0\u67E5\u901A\u8FC7\uFF080 \u9879\u544A\u8B66\uFF09" })
8509
+ }
8510
+ ),
8511
+ /* @__PURE__ */ jsxs6("div", { className: "univer-pdf-btn-row", style: { display: "grid", gridTemplateColumns: "1fr 1fr", gap: 6 }, children: [
8512
+ /* @__PURE__ */ jsx6(
8513
+ "button",
8514
+ {
8515
+ type: "button",
8516
+ "data-testid": "yudao-io-confirm-import",
8517
+ className: "univer-pdf-mini-btn is-primary",
8518
+ onClick: onConfirmImport,
8519
+ children: "\u786E\u8BA4\u5E94\u7528\u5230\u8BBE\u8BA1\u5668"
8520
+ }
8521
+ ),
8522
+ /* @__PURE__ */ jsx6(
8523
+ "button",
8524
+ {
8525
+ type: "button",
8526
+ "data-testid": "yudao-io-cancel-import",
8527
+ className: "univer-pdf-mini-btn",
8528
+ onClick: onCancelImport,
8529
+ children: "\u53D6\u6D88\u672C\u6B21\u5BFC\u5165"
8530
+ }
8531
+ )
8532
+ ] })
8533
+ ] })
8534
+ ] }),
8535
+ ioError && /* @__PURE__ */ jsxs6("div", { className: "univer-pdf-io-error-banner", "data-testid": "yudao-io-error-banner", role: "alert", children: [
8536
+ /* @__PURE__ */ jsx6("div", { children: ioError.message }),
8537
+ /* @__PURE__ */ jsx6(
8538
+ "button",
8539
+ {
8540
+ type: "button",
8541
+ "data-testid": "yudao-io-switch-retry",
8542
+ className: "univer-pdf-mini-btn is-soft-primary",
8543
+ disabled: importing || rendering,
8544
+ onClick: onSwitchAndRetry,
8545
+ children: `\u5207\u6362\u4E3A\u300C${ioError.fallbackTarget === "browser" ? "\u6D4F\u89C8\u5668\u5904\u7406" : "\u670D\u52A1\u7AEF\u5904\u7406"}\u300D\u91CD\u8BD5`
8546
+ }
8547
+ )
8548
+ ] })
8549
+ ] });
8550
+ };
8324
8551
  var PdfPreviewModal = () => {
8325
8552
  const instanceService = useDependency5(IUniverInstanceService6);
8326
8553
  const commandService = useDependency5(ICommandService6);
@@ -8338,15 +8565,22 @@ var PdfPreviewModal = () => {
8338
8565
  false,
8339
8566
  [instanceService]
8340
8567
  );
8568
+ const fileInputRef = useRef3(null);
8341
8569
  const [sampleJsonText, setSampleJsonText] = useState5("{}");
8342
8570
  const [pdfBytesState, setPdfBytesState] = useState5(null);
8343
8571
  const [rendering, setRendering] = useState5(false);
8572
+ const [importing, setImporting] = useState5(false);
8573
+ const [selectedImportFile, setSelectedImportFile] = useState5(null);
8574
+ const [pendingImport, setPendingImport] = useState5(null);
8575
+ const [ioError, setIoError] = useState5(null);
8344
8576
  const [jsonFormat, setJsonFormat] = useState5("univer");
8345
8577
  const [jsonEditorValue, setJsonEditorValue] = useState5("");
8346
8578
  const [statusTip, setStatusTip] = useState5("");
8347
8579
  const [watermarkText, setWatermarkText] = useState5("");
8348
8580
  const [excludeBasePdf, setExcludeBasePdf] = useState5(false);
8349
- const [ioTarget, setIoTarget] = useState5("browser");
8581
+ const [ioTarget, setIoTarget] = useState5(
8582
+ () => resolveInitialModalIoTarget(ioService.getIoCapabilities(), featureService.getModalTab())
8583
+ );
8350
8584
  const [interactiveForm, setInteractiveForm] = useState5(false);
8351
8585
  const [cjkTextMode, setCjkTextMode] = useState5("raster-hd");
8352
8586
  const [customFontBytes, setCustomFontBytes] = useState5(void 0);
@@ -8359,24 +8593,10 @@ var PdfPreviewModal = () => {
8359
8593
  const [accessibilityTagged, setAccessibilityTagged] = useState5(false);
8360
8594
  const [splitStartPage, setSplitStartPage] = useState5(1);
8361
8595
  const [splitEndPage, setSplitEndPage] = useState5(1);
8362
- useEffect4(() => {
8363
- if (!open || !unit) return;
8364
- const snap = unit.save();
8365
- setSampleJsonText(JSON.stringify(snap.metadata?.sampleData ?? {}, null, 2));
8366
- setWatermarkText(String(snap.metadata?.watermarkText ?? ""));
8367
- setExcludeBasePdf(Boolean(snap.metadata?.excludeBasePdfOnExport));
8368
- setPdfACompliant(Boolean(snap.pdfACompliant ?? snap.metadata?.pdfACompliant));
8369
- setAccessibilityTagged(Boolean(snap.accessibilityTagged ?? snap.metadata?.accessibilityTagged));
8370
- setIoTarget(ioService.getIoCapabilities().recommendedDefaultTarget);
8371
- setJsonEditorValue(
8372
- jsonFormat === "univer" ? JSON.stringify(snap, null, 2) : JSON.stringify(toPdfmeTemplate(snap), null, 2)
8373
- );
8374
- setStatusTip("");
8375
- }, [open, unit, jsonFormat, ioService, ioAdapter]);
8376
- const generatePreview = async (customDataText, overrideWm, overrideStripBg, overrideTarget, overrideExportOpts, overrideSeal) => {
8377
- if (!unit) return;
8378
- setRendering(true);
8379
- setStatusTip("");
8596
+ const compileCurrentPdfBytes = async (customDataText, overrideWm, overrideStripBg, overrideTarget, overrideExportOpts, overrideSeal) => {
8597
+ if (!unit) {
8598
+ throw new Error("\u5F53\u524D\u6CA1\u6709\u6D3B\u52A8 PDF \u6587\u6863\u5B9E\u4F8B");
8599
+ }
8380
8600
  const effectiveTarget = overrideTarget ?? ioTarget;
8381
8601
  const useSeal = overrideSeal ?? enableAuditSeal;
8382
8602
  const exportOptions = {
@@ -8388,54 +8608,269 @@ var PdfPreviewModal = () => {
8388
8608
  pdfACompliant: overrideExportOpts?.pdfACompliant ?? pdfACompliant,
8389
8609
  accessibilityTagged: overrideExportOpts?.accessibilityTagged ?? accessibilityTagged
8390
8610
  };
8391
- try {
8392
- const parsedData = JSON.parse(customDataText ?? sampleJsonText);
8393
- const rawSnap = unit.save();
8394
- const snapWithPrintOpts = {
8395
- ...rawSnap,
8396
- metadata: {
8397
- ...rawSnap.metadata ?? {},
8398
- watermarkText: overrideWm ?? watermarkText,
8399
- excludeBasePdfOnExport: overrideStripBg ?? excludeBasePdf
8400
- }
8401
- };
8402
- if (useSeal && !Array.isArray(parsedData) && effectiveTarget === "browser") {
8403
- const sealed = await exportSignedPdfWithAuditSeal(snapWithPrintOpts, parsedData, {
8404
- signer: auditSigner.trim() || "Univer PDF Audit Seal",
8405
- reason: "Document Export Verification",
8406
- exportOptions
8407
- });
8408
- setPdfBytesState(sealed.pdfBytes);
8409
- setStatusTip(`\u5DF2\u751F\u6210 SHA-256 \u9632\u7BE1\u6539\u7B7E\u7AE0 PDF\uFF01\u6458\u8981: ${sealed.digestHex.slice(0, 24)}...`);
8410
- } else if (Array.isArray(parsedData) && effectiveTarget === "browser") {
8411
- const bytes = await exportBatchPdfBytes(snapWithPrintOpts, parsedData, exportOptions);
8412
- setPdfBytesState(bytes);
8413
- setStatusTip(`\u5DF2\u901A\u8FC7\u6D4F\u89C8\u5668\u672C\u5730\u5F15\u64CE\u6279\u91CF\u5408\u5E76\u6E32\u67D3 ${parsedData.length} \u6761\u4E1A\u52A1\u5355\u636E\u4E3A\u8FDE\u7EED\u591A\u9875 PDF\uFF01`);
8414
- } else {
8415
- const bytes = await ioService.exportPdf({
8416
- unitId: unit.getUnitId(),
8417
- snapshot: snapWithPrintOpts,
8418
- data: parsedData,
8419
- options: exportOptions,
8420
- target: effectiveTarget
8421
- });
8422
- setPdfBytesState(bytes);
8423
- const modeBadges = [
8424
- exportOptions.interactiveForm ? "AcroForm\u4EA4\u4E92\u57DF" : null,
8425
- exportOptions.cjkTextMode !== "raster-hd" ? `CJK:${exportOptions.cjkTextMode}` : null,
8426
- exportOptions.printerOffsetXMm || exportOptions.printerOffsetYMm ? `\u504F\u79FB(${exportOptions.printerOffsetXMm ?? 0},${exportOptions.printerOffsetYMm ?? 0}mm)` : null
8427
- ].filter(Boolean).join(" + ");
8428
- setStatusTip(
8429
- `\u5DF2\u901A\u8FC7 ${effectiveTarget === "server" ? `\u670D\u52A1\u7AEF (${ioAdapter.name})` : "\u6D4F\u89C8\u5668\u672C\u5730\u5F15\u64CE"} \u7F16\u8BD1 PDF${modeBadges ? ` [${modeBadges}]` : ""}\uFF01`
8430
- );
8611
+ const parsedData = JSON.parse(customDataText ?? sampleJsonText);
8612
+ const rawSnap = unit.save();
8613
+ const snapWithPrintOpts = {
8614
+ ...rawSnap,
8615
+ metadata: {
8616
+ ...rawSnap.metadata ?? {},
8617
+ watermarkText: overrideWm ?? watermarkText,
8618
+ excludeBasePdfOnExport: overrideStripBg ?? excludeBasePdf
8431
8619
  }
8620
+ };
8621
+ if (useSeal && !Array.isArray(parsedData) && effectiveTarget === "browser") {
8622
+ const sealed = await exportSignedPdfWithAuditSeal(snapWithPrintOpts, parsedData, {
8623
+ signer: auditSigner.trim() || "Univer PDF Audit Seal",
8624
+ reason: "Document Export Verification",
8625
+ exportOptions
8626
+ });
8627
+ return {
8628
+ bytes: sealed.pdfBytes,
8629
+ tip: `\u5DF2\u751F\u6210 SHA-256 \u9632\u7BE1\u6539\u7B7E\u7AE0 PDF\uFF01\u6458\u8981: ${sealed.digestHex.slice(0, 24)}...`,
8630
+ target: effectiveTarget
8631
+ };
8632
+ }
8633
+ if (Array.isArray(parsedData) && effectiveTarget === "browser") {
8634
+ const bytes2 = await exportBatchPdfBytes(snapWithPrintOpts, parsedData, exportOptions);
8635
+ return {
8636
+ bytes: bytes2,
8637
+ tip: `\u5DF2\u901A\u8FC7\u6D4F\u89C8\u5668\u672C\u5730\u5F15\u64CE\u6279\u91CF\u5408\u5E76\u6E32\u67D3 ${parsedData.length} \u6761\u4E1A\u52A1\u5355\u636E\u4E3A\u8FDE\u7EED\u591A\u9875 PDF\uFF01`,
8638
+ target: effectiveTarget
8639
+ };
8640
+ }
8641
+ const bytes = await ioService.exportPdf({
8642
+ unitId: unit.getUnitId(),
8643
+ snapshot: snapWithPrintOpts,
8644
+ data: parsedData,
8645
+ options: exportOptions,
8646
+ target: effectiveTarget
8647
+ });
8648
+ const modeBadges = [
8649
+ exportOptions.interactiveForm ? "AcroForm\u4EA4\u4E92\u57DF" : null,
8650
+ exportOptions.cjkTextMode !== "raster-hd" ? `CJK:${exportOptions.cjkTextMode}` : null,
8651
+ exportOptions.printerOffsetXMm || exportOptions.printerOffsetYMm ? `\u504F\u79FB(${exportOptions.printerOffsetXMm ?? 0},${exportOptions.printerOffsetYMm ?? 0}mm)` : null
8652
+ ].filter(Boolean).join(" + ");
8653
+ return {
8654
+ bytes,
8655
+ tip: `\u5DF2\u901A\u8FC7 ${effectiveTarget === "server" ? `\u670D\u52A1\u7AEF (${ioAdapter.name})` : "\u6D4F\u89C8\u5668\u672C\u5730\u5F15\u64CE"} \u7F16\u8BD1 PDF${modeBadges ? ` [${modeBadges}]` : ""}\uFF01`,
8656
+ target: effectiveTarget
8657
+ };
8658
+ };
8659
+ const generatePreview = async (customDataText, overrideWm, overrideStripBg, overrideTarget, overrideExportOpts, overrideSeal, preserveSuccessTip) => {
8660
+ if (!unit) return;
8661
+ const effectiveTarget = overrideTarget ?? ioTarget;
8662
+ setRendering(true);
8663
+ setIoError(null);
8664
+ if (!preserveSuccessTip) {
8665
+ setStatusTip("");
8666
+ }
8667
+ try {
8668
+ const compiled = await compileCurrentPdfBytes(
8669
+ customDataText,
8670
+ overrideWm,
8671
+ overrideStripBg,
8672
+ effectiveTarget,
8673
+ overrideExportOpts,
8674
+ overrideSeal
8675
+ );
8676
+ setPdfBytesState(compiled.bytes);
8677
+ setStatusTip(preserveSuccessTip ?? compiled.tip);
8678
+ } catch (err) {
8679
+ setPdfBytesState(null);
8680
+ const fallbackTarget = resolveFallbackTarget(err, effectiveTarget);
8681
+ const msg = err?.message || String(err);
8682
+ setIoError({
8683
+ operation: "preview",
8684
+ message: `\u751F\u6210\u9884\u89C8\u5931\u8D25: ${msg}`,
8685
+ failedTarget: effectiveTarget,
8686
+ fallbackTarget
8687
+ });
8688
+ setStatusTip("");
8689
+ } finally {
8690
+ setRendering(false);
8691
+ }
8692
+ };
8693
+ const handleExportAndDownload = async (overrideTarget) => {
8694
+ if (!unit) return;
8695
+ const effectiveTarget = overrideTarget ?? ioTarget;
8696
+ setRendering(true);
8697
+ setIoError(null);
8698
+ setStatusTip("");
8699
+ try {
8700
+ const compiled = await compileCurrentPdfBytes(
8701
+ sampleJsonText,
8702
+ watermarkText,
8703
+ excludeBasePdf,
8704
+ effectiveTarget
8705
+ );
8706
+ setPdfBytesState(compiled.bytes);
8707
+ triggerBlobDownload(compiled.bytes, `${unit.getName() || "document"}.pdf`);
8708
+ setStatusTip(compiled.tip);
8432
8709
  } catch (err) {
8433
- const hint = err?.suggestedFallback === "server" ? "\uFF08\u672A\u9759\u9ED8\u964D\u7EA7\uFF0C\u53EF\u5207\u6362\u4E3A\u300C\u670D\u52A1\u7AEF\u5904\u7406\u300D\u91CD\u8BD5\uFF09" : "";
8434
- setStatusTip(`\u751F\u6210\u5931\u8D25: ${err?.message || String(err)}${hint}`);
8710
+ setPdfBytesState(null);
8711
+ const fallbackTarget = resolveFallbackTarget(err, effectiveTarget);
8712
+ const msg = err?.message || String(err);
8713
+ setIoError({
8714
+ operation: "export",
8715
+ message: `PDF \u5BFC\u51FA\u5931\u8D25: ${msg}`,
8716
+ failedTarget: effectiveTarget,
8717
+ fallbackTarget
8718
+ });
8435
8719
  } finally {
8436
8720
  setRendering(false);
8437
8721
  }
8438
8722
  };
8723
+ const runStagedImport = async (file, overrideTarget) => {
8724
+ if (!unit) return;
8725
+ const effectiveTarget = overrideTarget ?? ioTarget;
8726
+ setImporting(true);
8727
+ setIoError(null);
8728
+ setPendingImport(null);
8729
+ setStatusTip("");
8730
+ try {
8731
+ const report = await ioService.importPdfWithReport(file, {
8732
+ unitId: unit.getUnitId(),
8733
+ target: effectiveTarget
8734
+ });
8735
+ setPendingImport(report);
8736
+ } catch (err) {
8737
+ setPendingImport(null);
8738
+ const fallbackTarget = resolveFallbackTarget(err, effectiveTarget);
8739
+ const msg = err?.message || String(err);
8740
+ setIoError({
8741
+ operation: "import",
8742
+ message: `PDF \u5BFC\u5165\u89E3\u6790\u5931\u8D25: ${msg}`,
8743
+ failedTarget: effectiveTarget,
8744
+ fallbackTarget
8745
+ });
8746
+ } finally {
8747
+ setImporting(false);
8748
+ }
8749
+ };
8750
+ const handleImportFileChange = (e) => {
8751
+ const file = e.target.files?.[0];
8752
+ e.target.value = "";
8753
+ if (!file) return;
8754
+ setSelectedImportFile(file);
8755
+ void runStagedImport(file, ioTarget);
8756
+ };
8757
+ const handleConfirmStagedImport = () => {
8758
+ if (!unit || !pendingImport) return;
8759
+ const staged = pendingImport;
8760
+ if (staged.outcome.mode === "overlay") {
8761
+ commandService.syncExecuteCommand(ImportPdfSourceCommand2.id, {
8762
+ unitId: unit.getUnitId(),
8763
+ sourceDocumentRef: staged.outcome.sourceDocumentRef,
8764
+ pageSizes: staged.outcome.pageSizes
8765
+ });
8766
+ } else {
8767
+ commandService.syncExecuteCommand(ReplacePdfSnapshotCommand4.id, {
8768
+ unitId: unit.getUnitId(),
8769
+ snapshot: staged.snapshot
8770
+ });
8771
+ }
8772
+ setPendingImport(null);
8773
+ setIoError(null);
8774
+ const updatedSnap = unit.save();
8775
+ const nextSampleJson = JSON.stringify(updatedSnap.metadata?.sampleData ?? {}, null, 2);
8776
+ setSampleJsonText(nextSampleJson);
8777
+ setJsonEditorValue(
8778
+ jsonFormat === "univer" ? JSON.stringify(updatedSnap, null, 2) : JSON.stringify(toPdfmeTemplate(updatedSnap), null, 2)
8779
+ );
8780
+ const confirmTip = "\u5DF2\u5E94\u7528\u5230\u5F53\u524D\u8BBE\u8BA1\u5668\uFF0C\u8BF7\u7531\u5BBF\u4E3B\u4FDD\u5B58";
8781
+ setStatusTip(confirmTip);
8782
+ const caps = ioService.getIoCapabilities();
8783
+ const refreshTarget = ioTarget === "server" && !caps.formats.export.pdf.server ? "browser" : ioTarget;
8784
+ void generatePreview(
8785
+ nextSampleJson,
8786
+ String(updatedSnap.metadata?.watermarkText ?? watermarkText),
8787
+ Boolean(updatedSnap.metadata?.excludeBasePdfOnExport ?? excludeBasePdf),
8788
+ refreshTarget,
8789
+ void 0,
8790
+ void 0,
8791
+ confirmTip
8792
+ );
8793
+ };
8794
+ const handleCancelStagedImport = () => {
8795
+ setPendingImport(null);
8796
+ setIoError(null);
8797
+ setStatusTip("\u5DF2\u53D6\u6D88\u672C\u6B21\u5BFC\u5165\uFF0C\u5F53\u524D\u8BBE\u8BA1\u5668\u5185\u5BB9\u672A\u53D8\u66F4");
8798
+ };
8799
+ const handleSelectTarget = (nextTarget) => {
8800
+ setIoTarget(nextTarget);
8801
+ setIoError(null);
8802
+ setPdfBytesState(null);
8803
+ if (modalTab === "preview") {
8804
+ void generatePreview(sampleJsonText, watermarkText, excludeBasePdf, nextTarget);
8805
+ } else if (modalTab === "import") {
8806
+ const caps = ioService.getIoCapabilities();
8807
+ if (nextTarget === "browser" && caps.formats.export.pdf.browser || nextTarget === "server" && caps.formats.export.pdf.server) {
8808
+ void generatePreview(sampleJsonText, watermarkText, excludeBasePdf, nextTarget);
8809
+ }
8810
+ }
8811
+ };
8812
+ const handleSwitchAndRetry = async () => {
8813
+ if (!ioError) return;
8814
+ const nextTarget = ioError.fallbackTarget;
8815
+ const failedOp = ioError.operation;
8816
+ setIoTarget(nextTarget);
8817
+ setIoError(null);
8818
+ if (failedOp === "import" && selectedImportFile) {
8819
+ await runStagedImport(selectedImportFile, nextTarget);
8820
+ } else if (failedOp === "export") {
8821
+ await handleExportAndDownload(nextTarget);
8822
+ } else {
8823
+ await generatePreview(sampleJsonText, watermarkText, excludeBasePdf, nextTarget);
8824
+ }
8825
+ };
8826
+ useEffect4(() => {
8827
+ if (!open) {
8828
+ setPendingImport(null);
8829
+ setSelectedImportFile(null);
8830
+ setIoError(null);
8831
+ return;
8832
+ }
8833
+ if (!unit) return;
8834
+ const snap = unit.save();
8835
+ const initialSampleText = JSON.stringify(snap.metadata?.sampleData ?? {}, null, 2);
8836
+ const initialWm = String(snap.metadata?.watermarkText ?? "");
8837
+ const initialStripBg = Boolean(snap.metadata?.excludeBasePdfOnExport);
8838
+ const initialPdfA = Boolean(snap.pdfACompliant ?? snap.metadata?.pdfACompliant);
8839
+ const initialPdfUa = Boolean(snap.accessibilityTagged ?? snap.metadata?.accessibilityTagged);
8840
+ const caps = ioService.getIoCapabilities();
8841
+ const initialTarget = resolveInitialModalIoTarget(caps, featureService.getModalTab());
8842
+ setSampleJsonText(initialSampleText);
8843
+ setWatermarkText(initialWm);
8844
+ setExcludeBasePdf(initialStripBg);
8845
+ setPdfACompliant(initialPdfA);
8846
+ setAccessibilityTagged(initialPdfUa);
8847
+ setIoTarget(initialTarget);
8848
+ setIoError(null);
8849
+ setStatusTip("");
8850
+ const activeTab = featureService.getModalTab();
8851
+ if (activeTab === "preview") {
8852
+ void generatePreview(initialSampleText, initialWm, initialStripBg, initialTarget, {
8853
+ pdfACompliant: initialPdfA,
8854
+ accessibilityTagged: initialPdfUa
8855
+ });
8856
+ } else if (activeTab === "import") {
8857
+ if (initialTarget === "browser" && caps.formats.export.pdf.browser || initialTarget === "server" && caps.formats.export.pdf.server) {
8858
+ void generatePreview(initialSampleText, initialWm, initialStripBg, initialTarget, {
8859
+ pdfACompliant: initialPdfA,
8860
+ accessibilityTagged: initialPdfUa
8861
+ });
8862
+ } else {
8863
+ setPdfBytesState(null);
8864
+ }
8865
+ }
8866
+ }, [open, unit, ioService, ioAdapter]);
8867
+ useEffect4(() => {
8868
+ if (!open || !unit) return;
8869
+ const snap = unit.save();
8870
+ setJsonEditorValue(
8871
+ jsonFormat === "univer" ? JSON.stringify(snap, null, 2) : JSON.stringify(toPdfmeTemplate(snap), null, 2)
8872
+ );
8873
+ }, [open, unit, jsonFormat, modalTab]);
8439
8874
  const handleSilentPrint = async () => {
8440
8875
  if (!unit) return;
8441
8876
  setStatusTip("");
@@ -8466,23 +8901,7 @@ var PdfPreviewModal = () => {
8466
8901
  setStatusTip(`\u9759\u9ED8\u76F4\u6253\u672A\u6267\u884C: ${err?.message || String(err)}`);
8467
8902
  }
8468
8903
  };
8469
- useEffect4(() => {
8470
- if (open && modalTab === "preview" && unit) {
8471
- const snap = unit.save();
8472
- generatePreview(JSON.stringify(snap.metadata?.sampleData ?? {}, null, 2));
8473
- }
8474
- }, [open, modalTab, unit, ioAdapter]);
8475
8904
  if (!open || !unit) return null;
8476
- const handleDownloadPdf = () => {
8477
- if (!pdfBytesState) return;
8478
- const blob = new Blob([pdfBytesState.buffer], { type: "application/pdf" });
8479
- const url = URL.createObjectURL(blob);
8480
- const a = document.createElement("a");
8481
- a.href = url;
8482
- a.download = `${unit.getName() || "document"}.pdf`;
8483
- a.click();
8484
- setTimeout(() => URL.revokeObjectURL(url), 1e3);
8485
- };
8486
8905
  const handleBrowserPrint = () => {
8487
8906
  commandService.executeCommand(PrintPdfOperation.id, {
8488
8907
  unitId: unit.getUnitId(),
@@ -8497,13 +8916,10 @@ var PdfPreviewModal = () => {
8497
8916
  { startPage: Math.max(1, splitStartPage), endPage: Math.max(1, splitEndPage) }
8498
8917
  ]);
8499
8918
  setPdfBytesState(rangeBytes);
8500
- const blob = new Blob([rangeBytes.buffer], { type: "application/pdf" });
8501
- const url = URL.createObjectURL(blob);
8502
- const a = document.createElement("a");
8503
- a.href = url;
8504
- a.download = `${unit.getName() || "document"}-p${splitStartPage}-${splitEndPage}.pdf`;
8505
- a.click();
8506
- setTimeout(() => URL.revokeObjectURL(url), 1e3);
8919
+ triggerBlobDownload(
8920
+ rangeBytes,
8921
+ `${unit.getName() || "document"}-p${splitStartPage}-${splitEndPage}.pdf`
8922
+ );
8507
8923
  setStatusTip(`\u5DF2\u6309\u9875\u7801\u8303\u56F4 [${splitStartPage}..${splitEndPage}] \u62C6\u5206\u5E76\u4E0B\u8F7D\u72EC\u7ACB PDF\uFF01`);
8508
8924
  } catch (err) {
8509
8925
  setStatusTip(`\u62C6\u5206\u5931\u8D25: ${err?.message || String(err)}`);
@@ -8527,13 +8943,7 @@ var PdfPreviewModal = () => {
8527
8943
  const list = pdfBytesState ? [pdfBytesState, ...externalBuffers] : externalBuffers;
8528
8944
  const merged = await mergePdfBytes(list);
8529
8945
  setPdfBytesState(merged);
8530
- const blob = new Blob([merged.buffer], { type: "application/pdf" });
8531
- const url = URL.createObjectURL(blob);
8532
- const a = document.createElement("a");
8533
- a.href = url;
8534
- a.download = `${unit.getName() || "document"}-merged.pdf`;
8535
- a.click();
8536
- setTimeout(() => URL.revokeObjectURL(url), 1e3);
8946
+ triggerBlobDownload(merged, `${unit.getName() || "document"}-merged.pdf`);
8537
8947
  setStatusTip(`\u5DF2\u6210\u529F\u5408\u5E76 ${list.length} \u4EFD PDF \u6587\u6863\u5E76\u4E0B\u8F7D\uFF01`);
8538
8948
  } catch (err) {
8539
8949
  setStatusTip(`\u5408\u5E76\u5931\u8D25: ${err?.message || String(err)}`);
@@ -8631,13 +9041,7 @@ var PdfPreviewModal = () => {
8631
9041
  try {
8632
9042
  const calBytes = await exportCalibrationGridPdfBytes(unit.getDocument().pageSize);
8633
9043
  setPdfBytesState(calBytes);
8634
- const blob = new Blob([calBytes.buffer], { type: "application/pdf" });
8635
- const url = URL.createObjectURL(blob);
8636
- const a = document.createElement("a");
8637
- a.href = url;
8638
- a.download = `${unit.getName() || "document"}-calibration-grid.pdf`;
8639
- a.click();
8640
- setTimeout(() => URL.revokeObjectURL(url), 1e3);
9044
+ triggerBlobDownload(calBytes, `${unit.getName() || "document"}-calibration-grid.pdf`);
8641
9045
  setStatusTip("\u5DF2\u751F\u6210\u5E76\u4E0B\u8F7D 1mm / 5mm / 10mm \u6BEB\u7C73\u6821\u51C6\u6D4B\u8BD5\u5C3A PDF\uFF01\u53EF\u5957\u6253\u81F3\u7A7A\u767D\u8054\u8BFB\u53D6\u504F\u79FB\u91CF\u3002");
8642
9046
  } catch (err) {
8643
9047
  setStatusTip(`\u6821\u51C6\u5C3A\u751F\u6210\u5931\u8D25: ${err?.message || String(err)}`);
@@ -8651,7 +9055,9 @@ var PdfPreviewModal = () => {
8651
9055
  unitId: unit.getUnitId(),
8652
9056
  snapshot: unit.save()
8653
9057
  });
8654
- setStatusTip(ok ? `\u5DF2\u901A\u8FC7 IO \u94A9\u5B50 (${ioAdapter.name || "custom"}) \u4FDD\u5B58\u81F3\u5BBF\u4E3B\u540E\u7AEF\uFF01` : "\u5F53\u524D\u672A\u914D\u7F6E onSave \u540E\u7AEF\u4FDD\u5B58\u94A9\u5B50");
9058
+ setStatusTip(
9059
+ ok ? `\u5DF2\u901A\u8FC7 IO \u94A9\u5B50 (${ioAdapter.name || "custom"}) \u4FDD\u5B58\u81F3\u5BBF\u4E3B\u540E\u7AEF\uFF01` : "\u5F53\u524D\u672A\u914D\u7F6E onSave \u540E\u7AEF\u4FDD\u5B58\u94A9\u5B50"
9060
+ );
8655
9061
  } catch (err) {
8656
9062
  setStatusTip(`\u5BBF\u4E3B\u4FDD\u5B58\u5931\u8D25: ${err?.message || String(err)}`);
8657
9063
  }
@@ -8674,764 +9080,745 @@ var PdfPreviewModal = () => {
8674
9080
  const ioCaps = ioService.getIoCapabilities();
8675
9081
  const pdfCapReport = inspectPdfExportCapabilities(unit.save());
8676
9082
  const snapSizeKb = (pdfCapReport.snapshotByteSize / 1024).toFixed(1);
8677
- return /* @__PURE__ */ jsx6("div", { className: "univer-pdf-modal-backdrop", onClick: () => selectionService.setPreviewOpen(false), children: /* @__PURE__ */ jsxs6("div", { className: "univer-pdf-modal-card", onClick: (e) => e.stopPropagation(), children: [
8678
- /* @__PURE__ */ jsxs6("div", { className: "univer-pdf-modal-header", children: [
8679
- /* @__PURE__ */ jsxs6("div", { className: "univer-pdf-modal-tabs", children: [
8680
- /* @__PURE__ */ jsxs6(
8681
- "button",
8682
- {
8683
- type: "button",
8684
- className: `univer-pdf-modal-tab ${modalTab === "preview" ? "is-active" : ""}`,
8685
- style: { display: "inline-flex", alignItems: "center", gap: 5 },
8686
- onClick: () => featureService.setModalTab("preview"),
8687
- children: [
8688
- /* @__PURE__ */ jsx6(UiFilePdfIcon, {}),
8689
- /* @__PURE__ */ jsx6("span", { children: "PDF \u52A8\u6001\u6E32\u67D3\u9884\u89C8 & \u4E0B\u8F7D" })
8690
- ]
8691
- }
8692
- ),
8693
- /* @__PURE__ */ jsx6(
8694
- "button",
8695
- {
8696
- type: "button",
8697
- className: `univer-pdf-modal-tab ${modalTab === "json" ? "is-active" : ""}`,
8698
- onClick: () => featureService.setModalTab("json"),
8699
- children: `{ } JSON \u5951\u7EA6 (IPdfUnitData / pdfme \u4E92\u8F6C)`
8700
- }
8701
- )
8702
- ] }),
8703
- /* @__PURE__ */ jsxs6("div", { style: { display: "flex", alignItems: "center", gap: 10 }, children: [
8704
- /* @__PURE__ */ jsxs6(
8705
- "span",
8706
- {
8707
- style: {
8708
- fontSize: 11,
8709
- padding: "3px 8px",
8710
- borderRadius: 999,
8711
- background: isCustomBackendAdapter ? "#F3F5FF" : "#EEEFF1",
8712
- color: isCustomBackendAdapter ? "#2C53F1" : "#4E5565",
8713
- border: `1px solid ${isCustomBackendAdapter ? "#D2DAFA" : "#E3E5EA"}`,
8714
- fontWeight: 500
8715
- },
8716
- children: [
8717
- "IO \u7BA1\u9053: ",
8718
- ioAdapter.name || "frontend-default"
8719
- ]
8720
- }
8721
- ),
8722
- /* @__PURE__ */ jsx6(
8723
- "button",
8724
- {
8725
- type: "button",
8726
- className: "univer-pdf-modal-close",
8727
- onClick: () => selectionService.setPreviewOpen(false),
8728
- children: "\xD7"
8729
- }
8730
- )
8731
- ] })
8732
- ] }),
8733
- modalTab === "preview" ? /* @__PURE__ */ jsxs6("div", { className: "univer-pdf-modal-body-split", children: [
8734
- features.datasetBinding ? /* @__PURE__ */ jsxs6("div", { className: "univer-pdf-modal-side", children: [
8735
- /* @__PURE__ */ jsx6("div", { className: "univer-pdf-modal-label", children: "\u6D4B\u8BD5\u6570\u636E\u96C6 JSON\uFF08\u5B9E\u65F6\u586B\u5145\u52A8\u6001\u6587\u672C\u3001\u8868\u683C\u3001\u4E8C\u7EF4\u7801\uFF09" }),
8736
- /* @__PURE__ */ jsx6(
8737
- "textarea",
8738
- {
8739
- className: "univer-pdf-code-editor",
8740
- value: sampleJsonText,
8741
- onChange: (e) => setSampleJsonText(e.target.value)
8742
- }
8743
- ),
8744
- /* @__PURE__ */ jsx6(
8745
- "input",
8746
- {
8747
- type: "text",
8748
- placeholder: "\u9632\u4F2A\u659C\u5411\u6C34\u5370\u6587\u5B57\uFF08\u5982\uFF1A\u828B\u9053\u7968\u636E \xB7 \u590D\u5370\u65E0\u6548\uFF09",
8749
- value: watermarkText,
8750
- onChange: (e) => setWatermarkText(e.target.value),
8751
- style: {
8752
- border: "1px solid #D5D8DF",
8753
- borderRadius: 6,
8754
- padding: "5px 8px",
8755
- fontSize: 11.5,
8756
- color: "#1B1C1F",
8757
- background: "#FFFFFF"
8758
- }
8759
- }
8760
- ),
8761
- /* @__PURE__ */ jsxs6("label", { className: "univer-pdf-checkbox-row", style: { fontSize: 11.5 }, children: [
8762
- /* @__PURE__ */ jsx6(
8763
- "input",
8764
- {
8765
- type: "checkbox",
8766
- checked: excludeBasePdf,
8767
- onChange: (e) => {
8768
- setExcludeBasePdf(e.target.checked);
8769
- generatePreview(sampleJsonText, watermarkText, e.target.checked);
9083
+ const isUnifiedIoTab = modalTab === "preview" || modalTab === "import";
9084
+ const browserAvailable = modalTab === "import" ? Boolean(ioCaps.formats.import.pdf?.browser) : Boolean(ioCaps.formats.export.pdf?.browser);
9085
+ const serverAvailable = modalTab === "import" ? Boolean(ioCaps.formats.import.pdf?.server) : Boolean(ioCaps.formats.export.pdf?.server);
9086
+ const unifiedIoSection = /* @__PURE__ */ jsx6(
9087
+ PdfUnifiedIoSection,
9088
+ {
9089
+ ioTarget,
9090
+ browserAvailable,
9091
+ serverAvailable,
9092
+ snapSizeKb,
9093
+ editorEnabled,
9094
+ importing,
9095
+ rendering,
9096
+ selectedFileName: selectedImportFile?.name,
9097
+ pendingImport,
9098
+ ioError,
9099
+ fileInputRef,
9100
+ onSelectTarget: handleSelectTarget,
9101
+ onFileInputChange: handleImportFileChange,
9102
+ onPickFileClick: () => fileInputRef.current?.click(),
9103
+ onConfirmImport: handleConfirmStagedImport,
9104
+ onCancelImport: handleCancelStagedImport,
9105
+ onSwitchAndRetry: () => void handleSwitchAndRetry()
9106
+ }
9107
+ );
9108
+ return /* @__PURE__ */ jsx6("div", { className: "univer-pdf-modal-backdrop", onClick: () => selectionService.setPreviewOpen(false), children: /* @__PURE__ */ jsxs6(
9109
+ "div",
9110
+ {
9111
+ className: "univer-pdf-modal-card",
9112
+ "data-testid": "yudao-io-modal",
9113
+ role: "dialog",
9114
+ "aria-modal": "true",
9115
+ onClick: (e) => e.stopPropagation(),
9116
+ children: [
9117
+ /* @__PURE__ */ jsxs6("div", { className: "univer-pdf-modal-header", children: [
9118
+ /* @__PURE__ */ jsxs6("div", { className: "univer-pdf-modal-tabs", children: [
9119
+ /* @__PURE__ */ jsxs6(
9120
+ "button",
9121
+ {
9122
+ type: "button",
9123
+ className: `univer-pdf-modal-tab ${isUnifiedIoTab ? "is-active" : ""}`,
9124
+ style: { display: "inline-flex", alignItems: "center", gap: 5 },
9125
+ onClick: () => featureService.setModalTab("preview"),
9126
+ children: [
9127
+ /* @__PURE__ */ jsx6(UiFilePdfIcon, {}),
9128
+ /* @__PURE__ */ jsx6("span", { children: "PDF \u5BFC\u5165 / \u9884\u89C8\u4E0E\u5BFC\u51FA" })
9129
+ ]
8770
9130
  }
8771
- }
8772
- ),
8773
- /* @__PURE__ */ jsx6("span", { children: "\u9488\u5F0F\u5957\u6253\u6A21\u5F0F\uFF1A\u5BFC\u51FA/\u6253\u5370\u81EA\u52A8\u5265\u79BB\u5E95\u56FE PDF" })
8774
- ] }),
8775
- features.acroForm && /* @__PURE__ */ jsxs6("label", { className: "univer-pdf-checkbox-row", style: { fontSize: 11.5 }, children: [
8776
- /* @__PURE__ */ jsx6(
8777
- "input",
8778
- {
8779
- type: "checkbox",
8780
- checked: interactiveForm,
8781
- onChange: (e) => {
8782
- const checked = e.target.checked;
8783
- setInteractiveForm(checked);
8784
- generatePreview(sampleJsonText, watermarkText, excludeBasePdf, ioTarget, {
8785
- interactiveForm: checked
8786
- });
9131
+ ),
9132
+ /* @__PURE__ */ jsx6(
9133
+ "button",
9134
+ {
9135
+ type: "button",
9136
+ className: `univer-pdf-modal-tab ${modalTab === "json" ? "is-active" : ""}`,
9137
+ onClick: () => featureService.setModalTab("json"),
9138
+ children: `{ } JSON \u5951\u7EA6 (IPdfUnitData / pdfme \u4E92\u8F6C)`
8787
9139
  }
8788
- }
8789
- ),
8790
- /* @__PURE__ */ jsx6("span", { children: "\u4EA4\u4E92\u5F0F AcroForm \u8868\u5355\u57DF\u5BFC\u51FA (\u652F\u6301 PDF \u9605\u8BFB\u5668\u586B\u8868)" })
8791
- ] }),
8792
- /* @__PURE__ */ jsxs6("label", { className: "univer-pdf-checkbox-row", style: { fontSize: 11.5 }, children: [
8793
- /* @__PURE__ */ jsx6(
8794
- "input",
8795
- {
8796
- type: "checkbox",
8797
- checked: pdfACompliant,
8798
- onChange: (e) => {
8799
- const checked = e.target.checked;
8800
- setPdfACompliant(checked);
8801
- generatePreview(sampleJsonText, watermarkText, excludeBasePdf, ioTarget, {
8802
- pdfACompliant: checked
8803
- });
9140
+ )
9141
+ ] }),
9142
+ /* @__PURE__ */ jsxs6("div", { style: { display: "flex", alignItems: "center", gap: 10 }, children: [
9143
+ /* @__PURE__ */ jsxs6(
9144
+ "span",
9145
+ {
9146
+ style: {
9147
+ fontSize: 11,
9148
+ padding: "3px 8px",
9149
+ borderRadius: 999,
9150
+ background: isCustomBackendAdapter ? "#F3F5FF" : "#EEEFF1",
9151
+ color: isCustomBackendAdapter ? "#2C53F1" : "#4E5565",
9152
+ border: `1px solid ${isCustomBackendAdapter ? "#D2DAFA" : "#E3E5EA"}`,
9153
+ fontWeight: 500
9154
+ },
9155
+ children: [
9156
+ "IO \u7BA1\u9053: ",
9157
+ ioAdapter.name || "frontend-default"
9158
+ ]
8804
9159
  }
8805
- }
8806
- ),
8807
- /* @__PURE__ */ jsx6("span", { children: "PDF/A-1b \u957F\u671F\u5F52\u6863\u5408\u89C4 (/Metadata XMP + /OutputIntents)" })
8808
- ] }),
8809
- /* @__PURE__ */ jsxs6("label", { className: "univer-pdf-checkbox-row", style: { fontSize: 11.5 }, children: [
8810
- /* @__PURE__ */ jsx6(
8811
- "input",
8812
- {
8813
- type: "checkbox",
8814
- checked: accessibilityTagged,
8815
- onChange: (e) => {
8816
- const checked = e.target.checked;
8817
- setAccessibilityTagged(checked);
8818
- generatePreview(sampleJsonText, watermarkText, excludeBasePdf, ioTarget, {
8819
- accessibilityTagged: checked
8820
- });
9160
+ ),
9161
+ /* @__PURE__ */ jsx6(
9162
+ "button",
9163
+ {
9164
+ type: "button",
9165
+ className: "univer-pdf-modal-close",
9166
+ onClick: () => selectionService.setPreviewOpen(false),
9167
+ children: "\xD7"
8821
9168
  }
8822
- }
8823
- ),
8824
- /* @__PURE__ */ jsx6("span", { children: "PDF/UA \u65E0\u969C\u788D\u6807\u7B7E\u7ED3\u6784 (/StructTreeRoot + Alt-Text)" })
8825
- ] }),
8826
- (features.acroForm || features.sanitize && editorEnabled) && /* @__PURE__ */ jsxs6("div", { className: "univer-pdf-btn-row", children: [
8827
- features.acroForm && /* @__PURE__ */ jsx6(
8828
- "button",
8829
- {
8830
- type: "button",
8831
- className: "univer-pdf-mini-btn",
8832
- style: { flex: 1 },
8833
- onClick: () => {
8834
- const xml = exportFormDataToXfdf2(unit.save());
8835
- const blob = new Blob([xml], { type: "application/vnd.adobe.xfdf" });
8836
- const url = URL.createObjectURL(blob);
8837
- const a = document.createElement("a");
8838
- a.href = url;
8839
- a.download = `${unit.getName() || "form-data"}.xfdf`;
8840
- a.click();
8841
- setTimeout(() => URL.revokeObjectURL(url), 1e3);
8842
- setStatusTip("\u5DF2\u5BFC\u51FA Adobe \u6807\u51C6 XFDF \u8868\u5355\u6570\u636E\u6587\u4EF6");
8843
- },
8844
- children: "\u5BFC\u51FA XFDF"
8845
- }
8846
- ),
8847
- features.acroForm && editorEnabled && /* @__PURE__ */ jsx6(
8848
- "button",
8849
- {
8850
- type: "button",
8851
- className: "univer-pdf-mini-btn",
8852
- style: { flex: 1 },
8853
- onClick: () => {
8854
- const input = document.createElement("input");
8855
- input.type = "file";
8856
- input.accept = ".xfdf,.xml";
8857
- input.onchange = async () => {
8858
- const file = input.files?.[0];
8859
- if (!file) return;
8860
- const xml = await file.text();
8861
- const next = importFormDataFromXfdf2(unit.save(), xml);
8862
- commandService.syncExecuteCommand(ReplacePdfSnapshotCommand4.id, {
8863
- unitId: unit.getUnitId(),
8864
- snapshot: next
8865
- });
8866
- generatePreview();
8867
- setStatusTip("\u5DF2\u5BFC\u5165 XFDF \u6570\u636E\u5E76\u5237\u65B0 PDF \u9884\u89C8");
8868
- };
8869
- input.click();
8870
- },
8871
- children: "\u5BFC\u5165 XFDF"
8872
- }
8873
- ),
8874
- features.sanitize && editorEnabled && /* @__PURE__ */ jsx6(
8875
- "button",
8876
- {
8877
- type: "button",
8878
- className: "univer-pdf-mini-btn",
8879
- onClick: () => {
8880
- const cleaned = sanitizePdfUnit2(unit.save());
8881
- commandService.syncExecuteCommand(ReplacePdfSnapshotCommand4.id, {
8882
- unitId: unit.getUnitId(),
8883
- snapshot: cleaned
8884
- });
8885
- generatePreview();
8886
- setStatusTip("\u5DF2\u5B8C\u6210\u5143\u6570\u636E\u4E0E\u6279\u6CE8\u6E05\u7406 (Sanitize)");
8887
- },
8888
- children: "\u8131\u654F\u6E05\u7406"
8889
- }
8890
- )
9169
+ )
9170
+ ] })
8891
9171
  ] }),
8892
- /* @__PURE__ */ jsxs6("label", { className: "univer-pdf-checkbox-row", style: { fontSize: 11.5 }, children: [
8893
- /* @__PURE__ */ jsx6(
8894
- "input",
8895
- {
8896
- type: "checkbox",
8897
- checked: enableAuditSeal,
8898
- onChange: (e) => {
8899
- const checked = e.target.checked;
8900
- setEnableAuditSeal(checked);
8901
- generatePreview(sampleJsonText, watermarkText, excludeBasePdf, ioTarget, void 0, checked);
9172
+ isUnifiedIoTab ? /* @__PURE__ */ jsxs6("div", { className: "univer-pdf-modal-body-split", children: [
9173
+ features.datasetBinding ? /* @__PURE__ */ jsxs6("div", { className: "univer-pdf-modal-side", children: [
9174
+ unifiedIoSection,
9175
+ /* @__PURE__ */ jsx6("div", { className: "univer-pdf-modal-label", children: "\u6D4B\u8BD5\u6570\u636E\u96C6 JSON\uFF08\u5B9E\u65F6\u586B\u5145\u52A8\u6001\u6587\u672C\u3001\u8868\u683C\u3001\u4E8C\u7EF4\u7801\uFF09" }),
9176
+ /* @__PURE__ */ jsx6(
9177
+ "textarea",
9178
+ {
9179
+ className: "univer-pdf-code-editor",
9180
+ style: { minHeight: 96 },
9181
+ value: sampleJsonText,
9182
+ onChange: (e) => setSampleJsonText(e.target.value)
8902
9183
  }
8903
- }
8904
- ),
8905
- /* @__PURE__ */ jsx6(UiShieldSealIcon, { style: { color: "#4E5565" } }),
8906
- /* @__PURE__ */ jsx6("span", { children: "\u9644\u52A0 SHA-256 \u9632\u7BE1\u6539\u7B7E\u7AE0\u6458\u8981" })
8907
- ] }),
8908
- enableAuditSeal && /* @__PURE__ */ jsx6(
8909
- "input",
8910
- {
8911
- type: "text",
8912
- placeholder: "\u7B7E\u7AE0\u8D23\u4EFB\u4EBA / \u673A\u6784\u540D\u79F0",
8913
- value: auditSigner,
8914
- onChange: (e) => setAuditSigner(e.target.value),
8915
- style: {
8916
- border: "1px solid #D5D8DF",
8917
- borderRadius: 6,
8918
- padding: "4px 8px",
8919
- fontSize: 11,
8920
- color: "#1B1C1F",
8921
- background: "#FFFFFF"
8922
- }
8923
- }
8924
- ),
8925
- /* @__PURE__ */ jsxs6(
8926
- "div",
8927
- {
8928
- style: {
8929
- padding: "6px 8px",
8930
- background: "#F9FAFB",
8931
- border: "1px solid #E3E5EA",
8932
- borderRadius: 6,
8933
- display: "flex",
8934
- flexDirection: "column",
8935
- gap: 5
8936
- },
8937
- children: [
8938
- /* @__PURE__ */ jsx6("div", { style: { fontSize: 11, fontWeight: 600, color: "#1B1C1F" }, children: "\u9488\u5F0F\u786C\u4EF6\u504F\u79FB\u8865\u507F X/Y (mm)" }),
8939
- /* @__PURE__ */ jsxs6("div", { style: { display: "grid", gridTemplateColumns: "1fr 1fr", gap: 6 }, children: [
8940
- /* @__PURE__ */ jsxs6("label", { style: { display: "flex", alignItems: "center", gap: 4, fontSize: 11, color: "#4E5565" }, children: [
8941
- /* @__PURE__ */ jsx6("span", { children: "X:" }),
8942
- /* @__PURE__ */ jsx6(
8943
- "input",
8944
- {
8945
- type: "number",
8946
- step: "0.5",
8947
- value: printerOffsetXMm,
8948
- onChange: (e) => {
8949
- const nextX = Number(e.target.value) || 0;
8950
- setPrinterOffsetXMm(nextX);
8951
- generatePreview(sampleJsonText, watermarkText, excludeBasePdf, ioTarget, {
8952
- printerOffsetXMm: nextX
8953
- });
8954
- },
8955
- style: {
8956
- width: "100%",
8957
- border: "1px solid #D5D8DF",
8958
- borderRadius: 4,
8959
- padding: "2px 5px",
8960
- fontSize: 11,
8961
- color: "#1B1C1F",
8962
- background: "#FFFFFF"
8963
- }
8964
- }
8965
- )
8966
- ] }),
8967
- /* @__PURE__ */ jsxs6("label", { style: { display: "flex", alignItems: "center", gap: 4, fontSize: 11, color: "#4E5565" }, children: [
8968
- /* @__PURE__ */ jsx6("span", { children: "Y:" }),
8969
- /* @__PURE__ */ jsx6(
8970
- "input",
9184
+ ),
9185
+ /* @__PURE__ */ jsx6(
9186
+ "input",
9187
+ {
9188
+ type: "text",
9189
+ placeholder: "\u9632\u4F2A\u659C\u5411\u6C34\u5370\u6587\u5B57\uFF08\u5982\uFF1A\u5185\u90E8\u5355\u636E \xB7 \u590D\u5370\u65E0\u6548\uFF09",
9190
+ value: watermarkText,
9191
+ onChange: (e) => setWatermarkText(e.target.value),
9192
+ style: {
9193
+ border: "1px solid #D5D8DF",
9194
+ borderRadius: 6,
9195
+ padding: "5px 8px",
9196
+ fontSize: 11.5,
9197
+ color: "#1B1C1F",
9198
+ background: "#FFFFFF"
9199
+ }
9200
+ }
9201
+ ),
9202
+ /* @__PURE__ */ jsxs6("label", { className: "univer-pdf-checkbox-row", style: { fontSize: 11.5 }, children: [
9203
+ /* @__PURE__ */ jsx6(
9204
+ "input",
9205
+ {
9206
+ type: "checkbox",
9207
+ checked: excludeBasePdf,
9208
+ onChange: (e) => {
9209
+ setExcludeBasePdf(e.target.checked);
9210
+ void generatePreview(sampleJsonText, watermarkText, e.target.checked);
9211
+ }
9212
+ }
9213
+ ),
9214
+ /* @__PURE__ */ jsx6("span", { children: "\u9488\u5F0F\u5957\u6253\u6A21\u5F0F\uFF1A\u5BFC\u51FA/\u6253\u5370\u81EA\u52A8\u5265\u79BB\u5E95\u56FE PDF" })
9215
+ ] }),
9216
+ features.acroForm && /* @__PURE__ */ jsxs6("label", { className: "univer-pdf-checkbox-row", style: { fontSize: 11.5 }, children: [
9217
+ /* @__PURE__ */ jsx6(
9218
+ "input",
9219
+ {
9220
+ type: "checkbox",
9221
+ checked: interactiveForm,
9222
+ onChange: (e) => {
9223
+ const checked = e.target.checked;
9224
+ setInteractiveForm(checked);
9225
+ void generatePreview(sampleJsonText, watermarkText, excludeBasePdf, ioTarget, {
9226
+ interactiveForm: checked
9227
+ });
9228
+ }
9229
+ }
9230
+ ),
9231
+ /* @__PURE__ */ jsx6("span", { children: "\u4EA4\u4E92\u5F0F AcroForm \u8868\u5355\u57DF\u5BFC\u51FA (\u652F\u6301 PDF \u9605\u8BFB\u5668\u586B\u8868)" })
9232
+ ] }),
9233
+ /* @__PURE__ */ jsxs6("label", { className: "univer-pdf-checkbox-row", style: { fontSize: 11.5 }, children: [
9234
+ /* @__PURE__ */ jsx6(
9235
+ "input",
9236
+ {
9237
+ type: "checkbox",
9238
+ checked: pdfACompliant,
9239
+ onChange: (e) => {
9240
+ const checked = e.target.checked;
9241
+ setPdfACompliant(checked);
9242
+ void generatePreview(sampleJsonText, watermarkText, excludeBasePdf, ioTarget, {
9243
+ pdfACompliant: checked
9244
+ });
9245
+ }
9246
+ }
9247
+ ),
9248
+ /* @__PURE__ */ jsx6("span", { children: "PDF/A-1b \u957F\u671F\u5F52\u6863\u5408\u89C4 (/Metadata XMP + /OutputIntents)" })
9249
+ ] }),
9250
+ /* @__PURE__ */ jsxs6("label", { className: "univer-pdf-checkbox-row", style: { fontSize: 11.5 }, children: [
9251
+ /* @__PURE__ */ jsx6(
9252
+ "input",
9253
+ {
9254
+ type: "checkbox",
9255
+ checked: accessibilityTagged,
9256
+ onChange: (e) => {
9257
+ const checked = e.target.checked;
9258
+ setAccessibilityTagged(checked);
9259
+ void generatePreview(sampleJsonText, watermarkText, excludeBasePdf, ioTarget, {
9260
+ accessibilityTagged: checked
9261
+ });
9262
+ }
9263
+ }
9264
+ ),
9265
+ /* @__PURE__ */ jsx6("span", { children: "PDF/UA \u65E0\u969C\u788D\u6807\u7B7E\u7ED3\u6784 (/StructTreeRoot + Alt-Text)" })
9266
+ ] }),
9267
+ (features.acroForm || features.sanitize && editorEnabled) && /* @__PURE__ */ jsxs6("div", { className: "univer-pdf-btn-row", children: [
9268
+ features.acroForm && /* @__PURE__ */ jsx6(
9269
+ "button",
9270
+ {
9271
+ type: "button",
9272
+ className: "univer-pdf-mini-btn",
9273
+ style: { flex: 1 },
9274
+ onClick: () => {
9275
+ const xml = exportFormDataToXfdf2(unit.save());
9276
+ const blob = new Blob([xml], { type: "application/vnd.adobe.xfdf" });
9277
+ const url = URL.createObjectURL(blob);
9278
+ const a = document.createElement("a");
9279
+ a.href = url;
9280
+ a.download = `${unit.getName() || "form-data"}.xfdf`;
9281
+ a.click();
9282
+ setTimeout(() => URL.revokeObjectURL(url), 1e3);
9283
+ setStatusTip("\u5DF2\u5BFC\u51FA Adobe \u6807\u51C6 XFDF \u8868\u5355\u6570\u636E\u6587\u4EF6");
9284
+ },
9285
+ children: "\u5BFC\u51FA XFDF"
9286
+ }
9287
+ ),
9288
+ features.acroForm && editorEnabled && /* @__PURE__ */ jsx6(
9289
+ "button",
9290
+ {
9291
+ type: "button",
9292
+ className: "univer-pdf-mini-btn",
9293
+ style: { flex: 1 },
9294
+ onClick: () => {
9295
+ const input = document.createElement("input");
9296
+ input.type = "file";
9297
+ input.accept = ".xfdf,.xml";
9298
+ input.onchange = async () => {
9299
+ const file = input.files?.[0];
9300
+ if (!file) return;
9301
+ const xml = await file.text();
9302
+ const next = importFormDataFromXfdf2(unit.save(), xml);
9303
+ commandService.syncExecuteCommand(ReplacePdfSnapshotCommand4.id, {
9304
+ unitId: unit.getUnitId(),
9305
+ snapshot: next
9306
+ });
9307
+ void generatePreview();
9308
+ setStatusTip("\u5DF2\u5BFC\u5165 XFDF \u6570\u636E\u5E76\u5237\u65B0 PDF \u9884\u89C8");
9309
+ };
9310
+ input.click();
9311
+ },
9312
+ children: "\u5BFC\u5165 XFDF"
9313
+ }
9314
+ ),
9315
+ features.sanitize && editorEnabled && /* @__PURE__ */ jsx6(
9316
+ "button",
9317
+ {
9318
+ type: "button",
9319
+ className: "univer-pdf-mini-btn",
9320
+ onClick: () => {
9321
+ const cleaned = sanitizePdfUnit2(unit.save());
9322
+ commandService.syncExecuteCommand(ReplacePdfSnapshotCommand4.id, {
9323
+ unitId: unit.getUnitId(),
9324
+ snapshot: cleaned
9325
+ });
9326
+ void generatePreview();
9327
+ setStatusTip("\u5DF2\u5B8C\u6210\u5143\u6570\u636E\u4E0E\u6279\u6CE8\u6E05\u7406 (Sanitize)");
9328
+ },
9329
+ children: "\u8131\u654F\u6E05\u7406"
9330
+ }
9331
+ )
9332
+ ] }),
9333
+ /* @__PURE__ */ jsxs6("label", { className: "univer-pdf-checkbox-row", style: { fontSize: 11.5 }, children: [
9334
+ /* @__PURE__ */ jsx6(
9335
+ "input",
9336
+ {
9337
+ type: "checkbox",
9338
+ checked: enableAuditSeal,
9339
+ onChange: (e) => {
9340
+ const checked = e.target.checked;
9341
+ setEnableAuditSeal(checked);
9342
+ void generatePreview(sampleJsonText, watermarkText, excludeBasePdf, ioTarget, void 0, checked);
9343
+ }
9344
+ }
9345
+ ),
9346
+ /* @__PURE__ */ jsx6(UiShieldSealIcon, { style: { color: "#4E5565" } }),
9347
+ /* @__PURE__ */ jsx6("span", { children: "\u9644\u52A0 SHA-256 \u9632\u7BE1\u6539\u7B7E\u7AE0\u6458\u8981" })
9348
+ ] }),
9349
+ enableAuditSeal && /* @__PURE__ */ jsx6(
9350
+ "input",
9351
+ {
9352
+ type: "text",
9353
+ placeholder: "\u7B7E\u7AE0\u8D23\u4EFB\u4EBA / \u673A\u6784\u540D\u79F0",
9354
+ value: auditSigner,
9355
+ onChange: (e) => setAuditSigner(e.target.value),
9356
+ style: {
9357
+ border: "1px solid #D5D8DF",
9358
+ borderRadius: 6,
9359
+ padding: "4px 8px",
9360
+ fontSize: 11,
9361
+ color: "#1B1C1F",
9362
+ background: "#FFFFFF"
9363
+ }
9364
+ }
9365
+ ),
9366
+ /* @__PURE__ */ jsxs6(
9367
+ "div",
9368
+ {
9369
+ style: {
9370
+ padding: "6px 8px",
9371
+ background: "#F9FAFB",
9372
+ border: "1px solid #E3E5EA",
9373
+ borderRadius: 6,
9374
+ display: "flex",
9375
+ flexDirection: "column",
9376
+ gap: 5
9377
+ },
9378
+ children: [
9379
+ /* @__PURE__ */ jsx6("div", { style: { fontSize: 11, fontWeight: 600, color: "#1B1C1F" }, children: "\u9488\u5F0F\u786C\u4EF6\u504F\u79FB\u8865\u507F X/Y (mm)" }),
9380
+ /* @__PURE__ */ jsxs6("div", { style: { display: "grid", gridTemplateColumns: "1fr 1fr", gap: 6 }, children: [
9381
+ /* @__PURE__ */ jsxs6("label", { style: { display: "flex", alignItems: "center", gap: 4, fontSize: 11, color: "#4E5565" }, children: [
9382
+ /* @__PURE__ */ jsx6("span", { children: "X:" }),
9383
+ /* @__PURE__ */ jsx6(
9384
+ "input",
9385
+ {
9386
+ type: "number",
9387
+ step: "0.5",
9388
+ value: printerOffsetXMm,
9389
+ onChange: (e) => {
9390
+ const nextX = Number(e.target.value) || 0;
9391
+ setPrinterOffsetXMm(nextX);
9392
+ void generatePreview(sampleJsonText, watermarkText, excludeBasePdf, ioTarget, {
9393
+ printerOffsetXMm: nextX
9394
+ });
9395
+ },
9396
+ style: {
9397
+ width: "100%",
9398
+ border: "1px solid #D5D8DF",
9399
+ borderRadius: 4,
9400
+ padding: "2px 5px",
9401
+ fontSize: 11,
9402
+ color: "#1B1C1F",
9403
+ background: "#FFFFFF"
9404
+ }
9405
+ }
9406
+ )
9407
+ ] }),
9408
+ /* @__PURE__ */ jsxs6("label", { style: { display: "flex", alignItems: "center", gap: 4, fontSize: 11, color: "#4E5565" }, children: [
9409
+ /* @__PURE__ */ jsx6("span", { children: "Y:" }),
9410
+ /* @__PURE__ */ jsx6(
9411
+ "input",
9412
+ {
9413
+ type: "number",
9414
+ step: "0.5",
9415
+ value: printerOffsetYMm,
9416
+ onChange: (e) => {
9417
+ const nextY = Number(e.target.value) || 0;
9418
+ setPrinterOffsetYMm(nextY);
9419
+ void generatePreview(sampleJsonText, watermarkText, excludeBasePdf, ioTarget, {
9420
+ printerOffsetYMm: nextY
9421
+ });
9422
+ },
9423
+ style: {
9424
+ width: "100%",
9425
+ border: "1px solid #D5D8DF",
9426
+ borderRadius: 4,
9427
+ padding: "2px 5px",
9428
+ fontSize: 11,
9429
+ color: "#1B1C1F",
9430
+ background: "#FFFFFF"
9431
+ }
9432
+ }
9433
+ )
9434
+ ] })
9435
+ ] }),
9436
+ /* @__PURE__ */ jsxs6(
9437
+ "button",
8971
9438
  {
8972
- type: "number",
8973
- step: "0.5",
8974
- value: printerOffsetYMm,
8975
- onChange: (e) => {
8976
- const nextY = Number(e.target.value) || 0;
8977
- setPrinterOffsetYMm(nextY);
8978
- generatePreview(sampleJsonText, watermarkText, excludeBasePdf, ioTarget, {
8979
- printerOffsetYMm: nextY
8980
- });
8981
- },
8982
- style: {
8983
- width: "100%",
8984
- border: "1px solid #D5D8DF",
8985
- borderRadius: 4,
8986
- padding: "2px 5px",
8987
- fontSize: 11,
8988
- color: "#1B1C1F",
8989
- background: "#FFFFFF"
8990
- }
9439
+ type: "button",
9440
+ className: "univer-pdf-mini-btn",
9441
+ style: { display: "inline-flex", alignItems: "center", justifyContent: "center", gap: 4 },
9442
+ disabled: rendering,
9443
+ onClick: handleDownloadCalibrationGrid,
9444
+ children: [
9445
+ /* @__PURE__ */ jsx6(UiRulerGridIcon, {}),
9446
+ /* @__PURE__ */ jsx6("span", { children: "\u4E0B\u8F7D\u6BEB\u7C73\u6821\u51C6\u6D4B\u8BD5\u5C3A PDF" })
9447
+ ]
8991
9448
  }
8992
9449
  )
8993
- ] })
9450
+ ]
9451
+ }
9452
+ ),
9453
+ /* @__PURE__ */ jsxs6("div", { style: { display: "flex", flexDirection: "column", gap: 4 }, children: [
9454
+ /* @__PURE__ */ jsxs6("label", { style: { display: "flex", justifyContent: "space-between", alignItems: "center", fontSize: 11.5, color: "#31363F" }, children: [
9455
+ /* @__PURE__ */ jsx6("span", { children: "\u4E2D\u6587\u77E2\u91CF\u53EF\u68C0\u7D22\u6A21\u5F0F" }),
9456
+ /* @__PURE__ */ jsxs6(
9457
+ "select",
9458
+ {
9459
+ value: cjkTextMode,
9460
+ onChange: (e) => {
9461
+ const mode = e.target.value;
9462
+ setCjkTextMode(mode);
9463
+ void generatePreview(sampleJsonText, watermarkText, excludeBasePdf, ioTarget, {
9464
+ cjkTextMode: mode
9465
+ });
9466
+ },
9467
+ style: {
9468
+ border: "1px solid #D5D8DF",
9469
+ borderRadius: 4,
9470
+ padding: "2px 5px",
9471
+ fontSize: 11,
9472
+ color: "#1B1C1F",
9473
+ background: "#FFFFFF"
9474
+ },
9475
+ children: [
9476
+ /* @__PURE__ */ jsx6("option", { value: "raster-hd", children: "\u9AD8\u6E05\u6805\u683C\u6A21\u5F0F (3x DPI PNG)" }),
9477
+ /* @__PURE__ */ jsx6("option", { value: "cid-vector", children: "\u4E2D\u6587\u77E2\u91CF\u53EF\u68C0\u7D22\u6A21\u5F0F (cid-vector 0KB)" }),
9478
+ /* @__PURE__ */ jsx6("option", { value: "subset-ttf", children: "TTF \u5B57\u4F53\u5B50\u96C6\u77E2\u91CF\u5185\u5D4C (subset-ttf)" })
9479
+ ]
9480
+ }
9481
+ )
8994
9482
  ] }),
9483
+ cjkTextMode === "subset-ttf" && /* @__PURE__ */ jsx6(
9484
+ "button",
9485
+ {
9486
+ type: "button",
9487
+ className: "univer-pdf-mini-btn",
9488
+ onClick: () => {
9489
+ const input = document.createElement("input");
9490
+ input.type = "file";
9491
+ input.accept = ".ttf";
9492
+ input.onchange = async () => {
9493
+ const file = input.files?.[0];
9494
+ if (!file) return;
9495
+ const bytes = new Uint8Array(await file.arrayBuffer());
9496
+ setCustomFontBytes(bytes);
9497
+ setCustomFontName(file.name);
9498
+ void generatePreview(sampleJsonText, watermarkText, excludeBasePdf, ioTarget, {
9499
+ cjkTextMode: "subset-ttf",
9500
+ customFontBytes: bytes
9501
+ });
9502
+ };
9503
+ input.click();
9504
+ },
9505
+ children: customFontName ? `\u5DF2\u8F7D\u5165\u5B57\u4F53: ${customFontName}` : "\u4E0A\u4F20 .ttf \u5B57\u4F53\u542F\u7528\u5B50\u96C6\u5316\u5185\u5D4C"
9506
+ }
9507
+ )
9508
+ ] }),
9509
+ splitMergeQuickBox,
9510
+ /* @__PURE__ */ jsxs6("div", { className: "univer-pdf-btn-row", children: [
9511
+ /* @__PURE__ */ jsx6(
9512
+ "button",
9513
+ {
9514
+ type: "button",
9515
+ className: "univer-pdf-mini-btn is-primary",
9516
+ disabled: rendering,
9517
+ onClick: () => void generatePreview(),
9518
+ children: rendering ? "\u6E32\u67D3\u4E2D..." : "\u91CD\u65B0\u751F\u6210 PDF"
9519
+ }
9520
+ ),
9521
+ /* @__PURE__ */ jsx6(
9522
+ "button",
9523
+ {
9524
+ type: "button",
9525
+ className: "univer-pdf-mini-btn",
9526
+ disabled: rendering,
9527
+ onClick: () => {
9528
+ const baseObj = unit.save().metadata?.sampleData ?? { orderNo: "SO-2026-001" };
9529
+ const batchArr = [1, 2, 3].map((n) => ({
9530
+ ...baseObj,
9531
+ orderNo: `BATCH-2026-00${n}`,
9532
+ batchSeq: n
9533
+ }));
9534
+ const txt = JSON.stringify(batchArr, null, 2);
9535
+ setSampleJsonText(txt);
9536
+ void generatePreview(txt);
9537
+ },
9538
+ children: "\u6279\u91CF\u5957\u6253 (3\u5355\u5408\u5E76)"
9539
+ }
9540
+ ),
8995
9541
  /* @__PURE__ */ jsxs6(
9542
+ "button",
9543
+ {
9544
+ type: "button",
9545
+ "data-testid": "yudao-io-export-download",
9546
+ className: "univer-pdf-mini-btn",
9547
+ style: { display: "inline-flex", alignItems: "center", gap: 4 },
9548
+ disabled: rendering,
9549
+ onClick: () => void handleExportAndDownload(),
9550
+ children: [
9551
+ /* @__PURE__ */ jsx6(UiDownloadIcon, {}),
9552
+ /* @__PURE__ */ jsx6("span", { children: "\u4E0B\u8F7D PDF \u6587\u4EF6" })
9553
+ ]
9554
+ }
9555
+ ),
9556
+ features.print && /* @__PURE__ */ jsxs6(
8996
9557
  "button",
8997
9558
  {
8998
9559
  type: "button",
8999
9560
  className: "univer-pdf-mini-btn",
9000
- style: { display: "inline-flex", alignItems: "center", justifyContent: "center", gap: 4 },
9561
+ style: { display: "inline-flex", alignItems: "center", gap: 4 },
9001
9562
  disabled: rendering,
9002
- onClick: handleDownloadCalibrationGrid,
9563
+ onClick: handleBrowserPrint,
9564
+ children: [
9565
+ /* @__PURE__ */ jsx6(UiPrinterIcon, {}),
9566
+ /* @__PURE__ */ jsx6("span", { children: "\u6D4F\u89C8\u5668\u6253\u5370" })
9567
+ ]
9568
+ }
9569
+ ),
9570
+ features.print && /* @__PURE__ */ jsxs6(
9571
+ "button",
9572
+ {
9573
+ type: "button",
9574
+ className: "univer-pdf-mini-btn",
9575
+ style: { display: "inline-flex", alignItems: "center", gap: 4 },
9576
+ disabled: rendering,
9577
+ onClick: handleSilentPrint,
9578
+ children: [
9579
+ /* @__PURE__ */ jsx6(UiPrinterIcon, {}),
9580
+ /* @__PURE__ */ jsx6("span", { children: "\u9759\u9ED8\u76F4\u6253 (Lodop/\u672C\u5730\u6253\u5370\u52A9\u624B)" })
9581
+ ]
9582
+ }
9583
+ ),
9584
+ ioAdapter.onSave && /* @__PURE__ */ jsxs6(
9585
+ "button",
9586
+ {
9587
+ type: "button",
9588
+ className: "univer-pdf-mini-btn",
9589
+ style: { display: "inline-flex", alignItems: "center", gap: 4 },
9590
+ onClick: handleSaveToHost,
9003
9591
  children: [
9004
- /* @__PURE__ */ jsx6(UiRulerGridIcon, {}),
9005
- /* @__PURE__ */ jsx6("span", { children: "\u4E0B\u8F7D\u6BEB\u7C73\u6821\u51C6\u6D4B\u8BD5\u5C3A PDF" })
9592
+ /* @__PURE__ */ jsx6(UiSaveIcon, {}),
9593
+ /* @__PURE__ */ jsx6("span", { children: "\u4FDD\u5B58\u81F3\u540E\u7AEF" })
9006
9594
  ]
9007
9595
  }
9008
9596
  )
9009
- ]
9010
- }
9011
- ),
9012
- /* @__PURE__ */ jsxs6("div", { style: { display: "flex", flexDirection: "column", gap: 4 }, children: [
9013
- /* @__PURE__ */ jsxs6("label", { style: { display: "flex", justifyContent: "space-between", alignItems: "center", fontSize: 11.5, color: "#31363F" }, children: [
9014
- /* @__PURE__ */ jsx6("span", { children: "\u4E2D\u6587\u77E2\u91CF\u53EF\u68C0\u7D22\u6A21\u5F0F" }),
9597
+ ] }),
9598
+ statusTip && /* @__PURE__ */ jsx6("div", { className: "univer-pdf-status-banner", children: statusTip })
9599
+ ] }) : /* @__PURE__ */ jsxs6("div", { className: "univer-pdf-modal-side", style: { width: 320 }, children: [
9600
+ /* @__PURE__ */ jsx6("div", { className: "univer-pdf-modal-label", children: "\u901A\u7528 PDF \u5BFC\u5165\u4E0E\u5BFC\u51FA\u5DE5\u4F5C\u53F0" }),
9601
+ /* @__PURE__ */ jsx6("div", { style: { fontSize: 12, color: "#4E5565", lineHeight: 1.55 }, children: "\u5F53\u524D\u5904\u4E8E\u901A\u7528 PDF \u6587\u6863/\u6279\u6CE8\u6A21\u5F0F\uFF08\u672A\u5F00\u542F\u6570\u636E\u96C6\u7ED1\u5B9A\uFF09\u3002\u53EF\u9009\u62E9\u6D4F\u89C8\u5668\u6216\u670D\u52A1\u7AEF\u901A\u9053\u5B8C\u6210 PDF \u5BFC\u5165\u5BA1\u6838\u4E0E\u5BFC\u51FA\u4E0B\u8F7D\u3002" }),
9602
+ unifiedIoSection,
9015
9603
  /* @__PURE__ */ jsxs6(
9016
- "select",
9604
+ "button",
9017
9605
  {
9018
- value: cjkTextMode,
9019
- onChange: (e) => {
9020
- const mode = e.target.value;
9021
- setCjkTextMode(mode);
9022
- generatePreview(sampleJsonText, watermarkText, excludeBasePdf, ioTarget, {
9023
- cjkTextMode: mode
9024
- });
9025
- },
9026
- style: {
9027
- border: "1px solid #D5D8DF",
9028
- borderRadius: 4,
9029
- padding: "2px 5px",
9030
- fontSize: 11,
9031
- color: "#1B1C1F",
9032
- background: "#FFFFFF"
9033
- },
9606
+ type: "button",
9607
+ "data-testid": "yudao-io-export-download",
9608
+ className: "univer-pdf-mini-btn is-primary",
9609
+ style: { display: "inline-flex", alignItems: "center", justifyContent: "center", gap: 4 },
9610
+ disabled: rendering,
9611
+ onClick: () => void handleExportAndDownload(),
9034
9612
  children: [
9035
- /* @__PURE__ */ jsx6("option", { value: "raster-hd", children: "\u9AD8\u6E05\u6805\u683C\u6A21\u5F0F (3x DPI PNG)" }),
9036
- /* @__PURE__ */ jsx6("option", { value: "cid-vector", children: "\u4E2D\u6587\u77E2\u91CF\u53EF\u68C0\u7D22\u6A21\u5F0F (cid-vector 0KB)" }),
9037
- /* @__PURE__ */ jsx6("option", { value: "subset-ttf", children: "TTF \u5B57\u4F53\u5B50\u96C6\u77E2\u91CF\u5185\u5D4C (subset-ttf)" })
9613
+ /* @__PURE__ */ jsx6(UiDownloadIcon, {}),
9614
+ /* @__PURE__ */ jsx6("span", { children: "\u4E0B\u8F7D\u6807\u51C6 PDF \u6587\u4EF6" })
9038
9615
  ]
9039
9616
  }
9040
- )
9041
- ] }),
9042
- cjkTextMode === "subset-ttf" && /* @__PURE__ */ jsx6(
9043
- "button",
9044
- {
9045
- type: "button",
9046
- className: "univer-pdf-mini-btn",
9047
- onClick: () => {
9048
- const input = document.createElement("input");
9049
- input.type = "file";
9050
- input.accept = ".ttf";
9051
- input.onchange = async () => {
9052
- const file = input.files?.[0];
9053
- if (!file) return;
9054
- const bytes = new Uint8Array(await file.arrayBuffer());
9055
- setCustomFontBytes(bytes);
9056
- setCustomFontName(file.name);
9057
- generatePreview(sampleJsonText, watermarkText, excludeBasePdf, ioTarget, {
9058
- cjkTextMode: "subset-ttf",
9059
- customFontBytes: bytes
9060
- });
9061
- };
9062
- input.click();
9063
- },
9064
- children: customFontName ? `\u5DF2\u8F7D\u5165\u5B57\u4F53: ${customFontName}` : "\u4E0A\u4F20 .ttf \u5B57\u4F53\u542F\u7528\u5B50\u96C6\u5316\u5185\u5D4C"
9065
- }
9066
- )
9067
- ] }),
9068
- /* @__PURE__ */ jsxs6(
9069
- "div",
9070
- {
9071
- style: {
9072
- padding: "7px 9px",
9073
- background: "#FFFFFF",
9074
- border: "1px solid #E3E5EA",
9075
- borderRadius: 6,
9076
- display: "flex",
9077
- flexDirection: "column",
9078
- gap: 6
9079
- },
9080
- children: [
9081
- /* @__PURE__ */ jsxs6("div", { style: { display: "flex", justifyContent: "space-between", fontSize: 11 }, children: [
9082
- /* @__PURE__ */ jsx6("span", { style: { fontWeight: 600, color: "#1B1C1F" }, children: "\u7F16\u8BD1\u5BFC\u51FA\u65B9\u5F0F\uFF08\u6309\u6B21\u9009\u62E9\uFF09" }),
9083
- /* @__PURE__ */ jsxs6("span", { style: { color: "#7D8698" }, children: [
9084
- "\u5FEB\u7167 ",
9085
- snapSizeKb,
9086
- " KB"
9087
- ] })
9088
- ] }),
9089
- /* @__PURE__ */ jsxs6("div", { className: "univer-pdf-segmented", children: [
9090
- /* @__PURE__ */ jsxs6(
9091
- "button",
9617
+ ),
9618
+ /* @__PURE__ */ jsxs6(
9619
+ "button",
9620
+ {
9621
+ type: "button",
9622
+ className: "univer-pdf-mini-btn",
9623
+ style: { display: "inline-flex", alignItems: "center", justifyContent: "center", gap: 4 },
9624
+ disabled: rendering,
9625
+ onClick: handleDownloadCalibrationGrid,
9626
+ children: [
9627
+ /* @__PURE__ */ jsx6(UiRulerGridIcon, {}),
9628
+ /* @__PURE__ */ jsx6("span", { children: "\u4E0B\u8F7D\u6BEB\u7C73\u6821\u51C6\u6D4B\u8BD5\u5C3A PDF" })
9629
+ ]
9630
+ }
9631
+ ),
9632
+ /* @__PURE__ */ jsxs6("label", { className: "univer-pdf-checkbox-row", style: { fontSize: 11.5 }, children: [
9633
+ /* @__PURE__ */ jsx6(
9634
+ "input",
9635
+ {
9636
+ type: "checkbox",
9637
+ checked: enableAuditSeal,
9638
+ onChange: (e) => {
9639
+ const checked = e.target.checked;
9640
+ setEnableAuditSeal(checked);
9641
+ void generatePreview(sampleJsonText, watermarkText, excludeBasePdf, ioTarget, void 0, checked);
9642
+ }
9643
+ }
9644
+ ),
9645
+ /* @__PURE__ */ jsx6(UiShieldSealIcon, { style: { color: "#4E5565" } }),
9646
+ /* @__PURE__ */ jsx6("span", { children: "\u9644\u52A0 SHA-256 \u9632\u7BE1\u6539\u7B7E\u7AE0\u6458\u8981" })
9647
+ ] }),
9648
+ /* @__PURE__ */ jsxs6("div", { style: { display: "flex", flexDirection: "column", gap: 4 }, children: [
9649
+ /* @__PURE__ */ jsx6("div", { style: { fontSize: 11, fontWeight: 600, color: "#1B1C1F" }, children: "\u9488\u5F0F\u786C\u4EF6\u504F\u79FB\u8865\u507F X/Y (mm)" }),
9650
+ /* @__PURE__ */ jsxs6("div", { style: { display: "grid", gridTemplateColumns: "1fr 1fr", gap: 4 }, children: [
9651
+ /* @__PURE__ */ jsx6(
9652
+ "input",
9092
9653
  {
9093
- type: "button",
9094
- className: `univer-pdf-segmented-item ${ioTarget === "browser" ? "is-active" : ""}`,
9095
- onClick: () => {
9096
- setIoTarget("browser");
9097
- generatePreview(sampleJsonText, watermarkText, excludeBasePdf, "browser");
9654
+ type: "number",
9655
+ step: "0.5",
9656
+ title: "\u6C34\u5E73\u504F\u79FB X (mm)",
9657
+ value: printerOffsetXMm,
9658
+ onChange: (e) => {
9659
+ const nextX = Number(e.target.value) || 0;
9660
+ setPrinterOffsetXMm(nextX);
9661
+ void generatePreview(sampleJsonText, watermarkText, excludeBasePdf, ioTarget, {
9662
+ printerOffsetXMm: nextX
9663
+ });
9098
9664
  },
9099
- children: [
9100
- /* @__PURE__ */ jsx6(UiBrowserIcon, {}),
9101
- /* @__PURE__ */ jsx6("span", { children: "\u6D4F\u89C8\u5668\u5904\u7406" })
9102
- ]
9665
+ style: {
9666
+ width: "100%",
9667
+ boxSizing: "border-box",
9668
+ border: "1px solid #D5D8DF",
9669
+ borderRadius: 4,
9670
+ padding: "2px 4px",
9671
+ fontSize: 11,
9672
+ color: "#1B1C1F",
9673
+ background: "#FFFFFF"
9674
+ }
9103
9675
  }
9104
9676
  ),
9105
- /* @__PURE__ */ jsxs6(
9106
- "button",
9677
+ /* @__PURE__ */ jsx6(
9678
+ "input",
9107
9679
  {
9108
- type: "button",
9109
- className: `univer-pdf-segmented-item ${ioTarget === "server" ? "is-active" : ""}`,
9110
- onClick: () => {
9111
- setIoTarget("server");
9112
- generatePreview(sampleJsonText, watermarkText, excludeBasePdf, "server");
9680
+ type: "number",
9681
+ step: "0.5",
9682
+ title: "\u5782\u76F4\u504F\u79FB Y (mm)",
9683
+ value: printerOffsetYMm,
9684
+ onChange: (e) => {
9685
+ const nextY = Number(e.target.value) || 0;
9686
+ setPrinterOffsetYMm(nextY);
9687
+ void generatePreview(sampleJsonText, watermarkText, excludeBasePdf, ioTarget, {
9688
+ printerOffsetYMm: nextY
9689
+ });
9113
9690
  },
9114
- children: [
9115
- /* @__PURE__ */ jsx6(UiServerIcon, {}),
9116
- /* @__PURE__ */ jsxs6("span", { children: [
9117
- "\u670D\u52A1\u7AEF",
9118
- ioCaps.server.exportPdf ? "" : " (\u672A\u63A5\u5165)"
9119
- ] })
9120
- ]
9691
+ style: {
9692
+ width: "100%",
9693
+ boxSizing: "border-box",
9694
+ border: "1px solid #D5D8DF",
9695
+ borderRadius: 4,
9696
+ padding: "2px 4px",
9697
+ fontSize: 11,
9698
+ color: "#1B1C1F",
9699
+ background: "#FFFFFF"
9700
+ }
9121
9701
  }
9122
9702
  )
9123
9703
  ] })
9124
- ]
9125
- }
9126
- ),
9127
- splitMergeQuickBox,
9128
- /* @__PURE__ */ jsxs6("div", { className: "univer-pdf-btn-row", children: [
9129
- /* @__PURE__ */ jsx6(
9130
- "button",
9131
- {
9132
- type: "button",
9133
- className: "univer-pdf-mini-btn is-primary",
9134
- disabled: rendering,
9135
- onClick: () => generatePreview(),
9136
- children: rendering ? "\u6E32\u67D3\u4E2D..." : "\u91CD\u65B0\u751F\u6210 PDF"
9137
- }
9138
- ),
9139
- /* @__PURE__ */ jsx6(
9140
- "button",
9141
- {
9142
- type: "button",
9143
- className: "univer-pdf-mini-btn",
9144
- disabled: rendering,
9145
- onClick: () => {
9146
- const baseObj = unit.save().metadata?.sampleData ?? { orderNo: "SO-2026-001" };
9147
- const batchArr = [1, 2, 3].map((n) => ({
9148
- ...baseObj,
9149
- orderNo: `BATCH-2026-00${n}`,
9150
- batchSeq: n
9151
- }));
9152
- const txt = JSON.stringify(batchArr, null, 2);
9153
- setSampleJsonText(txt);
9154
- generatePreview(txt);
9155
- },
9156
- children: "\u6279\u91CF\u5957\u6253 (3\u5355\u5408\u5E76)"
9157
- }
9158
- ),
9159
- /* @__PURE__ */ jsxs6(
9160
- "button",
9161
- {
9162
- type: "button",
9163
- className: "univer-pdf-mini-btn",
9164
- style: { display: "inline-flex", alignItems: "center", gap: 4 },
9165
- disabled: !pdfBytesState,
9166
- onClick: handleDownloadPdf,
9167
- children: [
9168
- /* @__PURE__ */ jsx6(UiDownloadIcon, {}),
9169
- /* @__PURE__ */ jsx6("span", { children: "\u4E0B\u8F7D PDF \u6587\u4EF6" })
9170
- ]
9171
- }
9172
- ),
9173
- features.print && /* @__PURE__ */ jsxs6(
9174
- "button",
9175
- {
9176
- type: "button",
9177
- className: "univer-pdf-mini-btn",
9178
- style: { display: "inline-flex", alignItems: "center", gap: 4 },
9179
- disabled: rendering,
9180
- onClick: handleBrowserPrint,
9181
- children: [
9182
- /* @__PURE__ */ jsx6(UiPrinterIcon, {}),
9183
- /* @__PURE__ */ jsx6("span", { children: "\u6D4F\u89C8\u5668\u6253\u5370" })
9184
- ]
9185
- }
9186
- ),
9187
- features.print && /* @__PURE__ */ jsxs6(
9188
- "button",
9189
- {
9190
- type: "button",
9191
- className: "univer-pdf-mini-btn",
9192
- style: { display: "inline-flex", alignItems: "center", gap: 4 },
9193
- disabled: rendering,
9194
- onClick: handleSilentPrint,
9195
- children: [
9196
- /* @__PURE__ */ jsx6(UiPrinterIcon, {}),
9197
- /* @__PURE__ */ jsx6("span", { children: "\u9759\u9ED8\u76F4\u6253 (Lodop/\u672C\u5730\u6253\u5370\u52A9\u624B)" })
9198
- ]
9199
- }
9200
- ),
9201
- ioAdapter.onSave && /* @__PURE__ */ jsxs6(
9202
- "button",
9203
- {
9204
- type: "button",
9205
- className: "univer-pdf-mini-btn",
9206
- style: { display: "inline-flex", alignItems: "center", gap: 4 },
9207
- onClick: handleSaveToHost,
9208
- children: [
9209
- /* @__PURE__ */ jsx6(UiSaveIcon, {}),
9210
- /* @__PURE__ */ jsx6("span", { children: "\u4FDD\u5B58\u81F3\u540E\u7AEF" })
9211
- ]
9212
- }
9213
- )
9214
- ] }),
9215
- statusTip && /* @__PURE__ */ jsx6("div", { className: "univer-pdf-status-banner", children: statusTip })
9216
- ] }) : /* @__PURE__ */ jsxs6("div", { className: "univer-pdf-modal-side", style: { width: 220 }, children: [
9217
- /* @__PURE__ */ jsx6("div", { className: "univer-pdf-modal-label", children: "\u901A\u7528 PDF \u5BFC\u51FA\u9884\u89C8" }),
9218
- /* @__PURE__ */ jsx6("div", { style: { fontSize: 12, color: "#4E5565", lineHeight: 1.6 }, children: "\u5F53\u524D\u5904\u4E8E\u7EAF\u51C0 PDF \u6587\u6863/\u6279\u6CE8\u6A21\u5F0F\uFF08\u672A\u5F00\u542F\u6570\u636E\u96C6\u7ED1\u5B9A\uFF09\u3002\u53F3\u4FA7\u4E3A\u901A\u8FC7\u5F53\u524D IO \u7BA1\u9053\u7F16\u8BD1\u7684\u6807\u51C6 PDF \u9875\u9762\u3002" }),
9219
- /* @__PURE__ */ jsxs6(
9220
- "button",
9221
- {
9222
- type: "button",
9223
- className: "univer-pdf-mini-btn is-primary",
9224
- style: { display: "inline-flex", alignItems: "center", justifyContent: "center", gap: 4 },
9225
- disabled: !pdfBytesState,
9226
- onClick: handleDownloadPdf,
9227
- children: [
9228
- /* @__PURE__ */ jsx6(UiDownloadIcon, {}),
9229
- /* @__PURE__ */ jsx6("span", { children: "\u4E0B\u8F7D\u6807\u51C6 PDF \u6587\u4EF6" })
9230
- ]
9231
- }
9232
- ),
9233
- /* @__PURE__ */ jsxs6(
9234
- "button",
9235
- {
9236
- type: "button",
9237
- className: "univer-pdf-mini-btn",
9238
- style: { display: "inline-flex", alignItems: "center", justifyContent: "center", gap: 4 },
9239
- disabled: rendering,
9240
- onClick: handleDownloadCalibrationGrid,
9241
- children: [
9242
- /* @__PURE__ */ jsx6(UiRulerGridIcon, {}),
9243
- /* @__PURE__ */ jsx6("span", { children: "\u4E0B\u8F7D\u6BEB\u7C73\u6821\u51C6\u6D4B\u8BD5\u5C3A PDF" })
9244
- ]
9245
- }
9246
- ),
9247
- /* @__PURE__ */ jsxs6("label", { className: "univer-pdf-checkbox-row", style: { fontSize: 11.5 }, children: [
9248
- /* @__PURE__ */ jsx6(
9249
- "input",
9250
- {
9251
- type: "checkbox",
9252
- checked: enableAuditSeal,
9253
- onChange: (e) => {
9254
- const checked = e.target.checked;
9255
- setEnableAuditSeal(checked);
9256
- generatePreview(sampleJsonText, watermarkText, excludeBasePdf, ioTarget, void 0, checked);
9704
+ ] }),
9705
+ splitMergeQuickBox,
9706
+ features.print && /* @__PURE__ */ jsxs6(
9707
+ "button",
9708
+ {
9709
+ type: "button",
9710
+ className: "univer-pdf-mini-btn",
9711
+ style: { display: "inline-flex", alignItems: "center", justifyContent: "center", gap: 4 },
9712
+ disabled: rendering,
9713
+ onClick: handleBrowserPrint,
9714
+ children: [
9715
+ /* @__PURE__ */ jsx6(UiPrinterIcon, {}),
9716
+ /* @__PURE__ */ jsx6("span", { children: "\u6D4F\u89C8\u5668\u6253\u5370" })
9717
+ ]
9257
9718
  }
9258
- }
9259
- ),
9260
- /* @__PURE__ */ jsx6(UiShieldSealIcon, { style: { color: "#4E5565" } }),
9261
- /* @__PURE__ */ jsx6("span", { children: "\u9644\u52A0 SHA-256 \u9632\u7BE1\u6539\u7B7E\u7AE0\u6458\u8981" })
9262
- ] }),
9263
- /* @__PURE__ */ jsxs6("div", { style: { display: "flex", flexDirection: "column", gap: 4 }, children: [
9264
- /* @__PURE__ */ jsx6("div", { style: { fontSize: 11, fontWeight: 600, color: "#1B1C1F" }, children: "\u9488\u5F0F\u786C\u4EF6\u504F\u79FB\u8865\u507F X/Y (mm)" }),
9265
- /* @__PURE__ */ jsxs6("div", { style: { display: "grid", gridTemplateColumns: "1fr 1fr", gap: 4 }, children: [
9266
- /* @__PURE__ */ jsx6(
9267
- "input",
9719
+ ),
9720
+ features.print && /* @__PURE__ */ jsxs6(
9721
+ "button",
9268
9722
  {
9269
- type: "number",
9270
- step: "0.5",
9271
- title: "\u6C34\u5E73\u504F\u79FB X (mm)",
9272
- value: printerOffsetXMm,
9273
- onChange: (e) => {
9274
- const nextX = Number(e.target.value) || 0;
9275
- setPrinterOffsetXMm(nextX);
9276
- generatePreview(sampleJsonText, watermarkText, excludeBasePdf, ioTarget, {
9277
- printerOffsetXMm: nextX
9278
- });
9279
- },
9280
- style: {
9281
- width: "100%",
9282
- boxSizing: "border-box",
9283
- border: "1px solid #D5D8DF",
9284
- borderRadius: 4,
9285
- padding: "2px 4px",
9286
- fontSize: 11,
9287
- color: "#1B1C1F",
9288
- background: "#FFFFFF"
9289
- }
9723
+ type: "button",
9724
+ className: "univer-pdf-mini-btn",
9725
+ style: { display: "inline-flex", alignItems: "center", justifyContent: "center", gap: 4 },
9726
+ disabled: rendering,
9727
+ onClick: handleSilentPrint,
9728
+ children: [
9729
+ /* @__PURE__ */ jsx6(UiPrinterIcon, {}),
9730
+ /* @__PURE__ */ jsx6("span", { children: "\u9759\u9ED8\u76F4\u6253 (Lodop/\u672C\u5730\u6253\u5370\u52A9\u624B)" })
9731
+ ]
9290
9732
  }
9291
9733
  ),
9292
- /* @__PURE__ */ jsx6(
9293
- "input",
9734
+ ioAdapter.onSave && /* @__PURE__ */ jsxs6(
9735
+ "button",
9294
9736
  {
9295
- type: "number",
9296
- step: "0.5",
9297
- title: "\u5782\u76F4\u504F\u79FB Y (mm)",
9298
- value: printerOffsetYMm,
9299
- onChange: (e) => {
9300
- const nextY = Number(e.target.value) || 0;
9301
- setPrinterOffsetYMm(nextY);
9302
- generatePreview(sampleJsonText, watermarkText, excludeBasePdf, ioTarget, {
9303
- printerOffsetYMm: nextY
9304
- });
9305
- },
9306
- style: {
9307
- width: "100%",
9308
- boxSizing: "border-box",
9309
- border: "1px solid #D5D8DF",
9310
- borderRadius: 4,
9311
- padding: "2px 4px",
9312
- fontSize: 11,
9313
- color: "#1B1C1F",
9314
- background: "#FFFFFF"
9315
- }
9737
+ type: "button",
9738
+ className: "univer-pdf-mini-btn",
9739
+ style: { display: "inline-flex", alignItems: "center", justifyContent: "center", gap: 4 },
9740
+ onClick: handleSaveToHost,
9741
+ children: [
9742
+ /* @__PURE__ */ jsx6(UiSaveIcon, {}),
9743
+ /* @__PURE__ */ jsx6("span", { children: "\u4FDD\u5B58\u6A21\u677F\u81F3\u5BBF\u4E3B\u540E\u7AEF" })
9744
+ ]
9316
9745
  }
9317
- )
9318
- ] })
9319
- ] }),
9320
- splitMergeQuickBox,
9321
- features.print && /* @__PURE__ */ jsxs6(
9322
- "button",
9323
- {
9324
- type: "button",
9325
- className: "univer-pdf-mini-btn",
9326
- style: { display: "inline-flex", alignItems: "center", justifyContent: "center", gap: 4 },
9327
- disabled: rendering,
9328
- onClick: handleBrowserPrint,
9329
- children: [
9330
- /* @__PURE__ */ jsx6(UiPrinterIcon, {}),
9331
- /* @__PURE__ */ jsx6("span", { children: "\u6D4F\u89C8\u5668\u6253\u5370" })
9332
- ]
9333
- }
9334
- ),
9335
- features.print && /* @__PURE__ */ jsxs6(
9336
- "button",
9337
- {
9338
- type: "button",
9339
- className: "univer-pdf-mini-btn",
9340
- style: { display: "inline-flex", alignItems: "center", justifyContent: "center", gap: 4 },
9341
- disabled: rendering,
9342
- onClick: handleSilentPrint,
9343
- children: [
9344
- /* @__PURE__ */ jsx6(UiPrinterIcon, {}),
9345
- /* @__PURE__ */ jsx6("span", { children: "\u9759\u9ED8\u76F4\u6253 (Lodop/\u672C\u5730\u6253\u5370\u52A9\u624B)" })
9346
- ]
9347
- }
9348
- ),
9349
- ioAdapter.onSave && /* @__PURE__ */ jsxs6(
9350
- "button",
9351
- {
9352
- type: "button",
9353
- className: "univer-pdf-mini-btn",
9354
- style: { display: "inline-flex", alignItems: "center", justifyContent: "center", gap: 4 },
9355
- onClick: handleSaveToHost,
9356
- children: [
9357
- /* @__PURE__ */ jsx6(UiSaveIcon, {}),
9358
- /* @__PURE__ */ jsx6("span", { children: "\u4FDD\u5B58\u6A21\u677F\u81F3\u5BBF\u4E3B\u540E\u7AEF" })
9359
- ]
9360
- }
9361
- ),
9362
- statusTip && /* @__PURE__ */ jsx6("div", { className: "univer-pdf-status-banner", children: statusTip })
9363
- ] }),
9364
- /* @__PURE__ */ jsx6("div", { className: "univer-pdf-modal-viewer", children: /* @__PURE__ */ jsx6(PdfRenderedPagesViewer, { pdfBytes: pdfBytesState }) })
9365
- ] }) : /* @__PURE__ */ jsxs6("div", { className: "univer-pdf-modal-body-json", children: [
9366
- /* @__PURE__ */ jsxs6("div", { className: "univer-pdf-json-toolbar", children: [
9367
- /* @__PURE__ */ jsxs6("div", { className: "univer-pdf-segmented is-inline", children: [
9368
- /* @__PURE__ */ jsx6(
9369
- "button",
9370
- {
9371
- type: "button",
9372
- className: `univer-pdf-segmented-item ${jsonFormat === "univer" ? "is-active" : ""}`,
9373
- onClick: () => setJsonFormat("univer"),
9374
- children: "Univer IPdfUnitData \u6807\u51C6\u5951\u7EA6"
9375
- }
9376
- ),
9377
- /* @__PURE__ */ jsx6(
9378
- "button",
9379
- {
9380
- type: "button",
9381
- className: `univer-pdf-segmented-item ${jsonFormat === "pdfme" ? "is-active" : ""}`,
9382
- onClick: () => setJsonFormat("pdfme"),
9383
- children: "pdfme Template \u517C\u5BB9\u683C\u5F0F (mm)"
9384
- }
9385
- )
9386
- ] }),
9387
- /* @__PURE__ */ jsxs6("div", { className: "univer-pdf-btn-row", children: [
9746
+ ),
9747
+ statusTip && /* @__PURE__ */ jsx6("div", { className: "univer-pdf-status-banner", children: statusTip })
9748
+ ] }),
9749
+ /* @__PURE__ */ jsx6("div", { className: "univer-pdf-modal-viewer", children: /* @__PURE__ */ jsx6(PdfRenderedPagesViewer, { pdfBytes: pdfBytesState, hasError: Boolean(ioError) }) })
9750
+ ] }) : /* @__PURE__ */ jsxs6("div", { className: "univer-pdf-modal-body-json", children: [
9751
+ /* @__PURE__ */ jsxs6("div", { className: "univer-pdf-json-toolbar", children: [
9752
+ /* @__PURE__ */ jsxs6("div", { className: "univer-pdf-segmented is-inline", children: [
9753
+ /* @__PURE__ */ jsx6(
9754
+ "button",
9755
+ {
9756
+ type: "button",
9757
+ className: `univer-pdf-segmented-item ${jsonFormat === "univer" ? "is-active" : ""}`,
9758
+ onClick: () => setJsonFormat("univer"),
9759
+ children: "Univer IPdfUnitData \u6807\u51C6\u5951\u7EA6"
9760
+ }
9761
+ ),
9762
+ /* @__PURE__ */ jsx6(
9763
+ "button",
9764
+ {
9765
+ type: "button",
9766
+ className: `univer-pdf-segmented-item ${jsonFormat === "pdfme" ? "is-active" : ""}`,
9767
+ onClick: () => setJsonFormat("pdfme"),
9768
+ children: "pdfme Template \u517C\u5BB9\u683C\u5F0F (mm)"
9769
+ }
9770
+ )
9771
+ ] }),
9772
+ /* @__PURE__ */ jsxs6("div", { className: "univer-pdf-btn-row", children: [
9773
+ /* @__PURE__ */ jsx6(
9774
+ "button",
9775
+ {
9776
+ type: "button",
9777
+ className: "univer-pdf-mini-btn",
9778
+ onClick: () => {
9779
+ navigator.clipboard?.writeText(jsonEditorValue);
9780
+ setStatusTip("\u5DF2\u590D\u5236\u5230\u526A\u8D34\u677F\uFF01");
9781
+ },
9782
+ children: "\u590D\u5236 JSON"
9783
+ }
9784
+ ),
9785
+ ioAdapter.onSave && /* @__PURE__ */ jsxs6(
9786
+ "button",
9787
+ {
9788
+ type: "button",
9789
+ className: "univer-pdf-mini-btn",
9790
+ style: { display: "inline-flex", alignItems: "center", gap: 4 },
9791
+ onClick: handleSaveToHost,
9792
+ children: [
9793
+ /* @__PURE__ */ jsx6(UiSaveIcon, {}),
9794
+ /* @__PURE__ */ jsx6("span", { children: "\u4FDD\u5B58\u81F3\u540E\u7AEF\u5BBF\u4E3B" })
9795
+ ]
9796
+ }
9797
+ ),
9798
+ editorEnabled && /* @__PURE__ */ jsx6(
9799
+ "button",
9800
+ {
9801
+ type: "button",
9802
+ className: "univer-pdf-mini-btn is-primary",
9803
+ onClick: handleApplyImportedJson,
9804
+ children: "\u5BFC\u5165\u5E76\u5E94\u7528\u7F16\u8F91\u5668\u4E2D\u7684 JSON"
9805
+ }
9806
+ )
9807
+ ] })
9808
+ ] }),
9809
+ statusTip && /* @__PURE__ */ jsx6("div", { className: "univer-pdf-status-banner", children: statusTip }),
9388
9810
  /* @__PURE__ */ jsx6(
9389
- "button",
9390
- {
9391
- type: "button",
9392
- className: "univer-pdf-mini-btn",
9393
- onClick: () => {
9394
- navigator.clipboard?.writeText(jsonEditorValue);
9395
- setStatusTip("\u5DF2\u590D\u5236\u5230\u526A\u8D34\u677F\uFF01");
9396
- },
9397
- children: "\u590D\u5236 JSON"
9398
- }
9399
- ),
9400
- ioAdapter.onSave && /* @__PURE__ */ jsxs6(
9401
- "button",
9402
- {
9403
- type: "button",
9404
- className: "univer-pdf-mini-btn",
9405
- style: { display: "inline-flex", alignItems: "center", gap: 4 },
9406
- onClick: handleSaveToHost,
9407
- children: [
9408
- /* @__PURE__ */ jsx6(UiSaveIcon, {}),
9409
- /* @__PURE__ */ jsx6("span", { children: "\u4FDD\u5B58\u81F3\u540E\u7AEF\u5BBF\u4E3B" })
9410
- ]
9411
- }
9412
- ),
9413
- editorEnabled && /* @__PURE__ */ jsx6(
9414
- "button",
9811
+ "textarea",
9415
9812
  {
9416
- type: "button",
9417
- className: "univer-pdf-mini-btn is-primary",
9418
- onClick: handleApplyImportedJson,
9419
- children: "\u5BFC\u5165\u5E76\u5E94\u7528\u7F16\u8F91\u5668\u4E2D\u7684 JSON"
9813
+ className: "univer-pdf-code-editor",
9814
+ value: jsonEditorValue,
9815
+ onChange: (e) => setJsonEditorValue(e.target.value)
9420
9816
  }
9421
9817
  )
9422
9818
  ] })
9423
- ] }),
9424
- statusTip && /* @__PURE__ */ jsx6("div", { className: "univer-pdf-status-banner", children: statusTip }),
9425
- /* @__PURE__ */ jsx6(
9426
- "textarea",
9427
- {
9428
- className: "univer-pdf-code-editor",
9429
- value: jsonEditorValue,
9430
- onChange: (e) => setJsonEditorValue(e.target.value)
9431
- }
9432
- )
9433
- ] })
9434
- ] }) });
9819
+ ]
9820
+ }
9821
+ ) });
9435
9822
  };
9436
9823
 
9437
9824
  // src/controllers/menu.schema.ts
@@ -10137,6 +10524,7 @@ export {
10137
10524
  PdfLeftSidebar,
10138
10525
  PdfPreviewModal,
10139
10526
  PdfStatusBar,
10527
+ PdfUnifiedIoSection,
10140
10528
  PdfsUIController,
10141
10529
  en_US_default as PdfsUIEnUS,
10142
10530
  PdfsUIFeatureService,
@@ -10167,6 +10555,7 @@ export {
10167
10555
  openPdfInspectorSidebar,
10168
10556
  readBrowserFileAsOverlayOutcome,
10169
10557
  renderSourcePdfPageToCanvas,
10558
+ resolveInitialModalIoTarget,
10170
10559
  resolvePdfsUIFeatures
10171
10560
  };
10172
10561
  //# sourceMappingURL=index.js.map